squah-confluent commented on code in PR #21396:
URL: https://github.com/apache/kafka/pull/21396#discussion_r2777714569
##########
coordinator-common/src/main/java/org/apache/kafka/coordinator/common/runtime/CoordinatorRuntime.java:
##########
@@ -879,15 +880,23 @@ private void maybeFlushCurrentBatch(long currentTimeMs) {
}
}
+ private void failCurrentBatch(Throwable t) {
+ failCurrentBatch(t, true);
+ }
+
+ private void failCurrentBatchWithoutRelease(Throwable t) {
+ failCurrentBatch(t, false);
+ }
+
/**
* Fails the current batch, reverts to the snapshot to the base/start
offset of the
* batch, fails all the associated events.
*/
- private void failCurrentBatch(Throwable t) {
+ private void failCurrentBatch(Throwable t, boolean freeCurrentBatch) {
if (currentBatch != null) {
coordinator.revertLastWrittenOffset(currentBatch.baseOffset);
currentBatch.deferredEvents.complete(t);
- freeCurrentBatch();
+ if (freeCurrentBatch) freeCurrentBatch();
Review Comment:
A benefit of this approach is that we always set `currentBatch` to null when
failing a batch. Previously, we could fail to flush after a leadership change
before the unload, then fail to remove `currentBatch` and continue to use the
failed batch before the unload. I'd rather we didn't have to consider that
state.
--
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]