The job succeeded at loading and then failed afterwards, which is the ordinary
case rather than the unlucky one.
Daily job for 2026-07-26, appends into fact_orders
22:00 read source WHERE order_date = '2026-07-26' -> 412,908 rows
22:04 INSERT INTO fact_orders ... 412,908 rows appended
22:06 downstream aggregate step throws, task marked FAILED
22:11 scheduler retries the task from the beginning
22:15 INSERT INTO fact_orders ... 412,908 rows appended
fact_orders holds 825,816 rows for one day.
Revenue for 26 July is exactly double. Nothing errored.
The insert was durable and the task was not, so the retry replayed a step that
had already committed. Note that no alert can catch this: every task eventually
reported success, row counts grew as expected for a busy day, and the only
evidence is a revenue figure that looks like a good Sunday.
The fix is to make the run own the partition rather than add to it:
BEGIN;
DELETE FROM fact_orders WHERE order_date = DATE '2026-07-26';
INSERT INTO fact_orders (order_id, order_date, customer_key, amount_minor)
SELECT order_id, order_date, customer_key, amount_minor
FROM stg_orders
WHERE order_date = DATE '2026-07-26';
COMMIT;
Three details decide whether this actually works. The delete and the insert must
be one transaction or an interrupted run leaves the day empty, which is a
different wrong answer rather than a safe one. The partition predicate must be
derived from the run's logical date, not from now(), or a rerun of an old day
deletes today. And where the output is late-arriving by nature — a fact that can
be corrected weeks later — the honest shape is a merge on the business key
rather than a window overwrite, because the window you would have to replace
grows without bound.
The tempting non-fix is "check whether rows exist before inserting". That is a
read-modify-write across two systems with no shared transaction, so two
concurrent runs both see nothing and both insert.