lh0156 opened a new pull request, #23048:
URL: https://github.com/apache/kafka/pull/23048

   Closes KAFKA-13185
   
   ### Summary
   
   - Clear the pending `messageBatch` when a sink task pre-commit fails and the 
consumer is rewound to the last committed position.
   - Clear the matching `origOffsets` as well, so the discarded batch cannot 
advance `currentOffsets` during the recovery poll.
   - Add a regression test covering a retriable `put`, a failed `preCommit`, 
and the subsequent empty delivery.
   
   When `SinkTask.put` raises a `RetriableException`, `WorkerSinkTask` keeps 
the batch for redelivery. If the following `preCommit` also fails, the worker 
seeks to the last committed offset but previously retained that batch. The next 
poll could therefore deliver stale records, and retaining `origOffsets` could 
reintroduce offsets that had just been rewound. The recovery path now discards 
both pieces of pending state before polling again.
   
   ### Tests
   
   - `./gradlew :connect:runtime:test --tests 
org.apache.kafka.connect.runtime.WorkerSinkTaskTest.testPreCommitFailureClearsPendingMessageBatch
 --no-build-cache --console=plain`
   - `./gradlew :connect:runtime:spotlessCheck :connect:runtime:test --tests 
org.apache.kafka.connect.runtime.WorkerSinkTaskTest --no-build-cache 
--console=plain`
   - `./gradlew :connect:runtime:test --no-build-cache --console=plain`
   
   The regression test was verified RED before the fix because the stale batch 
was delivered with one record, then GREEN after the fix with an empty delivery 
and last-committed offsets preserved.


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