yifan-c commented on code in PR #1770:
URL: https://github.com/apache/cassandra/pull/1770#discussion_r940527375


##########
src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerCDC.java:
##########
@@ -190,14 +189,20 @@ public CommitLogSegment.Allocation allocate(Mutation 
mutation, int size) throws
         return alloc;
     }
 
-    // Non-blocking mode has just recently been enabled for CDC.
-    // The segment is still marked as FORBIDDEN. It should be set to PERMITTED.
-    private void ensureSegmentPermittedIfNotBlockWrites(CommitLogSegment 
segment)
+    // Permit a forbidden segment under the following conditions.
+    // - Non-blocking mode has just recently been enabled for CDC.
+    // - The CDC total space has droppped below the limit (e.g. CDC consumer 
cleans up).
+    private void permitSegmentMaybe(CommitLogSegment segment)
     {
-        if (!DatabaseDescriptor.getCDCBlockWrites() && segment.getCDCState() 
== CDCState.FORBIDDEN)
+        if (segment.getCDCState() != CDCState.FORBIDDEN)
+            return;
+
+        if (!DatabaseDescriptor.getCDCBlockWrites()
+            || cdcSizeTracker.sizeInProgress.get() < 
DatabaseDescriptor.getCDCTotalSpace())

Review Comment:
   It makes sense. The if statement is what I proposed in the earlier comment. 
The ease of handling in the current implementation is what I guessed by reading 
the code.



-- 
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