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

TDM Merger causes Confluence OOME due to infinite loop

    XMLWordPrintable

Details

    Description

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

      Problem summary

      Under specific conditions, Confluence can run out of memory when a user goes to edit a Confluence page or view his drafts (Username > Drafts), following a sequence of events:

      1. User A goes edit a page (Version 1)
      2. Confluence auto-saves a draft based on Version 1, and user does not save the page
      3. User B edits the same page and saves, promoting the page to Version 2
      4. User A views his drafts (or edits the page again)
      5. Confluence tries to merge the three versions (Version 1, Version 1 draft, and Version 2), and results in Confluence hanging

      Thread dump shows one or more threads looking like this and using 100% CPU:

      "TP-Processor58" daemon prio=10 tid=0x5cd56800 nid=0x7f24 runnable [0x5c4ff000]
         java.lang.Thread.State: RUNNABLE
      	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:801)
      	at java.util.HashMap$KeyIterator.next(HashMap.java:828)
      	at tdm.lib.Measure.calcQDistance(Measure.java:360)
      	at tdm.lib.Measure.qDist(Measure.java:306)
      	at tdm.lib.Measure.stringDist(Measure.java:187)
      	at tdm.lib.Measure.childListDistance(Measure.java:205)
      	at tdm.lib.HeuristicMatching.getBestCandidate(HeuristicMatching.java:160)
      	at tdm.lib.HeuristicMatching.matchSubtrees(HeuristicMatching.java:120)
      	at tdm.lib.HeuristicMatching.matchSubtrees(HeuristicMatching.java:131)
      	at tdm.lib.HeuristicMatching.matchSubtrees(HeuristicMatching.java:131)
      	at tdm.lib.HeuristicMatching.matchSubtrees(HeuristicMatching.java:131)
      	at tdm.lib.HeuristicMatching.matchSubtrees(HeuristicMatching.java:131)
      	at tdm.lib.HeuristicMatching.buildMatching(HeuristicMatching.java:74)
      	at tdm.lib.TriMatching. (TriMatching.java:42)
      	at tdm.lib.TriMatching. (TriMatching.java:31)
      	at com.atlassian.confluence.plugins.merge.TDMMerger.mergeContent(TDMMerger.java:57)
      	at com.atlassian.confluence.util.diffs.PageLayoutAwareMerger.mergeContent(PageLayoutAwareMerger.java:63)
      	at com.atlassian.confluence.pages.DefaultDraftManager.mergeContent(DefaultDraftManager.java:211)
      

      Workaround

      Warning:
      Workarounds involve deleting one or more drafts. Drafts contain edits that have not yet been saved, so important work can be lost by deleting them.

      5.5 and later
      If a user has been identified causing this problem, they can go to /users/viewmydrafts.action page and discard either all of their drafts or just the draft for the page that is known to trigger this problem.

      5.2 to 5.4
      Remove all drafts for the given user (Remember to replace <username> with the username of the user):

      DELETE FROM BODYCONTENT WHERE contentid IN (SELECT contentid FROM CONTENT WHERE contenttype = 'DRAFT' AND creator in (SELECT user_key FROM user_mapping where username = '<username>'));
      DELETE FROM CONTENT WHERE contenttype = 'DRAFT' AND creator in (SELECT user_key FROM user_mapping where username = '<username>');
      

      All versions
      Alternatively, all the drafts can be deleted directly from the DB:

      1. Back up Confluence DB as a precaution
      2. Run the following DELETE statements against the DB:
        DELETE FROM BODYCONTENT WHERE contentid IN (SELECT contentid FROM CONTENT WHERE contenttype = 'DRAFT');
        DELETE FROM CONTENT WHERE contenttype = 'DRAFT';
        
      3. Confluence Admin > Cache Statistics > Flush all (down at the bottom)

      Attachments

        Issue Links

          Activity

            People

              onevalainen Olli Nevalainen
              rchang Robert Chang
              Votes:
              8 Vote for this issue
              Watchers:
              26 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: