Skip to content

fix(consumer): decouple FetchRequest.MaxBytes from MaxResponseSize#3538

Merged
dnwe merged 1 commit into
mainfrom
dnwe/fetch-size
May 14, 2026
Merged

fix(consumer): decouple FetchRequest.MaxBytes from MaxResponseSize#3538
dnwe merged 1 commit into
mainfrom
dnwe/fetch-size

Conversation

@dnwe
Copy link
Copy Markdown
Collaborator

@dnwe dnwe commented May 14, 2026

Per KIP-74, a v3+ broker may return up to one extra RecordBatch beyond the requested MaxBytes to guarantee progress when a single record exceeds the limit. Sending request.MaxBytes = MaxResponseSize left no headroom, so legitimate responses tripped the response-header size check with "message of length N too large or too small".

Introduce Consumer.Fetch.MaxBytes (default 50 MiB, matching the JVM client's fetch.max.bytes) for the request limit, leaving MaxResponseSize as the OOM safety net.

Fixes #1370

Per KIP-74, a v3+ broker may return up to one extra RecordBatch beyond
the requested MaxBytes to guarantee progress when a single record
exceeds the limit. Sending request.MaxBytes = MaxResponseSize left no
headroom, so legitimate responses tripped the response-header size
check with "message of length N too large or too small".

Introduce Consumer.Fetch.MaxBytes (default 50 MiB, matching the JVM
client's fetch.max.bytes) for the request limit, leaving MaxResponseSize
as the OOM safety net.

Fixes #1370

Signed-off-by: Dominic Evans <dominic.evans@uk.ibm.com>
@dnwe dnwe added the fix label May 14, 2026
Copy link
Copy Markdown
Collaborator

@hindessm hindessm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dnwe
Copy link
Copy Markdown
Collaborator Author

dnwe commented May 14, 2026

I'm going to add a 'breaking' label to this one so its flagged up in the release notes. It's not technically a breaking change, but it is a change in behaviour that by default we'll only fetch up to 50MB in a single fetch request where before we could have fetched up to 100MB

@dnwe dnwe added the breaking label May 14, 2026
@dnwe dnwe merged commit 917cb7f into main May 14, 2026
18 checks passed
@dnwe dnwe deleted the dnwe/fetch-size branch May 14, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sarama Consumer should not check for MaxResponseSize in FetchResponse >= v3

2 participants