fix(kafka): stop deferred offset stores from queuing behind heartbeat polls - #129
Merged
Divyanshu Tiwari (divyanshu-tiwari) merged 2 commits intoSep 23, 2026
Merged
Conversation
Divyanshu Tiwari (divyanshu-tiwari)
requested a review
from a team
as a code owner
September 23, 2026 14:11
Amit Malakar (amitmalakariitb)
approved these changes
Sep 23, 2026
Ankur Gupta (ankur-pattern)
approved these changes
Sep 23, 2026
Divyanshu Tiwari (divyanshu-tiwari)
deleted the
fix/kafka-store-offset-lock
branch
September 23, 2026 14:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In group read mode,
Finishkeeps polling (heartbeatPoll, 1sPollunderconsumerMu) while deferred acks settle. Each settled ack callsstoreOffset, which also tookconsumerMu, and the ack tracker runs one ack at a time. With partitions paused, every poll blocks for its full second, so stores drained at only a few per second.Runs that read tens of thousands of records therefore spent hours in
Finishafter downstream tasks (e.g. the file writer's_SUCCESS) had already completed. If an external timeout killed the process first, very little was committed. Because acks settle out of order, the stored position per partition barely advances. The next run re-read an even larger backlog.StoreOffsetsandPauseare thread-safe in librdkafka, sostoreOffsetandpausePartitionno longer takeconsumerMu. The lock still serializesPoll/ReadMessage/Commit/Close;Closeruns only after the tracker has drained, so no store can overlap it.Validated with a local (uncommitted) test: 500 deferred acks settled under an active heartbeat loop went from ~19s to <1s.
go test -race ./internal/pkg/pipeline/...passes.Types of changes
Checklist