Skip to main content
Version: 0.7.x

Event time and watermarks

Event time is the instant an event happened at its source, carried inside the data. Processing time is when ArkFlow happens to read it. A stream that aggregates by event time must decide when it has seen all events for a window — the watermark is that decision, expressed as "no event older than this timestamp is expected".

Watermarks matter because windows, joins, and late-event policies all depend on them. Without a watermark, a window can never close deterministically and an outer join can never emit an unmatched row.

How ArkFlow advances the watermark​

A Job declares event time per source, with a timestamp field and a watermark strategy. Each source partition tracks its own watermark; the chain watermark is the minimum across active partitions, so one slow partition keeps windows open until it catches up or is declared idle.

Key rules:

  • Timestamp types. Int64 (milliseconds) and Arrow Timestamp columns in seconds, milliseconds, microseconds, or nanoseconds are normalized to milliseconds. Null timestamps are never held indefinitely: with route they follow late events to the side output, otherwise they are dropped and acknowledged.
  • Advance before classification. Within a batch the watermark advances first, then rows are classified. A batch containing [2100, 100] treats 100 immediately as late instead of holding it.
  • Bounded out-of-orderness. The watermark trails the maximum observed event time by out_of_orderness_ms. Larger values tolerate more reordering at the cost of longer window latency.
  • Idle partitions. A partition that produces no events for idle_timeout_ms stops holding the chain watermark back, so a quiet Kafka partition cannot freeze every window in the job. When it resumes, its events are classified against the current watermark and may be late.

Late and invalid events​

A row is late when its timestamp is below the current watermark. The source declares how to handle it:

PolicyBehaviorUse when
dropThe row is dropped and acknowledged.Late data has no business value and the cost of side output is unwanted.
routeThe row is emitted on the late-event side output.You want to inspect or archive late data without polluting the main result.
updateA window that is still inside its allowed-lateness period is corrected and re-emitted with __arkflow_window_update.Late corrections must revise a previously emitted aggregate.

Triggered windows are retained for their allowed-lateness period. After it expires the buffered window is cleaned up; an update that arrives later follows the late policy like any other late row.

Where to configure it​

Event time is declared on the Job's source (jobs[].sources[].time), not on the processor. See the field reference for time (source event-time declaration) and the end-to-end walkthrough in Streaming jobs. Distributed Jobs share the same semantics; see event-time semantics for watermark aggregation, checkpoint recovery, and the max_buffered_keys eviction bound.

Common misconceptions​

  • "Processing time is simpler, so it is always safer." Processing-time windows are simple but non-deterministic on replay: the same input can land in different windows. Use event time when the result must be reproducible after recovery.
  • "A watermark is a timer." It is a progress claim derived from data, not a wall-clock schedule. A stalled source stalls the watermark unless the partition is declared idle.
  • "Late data is a bug." Late data is normal under at-least-once replay and mobile/edge sources. Choose a policy instead of assuming ordering.