{"record":{"id":"07f037963bd0cd0d","repo":"gastownhall/beads","slug":"failed-to-commit-restore-w","errorCode":null,"errorMessage":"failed to commit restore: %w","messagePattern":"failed to commit restore: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/bd/backup_restore.go","lineNumber":112,"sourceCode":"\t}\n\n\t// After a force restore, the database's _project_id may differ from\n\t// metadata.json (the backup came from a different project). Sync\n\t// metadata.json to match the restored database so the identity check\n\t// doesn't reject subsequent connections.\n\tif force {\n\t\tif err := syncProjectIDFromDB(ctx, s); err != nil {\n\t\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to sync project ID after restore: %v\\n\", err)\n\t\t}\n\t}\n\n\t// Register the restore source as the backup destination so\n\t// `bd backup sync` works immediately without a separate `bd backup add`.\n\tregisterBackupRemote(ctx, bs, dir)\n\n\tif err := s.Commit(ctx, \"bd backup restore\"); err != nil {\n\t\tif !strings.Contains(err.Error(), \"nothing to commit\") {\n\t\t\treturn fmt.Errorf(\"failed to commit restore: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// registerBackupRemote registers dir as the default backup remote and saves\n// the local backup config. Errors are non-fatal warnings.\nfunc registerBackupRemote(ctx context.Context, bs storage.BackupStore, dir string) {\n\tbackupURL := resolveDoltBackupURL(dir)\n\n\t// Remove + re-add to handle the case where a remote already exists.\n\t_ = bs.BackupRemove(ctx, defaultDoltBackupName)\n\tif err := bs.BackupAdd(ctx, defaultDoltBackupName, backupURL); err != nil {\n\t\tfmt.Fprintf(os.Stderr, \"Warning: failed to register backup remote: %v\\n\", err)\n\t\treturn\n\t}\n\tif err := saveDoltBackupConfig(backupURL); err != nil {","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/cmd/bd/backup_restore.go#L94-L130","documentation":"After restoring the database files, runBackupRestore calls s.Commit(ctx, \"bd backup restore\") to record a Dolt commit marking the restore. Any commit error other than the benign 'nothing to commit' case is wrapped in this error, signaling the restored data was written but the post-restore commit could not be created.","triggerScenarios":"bs.RestoreDatabase succeeds but s.Commit fails — e.g. Dolt lock contention, disk full, corrupted merge/commit state after restore, or a driver error writing the new HEAD.","commonSituations":"Disk-full during restore; leftover dolt lock files from a crashed process; restored snapshot whose commit graph confuses the working set; read-only filesystem after restore.","solutions":["Inspect the wrapped error for the root Dolt/driver cause","Check for and remove stale Dolt lock files in the .beads database directory","Verify free disk space and filesystem writability","Re-run the restore ('bd backup restore <dir>') so the commit step executes on a clean state"],"exampleFix":"// before\nif err := s.Commit(ctx, \"bd backup restore\"); err != nil {\n\treturn fmt.Errorf(\"failed to commit restore: %w\", err)\n}\n// after\nif err := s.Commit(ctx, \"bd backup restore\"); err != nil {\n\tif !strings.Contains(err.Error(), \"nothing to commit\") {\n\t\treturn fmt.Errorf(\"failed to commit restore: %w\", err)\n\t}\n}","handlingStrategy":"retry","validationCode":"// pre-check writability and space before restore\nif err := unix.Access(beadsDir, unix.W_OK); err != nil { return err }\nif stat, err := os.Stat(beadsDir); err == nil && stat.Size() == 0 { /* suspicious target */ }","typeGuard":null,"tryCatchPattern":"if err := s.Commit(ctx, \"bd backup restore\"); err != nil {\n\tif !strings.Contains(err.Error(), \"nothing to commit\") {\n\t\tif isTransient(err) { time.Sleep(backoff); retryCommit() }\n\t\treturn fmt.Errorf(\"failed to commit restore: %w\", err)\n\t}\n}","preventionTips":["Ensure sufficient free disk space before restoring large backups","Clean stale Dolt lock files after any crashed bd process","Re-run the restore if the post-restore commit fails rather than continuing on a partially committed state","Monitor filesystem errors (EIO, ENOSPC) on the machine performing restores"],"tags":["dolt","commit","restore","go"],"backgroundTag":"post-restore-commit-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}