Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-40113

Excessive CPU usage with the Attachments Macro

    XMLWordPrintable

Details

    Description

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Summary

      There is a CPU spike that hangs when using the Attachments macro. This can be consistently replicated when there are 200+ attachments in a Confluence page. The issues seems to be the number of attachments since testing with 1 large file (e.g. 1 GB) rather than 200 medium-sized files does not cause the same issue.

      Steps to Reproduce

      1. Create 200+ test attachments. The following Linux script can be used to create 200 txt files from an exisitng Confluence log file
         for f in {0..200}
        do
            cat atlassian-confluence.log > "$f.txt"
        done	
      2. Log in to Confluence
      3. Create a test space and test page
      4. Drag and drop the 200 test files to the page
      5. Keep an eye on the CPU usage. The CPU should be stable at this point
      6. Edit the Confluence page and add the Attachments macro
      7. Save the page
      8. Notice the CPU will spike and hang
      9. Disable the 'Confluence Attachments Plugin' and notce the CPU goes down almost instantly

      Expected Results

      The CPU does not hang for long periods of time.

      Actual Results

      The CPU will spike and hang.

      Sometimes the following will be displayed in the atlassian-confleunce.log file

      ERROR [http-nio-8081-exec-1800] [content.render.xhtml.DefaultRenderer] render Rendering this content exceeded the timeout of 120 seconds.
      

      Thread Dump References Attachments Macro: com.atlassian.confluence.extra.attachments.AttachmentsMacro.execute

      "http-nio-8081-exec-1800" #301091 daemon prio=5 os_prio=0 tid=0x00007f4af0014000 nid=0x5d6a runnable [0x00007f4b8fc80000]
         java.lang.Thread.State: RUNNABLE
      	at org.apache.lucene.search.HitQueue.getSentinelObject(HitQueue.java:72)
      	at org.apache.lucene.search.HitQueue.getSentinelObject(HitQueue.java:22)
      	at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:73)
      	at org.apache.lucene.search.HitQueue.<init>(HitQueue.java:64)
      	at org.apache.lucene.search.TopScoreDocCollector.<init>(TopScoreDocCollector.java:275)
      	at org.apache.lucene.search.TopScoreDocCollector.<init>(TopScoreDocCollector.java:37)
      	at org.apache.lucene.search.TopScoreDocCollector$InOrderTopScoreDocCollector.<init>(TopScoreDocCollector.java:42)
      	at org.apache.lucene.search.TopScoreDocCollector$InOrderTopScoreDocCollector.<init>(TopScoreDocCollector.java:40)
      	at org.apache.lucene.search.TopScoreDocCollector.create(TopScoreDocCollector.java:258)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:487)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:444)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:281)
      	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:269)
      	at com.atlassian.bonnie.search.LuceneSearcher$1.perform(LuceneSearcher.java:97)
      	at com.atlassian.bonnie.LuceneConnection.withSearch(LuceneConnection.java:342)
      	at com.atlassian.bonnie.search.LuceneSearcher.search(LuceneSearcher.java:93)
      	at com.arsenale.plugins.lockpoint.conditions.ConditionCanAccessGliffyLink.shouldDisplay(SourceFile:57)
      	at com.atlassian.plugin.web.conditions.AndCompositeCondition.shouldDisplay(AndCompositeCondition.java:14)
      	at com.atlassian.plugin.web.DefaultWebInterfaceManager.filterFragmentsByCondition(DefaultWebInterfaceManager.java:153)
      	at com.atlassian.plugin.web.DefaultWebInterfaceManager.getDisplayableItems(DefaultWebInterfaceManager.java:106)
      	at com.atlassian.confluence.plugin.descriptor.web.ConfluenceWebInterfaceManager.getDisplayableItems(ConfluenceWebInterfaceManager.java:88)
      	at sun.reflect.GeneratedMethodAccessor10446.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:385)
      	at org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:374)
      	at com.atlassian.confluence.velocity.introspection.UnboxingMethod.invoke(UnboxingMethod.java:34)
      	at org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
      	at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:262)
      	at org.apache.velocity.runtime.parser.node.ASTReference.value(ASTReference.java:507)
      	at org.apache.velocity.runtime.parser.node.ASTExpression.value(ASTExpression.java:71)
      	at org.apache.velocity.runtime.parser.node.ASTSetDirective.render(ASTSetDirective.java:142)
      	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
      	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
      	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
      	at org.apache.velocity.runtime.directive.Foreach.performIteration(Foreach.java:393)
      	at org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:316)
      	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
      	at org.apache.velocity.runtime.parser.node.ASTBlock.render(ASTBlock.java:72)
      	at org.apache.velocity.runtime.parser.node.ASTIfStatement.render(ASTIfStatement.java:87)
      	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      	at org.apache.velocity.runtime.directive.Parse.render(Parse.java:263)
      	at com.atlassian.confluence.setup.velocity.ProfilingParseDirective.render(ProfilingParseDirective.java:24)
      	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
      	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      	at org.apache.velocity.Template.merge(Template.java:328)
      	at org.apache.velocity.Template.merge(Template.java:235)
      	at com.atlassian.confluence.util.velocity.VelocityUtils.renderTemplateWithoutSwallowingErrors(VelocityUtils.java:84)
      	at com.atlassian.confluence.util.velocity.VelocityUtils.renderTemplateWithoutSwallowingErrors(VelocityUtils.java:95)
      	at com.atlassian.confluence.util.velocity.VelocityUtils.getRenderedTemplateWithoutSwallowingErrors(VelocityUtils.java:73)
      	at com.atlassian.confluence.util.velocity.VelocityUtils.getRenderedTemplate(VelocityUtils.java:44)
      	at com.atlassian.confluence.util.velocity.VelocityUtils.getRenderedTemplate(VelocityUtils.java:32)
      	at com.atlassian.confluence.plugin.services.DefaultVelocityHelperService.getRenderedTemplate(DefaultVelocityHelperService.java:13)
      	at sun.reflect.GeneratedMethodAccessor1470.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.atlassian.plugin.osgi.hostcomponents.impl.DefaultComponentRegistrar$ContextClassLoaderSettingInvocationHandler.invoke(DefaultComponentRegistrar.java:117)
      	at com.sun.proxy.$Proxy264.getRenderedTemplate(Unknown Source)
      	at sun.reflect.GeneratedMethodAccessor1470.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:497)
      	at com.atlassian.plugin.osgi.bridge.external.HostComponentFactoryBean$DynamicServiceInvocationHandler.invoke(HostComponentFactoryBean.java:130)
      	at com.sun.proxy.$Proxy264.getRenderedTemplate(Unknown Source)
      	at com.atlassian.confluence.extra.attachments.AttachmentsMacro.execute(AttachmentsMacro.java:287)
      	
      	.....
      
         Locked ownable synchronizers:
      	- <0x00007f52cf420eb8> (a java.util.concurrent.ThreadPoolExecutor$Worker)

      Workaround

      Disable the Confluence Attachments Plugin macro and use an alternative attachment macro if available.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              ajean Andy J.
              Votes:
              5 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: