{"record":{"id":"aeda7f0314636c7a","repo":"vitessio/vitess","slug":"failed-to-initialize-clone-support-v","errorCode":null,"errorMessage":"failed to initialize clone support: %v","messagePattern":"failed to initialize clone support: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/mysqlctl/mysqld.go","lineNumber":1347,"sourceCode":"\n\t// Wait for mysqld to be ready, using root credentials, as no\n\t// user is created yet.\n\tparams := &mysql.ConnParams{\n\t\tUname:      \"root\",\n\t\tUnixSocket: cnf.SocketFile,\n\t}\n\tif err = mysqld.wait(ctx, cnf, params); err != nil {\n\t\tlog.Error(fmt.Sprintf(\"failed starting mysqld in time: %v\\n%v\", err, readTailOfMysqldErrorLog(cnf.ErrorLogPath)))\n\t\treturn err\n\t}\n\tif initDBSQLFile == \"\" { // default to built-in\n\t\tif err := mysqld.executeMysqlScript(ctx, params, config.DefaultInitDB); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to initialize mysqld: %v\", err)\n\t\t}\n\t\t// Execute clone-specific init SQL if enabled\n\t\tif mysqlCloneEnabled {\n\t\t\tif err := mysqld.executeMysqlScript(ctx, params, config.InitClone); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to initialize clone support: %v\", err)\n\t\t\t}\n\t\t}\n\t\treturn nil\n\t}\n\n\t// else, user specified an init db file\n\tsqlFile, err := os.Open(initDBSQLFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can't open init-db-sql-file (%v): %v\", initDBSQLFile, err)\n\t}\n\tdefer sqlFile.Close()\n\tscript, err := io.ReadAll(sqlFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"can't read init-db-sql-file (%v): %v\", initDBSQLFile, err)\n\t}\n\tif err := mysqld.executeMysqlScript(ctx, params, string(script)); err != nil {\n\t\treturn fmt.Errorf(\"can't run init-db-sql-file (%v): %v\", initDBSQLFile, err)\n\t}","sourceCodeStart":1329,"sourceCodeEnd":1365,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/mysqlctl/mysqld.go#L1329-L1365","documentation":"When the mysql clone support feature flag is enabled, Vitess runs an additional init SQL script (config.InitClone) right after the default init DB script during first-time mysqld initialization. If that clone-specific script fails, this error wraps the executeMysqlScript failure and aborts startup. It exists specifically to provision the clone plugin/support needed for clone-based backups.","triggerScenarios":"Mysqld.Start/Init with mysqlCloneEnabled=true executes config.InitClone via executeMysqlScript after DefaultInitDB; the mysql client invocation fails (script SQL rejected by the server, plugin unavailable, permissions).","commonSituations":"MySQL flavor without clone plugin support (e.g. MariaDB or old MySQL < 8.0) receiving clone setup SQL; clone plugin installation denied because of missing privileges or plugin dir issues; enabling the clone flag on an unsupported version.","solutions":["Check the inner error for the server's message — often 'clone plugin not supported' or a SQL syntax error.","Verify the MySQL version/flavor supports the clone plugin (MySQL 8.0+ only) before enabling the clone flag.","Disable the clone feature flag if your backend does not support clone-based operations.","Install/enable the clone plugin manually and grant the required privileges, then re-run init."],"exampleFix":"// before: clone flag on MariaDB\n-enable_mysqld_clone=true   # MariaDB has no clone plugin\n// after\n-enable_mysqld_clone=false  # or use MySQL 8.0+","handlingStrategy":"validation","validationCode":"if mysqlCloneEnabled {\n    v, err := mysqlctl.ParseVersionString(mysqlVersion)\n    if err != nil || v.Major < 8 {\n        return fmt.Errorf(\"clone support requires MySQL >= 8.0, got %s\", mysqlVersion)\n    }\n}","typeGuard":"func cloneSupported(flavor string, major int) bool {\n    return strings.HasPrefix(flavor, \"mysql\") && major >= 8\n}","tryCatchPattern":"if err := mysqld.Start(ctx, cnf, mysqldArgs, params); err != nil && strings.Contains(err.Error(), \"failed to initialize clone support\") {\n    // disable clone flag or upgrade MySQL, wipe datadir, retry\n}","preventionTips":["Enable the clone flag only on MySQL 8.0+ backends.","Verify the clone plugin loads (`INSTALL PLUGIN clone SONAME 'mysql_clone.so'`) in a staging run.","Document flavor requirements wherever the clone flag is documented.","Keep clone init SQL (config.InitClone) in sync with server version upgrades."],"tags":["mysql","clone","init","sql-script","mysqld"],"backgroundTag":"init-script-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}