[ https://issues.apache.org/jira/browse/CASSANDRA-13397?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Simon Zhou updated CASSANDRA-13397: ----------------------------------- 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: {code} 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"); } } {code} was: While looking into repair code, I realize that we should check return value of CountDownLatch.await(). However, there are some places we don't check and some of them may cause bad consequent behavior, like in ActiveRepairService#prepareForRepair and StorageProxy#describeSchemaVersions. I haven't checked the original version that has this bug but at least StorageProxy#describeSchemaVersions has the bug starting from 2010. Code to reproduce: {code} 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"); } } {code} > Return value of CountDownLatch.await() not being checked > -------------------------------------------------------- > > Key: CASSANDRA-13397 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13397 > Project: Cassandra > Issue Type: Bug > Reporter: Simon Zhou > Assignee: Simon Zhou > > 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: > {code} > 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"); > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)