{"record":{"id":"73ec4e422050db65","repo":"vitessio/vitess","slug":"could-not-set-the-permissive-sql-mode-on-target-us","errorCode":null,"errorMessage":"could not set the permissive sql_mode on target using %s: %v","messagePattern":"could not set the permissive sql_mode on target using (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/vreplicator.go","lineNumber":693,"sourceCode":"\t\tif err != nil {\n\t\t\tlog.Warn(fmt.Sprintf(\"Could not reset sql_mode on target using %s: %v\", query, err))\n\t\t}\n\t}\n\tvreplicationSQLMode := SQLMode\n\tsettings, _, err := vr.readSettings(ctx, dbClient)\n\tif err != nil {\n\t\treturn resetFunc, err\n\t}\n\tif settings.WorkflowType == binlogdatapb.VReplicationWorkflowType_OnlineDDL {\n\t\tvreplicationSQLMode = StrictSQLMode\n\t}\n\n\t// Now set it to a permissive mode that will allow us to recreate\n\t// any database object that exists on the source in full on the\n\t// target\n\tquery := fmt.Sprintf(setSQLModeQueryf, vreplicationSQLMode)\n\tif _, err := dbClient.Execute(query); err != nil {\n\t\treturn resetFunc, fmt.Errorf(\"could not set the permissive sql_mode on target using %s: %v\", query, err)\n\t}\n\n\treturn resetFunc, nil\n}\n\n// throttlerAppName returns the app name to be used by throttlerClient for this particular workflow\n// example results:\n//   - \"vreplication\" for most flows\n//   - \"vreplication:online-ddl\" for online ddl flows.\n//     Note that with such name, it's possible to throttle\n//     the workflow by either \"vreplication\" and/or \"online-ddl\"\n//     This is useful when we want to throttle all migrations. We throttle \"online-ddl\".\nfunc (vr *vreplicator) throttlerAppName() string {\n\tnames := []string{vr.WorkflowName, throttlerapp.VReplicationName.String()}\n\tif vr.WorkflowType == int32(binlogdatapb.VReplicationWorkflowType_OnlineDDL) {\n\t\tnames = append(names, throttlerapp.OnlineDDLName.String())\n\t}\n\treturn throttlerapp.Concatenate(names...)","sourceCodeStart":675,"sourceCodeEnd":711,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/vreplicator.go#L675-L711","documentation":"After saving the original sql_mode, setSQLMode applies a permissive mode (vreplicationSQLMode) so schema DDL from the source can be replayed verbatim on the target (e.g. to bypass ONLY_FULL_GROUP_BY / STRICT_* rejections). If the SET SESSION sql_mode statement fails, this error wraps the executed query and MySQL error.","triggerScenarios":"'SET @@session.sql_mode = ...' fails due to a dead connection, mysqld read-only session restrictions, or a proxy that disallows session-variable SETs. Called by replicate and newClientConnection during copy-phase setup.","commonSituations":"Vitess-to-Vitess VReplication targets that reject session variable changes; connection dropped between the SELECT and the SET; hardened MySQL profiles or intermediaries blocking SET sql_mode.","solutions":["Read the wrapped MySQL error; if the connection died, restart the tablet/workflow to re-establish a session.","Confirm the tablet's MySQL user may SET SESSION sql_mode (no restrictions via proxies or POLICY-layer blocks).","Check for vitess-to-vitess replication targets: ensure the target tablet does not forbid session variable changes.","Re-run the workflow after the connection/session issue is resolved — sql_mode is set per session."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Confirm SET SESSION sql_mode works for the tablet user:\n// mysql -u <vtuser> -h <target> -e \"SET @@session.sql_mode='NO_ENGINE_SUBSTITUTION'; SELECT 1;\"","typeGuard":null,"tryCatchPattern":"if _, err := dbClient.Execute(query); err != nil {\n\tlog.Warn(\"failed to set permissive sql_mode\", slog.String(\"query\", query), slog.Any(\"error\", err))\n\t// retry on a fresh connection; check proxy/intermediary if it keeps failing\n}","preventionTips":["Allow SET SESSION sql_mode for the replication user.","Avoid vitess-to-vitess targets or proxies that block session variable SETs.","Reconnect and retry on connection-loss error codes.","Keep source and target MySQL modes documented so DDL replay expectations are clear."],"tags":["vreplication","mysql","sql-mode","ddl"],"backgroundTag":"sql-mode-set-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}