fluss
fluss copied to clipboard
[kafka] Support Kafka idempotent producer
Search before asking
- [x] I searched in the issues and found nothing similar.
Motivation
Part of #5088. Kafka producers run with enable.idempotence=true by default and can't write to Fluss with that setting today.
Solution
- Support
InitProducerIdby callingInitWriter, and return the writer ID as the producer ID with epoch 0. - Map the Kafka producer ID and epoch to the V3
writerIdandwriterEpoch, and the Kafka base sequence tobaseSequence, with attributes bit 1 set so the last sequence isbaseSequence + lastOffsetDelta. - Each Kafka record is stored as one row, including records with a null value, so the last sequence always matches the Kafka batch.
- Return
OUT_OF_ORDER_SEQUENCE_NUMBERandINVALID_PRODUCER_EPOCHas a Kafka broker would. Like a Kafka broker, accept the first batch of a producer the bucket does not know yet. - While V3 is not enabled on the cluster (#5187),
InitProducerIdfails, so the producer gets a clear error instead of writing without idempotence. - Depends on #5089, #5187 and #5091.
- Tests: the Kafka Java producer with default settings, retries after timeouts and leader changes, epoch bumps, and batches with null values.
Willingness to contribute
- [x] I'm willing to submit a PR!