gastownhall/beads · error

creating wisps for migration 0047: %w

Error message

creating wisps for migration 0047: %w

What it means

When wisps is entirely missing, the pre-0047 repair creates it from wispsTableDDLForMigration0047 (the forward-canonical shape through v52, so later migrations like 0053 find no_history/started_at). This error wraps failure of that CREATE TABLE — SQL rejected the DDL, typically from a connection drop, a conflicting stale object, or a server DDL error.

Source

Thrown at internal/storage/schema/migration_repairs.go:206

// after 0020) and, on a database whose local wisp_dependencies predates
// 0022, expects idx_wisp_dep_type to already exist. Creating the 0020/0021-era
// shape here is exactly the #4695 bug shape one migration later: a real
// production repro hit "table not found: wisps" at 0047 and "unknown column
// no_history" at 0053 back to back (see the failed-workaround log in #4695).
// wispsTableDDLForMigration0047 / wispDependenciesTableDDLForMigration0047
// below are therefore the full shape as of immediately before 0053 runs --
// every column/index any main migration <=52 adds to these tables -- verified
// by building a bounded fresh chain (migrations 1..52 only) and comparing
// against SHOW CREATE TABLE, not by manual inspection. Nothing from 54/55
// (lease columns added then removed again) or 56 belongs here.
func ensureWispTablesForMixedBlockedRecompute(ctx context.Context, db DBConn) error {
	hasWisps, err := schemaTableExists(ctx, db, "wisps")
	if err != nil {
		return fmt.Errorf("checking wisps table: %w", err)
	}
	if !hasWisps {
		if _, err := db.ExecContext(ctx, wispsTableDDLForMigration0047); err != nil {
			return fmt.Errorf("creating wisps for migration 0047: %w", err)
		}
	}

	hasWispDeps, err := schemaTableExists(ctx, db, "wisp_dependencies")
	if err != nil {
		return fmt.Errorf("checking wisp_dependencies table: %w", err)
	}
	if !hasWispDeps {
		if _, err := db.ExecContext(ctx, wispDependenciesTableDDLForMigration0047); err != nil {
			return fmt.Errorf("creating wisp_dependencies for migration 0047: %w", err)
		}
		return nil
	}

	return ensureWispDependenciesSplitTargets(ctx, db)
}

// ensureWispIsBlockedForRecompute repairs a drift shape in ignored/0006's own

View on GitHub (pinned to 71377f2769)

Solutions

  1. Retry bd init — the DDL uses CREATE TABLE IF NOT EXISTS and is safe to re-run
  2. Check for a leftover conflicting object named wisps and remove it if stale
  3. Verify connectivity to the Dolt sql-server and retry
  4. Inspect the wrapped error; subsequent "unknown column no_history" at 0053 means the create still did not take
Defensive patterns

Strategy: validation

Validate before calling

// ensure no conflicting object exists before the DDL
var n int
db.QueryRowContext(ctx, `SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES
  WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'wisps'`).Scan(&n)
// n == 0 means the CREATE TABLE IF NOT EXISTS path is safe; n > 0 means it will be skipped

Try / catch

if _, err := db.ExecContext(ctx, wispsTableDDLForMigration0047); err != nil {
    if isTransient(err) {
        return ensureWispTablesForMixedBlockedRecompute(ctx, db) // IF NOT EXISTS makes re-run safe
    }
    return err
}

Prevention

When it happens

Trigger: Clone hitting migration 0047 without wisps (dolt_ignore'd tables never sync to clones; #4695 shape) and CREATE TABLE IF NOT EXISTS wisps (...) fails — connection drop mid-DDL, name collision with leftover objects, or server DDL rejection.

Common situations: Clone right after a schema bump before producers re-pushed; pre-1.0 database with stale cursor numbering treating 0020/0021 as applied; interrupted prior init attempt.

Related errors


AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30). Data as JSON: /api/errors/a006a595ef72b146. Report an issue: GitHub.