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

Return value of CountDownLatch.await() not being checked in Repair

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Low
    • Resolution: Fixed
    • Fix Version/s: 3.0.14, 3.11.0, 4.0
    • Component/s: None
    • Labels:
      None
    • Severity:
      Low

      Description

      While looking into repair code, I realize that we should check return value of CountDownLatch.await(). Most of the places that we don't check the return value, nothing bad would happen due to other protection. However, ActiveRepairService#prepareForRepair should have the check. Code to reproduce:

          public static void testLatch() throws InterruptedException {
              CountDownLatch latch = new CountDownLatch(2);
              latch.countDown();
      
              new Thread(() -> {
                  try {
                      Thread.sleep(1200);
                  } catch (InterruptedException e) {
                      System.err.println("interrupted");
                  }
                  latch.countDown();
                  System.out.println("counted down");
              }).start();
      
      
              latch.await(1, TimeUnit.SECONDS);
              if (latch.getCount() > 0) {
                  System.err.println("failed");
              } else {
                  System.out.println("success");
              }
          }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                szhou Simon Zhou
                Reporter:
                szhou Simon Zhou
                Authors:
                Simon Zhou
                Reviewers:
                Paulo Motta
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: