{"record":{"id":"a96ad2126a1f48b8","repo":"gastownhall/beads","slug":"schema-verify-fresh-bootstrap-history-w","errorCode":null,"errorMessage":"schema: verify fresh-bootstrap history: %w","messagePattern":"schema: verify fresh-bootstrap history: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/lock.go","lineNumber":131,"sourceCode":"\tvar databaseName, serverUUID, initialHead string\n\tif err := conn.QueryRowContext(ctx,\n\t\t\"SELECT DATABASE(), @@server_uuid, DOLT_HASHOF('HEAD')\",\n\t).Scan(&databaseName, &serverUUID, &initialHead); err != nil {\n\t\treturn nil, fmt.Errorf(\"schema: capture fresh-bootstrap identity: %w\", err)\n\t}\n\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}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/lock.go#L113-L149","documentation":"The library verifies a freshly created database is pristine by counting rows in dolt_log. This error wraps a driver failure of that COUNT query — the history check could not even run, so no heal capability is issued (fail closed).","triggerScenarios":"SELECT COUNT(*) FROM dolt_log errors because the session lost connectivity, the context expired, the database is not Dolt-initialized (no dolt_log table), or the pinned connection was poisoned by an earlier undrained result set.","commonSituations":"Pointing beads at a plain MySQL database that has no dolt_log system table; a Dolt database whose Dolt branch/init was wiped; ctx cancellation during slow server startup.","solutions":["Read the wrapped error; if it says the table doesn't exist, confirm the target is a Dolt database, not plain MySQL.","Reconnect and retry the bootstrap; the capability intentionally isn't granted on uncertainty.","Ensure the pinned conn has no undrained result sets from prior CALL/SELECT statements.","Give the context a generous timeout when the server is starting."],"exampleFix":"// before\nconn, _ := mysqlPool.Conn(ctx) // plain MySQL: no dolt_log\n// after\nconn, _ := doltServerPool.Conn(ctx) // Dolt sql-server endpoint","handlingStrategy":"validation","validationCode":"var one int\nif err := conn.QueryRowContext(ctx, \"SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = DATABASE() AND table_name = 'dolt_log'\").Scan(&one); err != nil || one != 1 {\n    return errors.New(\"target is not a Dolt database (dolt_log missing)\")\n}","typeGuard":null,"tryCatchPattern":"cap, err := schema.CaptureFreshBootstrapHealCapability(ctx, conn, endpoint, db)\nif err != nil && strings.Contains(err.Error(), \"verify fresh-bootstrap history\") {\n    // driver-level failure; check server type / connectivity, retry\n}","preventionTips":["Confirm the backend is Dolt (dolt_log/dolt_status exist) before bootstrap.","Use fresh pinned connections and bounded contexts.","Retry the create+capture sequence on transient errors."],"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"}