fix(protocol): backport ElectLeaders V1 non-flexible header fix#16
Merged
3AceShowHand merged 2 commits intopingcap:v1.41.2-pingcapfrom Apr 20, 2026
Merged
Conversation
Backport IBM#3478 and the supporting flexible codec changes\nneeded on v1.41.2-pingcap.\n\nThis fixes ElectLeaders V1 request/response header selection for\nlow-version clients talking to newer brokers.
8451a02 to
e71f850
Compare
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.
Summary
Backport the upstream
ElectLeadersprotocol fixes tov1.41.2-pingcapand align our flexible protocol codec with upstream so that low-versionElectLeadersrequests and responses use the correct header format.Problem
After
#3209was backported, our branch sat in a half-migrated state for flexible protocol handling:ElectLeadersV1 could be treated as flexible when it must use the non-flexible header formatkafka: insufficient data to decode packet, more bytes expectedWhat This PR Does
ElectLeadersrequest/response header version selection so V1 uses non-flexible headers and V2 uses flexible headersElectLeadersV1 and V2Why The Diff Is Larger Than The Upstream Fix PR
The direct upstream
ElectLeadersfix is small, but our branch did not yet fully match the upstream flexible codec architecture. To make the backport correct and reduce future cherry-pick conflicts, this PR also brings over the supporting codec changes that upstream already relies on.Upstream References
Primary upstream PR:
fix(protocol): handle ElectLeaders V1 non-flexible headersfix(protocol): handle ElectLeaders V1 non-flexible headers IBM/sarama#3478
Related upstream fix history:
fix: non-flexible ElectLeadersRequest V0/V1 encode/decodefix: non-flexible ElectLeadersRequest V0/V1 encode/decode IBM/sarama#3312
Supporting upstream commits backported here:
7b11d9ccrefactor: flexible decoding78601bd8refactor: flexible encoding9e0c1c29fix: decoder issues (#3327)Upstream issue:
ElectLeaderscompatibility bug;IBM/sarama#3478itself documents the problem and repro.Testing
Verified locally with:
env GOCACHE=/tmp/go-build-cache go test ./... -run '^$'env GOCACHE=/tmp/go-build-cache go test . -run '^TestElectLeaders(Request|Response|RequestHeaderVersion|ResponseHeaderVersion)$' -count=1