You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2022/05/06 15:30:41 UTC

[GitHub] [cassandra] josh-mckenzie commented on a diff in pull request #1605: CASSANDRA-17416: Test Failure: org.apache.cassandra.db.commitlog.CommitLogSegmentManagerCDCTest.testCDCIndexFileWriteOnSync

josh-mckenzie commented on code in PR #1605:
URL: https://github.com/apache/cassandra/pull/1605#discussion_r866942204


##########
test/unit/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerCDCTest.java:
##########
@@ -157,11 +157,25 @@ public void testCDCIndexFileWriteOnSync() throws IOException
         Assert.assertTrue("Index file not written: " + cdcIndexFile, cdcIndexFile.exists());
 
         // Read index value and confirm it's == end from last sync
-        BufferedReader in = new BufferedReader(new FileReader(cdcIndexFile));
-        String input = in.readLine();
-        Integer offset = Integer.parseInt(input);
-        Assert.assertEquals(syncOffset, (long)offset);
-        in.close();
+        String input = null;
+        // There could be a race between index file update (truncate & write) and read. See CASSANDRA-17416
+        // It is possible to read an empty line. In this case, re-try at most 5 times.
+        for (int i = 0; input == null && i < 5; i++)
+        {
+            try (BufferedReader in = new BufferedReader(new FileReader(cdcIndexFile)))

Review Comment:
   Worth putting a small sleep in here to give the system the wiggle room to allow the scheduler to put the index file writing thread back on the stack and write the file out instead of just spinning on it 5 times?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org