vitessio/vitess · warning
failed to parse defer_secondary_keys column: %v
Error message
failed to parse defer_secondary_keys column: %v
What it means
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.
Source
Thrown at go/vt/binlog/binlogplayer/binlog_player.go:611
startPos, err := DecodePosition(vrRow.AsString("pos", ""))
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse pos column: %v", err)
}
stopPos, err := replication.DecodePosition(vrRow.AsString("stop_pos", ""))
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse stop_pos column: %v", err)
}
workflowType, err := vrRow.ToInt32("workflow_type")
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse workflow_type column: %v", err)
}
workflowSubType, err := vrRow.ToInt32("workflow_sub_type")
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse workflow_sub_type column: %v", err)
}
deferSecondaryKeys, err := vrRow.ToBool("defer_secondary_keys")
if err != nil {
return VRSettings{}, fmt.Errorf("failed to parse defer_secondary_keys column: %v", err)
}
options := vrRow.AsString("options", "{}")
var workflowOptions vtctldata.WorkflowOptions
if err := json.Unmarshal([]byte(options), &workflowOptions); err != nil {
return VRSettings{}, fmt.Errorf("failed to parse options column: %v", err)
}
return VRSettings{
StartPos: startPos,
StopPos: stopPos,
MaxTPS: maxTPS,
MaxReplicationLag: maxReplicationLag,
State: binlogdatapb.VReplicationWorkflowState(binlogdatapb.VReplicationWorkflowState_value[vrRow.AsString("state", "")]),
WorkflowType: binlogdatapb.VReplicationWorkflowType(workflowType),
WorkflowName: vrRow.AsString("workflow", ""),
WorkflowSubType: binlogdatapb.VReplicationWorkflowSubType(workflowSubType),
DeferSecondaryKeys: deferSecondaryKeys,
WorkflowOptions: &workflowOptions,
}, nilView on GitHub (pinned to 01a25a7d17)
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.
Example fix
// before update _vt.vreplication set defer_secondary_keys='yes' where uid=1; // after update _vt.vreplication set defer_secondary_keys=0 where uid=1;
Defensive patterns
Strategy: validation
Validate before calling
qr, _ := dbClient.ExecuteFetch(fmt.Sprintf("SELECT defer_secondary_keys FROM _vt.vreplication WHERE uid=%d", uid), 1)
if len(qr.Rows) == 1 {
v := qr.Named().Row().AsString("defer_secondary_keys", "")
if v != "0" && v != "1" && v != "true" && v != "false" && v != "" {
return fmt.Errorf("defer_secondary_keys %q is not a boolean; set 0 or 1", v)
}
} Type guard
func isBoolLiteral(s string) bool {
switch s { case "", "0", "1", "true", "false": return true }
return false
} Try / catch
settings, err := binlogplayer.ReadVRSettings(dbClient, uid)
if err != nil && strings.Contains(err.Error(), "failed to parse defer_secondary_keys") {
_, _ = dbClient.ExecuteFetch(fmt.Sprintf("UPDATE _vt.vreplication SET defer_secondary_keys=0 WHERE uid=%d", uid), 0)
settings, err = binlogplayer.ReadVRSettings(dbClient, uid)
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse max_tps column: %v
- failed to parse max_replication_lag column: %v
- failed to parse workflow_type column: %v
- failed to parse workflow_sub_type column: %v
- overflow
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/d532f24a89fe9797.
Report an issue: GitHub.