{"record":{"id":"af0355ca0a581312","repo":"vitessio/vitess","slug":"error-droppping-user-q-w","errorCode":null,"errorMessage":"error droppping user %q: %w","messagePattern":"error droppping user %q: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqlshellbackupengine.go","lineNumber":664,"sourceCode":"\t\tresult, err = params.Mysqld.FetchSuperQuery(ctx, \"SELECT user, host FROM mysql.user\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tfor _, row := range result.Rows {\n\t\t\tuser := fmt.Sprintf(\"%s@%s\", row[0].ToString(), row[1].ToString())\n\n\t\t\tif user == currentUser {\n\t\t\t\tcontinue // we don't drop the current user\n\t\t\t}\n\t\t\tif slices.Contains(reservedUsers, user) {\n\t\t\t\tcontinue // we skip reserved MySQL users\n\t\t\t}\n\n\t\t\tparams.Logger.Infof(\"Dropping User %q\", user)\n\t\t\terr = params.Mysqld.ExecuteSuperQuery(ctx, fmt.Sprintf(\"DROP USER '%s'@'%s'\", row[0].ToString(), row[1].ToString()))\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"error droppping user %q: %w\", user, err)\n\t\t\t}\n\t\t}\n\t}\n\n\treturn err\n}\n","sourceCodeStart":646,"sourceCodeEnd":671,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqlshellbackupengine.go#L646-L671","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Grant the Vitess DBA user CREATE USER and DROP privileges, or run cleanup as an admin account","Terminate sessions owned by the affected users, then retry the restore","Check super_read_only / read_only flags and disable them before user cleanup","Inspect the wrapped error (%w) for the exact MySQL error code (e.g. ER_USER_NOT_DROPPED)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// confirm the DBA user can drop users before enabling user cleanup\nif err := mysqld.ExecuteSuperQuery(ctx, \"CREATE USER IF NOT EXISTS vitess_probe@localhost\"); err != nil {\n    log.Warn(\"DBA user lacks CREATE USER privilege; DROP USER will fail\", slog.Any(\"error\", err))\n} else {\n    _ = mysqld.ExecuteSuperQuery(ctx, \"DROP USER vitess_probe@localhost\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := engine.ExecuteRestore(ctx, params, backupDir); err != nil {\n    if strings.Contains(err.Error(), \"error droppping user\") {\n        // grant CREATE USER/DROP, kill blocking sessions, retry\n    }\n}","preventionTips":["Grant CREATE USER and DROP privileges to the Vitess DBA account","Disable super_read_only before user cleanup on replicas","Terminate user sessions (or set them to be killed) prior to restore","Keep the set of managed accounts small and free of active connections"],"tags":["mysql-shell","backup-restore","user-management"],"backgroundTag":"mysql-user-drop-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}