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

The DefaultMentionsEventExecutor produces 100% CPU load for one core

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 12.7-rc-1, 12.6.2
    • 12.6.1
    • Mentions
    • None
    • Debian 10.5; OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Debian-1deb10u1, mixed mode, sharing); xwiki-tomcat9-mariadb in version 12.6.1
    • Unit
    • Trivial
    • N/A
    • N/A
    • Pull Request accepted

    Description

      When keeping the wiki running but idle, the server has still one CPU busy at about 100% with a servlet container process.

      Stack traces show at first nothing conspicuous, but I guess it is the thread in the MentionsConsumer inner class of the org.xwiki.mentions.internal.DefaultMentionsEventExecutor as there is always at least one stack trace in state RUNNABLE for that thread.

      Also when I manually brute force uninstall the extension from XWiki by editing the /var/lib/xwiki/data/extension/repository/org%2Exwiki%2Eplatform%3Axwiki-platform-mentions-default/12%2E6%2E1/org%2Exwiki%2Eplatform%3Axwiki-platform-mentions-default-12%2E6%2E1.xed the CPU load goes away.
      Instead XWiki complains on startup about the missing component "Can't find descriptor for the component with type [interface org.xwiki.mentions.MentionsConfiguration] and hint [default]"  which is expected and shows that uninstalling the extension worked.

      I got quite a couple of stack dumps, and a typical stack trace for the "Mentions thread" looks like:

      [2020-08-15 14:55:50] [info] "Mentions thread" #119 daemon prio=4 os_prio=0 cpu=1031372.07ms elapsed=1647.72s tid=0x00007fb6f865e800 nid=0x13c3 runnable  [0x00007fb6c611c000]
      [2020-08-15 14:55:50] [info]    java.lang.Thread.State: RUNNABLE
      [2020-08-15 14:55:50] [info] #011at org.xwiki.mentions.internal.DefaultMentionsEventExecutor$MentionsConsumer.run(DefaultMentionsEventExecutor.java:184)
      [2020-08-15 14:55:50] [info] #011at java.lang.Thread.run(java.base@11.0.8/Thread.java:834)
      

      but there are also a few like:

      [2020-08-15 14:58:09] [info] "Mentions thread" #119 daemon prio=4 os_prio=0 cpu=1169789.03ms elapsed=1787.09s tid=0x00007fb6f865e800 nid=0x13c3 runnable  [0x00007fb6c611c000]
      [2020-08-15 14:58:09] [info]    java.lang.Thread.State: RUNNABLE
      [2020-08-15 14:58:09] [info] #011at org.xwiki.mentions.internal.async.MapBasedLinkedBlockingQueue.poll(MapBasedLinkedBlockingQueue.java:252)
      [2020-08-15 14:58:09] [info] #011at org.xwiki.mentions.internal.DefaultMentionsEventExecutor$MentionsConsumer.consume(DefaultMentionsEventExecutor.java:195)
      [2020-08-15 14:58:09] [info] #011at org.xwiki.mentions.internal.DefaultMentionsEventExecutor$MentionsConsumer.run(DefaultMentionsEventExecutor.java:184)
      [2020-08-15 14:58:09] [info] #011at java.lang.Thread.run(java.base@11.0.8/Thread.java:834)
      

      This looks like a "busy wait" loop to me.

      I locally patched my instance to use a "blocking wait" instead:

      diff --git a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/DefaultMentionsEventExecutor.java b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/DefaultMentionsEventExecutor.java
      index d9174c62daa..5f63b653c0c 100644
      --- a/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/DefaultMentionsEventExecutor.java
      +++ b/xwiki-platform-core/xwiki-platform-mentions/xwiki-platform-mentions-default/src/main/java/org/xwiki/mentions/internal/DefaultMentionsEventExecutor.java
      @@ -192,7 +192,7 @@ public void consume()
               {
                   MentionsData data = null;
                   try {
      -                data = DefaultMentionsEventExecutor.this.queue.poll();
      +                data = DefaultMentionsEventExecutor.this.queue.take();
                       if (data != null) {
                           data.increaseAttempts();
                           if (data.isStop()) {
      

      This made the problem go away for me, but two unit tests in the DefaultMentionsEventExecutorTest fail with this modification. I have not looked in the cause for this yet.

      Attachments

        Activity

          People

            camil7 Clemens Robbenhaar
            camil7 Clemens Robbenhaar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: