Skip to content

Commit

Permalink
fix: resolve and commit offsets from partial aborts
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Dec 19, 2021
1 parent 1fe29b0 commit 57b38d1
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/consumer/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,24 @@ module.exports = class Runner extends EventEmitter {
}

/**
* If the batch contained control records but no otherwise processable records then we
* still need to emit START|END batch instrumentation events to allow any listeners
* keeping track of offsets to know about the latest point of consumption
* If the batch contained only control records or only aborted messages then we still
* need to resolve and auto-commit to ensure the consumer can move forward.
*
* We also need to emit batch instrumentation events to allow any listeners keeping
* track of offsets to know about the latest point of consumption.
*/
if (batch.isEmptyControlRecord()) {
if (batch.isEmpty() && !batch.isEmptyIncludingFiltered()) {
this.instrumentationEmitter.emit(START_BATCH_PROCESS, payload)

this.consumerGroup.resolveOffset({
topic: batch.topic,
partition: batch.partition,
offset: batch.lastOffset(),
})
await this.autoCommitOffsetsIfNecessary()

this.instrumentationEmitter.emit(END_BATCH_PROCESS, { ...payload, duration: 0 })
return
}

if (batch.isEmpty()) {
Expand Down

0 comments on commit 57b38d1

Please sign in to comment.