Repository navigation
fix(binding-kafka): batch records that have no producer id - #3300
Merged
Merged
Conversation
Two records written without a producer id (producer id, epoch and sequence all -1) arrive at the produce client back to back. The produce request must carry them as one record batch of two records, with the batch header's producer id, epoch and base sequence left at -1. The scenario fails against the current client, which sends the first record on its own, so the batch holds one record where two are expected. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTq7qqb5tJqF7DRxHv
The produce client opened a new record batch whenever the batch's base sequence was not below the incoming record's sequence. A record without a producer id carries sequence -1 and the batch it starts has base sequence -1, so the test held for every such record and each one became its own batch. A produce request carries a single batch per partition, so each record cost its own request and round trip. Apply the sequence test only to records that have a producer id. Records without one now share a batch until the producer id or epoch changes. The fragmented message CRC scenario relied on one batch per record. Give each of its records a distinct producer id so each still produces its own batch and request, and update the batch header fields and CRCs to match. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoTq7qqb5tJqF7DRxHv
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
The produce client opened a new record batch whenever the batch's base sequence was not below the incoming record's sequence (
baseSequence >= sequence). A record without a producer id carries sequence-1, and the batch it starts has base sequence-1, so the test held for every such record and each one became its own batch. A produce request carries a single batch per partition and the client keeps one request in flight per partition stream, so each record cost its own request and round trip.The sequence test now applies only to records that have a producer id. Records without one share a batch until the producer id or epoch changes.
Two commits, test first:
test(binding-kafka): send records without a producer id in one batchadds the scenariomessage.values.no.producer.id(producer id, epoch and sequence all-1, two records). It fails against the previous client: the first request carries one record, 125 bytes where the batch of two records is 144.fix(binding-kafka): batch records that have no producer idis the one-line change inKafkaClientProduceFactory.Changed scenario
messages.fragmented.crcrelied on one batch per record. To keep it deterministic and independent of the batching policy, each of its eight records now has a distinct producer id (epoch 1, sequence 0), so each is still its own batch and request. The batch header producer fields and CRCs in the network scripts are updated to match. The CRC literals were computed from the batch bytes; the same calculation reproduces the previous literal for producer id-1. Four of them are above 2^31 and are written as their signed 32-bit values because k3po parses integer literals as signed ints.This scenario no longer covers fragmented values with a CRC on the path without a producer id.
Tests
./mvnw clean installfrom the repository root with checks enabled passes (219 modules, build cache restored).ClientProduceIT.shouldSendMessageValuesNoProducerIdfails before the fix and passes after.ProduceITmethods inspecs/binding-kafka.spec(networkandapplication) pass for the new scenario.Not addressed
Fixes #3299
Generated by Claude Code