jiafu1115 commented on code in PR #20913:
URL: https://github.com/apache/kafka/pull/20913#discussion_r3261872082


##########
storage/src/main/java/org/apache/kafka/server/log/remote/storage/RemoteLogManager.java:
##########
@@ -937,6 +946,68 @@ List<EnrichedLogSegment> candidateLogSegments(UnifiedLog 
log, Long fromOffset, L
             return candidateLogSegments;
         }
 
+        private boolean delayCopy(LogConfig logConfig, LogSegment previousSeg, 
long currentTimeMs, long totalLogSize, long cumulativeSize) {
+            if (logConfig == null) {
+                return false;
+            }
+
+            long copyLagMs = logConfig.remoteCopyLagMs();
+            long copyLagBytes = logConfig.remoteCopyLagBytes();
+            if (logger.isTraceEnabled()) {
+                logger.trace("delayCopy check for segment {}: copyLagMs={}, 
copyLagBytes={}, currentTimeMs={}, totalLogSize={}, cumulativeSize={}, 
sizeLagBytes={}",
+                        previousSeg, copyLagMs, copyLagBytes, currentTimeMs, 
totalLogSize, cumulativeSize, totalLogSize - cumulativeSize);
+            }
+
+            if (copyLagMs == 0 || copyLagBytes == 0) {
+                return false;
+            }
+
+            boolean needCheckCopyLagMs =  copyLagMs > 0;
+            boolean needCheckCopyLagBytes = copyLagBytes > 0;
+
+            // When no lag delay is enabled, upload immediately.
+            if (!needCheckCopyLagMs && !needCheckCopyLagBytes) {

Review Comment:
   I add the missed test case. Maybe the only difference about result between 
our code is whether this new added test case can passed or not.
   <img width="756" height="500" alt="image" 
src="https://github.com/user-attachments/assets/189e894a-4169-4c1b-87bd-ef446b0b2862";
 />
   
   another tiny difference is performance instead of result:
   my code approach:
   if one is MAX value. I don't check the configure.
   
   your code approach:
   if one is MAX value. you still check it and get the result is false.
   `          shouldUploadNow = segmentAgeMs >= effectiveCopyLagMs;
   `
   



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