ETL Root Cause Analysis: A Warehouse Odyssey
Follow an ETL root cause analysis from a wrong refunds total to the warehouse join that inflated it. Verify the fix with a reconciliation and backfill.
- etl root cause analysis
- data pipeline root cause analysis
- data reconciliation
- warehouse incidents
At 07:10 UTC, finance flags $39,240 in euro refunds on the November 25 close report. The ledger has €18,000, and the approved close rate is 1.10 dollars per euro. That makes $19,800. Yesterday the same report agreed with the ledger down to the cent. This morning the warehouse jobs are all green, and finance is waiting to sign the close.
This is an illustrative incident. Home is the close finance could sign yesterday, with one fact row per refund and a dollar amount finance could reproduce from the ledger and its rate sheet. The shipwreck is having both inputs in hand and still getting an answer nobody can sign. The ETL root cause analysis starts by finding the first table that disagrees with the source. It ends when finance can use the corrected close and a teammate can show why running the repair again leaves the same numbers.
Fundamentals of Data Engineering by Joe Reis and Matt Housley follows data from source systems through ingestion, transformation and serving. The root cause analysis guide starts with rival explanations and the evidence needed to decide between them. The handoff between those subjects is the work here. When a report doubles, which boundary do you check first? What evidence tells you to stop looking at the source and open the compiled join?
Table of Contents
- Define the close you trust
- The green run and other false leads
- Follow ETL lineage to the first wrong table
- Test the join against a known good run
- What else breaks at these pipeline boundaries
- Where Decim fits
- Verify the fix with an independent reconciliation
- Backfill the close without changing its terms
- Related reading
Define the close you trust
Start with the number finance is disputing. The filter is business_date=2026-11-25, the slice is EUR refunds, and the display currency is USD. The metric covers posted refunds in the New York business day, using the ledger snapshot taken for close and the latest approved rate published by the 06:00 UTC close cutoff the following morning. Finance has a signed rate sheet for that cutoff. It calls for 1.10. Keep the sheet and the ledger snapshot ID with the incident. You’ll want both when you run the repaired model.
On November 24 the report reconciled against those same controls for its own business date and cutoff. Save that run ID now, along with the input manifests and compiled model SQL. November 24 gives you a nearby baseline through the same code path. The ledger and the signed rate sheet give you the expected answer for November 25. Using yesterday’s dollar total as today’s target would confuse a working process with yesterday’s inputs.
Finance flags the November 25 close as provisional and pauses distribution. Before retrying anything, the pipeline owner saves the failed output and the run’s inputs and parameters. In this warehouse a rerun replaces the daily partition. A colleague who clicks Retry to see what happens could erase the rows you most need to inspect, or pull a newer revision of the rate and give you a different wrong answer. Keep the affected date and the exact snapshot in the handoff. The next person to join should be able to query the original output without touching the scheduled run.
refunds_with_fx, and home is a close finance can reproduce from the ledger and the signed sheet.The green run and other false leads
Start at the dashboard and take one layer away. Run its aggregate directly against daily_refunds for November 25 and EUR. The warehouse returns the same $39,240. If the warehouse had returned $19,800, you would have checked the dashboard’s extract age, filters and calculated fields. Here the dashboard is serving the bad number faithfully. A cache refresh would serve it again.
The amount looks roughly doubled. Someone suggests the refund processor sent yesterday’s batch twice. That theory predicts repeated refund IDs in the raw or staged ledger snapshot. The source manifest and landed ledger both have 1,200 posted refunds, including 300 in EUR. The staging table has 1,200 distinct refund IDs and the same €18,000 subtotal. A comparison of the EUR IDs and amounts against the archived source agrees. The raw and staged ledger checks take the processor theory off the table for this run. They leave the exchange rate feed open.
Another engineer points to a recent orchestration change. Check the run history for the exact business date, including upstream runs whose outputs were reused. The 06:30 run had one write attempt for the refunds fact, and the publish step installed one output partition. The compiled model and resolved date range match the previous day’s run after substituting its business date. Save the actual query ID and parameters. A green task tells you which query finished. If it also logged a row count, find out whether it was the number scanned, matched or committed. The scheduled job troubleshooting guide covers how to find a run’s arguments and execution context when those records are split across the scheduler and the worker.
The job duration is ordinary too. That’s useful when you’re deciding whether a warehouse slowdown explains the incident. To judge the number on the report, you need a contract such as one fact row per refund. The gap between those two kinds of checks is covered in observability vs root cause analysis. Here it lets you put down the execution dashboard and start comparing tables.
Follow ETL lineage to the first wrong table
Trace the number backward from daily_refunds. Its USD subtotal comes from refunds_with_fx, which should contain one row per refund ID. That model reads staged_refunds and staged_fx_rates. The ledger side held up under comparison. Now check the join output at the grain where you can still name one refund.
| November 25 boundary | Expected | Observed |
|---|---|---|
| Posted ledger refunds | 1,200 IDs, including 300 EUR | 1,200 IDs, including 300 EUR |
| Staged refund rows | One per posted refund | 1,200 rows and 1,200 distinct IDs |
| Refund rows after the FX join | One per staged refund | 1,500 rows and 1,200 distinct IDs |
| Daily report, EUR slice | $19,800 at the approved rate | $39,240 |
staged_refunds still agree. The grain breaks at refunds_with_fx, where 1,200 refunds become 1,500 rows.Lineage gave you the names of the tables. Counts by date and currency tell you where to put the next query. All 300 EUR IDs occur twice after the join. The USD rows, which use the same-currency rate of 1, still occur once each. Take one €100 refund, R817, and inspect both join outputs. It has a $108 row and a $110 row. The difference in values is a better clue than the word “duplicate.” It tells you to look at which two right-hand records matched.
On a bigger table, start with counts and checksums by partition to find where to read in detail. The input and comparison need a shared field order, a common representation of decimals and nulls, and an explicit sort order if you’re hashing a serialized file. Once a partition differs, compare keys and fields there. A checksum can narrow the search to EUR on November 25. It can’t tell you whether a refund vanished or gained a second rate, and a count alone can hide one missing refund offset by one extra row. Why derived datasets fall out of sync goes deeper on choosing a reconciliation grain.
Save the details needed to query along the actual lineage of this run. If staged_fx_rates is a view, reading it at 10:00 could give you a different set from the one the 06:30 job saw. In this case the model worked from persisted landing snapshots, so the source file manifest identifies the exact rate revision records. Find the loader’s file names and warehouse query IDs by searching for the run ID. The Google Cloud Logging query guide has filters for that lookup if your worker logs live there.
Test the join against a known good run
The join in the compiled SQL matches on business_date and currency. The rate feed used to supply one approved row per pair. In the November 25 file, it contains two for EUR. The €100 refund matches rev1 at 1.08, published at 04:12 UTC, and rev2 at 1.10, published at 05:41 UTC. Both are before the cutoff. rev2 supersedes rev1 under the close rules, and 1.10 is the rate on the signed sheet. The join treats them as two equally eligible rows and passes both along to the sum.
rev2 is the rate on the signed sheet. The old join also kept rev1, and that second match is where the close doubled.Compare with November 24. The same join keys gave each refund one match because its input file held one approved revision per pair. A config diff from the rate publisher shows that it switched from an export of the current rate to an export that retains approved revisions for audit. Confirm which export ran by checking the job’s recorded settings and file manifest. The source diff explains why the new file has both rows. The input row count at the join explains why the warehouse result changed with the same model SQL. The columns and types stayed the same through the switch, so a schema check would have passed. The assumption that broke was uniqueness at the join grain.
Write the claim so another engineer can try to break it. If the extra FX revision caused the overstatement, replaying the old join with the saved ledger and both rate rows should produce 1,500 rows, and handing it only the signed close rate for EUR should give 1,200. Run both in scratch tables. The EUR refunds in this example are all in whole euros, so rounding each refund to cents leaves the arithmetic unchanged. The second run should remove exactly the $19,440 contributed by rev1 on €18,000 in refunds. If the surplus remained after removing that row, you’d keep looking for another multiply matched join or a second writer. That prediction and its possible refutation are what the hypothesis-driven debugging guide asks you to write down before running a check. Here the two replays give the predicted result.
This is where the root cause analysis tools earn their keep in ETL. A timeline lines up the feed change, snapshot cutoff and model run. A round of Five Whys follows the duplicate refund to the second rate row and then to the export’s changed grain. Branch at the join if both retry duplication and rate fan-out are still live explanations. In a fishbone sketch those belong under write behavior and reference data, respectively. Each sends you to a different artifact. The query ID lets you confirm the write attempt, while the two match rows for R817 let a teammate reproduce the fan-out in isolation.
What else breaks at these pipeline boundaries
The join turned out to be the first wrong boundary in this run. Use the other boundaries to guide the investigation when your checks come back differently. If staged_refunds had disagreed with the ledger, for instance, the next question would have been whether the extract missed part of the ledger or the load dropped part of the extract.
staged_refunds had disagreed with the ledger, the next stop would have been extract and load. It didn’t, so the useful work was in the transform.Extract and load failures
Start with the manifest, the source close watermark and the files actually read. A late or missing input leaves an expected file or sequence gap. A partial load can start with a complete manifest and commit just a subset of its contents. If you expected 1,200 refunds and found 900 staged, compare the source manifest with the landing manifest before inspecting the warehouse load history and reject records. Check separately for absent objects, objects the job identity can’t read and rows the loader rejected after opening a file. The missing rows walkthrough goes into measuring losses in a run that passed its scheduler checks.
A schema change leaves other fingerprints. A strict loader may reject refund_amount after the producer renames it. A permissive loader might keep the row and populate the old field with null. You would still count 1,200 refund IDs. Compare null counts before and after parsing, and open one raw payload alongside its typed row. If the aggregate ignores the nulls, the report can understate refunds while the load count looks healthy. A change to source code or config deserves to be checked against the actual input. A diff that renames a field matters when the retained file actually carries the new name.
If the source inventory shows a file but the job’s listing is empty, check access under the identity recorded on the failed attempt. Permission changes can narrow a listing to the wrong prefix, and credential rotations can leave one worker using an expired secret while other runs work. Look for the loader’s access results and whether its fallback turned a read error into an empty input. The zero-row ETL guide covers that failure and other reasons a successful run can load nothing.
Transform and publish failures
Multiple matches for R817 pointed to the join in this incident. If the staged keys had already repeated, compare task attempts and commit IDs. A scheduler can retry after the warehouse committed and before the worker acknowledged completion. With append writes, both attempts can land rows for the same logical batch. A rerun should replace the same date partition or merge on a stable key at the correct grain. Check which keys the warehouse used and whether a failed attempt left any committed partitions before a second attempt started.
When the count difference sits around midnight, check the business day boundaries before changing the join. For the November 25 run, derive both ends of the window from New York local midnight, then convert them to UTC and use a half-open interval. With daylight saving transitions, the gap between those midnights can be 23 or 25 hours. A fixed 24-hour interval can pull rows into the wrong daily close. Compare event time with ingestion time too. A live stream may have seen a refund after the batch cutoff and counted it already. The stream vs batch discrepancies guide covers how to compare the windows used by the two paths.
Read the orchestrator’s run state and the warehouse’s published state side by side, especially after a retry or backfill. Check the logical run date and the partition that actually changed. If November 25 succeeded and November 24’s published version moved, you have a write-scope problem even if the backfilled date reconciles. In an Airflow setup, start with the DAG run, logical interval and individual task attempts. For custom ETL, the equivalent evidence is often a scheduler invocation, the program’s resolved arguments and a warehouse query ID. When a scheduler launches dbt, use the Airflow and dbt comparison to orient yourself between the orchestration layer and the transformation layer. The refunds case needed the job’s attempt history to rule out a second write and the compiled model to show where one write picked up both rates.
Where Decim fits
If the refunds pipeline is a discovered asynchronous data flow, Decim can investigate after someone reports the November 25 mismatch in the UI or through the API. The investigation record keeps competing explanations, including a duplicate-load theory ruled out by the staging comparison. A finding can cite the relevant GitHub source snapshot, an excerpt from Google Cloud Logging or a query result the team supplies. For example, the team can run a proposed SQL check for both rate matches on R817 and attach its result as evidence.
The team supplies the signed close inputs, runs the database checks and decides if the repaired output is ready to publish. If the investigation proposes a patch or a draft GitHub pull request for the rate selection, the team reviews and merges it. The signed close still depends on the reconciliation below.
Verify the fix with an independent reconciliation
Fix the model at the point where it chooses a rate. Select the latest approved publication available at the recorded cutoff for each required date and currency. Use the publisher’s documented revision order for simultaneous publications. Fail the publish if the winning revision is ambiguous or a required rate is missing. Once the selected rate is unique at the join grain, assert that each refund ID appears exactly once in the fact. Both dollar values for R817 survive a DISTINCT over the old join result. The close needs the row carrying the approved rate.
Have the team compare the repaired output against a control built from the frozen ledger snapshot and the separately supplied signed rate sheet. Use the same per-refund rounding rule that finance uses, with money represented as integer cents in the comparison. If your expected table reads the rate-selection model you just fixed, both sides can agree while using the wrong rate. Here close_control_refunds contains one row per posted refund with the signed revision and independently calculated amount. refunds_with_fx_candidate is the repaired fact staged for review. The query checks for differences in both directions. In PostgreSQL’s SELECT syntax, EXCEPT ALL keeps surplus copies visible even when every compared field is identical.
WITH expected AS (
SELECT refund_id, currency, amount_minor, usd_cents, fx_revision
FROM close_control_refunds
WHERE business_date = DATE '2026-11-25'
), actual AS (
SELECT refund_id, currency, amount_minor, usd_cents, fx_revision
FROM refunds_with_fx_candidate
WHERE business_date = DATE '2026-11-25'
)
SELECT 'missing_or_changed' AS difference, d.*
FROM (SELECT * FROM expected EXCEPT ALL SELECT * FROM actual) AS d
UNION ALL
SELECT 'extra_or_changed' AS difference, d.*
FROM (SELECT * FROM actual EXCEPT ALL SELECT * FROM expected) AS d;
The old fact gives 300 extra rows carrying rev1. The repaired candidate gives zero differences, with 1,200 rows and $19,800 in the EUR slice. Check the input control against the ledger manifest as well. An empty comparison of two empty tables would pass the query, and finance is expecting a particular set of refunds. Exercise one fixture with an after-cutoff revision and another with a missing rate. The first must preserve rev2 for the saved close, and the second must prevent a publish. These tests give the team a way to catch the next bad close before a dashboard refresh exposes it.
rev2 would pass this close and fail November 24.Run the repaired model against the saved November 24 inputs as well. That day’s file has one EUR revision, rev1, and it matches that day’s signed sheet. A patch that always picks rev2 would pass the incident replay and fail this earlier case. Keeping both fixtures makes the test about the selection rule, with one close where the choice matters and another where the model should preserve the result already on record.
Backfill the close without changing its terms
Use the feed change and archived manifests to bound the repair. Look for date and currency pairs with more than one eligible rate from the first revision-retaining export through the last run of the old model. In this case only November 25 needs replacement. November 24 remains the healthy reference, so record its published version before the backfill and confirm that it stays put. If a later revision arrived while the team was investigating, the historical run still needs the original cutoff and the preserved close inputs. If finance decides to reopen the close at a later cutoff, give that decision its own run and record.
Stage the repair, run the comparison, then replace only the affected partition in a transaction. Keep the scheduled writer from racing the repair for that date. Repeat the backfill with the same inputs and check the fact again by ID, values and revision. There should be no new rows or differences. A one-time backfill that happens to land the right amount still leaves the next operator a bad button if reusing it appends the same refunds.
After publishing, refresh dependent extracts and run the dashboard’s EUR subtotal against the published version. Finance sees $19,800 and signs the close. Attach the incident’s run IDs, the two saved FX records and the empty reconciliation result to the postmortem. Put the rate revision and cutoff in the run history for the next close. When a colleague asks where the other $19,440 went, pull up R817. The old result has two lines. The signed close has one at $110.
Related reading
For the same reasoning on an ordered queue, Root Cause Analysis Tools and Rules follows offsets 7411 and 7412 through a stuck indexer and a replay.
Related articles
- Root Cause Analysis Tools and Rules: An Odyssey Follow a stalled search index through seven root cause analysis tools, from the deploy everyone blamed to the replay that proved why one queue stopped. Read the article →
- Derived Data Out of Sync: Why Two Datasets That Should Agree Don't When a cache, search index or warehouse table disagrees with its source, find out whether the derived data is late or wrong, and which write path lost it. Read the article →
- Your pipeline succeeded and the rows are missing The worst ETL failures don't throw. They complete, report success and quietly drop rows nobody is counting. How silent row loss happens and how to find it. Read the article →
- Scheduled Job Troubleshooting: When a Job Fails Silently or Runs and Does Nothing How to troubleshoot scheduled jobs that fail silently or run and do nothing, with checks for cron, systemd, Kubernetes, Cloud Run, Airflow and SQL Agent. Read the article →
Decim investigates pipeline incidents
It reads your code, logs and tickets, works through the pipeline step by step, and confirms the cause with evidence you can check: every claim links to the log line, commit or check behind it. Then it proposes the fix and writes the report.
Request a demo