Data and Knowledge SystemsIngestion and freshnessPrincipal
How should a streaming report handle late events after publishing a window’s count?
By Amit Kumar3 min readWorked answer includedReviewed 28 Sept 2026
The question
Interview question
An incident report publishes a count of 52 for the UTC hour 10:00–11:00, then receives a valid event whose occurrence time is 10:45. A later answer reports 53 for that same hour. Explain how event-time watermarks, triggers and allowed lateness can produce this behavior. Design a provisional, correction or immutable-report contract, and describe what the assistant must cite. Use Flink’s keyed event-time window API as a concrete implementation example.
Draft your approach first
Take a few minutes before you read the answer. Name the constraint that matters most, the failure you are designing for and how you would know it worked.
Reveal the worked answerWorked answer
A streaming report can publish a result before every event for that period has arrived. Some sources are delayed or disconnected. The system therefore needs a rule for when to publish and a separate rule for what to do if older events arrive later. Calling an output “final” without defining those rules creates a promise that the pipeline may not satisfy.
Event time is when the incident occurred. Processing time is when a worker handles it. A watermark is a progress signal used to decide when event-time windows can be evaluated. It is not proof that no older event can arrive in the future. For the hypothetical UTC interval 10:00–11:00, an event at 10:45 belongs to that hour even if it arrives after the initial count is published.
Flink’s keyed event-time windows provide a specific illustration. Its version 1.19 window documentation describes default zero allowed lateness, optional retention for late events and the possibility of another firing with the EventTimeTrigger. The relevant boundary is the end and cleanup of this event’s assigned window. An event is not necessarily discarded merely because its timestamp is behind some watermark while its own window is still open.
With an allowed-lateness interval, the operator can retain the window after its first firing. A qualifying late event can update the retained count and cause another output. Under zero allowed lateness, an event arriving after that window’s cleanup boundary is no longer included by the ordinary window operator. Applications may configure a side output for dropped late data. Other triggers or APIs can behave differently, so inspect the actual assigner, trigger, lateness setting and deployed version before inferring the path from two numbers.
Suppose the first output says 52 and a retained late firing says 53. Both outputs describe the same window, not two disjoint batches to add together. The sink needs an update protocol, such as a stable window identity with an increasing report revision and replacement value. A consumer that adds both outputs obtains 105 and creates a second bug. If events can be duplicated, deduplicate their source identities before counting or use an aggregation protocol that accounts for repeated delivery.
Choose a product contract deliberately. A provisional report can identify the current count and the boundary after which corrections become less likely or stop under policy. A revision-based report preserves the original output and publishes a correction with the changed count and reason. A business process requiring immutable reports can place later discoveries in an adjustment period, provided readers understand that the immutable number describes that accounting rule rather than a permanently complete occurrence count.
Trace the late event through its original timestamp, timezone conversion, source partition, ingest time, operator watermark, assigned window and sink update. A slow or idle input may hold back watermark progress, and an idleness policy may let progress advance while a disconnected source later returns older events. An ingestion heartbeat is not evidence that all incident sources completed the hour. Measure lateness by source and the age of unincorporated events, not only the time a report was generated.
The assistant should receive the report identity, revision, occurrence interval, evidence cutoff and provisional or final status together. An answer quoting 53 must cite that revision. It should not reuse the explanation from the 52-count revision if the new incident changes a conclusion. A historical question about what operators saw at 11:05 needs the report available then, while a question about today’s corrected occurrence count needs the latest applicable revision.
Test a late event before cleanup, another after cleanup, repeated delivery, a restart and two revisions reaching the sink out of order. Verify both numerical state and the source revision shown to the reader. The question about a Sunday incident arriving on Tuesday concerns assigning an event to the correct week. Here the event already belongs to the correct hour, and the design must explain whether a published result may change.
Related questions
Keep practising data and knowledge systems
Follow another question in this area, or search the complete library.
Get my essays on AI engineering and distributed systems by email. Subscribe to ArchCrux