Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25420

Errors are logged when deleting a wiki whose users have cached asynchronous rendering results

    XMLWordPrintable

Details

    • Unit
    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      1. Create a subwiki
      2. 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)
      3. 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:

      ERROR o.x.s.a.DefaultAuthorizationManager - Failed to load rights for user [subwiki:XWiki.LocalSubWikiUser] on [subwiki:XWiki.LocalSubWikiUser].
      org.xwiki.security.authorization.AuthorizationException: Failed to get groups for user or group [subwiki:XWiki.LocalSubWikiUser] in wiki [Wiki subwiki]
      	at org.xwiki.security.internal.DefaultUserBridge.getGroupsReferencesFor(DefaultUserBridge.java:129)
      	...
      	at org.xwiki.security.authorization.DefaultAuthorizationManager.hasAccess(DefaultAuthorizationManager.java:116)
      	at org.xwiki.rendering.async.internal.AsyncRendererCache.checkRight(AsyncRendererCache.java:301)
      	at org.xwiki.rendering.async.internal.AsyncRendererCache.cleanCacheForRight(AsyncRendererCache.java:295)
      	at org.xwiki.rendering.async.internal.AsyncRendererCacheListener.onEvent(AsyncRendererCacheListener.java:88)
      	at org.xwiki.security.authorization.internal.DefaultSecurityCacheRulesInvalidatorListener.onEvent(DefaultSecurityCacheRulesInvalidatorListener.java:180)
      	at com.xpn.xwiki.XWiki.afterDelete(XWiki.java:4718)
      	...
      	at org.xwiki.wiki.internal.manager.DefaultWikiDeleter.delete(DefaultWikiDeleter.java:68)
      	at org.xwiki.wiki.internal.manager.DefaultWikiManager.delete(DefaultWikiManager.java:147)
      	at org.xwiki.wiki.script.WikiManagerScriptService.deleteWiki(WikiManagerScriptService.java:222)
      Caused by: com.xpn.xwiki.XWikiException: Error number 0 in 0: Exception while executing query. Named query = [listGroupsForUser]
      Caused by: org.xwiki.query.QueryException: Exception while executing query. Named query = [listGroupsForUser]
      Caused by: com.xpn.xwiki.XWikiException: Error number 2 in 0: No wiki with id [subwiki] could be found
      

      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.

      Attachments

        Issue Links

          Activity

            People

              surli Simon Urli
              surli Simon Urli
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: