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

Watermarks as progress estimatesIdle sources and watermark stallsLate-data and update policy
1

Read

In this order, only the parts listed

0 of 4 done

  1. 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

  2. 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

  3. 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

  4. 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

2

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.
3

Try it yourself

Closed-book, before checking anything

Closed-book, advance two input watermarks to 5 and a stalled 2, compute the operator watermark, apply idleness detection, then route an event at time 3 under the drop versus update policy.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 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. 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. 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. 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.

5

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