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


##########
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:
   `The CDCSizeTracker must have run at least once. In this case, the size of 
the file (allocatingFrom) is already counted.` <- I didn't connect that. You're 
right.
   
   `maybe we want to created the link unless the state is FORBIDDEN?`
   🤔 We shouldn't hard link the file if the cdcState in there is FORBIDDEN 
should we?
   ```
   // Hard link file in cdc folder for realtime tracking
   FileUtils.createHardLink(segment.logFile, segment.getCDCFile());
   ```



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