Unit 9 of 15 · about 4 hours · derive, implement
Watermarks, idle-source stalls and late-data policy
Windows never close by themselves: something must declare the past complete while stragglers still arrive. The watermark is that declaration, and the late-data policy is what keeps it honest.
You'll be able to
- Derive an operator's event time as the minimum over its inputs and show how one idle source stalls it.
- Explain watermarks as progress estimates and configure idleness detection plus allowed lateness with a side output.
- Implement a late-data policy (drop with a counter versus update with a correction) inside a retention horizon.
Covers
Read
In this order, only the parts listed
0 of 4 done
- Low watermarks and bounded deduplicationMillWheel: Fault-Tolerant Stream Processing at Internet Scale (Akidau et al., 2013)
Low watermarks with the recursive definition over inputs; at-least-once delivery with deduplication and strong productions; the retention bound on what dedup can catch
- Generating watermarks and handling idle sourcesApache Flink 2.3 - Event Time, State and Checkpointing
Dealing With Idle Sources (the minimum-over-inputs stall with
.withIdleness); periodic versus punctuated watermark generators; how operators process watermarks - Allowed lateness and late-data side outputsApache Flink 2.3 - Event Time, State and Checkpointing
Allowed Lateness (default 0 drops events behind the watermark, in-lateness refires via the event-time trigger); getting late data as a side output
- Stragglers and timestamp estimationDDIA 2e - Chapters 11 to 13 Batch and Stream Processing
Chapter 12, Handling straggler events and Whose clock are you using (pp. 520 to 521): ignore versus publish a correction; the three timestamps that estimate true event time from an untrusted device clock
Focus on
- A watermark of asserts that no more events with timestamp at most should follow. It is a progress estimate, not a promise the transport enforces.
- An operator's event time is the minimum watermark over its inputs, so one idle partition stalls the whole operator unless idleness is declared with
.withIdleness. - The late-data policy is explicit: drop with a counter, or update with a correction through accumulate or retract modes. Flink drops events behind the watermark by default, since allowed lateness is 0.
- Deduplication and corrections hold only within retention. A duplicate older than the horizon looks new again, and expired window state cannot be corrected.
Common mistakes · 3
- Treating watermarks as guarantees. Late events still arrive; the policy decides their fate, not the watermark.
- Taking the maximum over inputs. Progress follows the slowest input, which is the minimum.
- Raising allowed lateness without budgeting state. Buffered events and corrections accumulate until the horizon passes.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Two inputs hold watermarks 5 and 2. What is the operator's event time, and what happens to a window ending at 5?Answer
Event time 2, the minimum. The window cannot fire yet; the stalled input holds it back until its watermark advances or idleness is declared.
2.Allowed lateness is 0 and an event arrives behind the watermark. What happens to it by default, and where can it go instead?Answer
It is dropped. With a side output configured, it is routed there for counting or separate handling instead of vanishing silently.
3.MillWheel redelivers an event first seen a month ago. Does deduplication catch it?Answer
Only if the dedup horizon still covers it. Past the retention bound the redelivery looks new and is processed again.
4.A phone buffers events offline for a day, then uploads them. Which timestamp describes the user action, and why is it suspect?Answer
The device-clock occurrence time describes the action, but device clocks may be wrong. The server-receive time is accurate yet describes arrival, so the three-timestamp method estimates the offset between them.
Practice
- AlgoMaster: Deduplicate Stream Events with TTL
Accept within the TTL is rejected; the expiry boundary accepts and replaces the stored time; rejections do not refresh the TTL
A single-process drill that makes the retention horizon concrete, on a subscription the learner owns. Watermark propagation and the drop-versus-update policy are mini-project work.
You're done when
You can compute operator watermarks by hand, configure idleness and lateness for a stated policy, and say exactly which late events each choice drops or corrects.
Only when you can do this without notes.
Leads to
Notes
Resources · 3 for this unit, 15 more in the section
- DDIA 2e - Chapters 11 to 13 Batch and Stream ProcessingMartin Kleppmann and Chris Riccomini · primary
Read batch processing, stream processing and the streaming-systems philosophy in order. For every guarantee, mark the source position, operator state, output effect and recovery boundary it actually covers.
- MillWheel: Fault-Tolerant Stream Processing at Internet Scale (Akidau et al., 2013)PVLDB · support
Read low watermarks, persistent state, strong productions and exactly-once delivery by deduplication. The deduplication holds only within its retention bound.
- Apache Flink 2.3 - Event Time, State and CheckpointingApache Flink · required
Read the 2.3 concepts pages on time (event time, watermarks, lateness, windowing) and stateful stream processing (keyed state, checkpoint barriers, recovery, unaligned checkpoints, exactly-once versus at-least-once), then the watermark-generation guide on idle sources. Use them to build one bounded local processor; exactly-once covers state and participating sinks only.
Also in this section
- The Log: What Every Software Engineer Should Know About Real-time Data's Unifying Abstraction (Kreps, 2013)LinkedIn Engineering · support
Read it first as the short concept spine for logs, replicas, data integration and stream processing, before DDIA 2e Chapters 11 to 13.
- Kafka: a Distributed Messaging System for Log Processing (Kreps, Narkhede and Rao, 2011)NetDB workshop (mirror) · support
Read it as the design ancestor of your mini log: segments, offsets, pull consumers and consumer groups. Replication is future work in this paper, so take durability from the current docs.
- The Dataflow Model (Akidau et al., 2015)Google (author copy) · required
Read the model section: event time versus processing time, windowing, triggers and accumulation. Implement one trigger and one accumulation mode, not the catalog.
- Lightweight Asynchronous Snapshots for Distributed Dataflows (Carbone et al., 2015)arXiv · required
Read the asynchronous barrier snapshotting algorithm for acyclic graphs and its recovery; skip the cyclic extension. Barriers assume FIFO channels.
- Distributed Snapshots: Determining Global States of Distributed Systems (Chandy and Lamport, 1985)Leslie Lamport · support
Read the marker-sending and marker-receiving rules and why the recorded state is consistent. The algorithm needs FIFO channels.
- Apache Kafka 4.3 - Design, Log, Rebalance and Transaction ProtocolsApache Kafka · required
Read the 4.3 design page (replication and in-sync replicas, acknowledgements and
min.insync.replicas, delivery semantics, idempotence and transactions, the consumer, log compaction), the log implementation page, and the consumer rebalance protocol and transaction protocol pages (https://kafka.apache.org/43/operations/). Kafka 4.0 removed ZooKeeper. Run experiments in theapache/kafka:4.3.1image and compare each contract with your mini log. - Gossip Glomers - Kafka-Style LogFly.io and Jepsen · required
Each challenge runs locally under Maelstrom (v0.2.4; the pages were tested on 0.2.3) with its checker and, where the page says so, the partition nemesis; keep the run directory as the history. Do 5a to 5c:
send,poll,commit_offsetsandlist_committed_offsetson one node, then two nodes overlin-kv, then with fewer messages. The checker catches lost writes and nonmonotonic or skipped offsets; it does not check recency or exactly-once effects. - AWS Builders' Library - Avoiding Insurmountable Queue BacklogsAmazon Web Services · support
Read it for how backlogs grow and why they take long to drain, and for backpressure, prioritization, sidelining and constant work. Compare its recovery strategies with the bounded backlog and lag measurements of your consumer.
- Confluent Schema Registry - Schema Evolution and CompatibilityConfluent · support
Use only the compatibility-type definitions (backward, forward, full and their transitive forms) as the vocabulary for your schema checks, with the Avro schema resolution rules as the mechanism.
- HLD Handbook - Queues, Streaming, Stream vs Batch and CDCHLD Handbook · required
Read only Part 2 message queues and pub-sub plus Part 4 stream versus batch and change data capture. Use Part 5 event-driven architecture after the underlying log and replay contract is clear.
- MIT 6.5840 - Lab 1 MapReduceMIT PDOS · support
Complete or review the coordinator and worker lab to connect deterministic batch dataflow, task retries and output publication. Do not confuse its shared-filesystem assumptions with the durable log contract.
- Replicated Log and Stream Processor - Full Data PathRoadmap-Final · support
Complete partitioned log, producer identity, consumer ownership, offsets, backpressure, event-time state, checkpoint, replay and sink boundary. Run the required producer, consumer, storage and late-data fault campaign.
- Apache Iceberg - Table SpecificationApache Iceberg · reference
Read the snapshot, manifest list and manifest sections for the read path, and the table metadata section for the atomic metadata-file swap that commits a snapshot.
- Delta Lake Protocol (pinned commit)Delta Lake · reference
Read the transaction log replay and checkpoint sections for how readers reconstruct table state, and the concurrency section for the optimistic commit rule.
- Apache Avro 1.12.0 Specification - Schema ResolutionApache Avro · reference
Read Schema Resolution only: records match by field name, writer-only fields are ignored, reader-only fields are filled from defaults, plus the promotion rules.