gastownhall/beads · error

failed to query dolt_status: %w

Error message

failed to query dolt_status: %w

What it means

After pinning a connection, the commit path queries dolt_status to discover dirty tables (excluding dolt_ignore'd tables like wisps and leases). This error wraps a failure of that QueryContext call itself. It means dirty-table discovery failed, so the commit is aborted before anything is staged; per the code comment this is treated as a rare edge case rather than a recoverable fallback.

Source

Thrown at internal/storage/dolt/store.go:3065

	// GH#2455: stage each dirty table individually, skipping config unless the
	// mode opts it in, to avoid sweeping up stale issue_prefix changes from
	// concurrent operations. Exclude dolt_ignore'd tables (wisps, wisp_%, leases)
	// with the same anti-join HasCommittablePending uses: they surface in
	// dolt_status but are never stageable, and the fail-hard DOLT_ADD loop below
	// must see only tables it can actually stage. A dirty wisp or lease row is the
	// normal steady state; staging it depends on Dolt's version-specific
	// ignored-table DOLT_ADD behavior (a silent no-op on 2.2.0), so filtering here
	// keeps ordinary commits from failing whenever an ignored table is dirty.
	rows, err := conn.QueryContext(ctx, `
		SELECT s.table_name FROM dolt_status s
		WHERE NOT EXISTS (
			SELECT 1 FROM dolt_ignore di
			WHERE di.ignored = 1
			AND s.table_name LIKE di.pattern
		)`)
	if err != nil {
		// If dolt_status fails, fall back to nothing (rare edge case).
		return fmt.Errorf("failed to query dolt_status: %w", err)
	}
	var tables []string
	configDirty := false
	for rows.Next() {
		var table string
		if err := rows.Scan(&table); err != nil {
			_ = rows.Close()
			return fmt.Errorf("failed to scan dolt_status: %w", err)
		}
		if table == "config" {
			configDirty = true
			if mode == configExclude {
				continue
			}
		}
		tables = append(tables, table)
	}
	_ = rows.Close()

View on GitHub (pinned to 71377f2769)

Solutions

  1. Check the wrapped driver error; retry the operation on a fresh pinned connection if it was transient.
  2. Upgrade the Dolt engine/driver to a current version if dolt_status is unsupported or buggy.
  3. Verify no other session holds conflicting locks on the working set (e.g. an open merge or concurrent DOLT_COMMIT).
  4. Re-run bd sync/commit; the abort happened before staging, so no partial state persists.
Defensive patterns

Strategy: retry

Validate before calling

// precheck engine support
var one int
if err := conn.QueryContext(ctx, "SELECT 1 FROM dolt_status LIMIT 1").Scan(&one); err != nil {
	// dolt_status unusable — surface engine/version problem first
}

Try / catch

err := store.Commit(ctx, msg)
if err != nil && strings.Contains(err.Error(), "failed to query dolt_status") {
	// retry on fresh connection; else report engine issue
}

Prevention

When it happens

Trigger: The SELECT against dolt_status fails: Dolt server error, session/transaction state invalid on the pinned connection, dolt_status table unavailable (very old Dolt version), or transient I/O error during query execution.

Common situations: Running against a Dolt version that predates or misbehaves for dolt_status; a killed Dolt process mid-query; corrupted session state after a prior failed stored-procedure call on the same connection.

Related errors


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