nodece commented on code in PR #26184:
URL: https://github.com/apache/pulsar/pull/26184#discussion_r3578059600


##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedCursorImpl.java:
##########
@@ -1275,6 +1275,18 @@ public int 
getNonContiguousDeletedMessagesRangeSerializedSize() {
 
     @Override
     public long getEstimatedSizeSinceMarkDeletePosition() {
+        Position markDeletePosition = this.markDeletePosition;
+        Position lastPosition = ledger.getLastPosition();
+        if (markDeletePosition == null || 
markDeletePosition.compareTo(lastPosition) >= 0) {

Review Comment:
   I wonder if we can simplify this a bit.
   
   Since this method only estimates the backlog size, would it be sufficient to 
return 0 whenever `markDeletePosition == null` or 
`markDeletePosition.compareTo(lastPosition) >= 0`?
   
   ```
   if (markDeletePosition == null
           || markDeletePosition.compareTo(lastPosition) >= 0) {
       return 0;
   }
   ```
   
   This avoids introducing special handling for `ledgerExists()` and 
`isMarkDeletePositionOnEmptyCurrentLedger()`, while also covering the ledger 
rollover case where `getLastPosition()` temporarily lags behind 
`markDeletePosition`.
   
   Besides the temporary inconsistency during ledger rollover, are there any 
other cases that this logic is intended to cover?
   



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

Reply via email to