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

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

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 3.0.14, 3.11.0, 4.0-alpha1, 4.0
    • None
    • None
    • 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

        1. CASSANDRA-13397-v1.patch
          3 kB
          Simon Zhou

        Issue Links

          Activity

            People

              szhou Simon Zhou
              szhou Simon Zhou
              Simon Zhou
              Paulo Motta
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: