DL1231 commented on code in PR #20837:
URL: https://github.com/apache/kafka/pull/20837#discussion_r2540500858


##########
core/src/main/java/kafka/server/share/SharePartition.java:
##########
@@ -1885,7 +1908,21 @@ private int acquireSubsetBatchRecords(
                     continue;
                 }
 
-                InFlightState updateResult =  
offsetState.getValue().tryUpdateState(RecordState.ACQUIRED, 
DeliveryCountOps.INCREASE,
+                int recordDeliveryCount = 
offsetState.getValue().deliveryCount();
+                // On last delivery attempt, submit acquired records,
+                // bad record will be delivered alone next time
+                if (maxDeliveryCount > 2 && recordDeliveryCount == 
maxDeliveryCount - 1 && acquiredCount > 0) {
+                    hasBadRecord = true;
+                    break;
+                }
+
+                // On repeated delivery failures (>= 
badRecordDeliveryThreshold), progressively reduce batch size to isolate bad 
record
+                if (recordDeliveryCount >= badRecordDeliveryThreshold && 
maxFetchRecordsWhileBadRecord < 0) {
+                    maxFetchRecordsWhileBadRecord = Math.max(1, (long) 
inFlightBatch.offsetState().size() >> (recordDeliveryCount - 
badRecordDeliveryThreshold + 1));
+                    hasBadRecord = true;
+                }

Review Comment:
   Done.



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