importer: bound verification queries server-side, and add validation-query for the ad-hoc ones #209
No reviewers
Labels
No labels
blocked
claude-wip
map-report
map:is
map:se
needs-review
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
art/ismap!209
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "importer-validation-timeouts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two commits. The first closes a hole in machinery already relied on; the second
adds the missing half.
1. The acceptance timeout was client-side only
A test's
timeout:was acontext.WithTimeoutand nothing else. pgx cancels aquery when the context expires, but a cancel is a message the client sends,
so the bound was only ever as good as the client's liveness and its error
handling — not the guarantee the mechanism was built to give.
runAcceptanceTestsnow takes its connection throughacquireBounded, whichsets
statement_timeoutfrom the test's owntimeout:andlock_timeoutto 5 s,and resets both before the connection returns to the pool (a leaked 10 s
statement_timeouton a reused connection would turn the safety net into asource of spurious failures).
lock_timeoutis the other half: a verification query has no business queueingbehind DDL. An import's swap takes
AccessExclusiveLockon the partition, and acheck that waits for it both stalls itself and — holding
AccessShareLockonwhat it has already read — can stall the swap.
Measured: a test declaring
timeout: 10againstSELECT pg_sleep(300)failsat 10.002 s with SQLSTATE 57014 instead of running to completion.
It caught a real mis-declaration.
conf/pl's buildings R120 —sum(ST_NumGeometries(geom))over ~9.5M multipolygons — has been reported as anintermittent 10 s timeout in #101, #107 and #108. It is not intermittent and it
is not the machine: it takes 19.3 s, and only looked flaky because the
client-side cancel raced it. Moved to the 100 rung, where its sibling urząd check
already sits.
Full sweep under
--acceptance all: is 42/42, se 55/55, pl 52/52, fi 57/57,gr 60/60, world 34/34.
Not claimed: that this rescues a query whose client was SIGKILLed. On this box
a killed importer's backend went away within seconds even with
client_connection_check_intervalat its 0 default — not isolated, and not aproperty to lean on. The point is that the bound no longer depends on finding out.
2.
importer validation-query <config> <file.sql>The motivating incident: a verification query written during an investigation ran
for 9h40m, held
AccessShareLockon a partition an import then needed toswap, and blocked that import for 7h36m. The import looked slow; it was
queued. Ad-hoc verification had no bound because a single-shot query has no
business being committed to a config file just to inherit one.
Same
acquireBoundedconnection, so the samestatement_timeoutandlock_timeout;--timeoutis on the same ladder (1, 10, 100, 1000) and defaultsto 1000.
Deliberately not a general SQL runner:
BEGIN READ ONLY— a file that tries to write is refused by the server(SQLSTATE 25006), structural rather than a promise
how queries get mangled, and the file survives the run
graduate into the owning layer's or contract's
acceptance_tests:at therung its measured runtime earns.
validation-queryis the scratchpad, theconfig is the durable record — the relationship the deep tier already has with
the fast tier.
Verified live: a normal query returns rows + runtime;
pg_sleep(300)at--timeout 10fails at 10.001 s;CREATE TABLEis refused and the table does notexist afterwards;
--timeout 25is rejected as off-ladder. Offline CLI testscover argument/ladder validation and the help path.
docs/importer-cli.mddocuments both halves.
validation-query, the ad-hoc half of the acceptance bound f7492dae0e