gastownhall/beads · warning
flush: failed to list databases: %w
Error message
flush: failed to list databases: %w
What it means
FlushWorkingSet wraps a failure of the 'SHOW DATABASES' query with this message after a successful ping, meaning the connection dropped or the server rejected the query mid-flush. The caller treats the whole flush as failed (best-effort; the stop proceeds with a warning), so uncommitted working-set changes may be lost for that shutdown.
Source
Thrown at internal/doltserver/doltserver.go:1588
Port: port,
User: "root",
}.String()
db, err := sql.Open("mysql", dsn)
if err != nil {
return fmt.Errorf("flush: failed to open connection: %w", err)
}
defer db.Close()
db.SetMaxOpenConns(1)
db.SetConnMaxLifetime(10 * time.Second)
if err := db.PingContext(ctx); err != nil {
return fmt.Errorf("flush: server not reachable: %w", err)
}
// List all databases, skipping system databases
rows, err := db.QueryContext(ctx, "SHOW DATABASES")
if err != nil {
return fmt.Errorf("flush: failed to list databases: %w", err)
}
var databases []string
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
continue
}
// Skip Dolt system databases
if name == "information_schema" || name == "mysql" || name == "performance_schema" {
continue
}
databases = append(databases, name)
}
_ = rows.Close()
if len(databases) == 0 {
return nil
}View on GitHub (pinned to 71377f2769)
Solutions
- Retry bd dolt stop — the error is often transient if the server was mid-restart
- Confirm only one bd process is managing the server (avoid concurrent stop/start from other terminals or CI jobs)
- Check the dolt server log for engine errors or connection kills at the failure time
- If on a remote server, verify network stability (a dropped connection between ping and query produces exactly this error)
- As a fallback, run explicit dolt commits (cd <data-dir> && dolt add -A && dolt commit -m 'manual flush') to protect uncommitted work
Example fix
// before: concurrent stop/start kills the flush connection // $ (terminal A) bd dolt stop & (terminal B) bd dolt restart // after: serialize server lifecycle operations // $ bd dolt restart # single command handles flush + stop + start
Defensive patterns
Strategy: retry
Validate before calling
// Sanity-check the connection is still usable before the flush queries
conn, err := net.DialTimeout("tcp", net.JoinHostPort(host, strconv.Itoa(port)), 2*time.Second)
if err != nil {
return fmt.Errorf("server unreachable on %s:%d; aborting flush", host, port)
}
conn.Close() Try / catch
err := doltserver.FlushWorkingSet(host, port)
if err != nil && strings.Contains(err.Error(), "failed to list databases") {
// transient drop (restart/limits): one retry, then log and continue best-effort
time.Sleep(time.Second)
if err := doltserver.FlushWorkingSet(host, port); err != nil {
log.Printf("warning: flush failed after retry: %v", err)
}
} Prevention
- Serialize all server lifecycle operations through a single bd process
- Raise server connection limits on shared multi-user servers
- Check the dolt server log for engine errors on SHOW DATABASES
- Keep server and client dolt versions compatible
- Commit explicitly before shutdowns on unstable networks
When it happens
Trigger: db.QueryContext(ctx, "SHOW DATABASES") errors after the ping succeeded: the connection died between ping and query (server restart/crash in that window), the server killed the connection (max connections, idle timeout misconfig), or Dolt returned an engine error enumerating databases.
Common situations: Server being concurrently restarted by another bd process during shutdown; connection-limit exhaustion on a shared server; flaky network to a remote shared server; Dolt version-specific errors on SHOW DATABASES.
Related errors
- ensure global db: failed to create %s: %w
- flush: failed to open connection: %w
- flush: server not reachable: %w
- failed to open server connection: %w
- failed to begin transaction: %w
AI-assisted analysis of gastownhall/beads@71377f2769 (2026-08-30).
Data as JSON: /api/errors/23c43d3c9088b889.
Report an issue: GitHub.