fluss icon indicating copy to clipboard operation
fluss copied to clipboard

[common] Introduce V3 log record batch format with writer epoch

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. The V2 batch header only has a writer ID and a batch sequence. Writer epochs and Kafka's record-level sequence numbers need a writer epoch in the header and a way to know the last sequence of a batch.

Solution

  • Add log magic V3, which adds writerEpoch (2 bytes) after writerId. The header grows to 58 bytes and batchSequence becomes baseSequence.
  • Attributes bit 1 sets the sequence mode. When it is clear, the last sequence equals the base sequence and sequences count batches, as today. When it is set, the last sequence is baseSequence + lastOffsetDelta and sequences count records, wrapping around like Kafka.
  • Read V0–V2 batches with writerEpoch = 0 and bit 1 clear.
  • V3 writes are enabled through the cluster feature gate in #5187.
  • Convert V3 batches to the old format for FETCH_LOG v0 clients, with the same rows and offsets, including batches in remote segments. The conversion builds on the FETCH_LOG versions from #5187.
  • Add V3 read support to the Java client. The Rust client follows in #5144.
  • Tests: V2 and V3 batches in the same table read by the Java client, and old clients reading and writing on a cluster with V3 enabled.

Willingness to contribute

  • [x] I'm willing to submit a PR!

dstolis avatar Nov 07 '26 08:11 dstolis