Skip to content

Commit fc42d66

Browse files
committed
Update docs: state the hashtext collision risk plainly in migration-runner README
The prior wording read as a guarantee ("distinct packages never contend") when what's actually true is narrower: the lock key is a 32-bit hash of the ledger table name, not the name itself, so two distinct names could in principle collide — a liveness cost (one package's boot waits on another's), never a correctness one. Verified against a live hashtext() that today's six ledger table names don't collide, and says so, with the reminder to reverify for a seventh.
1 parent f00ceff commit fc42d66

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/migration-runner/README.md‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ the ledger and finds every migration already applied. Postgres also releases
2020
a session-level advisory lock automatically if the holding connection dies,
2121
so a crashed replica never wedges the lock for the next boot.
2222

23-
The lock key is derived from the ledger table name, which is already unique
24-
per package (`bench_migrations`, `insights_migrations`, ...), so distinct
25-
packages never contend on the same lock.
23+
The lock key is `hashtext(ledgerTable)`, a 32-bit hash of the ledger table
24+
name rather than the name itself, so two distinct table names could in
25+
principle hash to the same key — two packages would then serialize their
26+
boot-time migrations against each other instead of running in parallel, a
27+
liveness cost (one waits its turn) and never a correctness one (each still
28+
applies to its own schema and ledger). The six current ledger tables
29+
(`access_policy_migrations`, `bench_migrations`, `evals_migrations`,
30+
`inference_catalog_migrations`, `insights_migrations`,
31+
`preferences_migrations`) do not collide — verified against a live
32+
`hashtext()`. Confirm the same before naming a seventh.
2633

2734
## What it does not change
2835

0 commit comments

Comments
 (0)