{"record":{"id":"94c50ac5507dcf7b","repo":"gastownhall/beads","slug":"schema-verify-fresh-bootstrap-working-set-w","errorCode":null,"errorMessage":"schema: verify fresh-bootstrap working set: %w","messagePattern":"schema: verify fresh-bootstrap working set: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/lock.go","lineNumber":137,"sourceCode":"\tif databaseName != expectedDatabase {\n\t\treturn nil, fmt.Errorf(\"schema: capture fresh-bootstrap identity: database is %q, want %q\", databaseName, expectedDatabase)\n\t}\n\tif serverUUID == \"\" {\n\t\treturn nil, errors.New(\"schema: capture fresh-bootstrap identity: empty server UUID\")\n\t}\n\tif initialHead == \"\" {\n\t\treturn nil, errors.New(\"schema: capture fresh-bootstrap identity: empty initial HEAD\")\n\t}\n\n\tvar commitCount, dirtyCount int\n\tif err := conn.QueryRowContext(ctx, \"SELECT COUNT(*) FROM dolt_log\").Scan(&commitCount); err != nil {\n\t\treturn nil, fmt.Errorf(\"schema: verify fresh-bootstrap history: %w\", err)\n\t}\n\tif commitCount != 1 {\n\t\treturn nil, fmt.Errorf(\"schema: verify fresh-bootstrap history: got %d commits, want 1\", commitCount)\n\t}\n\tif err := conn.QueryRowContext(ctx, \"SELECT COUNT(*) FROM dolt_status\").Scan(&dirtyCount); err != nil {\n\t\treturn nil, fmt.Errorf(\"schema: verify fresh-bootstrap working set: %w\", err)\n\t}\n\tif dirtyCount != 0 {\n\t\treturn nil, fmt.Errorf(\"schema: verify fresh-bootstrap working set: got %d dirty entries, want 0\", dirtyCount)\n\t}\n\n\treturn &FreshBootstrapHealCapability{\n\t\tendpoint:     endpoint,\n\t\tserverUUID:   serverUUID,\n\t\tdatabaseName: databaseName,\n\t\tinitialHead:  initialHead,\n\t}, nil\n}\n\n// WithFreshBootstrapHeal enables the fresh-bootstrap self-heal for the #4566\n// dirty-table guard (gastownhall/beads#5012). The capability must have been\n// captured immediately after this logical open's exact CREATE DATABASE, and\n// endpoint must identify the connection pool used for migration. Before any\n// DOLT_RESET, MigrateUpWithLock revalidates the capability against the pinned,","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/lock.go#L119-L155","documentation":"Counting rows in dolt_status (the working-set dirtiness check) failed at the driver level. The library cannot confirm the fresh database has a clean working set, so it fails closed and issues no heal capability.","triggerScenarios":"SELECT COUNT(*) FROM dolt_status errors due to connection loss, context cancellation, a non-Dolt backend without dolt_status, or a poisoned pinned session.","commonSituations":"Same as other system-table failures: wrong server type, transient network drop during bootstrap, server restart mid-capture.","solutions":["Inspect the wrapped driver error and fix the underlying cause (connectivity, server type).","Confirm the target is a Dolt sql-server exposing dolt_status.","Retry the full create-database + capture sequence.","Avoid reusing a pinned conn after an error; get a fresh pinned connection."],"exampleFix":"// before\n_ = conn // reused stale conn after earlier failure\n// after\nconn, err := pool.Conn(ctx)\nif err != nil { return err }\ncap, err := schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, db)","handlingStrategy":"retry","validationCode":"if err := conn.PingContext(ctx); err != nil { return fmt.Errorf(\"connection unusable: %w\", err) }","typeGuard":null,"tryCatchPattern":"cap, err := schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, db)\nif err != nil && strings.Contains(err.Error(), \"verify fresh-bootstrap working set\") {\n    // transient; retry create+capture after reconnect\n}","preventionTips":["Ping/reconnect before capture.","Use a context with adequate timeout during server startup.","Keep the target on a Dolt sql-server so dolt_status exists.","Get a new pinned connection after any prior error on the session."],"tags":["go","database","dolt","bootstrap"],"backgroundTag":"dolt-system-table-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}