Chapter 26 · Reading
Recognize sequences and absence
A missing event needs a clock, not only a predicate.
Prerequisites Detect event sequences and When can time move forward? Find chapters in the course contents.
Decide which events make a match, when a missing event triggers a timeout and how a late arrival changes the result.
The situation
A device fails twice and then recovers. Another device fails and never sends another record. The first question can be answered by processing an arriving success; the second cannot. It needs a declared clock and a mechanism that can act when no new record arrives.
A pattern is a state machine with policy
Specify which events start, extend, complete or invalidate a partial match. State the key and ordering requirement. Two consecutive failures then success is different from any two failures within a horizon then success. Decide whether unrelated events are ignored, reset the sequence or create another branch of matching state.
Define whether matches overlap and whether one event can participate in several matches. A retry can deliver the same failure twice and create a false match unless identity policy handles it. A useful external match ID can be derived from the pattern version, key and ordered input identities, making repeated delivery of the same match recognizable by a sink.
Absence requires a progress boundary
An event-driven callback cannot decide that no success arrived merely because it was not called. Processing-time notification can express elapsed observation time, while an event-time timeout depends on progress past a deadline. A stalled or idle input changes when an event-time absence claim becomes safe under the chosen policy.
For a worked contract, start a recovery deadline at event time 10 plus ten seconds. If input progress remains at 18, an event-time timeout at 20 cannot yet fire. When progress passes the declared boundary, the system may emit the timeout. A success arriving afterward must follow a stated late/correction policy rather than rewinding progress silently.
Worked case
This worked case uses an example written for the course.
| Observation | Progress | Allowed conclusion | Unresolved issue |
|---|---|---|---|
| Failure at event time 10 | 10 | Start partial match/deadline | No recovery outcome yet |
| No success observed | 18 | Keep waiting under event-time contract | Input may still contain an earlier success |
| Progress reaches declared timeout boundary | 20 | Emit timeout under stated convention | Late correction policy still matters |
| Success with time 19 arrives later | Already past boundary | Apply explicit late/correction rule | Do not pretend progress rewound |
Late events and reset rules change answers
Reordering events within a bounded event-time horizon can improve sequence interpretation but requires retained partial history and progress assumptions. A processing-order recognizer makes a simpler claim about observations, not necessarily about the original order of business events. Neither should be described as universally correct without its business contract.
Reset partial state after completion, invalidation or expiry according to that contract. Clean up keys that never return, not only keys that receive another event. If state and timer notifications must survive a crash, checkpoint them consistently with the source position. An expired match that an external alert already acted on may need an explicit retraction or reconciliation message.
Keep detection separate from notification effects
A correct local match does not prove an email or paging action happened once. Record match identity, detection time, source event times, pattern version and the chosen deadline basis. Bound notification retries and preserve unknown outcomes. Separate detector health from source silence so a broken detector does not report the world as healthy.
Test positive and negative cases: one failure, duplicate failure, success exactly at the boundary, late success after timeout, idle source, restart with a pending deadline and a burst of overlapping partial matches. Report state cardinality and alert amplification; a high match count can be a resource problem even at a moderate input rate.
Think it through
Should a safety alert use event-time or processing-time absence detection if the source can go offline for an hour? Name the tradeoffs and a case where you need two different alerts.
Show hints
Hint 1
A liveness alarm and a complete historical interpretation may have different deadlines.
Hint 2
Input silence can prevent event-time progress.
Hint 3
A processing-time alarm may later need a corrected business interpretation.
Show explanation
Often separate operational liveness from historical pattern interpretation. A processing-time alarm can warn that a recovery signal has not been observed promptly, while event-time processing later classifies the business sequence under a lateness policy. Name the clock, source health assumption and correction path for each. No single timeout setting removes the tradeoff.
How frameworks implement this
Flink CEP provides richer pattern operators and match-skip semantics that require version-specific study. Bytewax state/timer interfaces can implement authored recognizers; the lab demonstrates positive event-driven matching only. Kafka offsets do not themselves establish an event-time absence boundary.
ReferencesPrimary sources for this chapter’s design case
Use these guides to check the framework or protocol contract discussed in this chapter. Moving “stable” or “current” guides can describe a different release; check the version used by your deployment. These readings do not execute the distributed frameworks they compare.
Flink CEP
Bytewax input and state interfaces
Flink event time