{"record":{"id":"d532f24a89fe9797","repo":"vitessio/vitess","slug":"failed-to-parse-defer-secondary-keys-column-v","errorCode":null,"errorMessage":"failed to parse defer_secondary_keys column: %v","messagePattern":"failed to parse defer_secondary_keys column: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"go/vt/binlog/binlogplayer/binlog_player.go","lineNumber":611,"sourceCode":"\tstartPos, err := DecodePosition(vrRow.AsString(\"pos\", \"\"))\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse pos column: %v\", err)\n\t}\n\tstopPos, err := replication.DecodePosition(vrRow.AsString(\"stop_pos\", \"\"))\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse stop_pos column: %v\", err)\n\t}\n\tworkflowType, err := vrRow.ToInt32(\"workflow_type\")\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse workflow_type column: %v\", err)\n\t}\n\tworkflowSubType, err := vrRow.ToInt32(\"workflow_sub_type\")\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse workflow_sub_type column: %v\", err)\n\t}\n\tdeferSecondaryKeys, err := vrRow.ToBool(\"defer_secondary_keys\")\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse defer_secondary_keys column: %v\", err)\n\t}\n\toptions := vrRow.AsString(\"options\", \"{}\")\n\tvar workflowOptions vtctldata.WorkflowOptions\n\tif err := json.Unmarshal([]byte(options), &workflowOptions); err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse options column: %v\", err)\n\t}\n\treturn VRSettings{\n\t\tStartPos:           startPos,\n\t\tStopPos:            stopPos,\n\t\tMaxTPS:             maxTPS,\n\t\tMaxReplicationLag:  maxReplicationLag,\n\t\tState:              binlogdatapb.VReplicationWorkflowState(binlogdatapb.VReplicationWorkflowState_value[vrRow.AsString(\"state\", \"\")]),\n\t\tWorkflowType:       binlogdatapb.VReplicationWorkflowType(workflowType),\n\t\tWorkflowName:       vrRow.AsString(\"workflow\", \"\"),\n\t\tWorkflowSubType:    binlogdatapb.VReplicationWorkflowSubType(workflowSubType),\n\t\tDeferSecondaryKeys: deferSecondaryKeys,\n\t\tWorkflowOptions:    &workflowOptions,\n\t}, nil","sourceCodeStart":593,"sourceCodeEnd":629,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlogplayer/binlog_player.go#L593-L629","documentation":"Returned by the binlog player when the defer_secondary_keys column value from the vreplication metadata row cannot be parsed, wrapping the underlying conversion error.","triggerScenarios":"vrRow.ToBool(\"defer_secondary_keys\") fails: the column contains a value the helper cannot interpret (NULL where the helper doesn't allow it, or non-boolean text like 'yes'/'on' inserted manually).","commonSituations":"Hand-edited rows storing 'yes' instead of 1/0 or true/false; restore of _vt tables from a version before the column existed with odd defaults; data corruption.","solutions":["Check: `select uid, defer_secondary_keys from _vt.vreplication where uid=<id>`.","Normalize the value: `update _vt.vreplication set defer_secondary_keys=0 where uid=<id>` (0 is the safe default preserving prior behavior).","Restore the canonical _vt schema if the column type/definition drifted.","Avoid manual writes to boolean columns; use 1/0 or true/false literals."],"exampleFix":"// before\nupdate _vt.vreplication set defer_secondary_keys='yes' where uid=1;\n// after\nupdate _vt.vreplication set defer_secondary_keys=0 where uid=1;","handlingStrategy":"validation","validationCode":"qr, _ := dbClient.ExecuteFetch(fmt.Sprintf(\"SELECT defer_secondary_keys FROM _vt.vreplication WHERE uid=%d\", uid), 1)\nif len(qr.Rows) == 1 {\n\tv := qr.Named().Row().AsString(\"defer_secondary_keys\", \"\")\n\tif v != \"0\" && v != \"1\" && v != \"true\" && v != \"false\" && v != \"\" {\n\t\treturn fmt.Errorf(\"defer_secondary_keys %q is not a boolean; set 0 or 1\", v)\n\t}\n}","typeGuard":"func isBoolLiteral(s string) bool {\n\tswitch s { case \"\", \"0\", \"1\", \"true\", \"false\": return true }\n\treturn false\n}","tryCatchPattern":"settings, err := binlogplayer.ReadVRSettings(dbClient, uid)\nif err != nil && strings.Contains(err.Error(), \"failed to parse defer_secondary_keys\") {\n\t_, _ = dbClient.ExecuteFetch(fmt.Sprintf(\"UPDATE _vt.vreplication SET defer_secondary_keys=0 WHERE uid=%d\", uid), 0)\n\tsettings, err = binlogplayer.ReadVRSettings(dbClient, uid)\n}","preventionTips":["Write booleans as 0/1 in SQL, never 'yes'/'on'.","Keep the column's zero-value behavior (0 = don't defer) when editing.","Avoid manual edits; use VExec."],"tags":["vreplication","parsing","mysql","boolean"],"backgroundTag":"column-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}