gastownhall/beads · error
restoring pre-0041 nonlocal rows: %w
Error message
restoring pre-0041 nonlocal rows: %w
What it means
repairPartial0041NonlocalDelete restores the four pre-0041 dolt_nonlocal_tables rows with INSERT IGNORE so shipped 0041's DELETE+COMMIT has a real diff (its own commit lacks --skip-empty and fails with "nothing to commit" on an already-empty table). This error wraps failure of that INSERT — connection drop, table missing, or a column-shape mismatch on a drifted database.
Source
Thrown at internal/storage/schema/migration_repairs.go:152
// its shipped body can replay. 0041 begins by clearing dolt_nonlocal_tables and
// committing ("disable nonlocal tables for fk migrations"). If a transient
// interrupts 0041 after that commit but before its version row records, the
// retry re-runs 0041 against an already-empty table: the DELETE stages nothing
// and the paired DOLT_COMMIT (no --skip-empty in the shipped bytes) fails with
// "nothing to commit". Restore the pre-0041 invariant — the four rows 0040
// leaves — so the frozen DELETE+COMMIT has a real diff again. No-op when those
// rows are already present (the common path).
func repairPartial0041NonlocalDelete(ctx context.Context, db DBConn) error {
present, err := anyNonlocalFrozenRowPresent(ctx, db)
if err != nil {
return err
}
if present {
return nil
}
if _, err := db.ExecContext(ctx,
"INSERT IGNORE INTO dolt_nonlocal_tables (table_name, target_ref, options) VALUES "+nonlocalFrozenRowsValues); err != nil {
return fmt.Errorf("restoring pre-0041 nonlocal rows: %w", err)
}
if err := commitNonlocalRepair(ctx, db,
"repair: restore pre-0041 nonlocal rows before replay"); err != nil {
return fmt.Errorf("committing 0041 nonlocal repair: %w", err)
}
return nil
}
// ensureWispTablesForMixedBlockedRecompute repairs #4695 (and the identical
// #4176 clone-skew shape): migration 0047's final recompute block joins
// wisps/wisp_dependencies unconditionally in a WITH RECURSIVE UPDATE. Those
// tables are dolt_ignore'd (0019_wisps_dolt_ignore,
// 0040_ignored_tables_also_nonlocal_tables), so they never sync to a clone,
// and MigrateUp runs the main sequence (which reaches 0047) before the
// ignored sequence that (re)creates them locally. Any clone whose
// schema_migrations cursor arrives below the binary's latest -- the normal
// window right after a schema bump, before every producer has re-pushed, and
// also how a pre-1.0 database's stale cursor numbering can treat the mainView on GitHub (pinned to 71377f2769)
Solutions
- Retry bd init — the repair is idempotent and guarded by row presence
- Verify dolt_nonlocal_tables has table_name/target_ref/options columns; a drifted shape needs manual schema repair
- Ensure exclusive access to the database during init
- Check connectivity and inspect the wrapped error for the SQL cause
Defensive patterns
Strategy: retry
Validate before calling
// check the table shape matches what the repair inserts
var n int
db.QueryRowContext(ctx, `SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'dolt_nonlocal_tables'
AND COLUMN_NAME IN ('table_name','target_ref','options')`).Scan(&n)
// n must be 3 before INSERT IGNORE ... (table_name, target_ref, options) can succeed Try / catch
if err := repairPartial0041NonlocalDelete(ctx, db); err != nil {
if isTransient(err) {
return repairPartial0041NonlocalDelete(ctx, db) // guarded, idempotent
}
return fmt.Errorf("0041 repair failed: %w", err)
} Prevention
- Retry init — the restore is INSERT IGNORE and guarded by row presence
- Verify dolt_nonlocal_tables column shape on drifted databases before upgrading
- Run migrations with a stable connection and exclusive access
- Back up before upgrading databases with nonstandard history
When it happens
Trigger: bd init re-running 0041 after a transient interrupted it post-clear-commit but pre-version-record; the INSERT IGNORE of wisps/wisp_*/repo_mtimes/local_metadata rows fails (connection drop, table absent, or drifted column set).
Common situations: Interrupted upgrade against a shared Dolt sql-server; drifted clone where dolt_nonlocal_tables lacks the (table_name, target_ref, options) shape; concurrent access during repair.
Related errors
- staging %s: %w
- clearing partial 0040 nonlocal rows: %w
- read labels for %s: %w
- copy label %q for %s: %w
- read dependencies for %s: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/bd7a45a9c9f51135.
Report an issue: GitHub.