{"record":{"id":"dfb3894b1e7be1e3","repo":"gastownhall/beads","slug":"committing-0040-nonlocal-repair-w","errorCode":null,"errorMessage":"committing 0040 nonlocal repair: %w","messagePattern":"committing 0040 nonlocal repair: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/migration_repairs.go","lineNumber":128,"sourceCode":"// [wisps]\", bricking the database. 0040 is a shipped, content-hashed migration\n// and cannot be edited (see the file header), so instead clear any of those four\n// rows before the replay and commit the removal, leaving 0040's INSERT+COMMIT\n// pairs a clean, real diff. No-op when 0040 never partially applied.\nfunc repairPartial0040NonlocalInsert(ctx context.Context, db DBConn) error {\n\tpresent, err := anyNonlocalFrozenRowPresent(ctx, db)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif !present {\n\t\treturn nil\n\t}\n\tif _, err := db.ExecContext(ctx,\n\t\t\"DELETE FROM dolt_nonlocal_tables WHERE table_name IN \"+nonlocalFrozenRowsInList); err != nil {\n\t\treturn fmt.Errorf(\"clearing partial 0040 nonlocal rows: %w\", err)\n\t}\n\tif err := commitNonlocalRepair(ctx, db,\n\t\t\"repair: clear partial 0040 nonlocal rows before replay\"); err != nil {\n\t\treturn fmt.Errorf(\"committing 0040 nonlocal repair: %w\", err)\n\t}\n\treturn nil\n}\n\n// repairPartial0041NonlocalDelete heals a partially-applied migration 0041 so\n// its shipped body can replay. 0041 begins by clearing dolt_nonlocal_tables and\n// committing (\"disable nonlocal tables for fk migrations\"). If a transient\n// interrupts 0041 after that commit but before its version row records, the\n// retry re-runs 0041 against an already-empty table: the DELETE stages nothing\n// and the paired DOLT_COMMIT (no --skip-empty in the shipped bytes) fails with\n// \"nothing to commit\". Restore the pre-0041 invariant — the four rows 0040\n// leaves — so the frozen DELETE+COMMIT has a real diff again. No-op when those\n// rows are already present (the common path).\nfunc repairPartial0041NonlocalDelete(ctx context.Context, db DBConn) error {\n\tpresent, err := anyNonlocalFrozenRowPresent(ctx, db)\n\tif err != nil {\n\t\treturn err\n\t}","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/migration_repairs.go#L110-L146","documentation":"After clearing the partial 0040 rows, the repair commits the removal via commitNonlocalRepair (DOLT_ADD + DOLT_COMMIT --skip-empty). This error wraps failure of that commit step — the staged change could not be committed, usually from a connection drop or Dolt commit-procedure failure.","triggerScenarios":"The DELETE succeeded but CALL DOLT_ADD/DOLT_COMMIT failed: connection interrupted mid-commit on a shared sql-server; dirty/conflicted Dolt working set; server-side procedure error.","commonSituations":"Network flake during bd init; working set left dirty by a previously crashed process; Dolt version incompatibility.","solutions":["Retry bd init — the row-presence guard makes the repair safely re-runnable","Resolve any dirty/conflicted Dolt working-set state before retrying","Verify the Dolt server is healthy and reachable","Inspect the wrapped underlying error for the specific commit failure"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := commitNonlocalRepair(ctx, db, \"repair: clear partial 0040 nonlocal rows before replay\"); err != nil {\n    if isTransient(err) {\n        return retryRepair(ctx, db) // presence guard makes retry safe\n    }\n    return err\n}","preventionTips":["Retry on transient commit failures; --skip-empty and the presence guard keep re-runs clean","Resolve dirty/conflicted Dolt working-set state before upgrading","Do not kill bd mid-migration; let the pass finish or retry it","Keep Dolt server and client versions aligned"],"tags":["dolt","migration","commit","transient"],"backgroundTag":"dolt-commit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}