How are transaction markers timestamped, and what timestamp do committed records carry under LogAppendTime vs CreateTime?
answer
- CreateTime = producer time; LogAppendTime = broker overwrites at append
- marker stamped at coordinator/append finalization time
- data timestamps fixed at original append, not at commit
- LogAppendTime set on first append, not on marker
- long open txn: event-time << visibility time
basics
~20 sMarkers are control batches the broker stamps with broker append time. Data records keep their producer CreateTime unless the topic uses message.timestamp.type=LogAppendTime, in which case the leader overwrites every record's timestamp with the broker's append time when it appends the batch.
solid answer
~40 sA topic's `message.timestamp.type` is either CreateTime (default) or LogAppendTime. Under CreateTime, each record carries the timestamp the producer set, and the batch's max timestamp reflects producer time. Under LogAppendTime, the partition leader overwrites the batch's timestamp with its own broker clock at append, so all records in the batch share the broker append time and downstream time-based logic (log retention, time-index lookups, stream event-time) sees broker time. Transaction markers are control batches written by the coordinator's WriteTxnMarkers path; the appending leader stamps them with its append-time clock, and they are excluded from normal max-timestamp/time-index accounting for application data. Practically: committing a transaction does not retroactively change committed records' timestamps — those were fixed when the records were originally appended (CreateTime preserved, or LogAppendTime stamped at first append), regardless of when the marker later lands.
go deeper
Know CreateTime keeps producer time and LogAppendTime uses broker time; commit doesn't change record timestamps.
Explain that LogAppendTime overwrites at original append and that markers are broker-stamped control batches.
Reason about the gap between event-time (original append) and visibility-time (marker) for stream processing.
Discuss retention/time-index implications and watermark/late-data behavior in read_committed streaming pipelines.
## Timestamp types Every Kafka record has a timestamp. The topic config **`message.timestamp.type`** controls its meaning: - **CreateTime** (default): the timestamp is whatever the *producer* set (usually `System.currentTimeMillis()` at send, or an explicit value via `ProducerRecord(timestamp, ...)`). The broker preserves it. - **LogAppendTime**: the *partition leader* overwrites the timestamp with its own wall clock at the instant it appends the batch to the log. Every record in that appended batch effectively reports the broker append time. The producer's original timestamp is discarded for storage purposes. The choice affects: log **retention** (`log.retention.ms` compares against record timestamps), the **time index** (`.timeindex`, used by `offsetsForTimes`), and any **event-time** processing in Kafka Streams or consumers. ## How markers fit in A **transaction marker** is a control batch appended by the partition leader when it handles the coordinator's `WriteTxnMarkers` request. Like any append, the leader assigns it a timestamp using the broker clock. Markers are control batches, so: - They are **not** application records; the consumer never delivers them and they do not appear in user-facing time-based queries the way data does. - The marker's own timestamp is essentially the *coordinator-driven append time* — i.e., the time the transaction was finalized on that partition, not the time the data was produced. ## The key correctness point: commit does not rewrite data timestamps The data records of a transaction are appended **when the producer sends them** (during the open transaction), long before the marker is written at commit. Their timestamps are fixed at that first append: - Under **CreateTime**, they keep the producer's timestamps permanently. - Under **LogAppendTime**, they were stamped with the broker append time *at the moment of the original data append*, NOT at marker/commit time. So if a transaction stays open for 30 seconds, its records still carry timestamps from when they were produced/appended, even though the COMMIT marker (and thus visibility) happens 30 seconds later. This matters for stream processing: event-time windows key off the record timestamps, not the commit/marker time, so a long transaction can produce records whose event-time is well before they become visible — a source of apparent 'late' data and watermark complications in read_committed pipelines. ## Edge cases / propagation - The batch **maxTimestamp** and time-index entries are derived from the data batches; control (marker) batches are handled specially so they don't corrupt application time indexing. - Because LogAppendTime is set at original append, replaying/compaction does not change it; markers do not 'propagate' a new timestamp onto the data. - Mixing producers with skewed clocks under CreateTime can make retention/ordering surprising; LogAppendTime trades producer event-time fidelity for monotone broker-side time. Transactions don't alter this trade-off — only original append time matters.
- If a transaction stays open for 30s, does the COMMIT marker change the committed records' timestamps?No. The data records' timestamps were fixed at their original append (producer CreateTime, or broker time under LogAppendTime). The marker only finalizes visibility; it does not rewrite data timestamps.
- Under LogAppendTime, at what moment is a record's timestamp set?When the partition leader first appends the data batch to the log during the open transaction — not when the commit marker is later written.
saying these in an interview costs you the question
- Claiming LogAppendTime stamps records at commit/marker time rather than original append time.
- Saying a transaction commit rewrites or shifts data record timestamps.
- Confusing the marker's timestamp with the data records' timestamps.
- Assuming event-time windows key off commit time rather than record timestamp.