Dependent runs follow the companies watermark¶
Status: accepted Date: 2026-09-29 Decider: Chris Issue: #408 Amends: ADR-0005 (delta and reconcile scheduling)
Context¶
production_units.cvr and financial_reports.cvr are foreign keys into
companies. Every daily run started at 03:00 and every monthly reconcile at
04:00 on the first, so a production unit or publication for a company
registered that night could arrive before its company. The dependent run then
failed on its foreign key. In a full backfill this fails the whole staging
swap: a companies scroll takes hours, and units opened in that time name
companies the scroll did not see.
408 named two options: a clock offset between the schedules, which is only¶
correct while the parent run finishes inside the offset, or a real dependency between the runs.
Decision¶
EntityConfig.followsnames the run an entity depends on. Production units and Regnskab publications followcvr/virksomhed.- A dependent scroll, delta or population, reads only documents whose own
sidstOpdateretis before the latest companies watermark for the same population bound. The companies watermark is the newestsidstOpdateretthe companies run loaded, so every company a dependent document can name is already incompanies. Newer documents wait for the next run, which reads from the dependent's own watermark. - With no successful companies run yet there is no bound, and the foreign key alone guards the load.
- The schedules only set freshness, not correctness: dependents run daily at
04:00 (
dependent_batch_schedule), one hour after companies and people, and their reconciles run on the second of the month (dependent_reconcile_schedule), a day after the companies reconcile.
Consequences¶
- No foreign-key failure from run order, in deltas, reconciles, or the one-time backfill.
- A unit or publication updated after the last companies run appears one run later. A dependent reconcile leaves such documents out of its swapped population until the next delta adds them back.
- The bound assumes a company exists in the register before a unit or publication names it. A document that breaks this still fails loudly on the foreign key, as before.