LAB 05 · PYTHON / SQL
The job ran once.
The boundary row ran twice.
A daily revenue total rises after a rerun. The duplicate event_ids occur exactly at the stored incremental boundary.
Several source events can share one timestamp. Replacing >= with > alone can lose valid events at that same boundary.
Trace the cursor and decide whether the source selection and the sink behaviour make reruns safe.
LOAD EXCERPT
Relevant cursor logic only
last_seen_at = checkpoint["updated_at"]
batch = source.query(
"SELECT event_id, updated_at, amount "
"FROM order_events "
"WHERE updated_at >= :last_seen_at",
last_seen_at=last_seen_at,
)
warehouse.append("order_events_stage", batch)
checkpoint = {"updated_at": batch["updated_at"].max()}
The load has one cursor value and an append-only staging write. The question is whether that is enough to make a rerun safe.
EVIDENCE TRAIL
Open the signals in order
01Run reconciliationDid the rerun add new events or repeat old ones?
Prior staged rows: 418,205
Rerun rows inserted: 27
New event_id values: 8
Repeated event_id values: 19
Repeated updated_at: 2026-11-28T00:00:00ZThe rerun did not merely process new source data. Most added rows already existed at the stored boundary timestamp.
02Boundary sampleWhat happened to records around the cursor?
event_id updated_at existed before loaded on rerun
evt_901 2026-11-28T00:00:00Z yes yes
evt_918 2026-11-28T00:00:00Z yes yes
evt_944 2026-11-28T00:00:01Z no yesThe inclusive selection keeps the boundary intentionally, but the append write has no way to recognise the replayed rows.
03Cursor contractCan one timestamp identify a unique resume point?
Multiple events can have the same updated_at. A time-only cursor cannot distinguish events already written at the boundary from events that arrived with the same timestamp later.
The load therefore needs a deterministic tie-breaker, or an overlap window paired with sink-side deduplication.
LIKELY ROOT CAUSEA time-only, inclusive watermark replayed boundary events into an append-only sink.
The original job avoids missed late arrivals by re-reading the timestamp boundary, but it has no idempotency guard or deterministic tie-breaker. It therefore duplicates any event that shares the cursor timestamp.
WHERE updated_at >= :last_seen_atWHERE updated_at > :last_seen_at OR (updated_at = :last_seen_at AND event_id > :last_event_id)REVIEW BEFORE APPLYINGStore the composite cursor only after the sink write commits. If the source has no stable event ID, retain an overlap window and deduplicate in a mergeable staging table.