TakaHiR07 commented on code in PR #4638:
URL: https://github.com/apache/bookkeeper/pull/4638#discussion_r2299674287


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java:
##########
@@ -455,9 +455,10 @@ void batchRecoverLedgerFragmentEntry(final long 
startEntryId,
         int entriesToReplicateCnt = (int) (endEntryId - startEntryId + 1);
         int maxBytesToReplicate = conf.getReplicationRateByBytes();
         if (replicationThrottle != null) {
-            if (maxBytesToReplicate != -1 && maxBytesToReplicate > 
averageEntrySize.get() * entriesToReplicateCnt) {
-                maxBytesToReplicate = averageEntrySize.get() * 
entriesToReplicateCnt;
-            }
+            int bytesToReplicateCnt = averageEntrySize.get() * 
entriesToReplicateCnt;
+            bytesToReplicateCnt = bytesToReplicateCnt >= 0 ? 
bytesToReplicateCnt : Integer.MAX_VALUE;
+            maxBytesToReplicate = Math.min(maxBytesToReplicate, 
bytesToReplicateCnt);

Review Comment:
   This modification is incorrect. maxBytesToReplicate still may be negative if 
averageEntrySize.get() is negative, and then 
replicationThrottle.acquire(maxBytesToReplicate) is stuck.
   
   I think we should "wrap around" the negative value and make it become 
positive. We should keep the bookie Availability first.
   
   



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