Steps to reproduce
- Create a subwiki
- Log in with a user of the subwiki and view pages rendered asynchronously (so that rendering results associated with right checks for that user are cached)
- Delete the subwiki
Expected The wiki is deleted without error. Actual The wiki is deleted, but an error is logged for each cached right check involving the deleted wiki:
Analysis DefaultWikiDeleter#delete deletes the wiki descriptor document before the wiki database. Deleting the descriptor triggers a RightUpdatedEvent (DefaultSecurityCacheRulesInvalidatorListener), on which AsyncRendererCacheListener calls AsyncRendererCache#cleanCacheForRight(): every right check associated with a cached rendering result is evaluated again, including the ones whose user or entity belongs to the wiki being deleted. Since the wiki descriptor is gone, evaluating them fails and DefaultAuthorizationManager logs an error (and returns false, so the cache entries are removed anyway). The WikiDeletedEvent handling of AsyncRendererCacheListener comes later, after the database is deleted, and doesn't remove the right checks of the deleted wiki. A possible fix: in AsyncRendererCache, remove the entries associated with a right check whose user or entity belongs to a wiki that doesn't exist anymore, without evaluating it. Found in the logs of SubWikiIT (xwiki-platform-wiki-test-docker) in the XWiki Environment Tests job on CI (master builds 1406 and 1409, in 6 of the 8 environment runs), when the test deletes the subwiki it created. |