|
2026-09-24
| ||
| 00:53 | • Ticket [0e488373ec] Schema changes must migrate online, not wipe every index status still Fixed with 1 other change artifact: 0c66e75fe8 user: zeitgeist | |
|
2026-08-19
| ||
| 12:44 | • Fixed ticket [0e488373ec]. artifact: 628e48c253 user: dmestas | |
| 12:10 | • Ticket [0e488373ec]: 1 change artifact: 4ecc6ef929 user: dmestas | |
| 10:44 | • New ticket [0e488373ec]. artifact: 9edc6a5de6 user: dmestas | |
Schema changes must migrate online, not wipe every index
It is also a trap rather than a tool, because `Index.Reset` deletes ROWS and never changes SHAPE. So the one thing the version stamp exists to signal is the one thing its remedy cannot perform: on 2026-08-19 a version bump that added five ticket columns wiped every index and then failed every ticket fold with "no such column", because `CREATE TABLE IF NOT EXISTS` cannot widen a table that already exists.
### Required
1. **Additive migration is the default path.** `ALTER TABLE ... ADD COLUMN` plus a bounded backfill, applied online, with no wipe. `Open` already documents this as "the lighter mechanism than a rebuild" and already carries a migration list; new columns belong there. The version bump should be reserved for changes that genuinely cannot be expressed additively.
2. **`Reset` must actually reset the shape** — drop the derived tables and re-exec the schema — or the version mechanism must stop implying it can. Today it silently promises one and delivers the other.
3. **Rebuild online, never in place.** Build into a new index file and swap atomically, so the serving index is never the one being rebuilt. This also removes the exclusive-access deadlock: today `quarry reindex` and `quarry serve` contend for the same files, so the only way to repair a store is to take the forge down.
4. **Stage it.** Reindex one repository, verify it against the store, then continue. Wiping 23 at once turns a recoverable mistake into a corpus-wide one.
### Acceptance
Adding a column to a derived table must be shippable with the forge serving traffic throughout, and must not be able to empty an index if the migration is wrong.
Fixed the substance; one refinement deliberately remains.
1. Additive is codified as the default. The migration list is now a
named migrations var whose comment states the policy, and
schemaVersion's doc points at it first: an ALTER ships online with
the forge serving throughout; bump the version ONLY when the change
cannot be expressed additively.
2. Reset now actually resets the shape. It drops every derived
table (fts and its shadows, attachment — which the row-delete list had
silently missed — included) and reapplies the schema through the same
applySchema that Open uses, so "the shape" has exactly one
definition, then stamps the version. TestResetRepairsShape recreates
the incident (a column the file's shape lacks) and proves Reset →
refold lands, search corpus included. The version mechanism no longer
promises a repair it cannot perform.
3. Repair no longer costs an outage. repo.reindex (POST
/api/v1/r/{repo}/reindex, Admin) runs the wipe-and-replay in process
while the forge serves. It goes through the ingest lane, so a
fleet-wide repair is staged at --ingest-limit stores at a time rather
than a stampede; the indexing flag shows on /fleet while it runs; the
generation bump drops the memos hanging off the old shape. A nil
pipeline refuses cleanly. The offline CLI remains for a stopped server.
4. Staging already existed — --ingest-limit (default 3) bounds concurrent rebuilds — and is now load-bearing for the op above.
Remaining, out of scope: a zero-degraded-window rebuild. During an in-process reindex the repo's surfaces serve partial data (flagged as indexing) until the replay lands. The clean fix is running the whole Reset+replay in one WAL transaction so readers keep the old snapshot until commit — plumbing a single tx through the fold batches. Worth doing when a rebuild window on a big store actually hurts someone.