Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-5244

Compactions don't work while node is bootstrapping

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Critical
    • Resolution: Fixed
    • Fix Version/s: 1.2.2
    • Component/s: None
    • Labels:

      Description

      It seems that there is a race condition in StorageService that prevents compactions from completing while node is in a bootstrap state.

      I have been able to reproduce this multiple times by throttling streaming throughput to extend the bootstrap time while simultaneously inserting data to the cluster.

      The problems lies in the synchronization of initServer(int delay) and reportSeverity(double incr) methods as they both try to acquire the instance lock of StorageService through the use of synchronized keyword. As initServer does not return until the bootstrap has completed, all calls to reportSeverity will block until that. However, reportSeverity is called when starting compactions in CompactionInfo and thus all compactions block until bootstrap completes.

      This might severely degrade node's performance after bootstrap as it might have lots of compactions pending while simultaneously starting to serve reads.

      I have been able to solve the issue by adding a separate lock for reportSeverity and removing its class level synchronization. This of course is not a valid approach if we must assume that any of Gossiper's IEndpointStateChangeSubscribers could potentially end up calling back to StorageService's synchronized methods. However, at least at the moment, that does not seem to be the case.

      Maybe somebody with more experience about the codebase comes up with a better solution?

      (This might affect DynamicEndpointSnitch as well, as it also calls to reportSeverity in its setSeverity method)

      1. 5244.txt
        2 kB
        Brandon Williams

        Issue Links

          Activity

          Hide
          jbellis Jonathan Ellis added a comment -

          Thanks for the detective work, Jouni. I'll let Brandon comment on solutions; in the meantime, marking Minor since while inconvenient this does not compromise correctness.

          Show
          jbellis Jonathan Ellis added a comment - Thanks for the detective work, Jouni. I'll let Brandon comment on solutions; in the meantime, marking Minor since while inconvenient this does not compromise correctness.
          Hide
          brandon.williams Brandon Williams added a comment - - edited

          This is more severe than we originally thought, and causes CASSANDRA-5129 when there is a secondary index:

          "CompactionExecutor:1" daemon prio=10 tid=0x00007effbc03c800 nid=0x7abf waiting for monitor entry [0x00007effc843a000]
             java.lang.Thread.State: BLOCKED (on object monitor)
              at org.apache.cassandra.service.StorageService.reportSeverity(StorageService.java:905)
              - waiting to lock <0x00000000ca576ac8> (a org.apache.cassandra.service.StorageService)
              at org.apache.cassandra.db.compaction.CompactionInfo$Holder.started(CompactionInfo.java:141)
              at org.apache.cassandra.metrics.CompactionMetrics.beginCompaction(CompactionMetrics.java:90)
              at org.apache.cassandra.db.compaction.CompactionManager$9.run(CompactionManager.java:813)
              at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
              at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
              at java.util.concurrent.FutureTask.run(FutureTask.java:138)
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
              at java.lang.Thread.run(Thread.java:662)
          
          Show
          brandon.williams Brandon Williams added a comment - - edited This is more severe than we originally thought, and causes CASSANDRA-5129 when there is a secondary index: "CompactionExecutor:1" daemon prio=10 tid=0x00007effbc03c800 nid=0x7abf waiting for monitor entry [0x00007effc843a000] java.lang.Thread.State: BLOCKED (on object monitor) at org.apache.cassandra.service.StorageService.reportSeverity(StorageService.java:905) - waiting to lock <0x00000000ca576ac8> (a org.apache.cassandra.service.StorageService) at org.apache.cassandra.db.compaction.CompactionInfo$Holder.started(CompactionInfo.java:141) at org.apache.cassandra.metrics.CompactionMetrics.beginCompaction(CompactionMetrics.java:90) at org.apache.cassandra.db.compaction.CompactionManager$9.run(CompactionManager.java:813) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662)
          Hide
          brandon.williams Brandon Williams added a comment -

          It seems to me the only reason we're synchronizing here is for the increment, and we don't need to get our own severity out of gossip, so we can just track a local AtomicDouble instead.

          Show
          brandon.williams Brandon Williams added a comment - It seems to me the only reason we're synchronizing here is for the increment, and we don't need to get our own severity out of gossip, so we can just track a local AtomicDouble instead.
          Hide
          vijay2win@yahoo.com Vijay added a comment -

          +1

          Show
          vijay2win@yahoo.com Vijay added a comment - +1
          Hide
          brandon.williams Brandon Williams added a comment -

          Committed.

          Show
          brandon.williams Brandon Williams added a comment - Committed.
          Hide
          mkjellman Michael Kjellman added a comment -

          this looks good.

          Show
          mkjellman Michael Kjellman added a comment - this looks good.

            People

            • Assignee:
              brandon.williams Brandon Williams
              Reporter:
              jihartik Jouni Hartikainen
              Reviewer:
              Vijay
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development