{"record":{"id":"5862fea08aced181","repo":"gastownhall/beads","slug":"reading-pre-migration-status-w","errorCode":null,"errorMessage":"reading pre-migration status: %w","messagePattern":"reading pre-migration status: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/schema.go","lineNumber":595,"sourceCode":"\t\treturn 0, fmt.Errorf(\"checking schema migration work: %w\", err)\n\t}\n\tif !needed {\n\t\t// No migration pass will run, so nothing downstream commits the seed:\n\t\t// it would sit as an uncommitted working-set diff until an unrelated\n\t\t// write/pull sweeps it into its commit (and a read-only repo carries\n\t\t// it indefinitely). Commit it here, scoped and labeled, so the\n\t\t// out-of-band-copy heal converges in one pass.\n\t\tif seedChanged {\n\t\t\tif err := commitSeededDoltIgnore(ctx, db); err != nil {\n\t\t\t\treturn 0, err\n\t\t\t}\n\t\t}\n\t\treturn 0, nil\n\t}\n\n\tdirtyBeforeAll, err := dirtyTables(ctx, db, false)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"reading pre-migration status: %w\", err)\n\t}\n\t// dolt_ignore is pass-owned state: seedDoltIgnorePatterns above may have\n\t// just dirtied it on an under-seeded database. Exempting it from the\n\t// pre-existing-dirty guards (like the aux-rekey tables below) keeps the\n\t// pending-migration and changed-signature gates off it.\n\tdelete(dirtyBeforeAll, \"dolt_ignore\")\n\tif err := unstagePreExistingTables(ctx, db, dirtyBeforeAll); err != nil {\n\t\treturn 0, fmt.Errorf(\"unstaging pre-migration tables: %w\", err)\n\t}\n\t// The seed must not ride the migration pass: every step of the pass\n\t// commits atomically, and a pass killed between steps must leave a CLEAN\n\t// working set (the #4566 self-heal contract) — but the seeded dolt_ignore\n\t// rows would stay dirty until the pass's final commit, so an interrupted\n\t// retry sees a dirty working set and refuses to converge. Commit the seed\n\t// scoped and labeled now, after pre-existing staged tables were unstaged\n\t// (so nothing else rides into the commit) and before the first step runs.\n\tif seedChanged {\n\t\tif err := commitSeededDoltIgnore(ctx, db); err != nil {","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/schema.go#L577-L613","documentation":"This error wraps a failure of `dirtyTables` — MigrateUp reads the pre-migration dirty-table state to enforce its pre-existing-dirty guards (a dirty working set before the pass is an error condition). Failing here aborts the migration before any step runs.","triggerScenarios":"MigrateUp calling dirtyTables(ctx, db, false) and the underlying `dolt status`-equivalent query fails — Dolt server error, locked working set, corrupted working-set metadata, or context cancellation.","commonSituations":"Another Dolt client holds the working set; a crashed prior migration left inconsistent working-set state; networked Dolt connection dropped mid-read; server freshly restarted and not serving status.","solutions":["Inspect the wrapped cause for the underlying failure","Run `dolt status` manually against the repo to check working-set health","Wait for concurrent Dolt writers to finish, then retry","If a previous crashed pass left the set inconsistent, follow the #4566 self-heal path (clean or commit the working set) and re-run"],"exampleFix":"// before: dirtyTables blocked by another writer\n$ bd migrate // hangs/fails reading status\n// after: ensure single writer, then retry\n$ pkill -f 'bd migrate' && bd migrate","handlingStrategy":"try-catch","validationCode":"// check working set is readable and clean before migrating\nrows, err := db.QueryContext(ctx, \"CALL DOLT_STATUS()\")\nif err != nil { return err }\n// inspect dirty state; abort or clean before MigrateUp","typeGuard":null,"tryCatchPattern":"_, err := schema.MigrateUp(ctx, db)\nif err != nil && strings.Contains(err.Error(), \"reading pre-migration status\") {\n\t// dirtyTables read failed: check server and concurrent writers\n\treturn fmt.Errorf(\"cannot read working-set status; resolve and retry: %w\", err)\n}","preventionTips":["Run `dolt status` before migrating to confirm a readable, clean working set","Avoid concurrent Dolt clients on the same workspace during migration","Recover cleanly after a crashed migration pass before retrying"],"tags":["dolt","migration","working-set","dirty-tables"],"backgroundTag":"dolt-status-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}