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


##########
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` sums up the size of all commit logs, including CDC and 
non-CDC files, since it creates hard links for all newly created files. (A side 
question is.. maybe we want to created the link unless the state is 
`FORBIDDEN`?). So the size is often an over-estimate when the workload contains 
both CDC and non-CDC traffic. 
   Back to the scenario in `allocate`... if the state was previously 
`FORBIDDEN`, it means the total size has exceeded the limit at the time of 
creation. Now, the total size drops below the limit. The `CDCSizeTracker` must 
have run at least once. In this case, the size of the file (`allocatingFrom`) 
is already counted. 



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