vitessio/vitess · error

error droppping user %q: %w

Error message

error droppping user %q: %w

What it means

When shouldDeleteUsers is set, cleanupMySQL iterates the mysql.user table and drops each non-reserved user (skipping the current user and internal/reserved accounts). This error wraps a failed `DROP USER` statement for a specific user@host pair.

Source

Thrown at go/vt/mysqlctl/mysqlshellbackupengine.go:664

		result, err = params.Mysqld.FetchSuperQuery(ctx, "SELECT user, host FROM mysql.user")
		if err != nil {
			return err
		}

		for _, row := range result.Rows {
			user := fmt.Sprintf("%s@%s", row[0].ToString(), row[1].ToString())

			if user == currentUser {
				continue // we don't drop the current user
			}
			if slices.Contains(reservedUsers, user) {
				continue // we skip reserved MySQL users
			}

			params.Logger.Infof("Dropping User %q", user)
			err = params.Mysqld.ExecuteSuperQuery(ctx, fmt.Sprintf("DROP USER '%s'@'%s'", row[0].ToString(), row[1].ToString()))
			if err != nil {
				return fmt.Errorf("error droppping user %q: %w", user, err)
			}
		}
	}

	return err
}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Grant the Vitess DBA user CREATE USER and DROP privileges, or run cleanup as an admin account
  2. Terminate sessions owned by the affected users, then retry the restore
  3. Check super_read_only / read_only flags and disable them before user cleanup
  4. Inspect the wrapped error (%w) for the exact MySQL error code (e.g. ER_USER_NOT_DROPPED)
Defensive patterns

Strategy: validation

Validate before calling

// confirm the DBA user can drop users before enabling user cleanup
if err := mysqld.ExecuteSuperQuery(ctx, "CREATE USER IF NOT EXISTS vitess_probe@localhost"); err != nil {
    log.Warn("DBA user lacks CREATE USER privilege; DROP USER will fail", slog.Any("error", err))
} else {
    _ = mysqld.ExecuteSuperQuery(ctx, "DROP USER vitess_probe@localhost")
}

Try / catch

if _, err := engine.ExecuteRestore(ctx, params, backupDir); err != nil {
    if strings.Contains(err.Error(), "error droppping user") {
        // grant CREATE USER/DROP, kill blocking sessions, retry
    }
}

Prevention

When it happens

Trigger: ExecuteRestore -> cleanupMySQL with shouldDeleteUsers=true when ExecuteSuperQuery("DROP USER 'user'@'host'") fails, e.g. missing CREATE USER privilege or the user owns active sessions/objects.

Common situations: DBA user lacking DROP USER / CREATE USER privilege; users with active connections blocking the drop; grants referencing the user preventing deletion; super_read_only enabled on the replica.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/af0355ca0a581312. Report an issue: GitHub.