dcapwell commented on code in PR #3743:
URL: https://github.com/apache/cassandra/pull/3743#discussion_r1917511632


##########
src/java/org/apache/cassandra/journal/Journal.java:
##########
@@ -906,8 +941,19 @@ private String maybeAddDiskSpaceContext(String message)
     @VisibleForTesting
     public void truncateForTesting()
     {
-        advanceSegment(null);
-        segments.set(Segments.none());
+        ActiveSegment<?, ?> discarding = currentSegment;
+        if (discarding.index.size() > 0) // if there is no data in the 
segement then ignore it
+        {
+            closeCurrentSegmentForTestingIfNonEmpty();
+            // wait for the ActiveSegment to get released, else can see weird 
race conditions;
+            // this thread will see the static segmenet and will release it 
(which will delete the file),
+            // and the sync thread will then try to release and will fail as 
the file no longer exists...
+            while (discarding.selfRef().globalCount() > 0) {}

Review Comment:
   done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to