You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "smjn (via GitHub)" <gi...@apache.org> on 2026/07/22 11:59:47 UTC
[PR] MINOR: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
smjn opened a new pull request, #22905:
URL: https://github.com/apache/kafka/pull/22905
### What
A compressed source record could decompress to far more data than its on-wire size suggests, since the previous implementation fully materialized a compressed batch via `DefaultRecordBatch.iterator()` and allocated per-record buffers based on an unchecked, attacker-controlled length. Compressed v2 batches are now decompressed into a size-capped buffer before any record is parsed, so even a single oversized record can't force a large allocation; the cap is derived from the DLQ topic's own `max.message.bytes` rather than an arbitrary constant. Uncompressed batches are left uncapped (no expansion risk), and fetch()/resume() now catch Throwable so an OOM can't escape uncontained.
### Testing
Added new unit tests in `ShareGroupDLQRecordFetcherTest` and integ tests in `ShareConsumerDLQTest`.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20723: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
Posted by "smjn (via GitHub)" <gi...@apache.org>.
smjn commented on code in PR #22905:
URL: https://github.com/apache/kafka/pull/22905#discussion_r3637458548
##########
server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:
##########
@@ -197,19 +236,163 @@ private long collect(long readFrom, LogReadResult logReadResult) {
/**
* Adds the records within the requested range to the map and returns the offset to read from next
- * (never moves backwards). Records below readFrom or above endOffset are ignored.
+ * (never moves backwards). Records below readFrom or above endOffset are ignored. Sets {@link #aborted}
+ * and stops early if the decompression budget ({@link #maxDecompressedBytes}) is exhausted.
Review Comment:
nextOffset tracks which offset we want to read from next. When we encounter endOffset - we do not want to go any further. It represents the progress made so far, which is the invariant.
In `runFrom` we make sure that no progress completes the future.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20723: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield merged PR #22905:
URL: https://github.com/apache/kafka/pull/22905
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20723: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
Posted by "smjn (via GitHub)" <gi...@apache.org>.
smjn commented on code in PR #22905:
URL: https://github.com/apache/kafka/pull/22905#discussion_r3637458548
##########
server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:
##########
@@ -197,19 +236,163 @@ private long collect(long readFrom, LogReadResult logReadResult) {
/**
* Adds the records within the requested range to the map and returns the offset to read from next
- * (never moves backwards). Records below readFrom or above endOffset are ignored.
+ * (never moves backwards). Records below readFrom or above endOffset are ignored. Sets {@link #aborted}
+ * and stops early if the decompression budget ({@link #maxDecompressedBytes}) is exhausted.
Review Comment:
nextOffset tracks which offset we want to read from next. When we encounter endOffset - we do not want to go any further. It represents the progress made so far, which is the invariant.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20723: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
Posted by "smjn (via GitHub)" <gi...@apache.org>.
smjn commented on PR #22905:
URL: https://github.com/apache/kafka/pull/22905#issuecomment-5057297356
> Thanks for the PR. This is a good improvement.
>
> If I understand correctly, this code will only collect decompressed records where the size of the entire decompressed batch is less than the max message bytes of the DLQ topic.
@AndrewJSchofield
Thanks for the review.
I have raised a revision where decompressed data is bounded on per batch basis - so if we have batches b1, b2, BIGB3, b4, where BIGB3 is huge - only that will be skipped.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20723: Bound decompression memory in ShareGroupDLQRecordFetcher [kafka]
Posted by "AndrewJSchofield (via GitHub)" <gi...@apache.org>.
AndrewJSchofield commented on code in PR #22905:
URL: https://github.com/apache/kafka/pull/22905#discussion_r3636706253
##########
server/src/main/java/org/apache/kafka/server/share/dlq/ShareGroupDLQRecordFetcher.java:
##########
@@ -197,19 +236,163 @@ private long collect(long readFrom, LogReadResult logReadResult) {
/**
* Adds the records within the requested range to the map and returns the offset to read from next
- * (never moves backwards). Records below readFrom or above endOffset are ignored.
+ * (never moves backwards). Records below readFrom or above endOffset are ignored. Sets {@link #aborted}
+ * and stops early if the decompression budget ({@link #maxDecompressedBytes}) is exhausted.
Review Comment:
What does the return value here actually signify? It looks like the next offset to be read, but I wonder what the `if (record.offset() > endOffset) return nextOffset` logic achieves. The next offset doesn't advance in that case, which seems unintuitive.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org