yifan-c commented on a change in pull request #1379:
URL: https://github.com/apache/cassandra/pull/1379#discussion_r786431467
##########
File path:
src/java/org/apache/cassandra/db/commitlog/CommitLogSegmentManagerCDC.java
##########
@@ -264,29 +301,31 @@ public void start()
*/
void processNewSegment(CommitLogSegment segment)
{
- // See synchronization in CommitLogSegment.setCDCState
- synchronized(segment.cdcStateLock)
+ int segmentSize = defaultSegmentSize();
+ long allowance = allowableCDCBytes();
+ boolean blocking = DatabaseDescriptor.getCDCBlockWrites();
+
+ synchronized (segment.cdcStateLock)
{
- int segmentSize = defaultSegmentSize();
- long allowance = allowableCDCBytes();
- boolean blocking = DatabaseDescriptor.getCDCBlockWrites();
segment.setCDCState(blocking && segmentSize +
sizeInProgress.get() > allowance
? CDCState.FORBIDDEN
: CDCState.PERMITTED);
- // Remove the oldest cdc segment file when exceeding the CDC
storage allowance
- while (!blocking && segmentSize + sizeInProgress.get() >
allowance)
- {
- long releasedSize =
segmentManager.deleteOldestLinkedCDCCommitLogSegment();
- sizeInProgress.getAndAdd(-releasedSize);
- logger.debug("Freed up {} bytes after deleting the oldest
CDC commit log segment in non-blocking mode. " +
- "Total on-disk CDC size: {}; allowed CDC
size: {}",
- releasedSize, sizeInProgress.get() +
segmentSize, allowance);
- }
-
// Aggresively count in the (estimated) size of new segments.
if (segment.getCDCState() == CDCState.PERMITTED)
- sizeInProgress.getAndAdd(segmentSize);
+ addSize(segmentSize);
+ }
+
+ // Remove the oldest cdc segment file when exceeding the CDC
storage allowance
+ if (!blocking && sizeInProgress.get() > allowance)
+ {
+ long bytesToFree = sizeInProgress.get() - allowance;
+ long remaningSize =
segmentManager.deleteOldLinkedCDCCommitLogSegment(bytesToFree);
+ long releasedSize = sizeInProgress.get() - remaningSize;
+ sizeInProgress.getAndSet(remaningSize);
+ logger.debug("Freed up {} ({}) bytes after deleting the oldest
CDC commit log segments in non-blocking mode. " +
+ "Total on-disk CDC size: {}; allowed CDC size:
{}",
Review comment:
The value of the `remainingSize` is used in the log message.
`sizeInProgress` is updated with `remainingSize` just before logging. I am OK
to use `remainingSize` instead.
It is a debug message. I was using `bytesToFree` and `releasedSize` to
inspect what is the size it expects to reclaim and what is the size it actually
reclaimed.
--
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]