Pipelines that break: what each sync design gets wrong when the source changes
Copying each 4-minute slice once left 105 of 10,196 rows wrong in four hours, and copying every change left none. Reload small tables and copy every change in big ones.
Earthquake records keep changing for days after they're published. One design copied each 4-minute slice of earthquakes, by when they happened, once and never looked again. It ended 105 rows wrong while every load reported success. Of those, 48 missed a correction, 53 were missing and 4 sat under an old record number. A change feed copies every change. It caught all three and ended with none wrong. A full re-copy every run also ended with none, but after the first load it read 424 times the change feed's data. A change feed costs about US$8,000 to build. Below about 14 million rows, the size line, re-copying every 4 minutes costs less than that a year, at US$6.25 per terabyte read.
Rows wrong in each design's table after the last of 61 reads.
What to do
A sync copies a table you don't own, like an app's database, on a schedule. Before choosing a design, record the source for a few days and count what it corrects, deletes and re-publishes under a new number, a re-key. In four hours this feed corrected 49, re-published 4 and deleted none.
Below the size line, re-copy the whole table every run. Above it, build a change feed. Each run reads every record changed since the last, plus a 30-minute margin, deletions included. It drops records filed under a replaced number.
What it is worth
Updating only records marked as changed ended 4 wrong: it counted the 4 re-published earthquakes twice and never sees a deletion.
Re-reading the last day every run still left 86 wrong, at 8.4 times the change feed's data. Re-reading 3 days left 53, at 30.1 times, and 7 days 21, at 77.3 times. Of the 79 new earthquakes, 46 first appeared more than a day after they happened.
At 100 million rows, re-copying every 4 minutes would cost about US$58,600 a year, against US$8,000 to build a change feed.
How I would put this to work with a team
The pipeline. A Dagster project on DuckDB starts a run every 240 seconds. Retries recovered 33 of 240 runs. After an hour of skipped reads, the catch-up run left the change feed right and the slice table 77 wrong.
The checks. Six checks run after every load, each with a named owner. On both tables that went wrong, the row count fired at every wrong read but one. Three others never fired on a wrong table. The old-id check fired on every table, so it won't gate a load. Only the platform's jobs write tables, and changing a check needs the feed owner's approval.
The code. The pipeline, designs and 16 tests ship with this page, in dag/, tools/ and tests/, with a CI workflow.
If I owned this sync:
- What runs. The design the size line picks, retrying only network and service errors.
- Who is paged. The data platform on call, for four failed attempts, a table over 30 minutes stale or a blocked load. The feed owner, for quarantined records, within a working day.
- What blocks a load. A row count that differs from the source's count in the same read. Loads would publish from a staging copy only when the counts match.
- In what order. Record for a week, then build what the counts pick, then the checks and the gate. Monthly, a full reload beside the sync.
The three numbers that matter
- 105 of 10,196 rows wrong in the slice table after four hours.
- 0 rows wrong in the change feed, which read 0.24% of a full reload's data after the first load.
- About 14 million rows where a change feed pays for itself within a year, at a run every 4 minutes.
What would change the conclusion
Below about 14 million rows, re-copy in full; above, build a change feed.
- If no record in a week of your source arrives or changes more than a day late, re-reading the last day is enough. Here 5,289 of 10,196 earthquakes were last updated over a day late.
- If a week shows no deletions or re-keys, updating only changed records may do: test it against a full reload.
- If the change feed, run live for a week beside a full reload, keeps a deleted row the reload dropped, I'd add a nightly check of ids against the source. If it ever disagrees with the reload a read later on any other row, I'd re-copy in full at every size, less often as tables grow. The deletion record lists about 40 a week; these reads met none.
The main limit
It's one public earthquake feed, read 61 times over four hours. With 4 records re-published and none deleted, the smaller errors rest on few rows. The full reload is right by construction. The replay can't show a record that becomes visible late, so the change feed's zero is a best case, and every margin tested ended 0 wrong.
The row count can't see a corrected value. About 29 records a read failed the row contract in the replay, at most one in any live run. The read failures, one first attempt in ten, and the outage were planted. The CI workflow passed its first run.
The declared lead finding was that updating only changed records would end 5 or more wrong. It ended 4. The time-slice comparison was chosen after the results, at 44 of the 61 reads. Of the 7 declared predictions, 2 held. Counting the first load, the full reload read 54 times the change feed's data, not the predicted 100 or more. The counts of late updates and deletions, the re-reads of 1, 3 and 7 days and a second recording were added after the results. That recording, 94 reads over 6 hours, held no deletion either; the slice table ended 46 wrong, updating changed records 7, the change feed none. The week-long live comparison hasn't run.
The 14 million row line assumes US$6.25 per terabyte read and a build of 2 engineer-weeks at US$4,000 a week, and leaves out upkeep. At the line a re-copy moves about 9.7 GB every 4 minutes, so load on the source may set it first. Across the assumed ranges it runs from 1.7 to 171 million rows, and nightly runs move it 360 times higher.