#9335·greptimedb

Kafka WAL: an append reported as failed may be persisted and replayed after its row sequences are reused

Author: fengjiachunCreated Sep 23, 2026Updated Sep 23, 2026
LabelsC-bug

What type of bug is this?

Data corruption

What subsystems are affected?

Datanode

Minimal reproduce step

Not reproduced deterministically yet; the sequence below follows from the code paths named.

  1. A region write goes to KafkaLogStore::append_batch, and the append returns an error although the record was persisted: either another region in the same batch failed (append_batch joins the per-region produces with try_join_all, so one error fails the call after other regions' records were written), or the produce timed out after the broker stored it (rskafka retries on I/O errors and timeouts without an idempotent producer, producer_id / base_sequence are -1, so a timed-out request may be stored, possibly twice).
  2. Mito reports the write as failed and does not advance the region's committed_sequence (region_write_ctx.rs, the write_wal error path in worker/handle_write.rs), so the next write to the region reuses the same row sequences and is acknowledged.
  3. Restart before a flush covers the later write.

What did you expect to see?

Only acknowledged writes are visible after replay.

What did you see instead?

Replay filters records only by entry_id > flushed_entry_id and re-inserts rows with the sequences recorded in the WAL; deduplication keeps the highest sequence per primary key and timestamp. The persisted-but-failed record is replayed next to the acknowledged write that reused its sequences, and the unacknowledged value can win. If the failed record landed at a higher offset than the later write (client timeout 5 s, broker timeout 30 s), a flush does not cover it either. Append-mode tables can also get duplicate rows from a retried produce.

What operating system did you use?

Any

What version of GreptimeDB did you use?

main

Relevant log output and stack trace

None. Found while reviewing the same failure mode in the object store WAL (#9320, #9334). Related observation: after replay, set_sequence_and_entry_id assigns committed_sequence from the last replayed entry rather than taking the maximum, so it can move backwards; with the experimental sequence-range incremental read of Flow, rows that replay with a sequence at or below the boundary Flow already consumed are never read by Flow.