vitessio/vitess · error
error droppping database %q: %w
Error message
error droppping database %q: %w
What it means
During restore, cleanupMySQL drops all non-internal databases found on the target before the mysql-shell load. This error wraps a failure of the `DROP DATABASE IF EXISTS` super-query for a given database name.
Source
Thrown at go/vt/mysqlctl/mysqlshellbackupengine.go:629
func cleanupMySQL(ctx context.Context, params RestoreParams, shouldDeleteUsers bool) error {
params.Logger.Infof("Cleaning up MySQL ahead of a restore")
result, err := params.Mysqld.FetchSuperQuery(ctx, "SHOW DATABASES")
if err != nil {
return err
}
// drop all databases
for _, row := range result.Rows {
dbName := row[0].ToString()
if slices.Contains(internalDBs, dbName) {
continue // not dropping internal DBs
}
params.Logger.Infof("Dropping DB %q", dbName)
err = params.Mysqld.ExecuteSuperQuery(ctx, fmt.Sprintf("DROP DATABASE IF EXISTS `%s`", row[0].ToString()))
if err != nil {
return fmt.Errorf("error droppping database %q: %w", row[0].ToString(), err)
}
}
if shouldDeleteUsers {
// get current user
var currentUser string
result, err = params.Mysqld.FetchSuperQuery(ctx, "SELECT user()")
if err != nil {
return fmt.Errorf("error fetching current user: %w", err)
}
for _, row := range result.Rows {
currentUser = row[0].ToString()
}
// drop all users except reserved ones
result, err = params.Mysqld.FetchSuperQuery(ctx, "SELECT user, host FROM mysql.user")
if err != nil {View on GitHub (pinned to 01a25a7d17)
Solutions
- Check the DBA user has DROP privileges and the server is not in super_read_only mode
- Kill active connections holding the database open, then retry the restore
- Inspect the wrapped inner error (%w) for the underlying MySQL error code and address it
Defensive patterns
Strategy: try-catch
Validate before calling
// before restore: verify drop rights and read-only state qr, err := mysqld.FetchSuperQuery(ctx, "SELECT @@read_only | @@super_read_only") // expect 0; also ensure DBA user has DROP privilege
Try / catch
if _, err := engine.ExecuteRestore(ctx, params, backupDir); err != nil {
var dbErr mysql.Err // or inspect the wrapped %w error
if errors.As(err, &dbErr) {
log.Error("restore cleanup failed dropping database", slog.Any("error", err))
}
} Prevention
- Grant the DBA user DROP privilege on all application databases
- Disable read_only / super_read_only before restore
- Ensure no long-lived connections hold locks on the databases being dropped
When it happens
Trigger: ExecuteRestore -> cleanupMySQL when params.Mysqld.ExecuteSuperQuery("DROP DATABASE IF EXISTS `name`") fails for one of the enumerated databases (returned by SHOW DATABASES filtering out internal DBs).
Common situations: Insufficient privileges (DROP not granted to the DBA user); database in use / locked by active connections; disk or replication issues; read-only mode (super_read_only) preventing DDL.
Related errors
- %w: "progressFile" needs to be empty as vitess always starts
- %w: "skipBinlog" needs to set to true
- %w: failed to fetch MySQL version: %v
- %w: failed to parse MySQL version (version: %s): %v
- %w: error checking if server supports disabling redo log: %v
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/d0699844545971ad.
Report an issue: GitHub.