{"record":{"id":"61e6e5f9762aec76","repo":"gastownhall/beads","slug":"checking-wisps-table-w","errorCode":null,"errorMessage":"checking wisps table: %w","messagePattern":"checking wisps table: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/schema/migration_repairs.go","lineNumber":202,"sourceCode":"// The created shape must be forward-canonical, not the original 0020/0021\n// content: this repair fires at v47, but the SAME empty tables then ride\n// through every later main migration in the same pass, including 0053 --\n// which INSERTs wisps.no_history/started_at into issues (added by 0023/0027,\n// after 0020) and, on a database whose local wisp_dependencies predates\n// 0022, expects idx_wisp_dep_type to already exist. Creating the 0020/0021-era\n// shape here is exactly the #4695 bug shape one migration later: a real\n// production repro hit \"table not found: wisps\" at 0047 and \"unknown column\n// no_history\" at 0053 back to back (see the failed-workaround log in #4695).\n// wispsTableDDLForMigration0047 / wispDependenciesTableDDLForMigration0047\n// below are therefore the full shape as of immediately before 0053 runs --\n// every column/index any main migration <=52 adds to these tables -- verified\n// by building a bounded fresh chain (migrations 1..52 only) and comparing\n// against SHOW CREATE TABLE, not by manual inspection. Nothing from 54/55\n// (lease columns added then removed again) or 56 belongs here.\nfunc ensureWispTablesForMixedBlockedRecompute(ctx context.Context, db DBConn) error {\n\thasWisps, err := schemaTableExists(ctx, db, \"wisps\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking wisps table: %w\", err)\n\t}\n\tif !hasWisps {\n\t\tif _, err := db.ExecContext(ctx, wispsTableDDLForMigration0047); err != nil {\n\t\t\treturn fmt.Errorf(\"creating wisps for migration 0047: %w\", err)\n\t\t}\n\t}\n\n\thasWispDeps, err := schemaTableExists(ctx, db, \"wisp_dependencies\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"checking wisp_dependencies table: %w\", err)\n\t}\n\tif !hasWispDeps {\n\t\tif _, err := db.ExecContext(ctx, wispDependenciesTableDDLForMigration0047); err != nil {\n\t\t\treturn fmt.Errorf(\"creating wisp_dependencies for migration 0047: %w\", err)\n\t\t}\n\t\treturn nil\n\t}\n","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/schema/migration_repairs.go#L184-L220","documentation":"ensureWispTablesForMixedBlockedRecompute probes for the wisps table before migration 0047's recompute block, which joins wisps unconditionally. This error wraps failure of the INFORMATION_SCHEMA.TABLES existence probe itself — the catalog query failed (connection error, server problem), distinct from the table simply being absent.","triggerScenarios":"bd init reaching the pre-0047 repair on a clone with cursor skew (#4695/#4176) while the INFORMATION_SCHEMA.TABLES lookup for 'wisps' fails — dropped connection to the shared Dolt sql-server or a server error.","commonSituations":"Clone whose schema_migrations cursor is behind after a schema bump; transient network outage during upgrade; overloaded shared Dolt server.","solutions":["Retry bd init once connectivity is stable","Verify Dolt sql-server health (bd doctor)","If INFORMATION_SCHEMA queries consistently fail, check Dolt server version compatibility","Inspect the wrapped error for the underlying SQL/network cause"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// pre-check the catalog probe path\nvar n int\nerr := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES\n  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'wisps'`).Scan(&n)\n// err != nil here means the same probe the repair uses will fail","typeGuard":null,"tryCatchPattern":"hasWisps, err := schemaTableExists(ctx, db, \"wisps\")\nif err != nil {\n    if isTransient(err) {\n        return ensureWispTablesForMixedBlockedRecompute(ctx, db) // idempotent re-probe\n    }\n    return err\n}","preventionTips":["Retry init after restoring connectivity — all pre-0047 steps re-probe the schema","Check server health (bd doctor) when INFORMATION_SCHEMA queries fail","Avoid upgrading clones over unstable network links","Keep Dolt server software current"],"tags":["dolt","migration","sql","transient"],"backgroundTag":"table-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}