Uploaded image for project: 'Jackrabbit Oak'
  1. Jackrabbit Oak
  2. OAK-7162

Race condition on revisions head between compaction and scheduler could result in skipped commit

    XMLWordPrintableJSON

Details

    Description

      There is a race condition on TarRevisions#head between a running compaction trying to set the new head [0] and the scheduler doing the same after executing a specific commit [1]. If the compaction thread is first, then the head assignment in the scheduler will fail and not be re-attempted.

      IMO, the simple if statement should be changed to a while loop in which the head is refreshed and the commit is re-applied against the new head, before attempting again to set a new head in TarRevisions. This is somehow similar to what we previously had [2], but without the unneeded optimistic/pessimistic strategies involving tokens.

      [0] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/file/FileStore.java#L764
      [1] https://github.com/apache/jackrabbit-oak/blob/trunk/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/scheduler/LockBasedScheduler.java#L253
      [2] https://github.com/apache/jackrabbit-oak/blob/1.6/oak-segment-tar/src/main/java/org/apache/jackrabbit/oak/segment/SegmentNodeStore.java#L686

      Attachments

        1. OAK-7162.patch
          4 kB
          Andrei Dulceanu
        2. OAK-7162-02.patch
          5 kB
          Andrei Dulceanu
        3. OAK-7162-03.patch
          5 kB
          Andrei Dulceanu
        4. OAK-7162-test.patch
          6 kB
          Andrei Dulceanu

        Activity

          People

            adulceanu Andrei Dulceanu
            adulceanu Andrei Dulceanu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: