fluss icon indicating copy to clipboard operation
fluss copied to clipboard

[kafka] Support Kafka idempotent producer

Open dstolis opened this issue 3 weeks ago • 0 comments

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 InitProducerId by calling InitWriter, and return the writer ID as the producer ID with epoch 0.
  • Map the Kafka producer ID and epoch to the V3 writerId and writerEpoch, and the Kafka base sequence to baseSequence, with attributes bit 1 set so the last sequence is baseSequence + 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_NUMBER and INVALID_PRODUCER_EPOCH as 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), InitProducerId fails, 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!

dstolis avatar Nov 07 '26 08:11 dstolis