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

Coalescing strategy can enter infinite loop

    XMLWordPrintableJSON

    Details

    • Severity:
      Normal
    • Since Version:

      Description

      boolean maybeSleep(int messages, long averageGap, long maxCoalesceWindow, Parker parker)

      maybeSleep() can enter an infinite loop if messages or averageGap ends up being 0 because sleep will be 0 and the while loop will never exit. I've noticed that on one of my clusters twice this week.

      This can happen if in averageGap() sum is bigger than MEASURED_INTERVAL, which should be pretty rare but apparently happen to me.

      Even if the diagnostic is wrong (and I'm pretty sure that this thread was using 100% CPU doing nothing), the fix seems pretty safe to apply.

      diff --git a/src/java/org/apache/cassandra/utils/CoalescingStrategies.java b/src/java/org/apache/cassandra/utils/CoalescingStrategies.java
      index 0aa980f..982d4a6 100644
      --- a/src/java/org/apache/cassandra/utils/CoalescingStrategies.java
      +++ b/src/java/org/apache/cassandra/utils/CoalescingStrategies.java
      @@ -100,7 +100,7 @@ public class CoalescingStrategies
           {
               // only sleep if we can expect to double the number of messages we're sending in the time interval
               long sleep = messages * averageGap;
      -        if (sleep > maxCoalesceWindow)
      +        if (!sleep || sleep > maxCoalesceWindow)
                   return false;
       
               // assume we receive as many messages as we expect; apply the same logic to the future batch:
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                iksaif Corentin Chary
                Reporter:
                iksaif Corentin Chary
                Authors:
                Corentin Chary
                Reviewers:
                Jeff Jirsa
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: