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

The notifications loop forever when the requested count is 0 or not a number

    XMLWordPrintable

Details

    • Unknown
    • N/A
    • N/A

    Description

      Steps to reproduce

      Edit a page, insert the Notifications macro with a count of 0, then save and view the page.

      {{notifications count="0"/}}
      

      The same happens with a count that is not a number, like count="abc" or count="1.5".

      Expected result

      The macro shows no event, or an error message saying that the count must be a positive number.

      Actual result

      The macro stays on its loading placeholder forever, and the server keeps one CPU busy for each such page view. The asynchronous rendering job never ends: in DefaultParametrizedNotificationManager#getRawEvents, the batch size is expectedCount * 2, so 0. Each search returns an empty batch, batch.size() < batchSize is false since 0 < 0, and batchSize <<= 1 keeps it at 0, so the loop never stops, running a Solr query on every pass.

      Two such stuck jobs fill the notifications job group: every Notifications macro of the wiki then stays on its placeholder until the instance is restarted, and a normal shutdown no longer completes.

      Any user who can edit a page can trigger it. The REST resource /rest/notifications takes a count parameter too, and may reach the same code, which was not tried.

      The loop was introduced by XWIKI-15927. Found while auditing the macro for the WYSIWYG usability of XWiki macros, on XWiki 18.8.0: https://design.xwiki.org/xwiki/bin/view/Proposal/WYSIWYGusabilityofXWikimacros/Macros/notifications/

      Attachments

        Issue Links

          Activity

            People

              Lucas C Charpentier Lucas
              Lucas C Charpentier Lucas
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: