{"record":{"id":"660bad74fa37f3f6","repo":"vitessio/vitess","slug":"failed-to-parse-max-replication-lag-column-v","errorCode":null,"errorMessage":"failed to parse max_replication_lag column: %v","messagePattern":"failed to parse max_replication_lag column: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlogplayer/binlog_player.go","lineNumber":591,"sourceCode":"func ReadVRSettings(dbClient DBClient, uid int32) (VRSettings, error) {\n\tquery := fmt.Sprintf(GetWorkflowQuery, uid)\n\tqr, err := dbClient.ExecuteFetch(query, 1)\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"error %v in selecting vreplication settings %v\", err, query)\n\t}\n\n\tif len(qr.Rows) != 1 {\n\t\treturn VRSettings{}, fmt.Errorf(\"checkpoint information not available in db for %v\", uid)\n\t}\n\tvrRow := qr.Named().Row()\n\n\tmaxTPS, err := vrRow.ToInt64(\"max_tps\")\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse max_tps column: %v\", err)\n\t}\n\tmaxReplicationLag, err := vrRow.ToInt64(\"max_replication_lag\")\n\tif err != nil {\n\t\treturn VRSettings{}, fmt.Errorf(\"failed to parse max_replication_lag column: %v\", err)\n\t}\n\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\")","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlogplayer/binlog_player.go#L573-L609","documentation":"Same conversion failure as max_tps but for the max_replication_lag column, which throttles vreplication based on source lag. A non-integer value in the checkpoint row aborts loading of settings for the stream.","triggerScenarios":"vrRow.ToInt64(\"max_replication_lag\") fails: non-numeric or NULL value stored in the column, or schema drift between Vitess versions changing the column representation.","commonSituations":"Manual row edits; restoring _vt tables from a mismatched-version backup; corrupted row from an interrupted insert.","solutions":["Check the value: `select uid, max_replication_lag from _vt.vreplication where uid=<id>`.","Correct it via `update _vt.vreplication set max_replication_lag=<seconds> where uid=<id>` (e.g. 10 or 9223372036854775807 for disabled).","Restore the canonical _vt.vreplication schema if column types drifted after a version upgrade/downgrade."],"exampleFix":"// before\nupdate _vt.vreplication set max_replication_lag=NULL where uid=1;\n// after\nupdate _vt.vreplication set max_replication_lag=10 where uid=1;","handlingStrategy":"validation","validationCode":"qr, _ := dbClient.ExecuteFetch(fmt.Sprintf(\"SELECT max_replication_lag FROM _vt.vreplication WHERE uid=%d\", uid), 1)\nif len(qr.Rows) == 1 {\n\tv := qr.Named().Row().AsString(\"max_replication_lag\", \"\")\n\tif _, err := strconv.ParseInt(v, 10, 64); err != nil {\n\t\treturn fmt.Errorf(\"max_replication_lag is not an integer (%q)\", v)\n\t}\n}","typeGuard":"func isNumeric(s string) bool {\n\t_, err := strconv.ParseInt(s, 10, 64)\n\treturn err == nil\n}","tryCatchPattern":"settings, err := binlogplayer.ReadVRSettings(dbClient, uid)\nif err != nil && strings.Contains(err.Error(), \"failed to parse max_replication_lag\") {\n\t_, _ = dbClient.ExecuteFetch(fmt.Sprintf(\"UPDATE _vt.vreplication SET max_replication_lag=%d WHERE uid=%d\", 10, uid), 0)\n\tsettings, err = binlogplayer.ReadVRSettings(dbClient, uid)\n}","preventionTips":["Store lag in whole seconds as integers only.","Use VExec or the workflow API for edits, not raw SQL.","Restore _vt tables only from matching-version backups."],"tags":["vreplication","data-corruption","mysql","parsing"],"backgroundTag":"column-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}