{"record":{"id":"436c1820e18c6272","repo":"vitessio/vitess","slug":"unexpected-result-from-s-v","errorCode":null,"errorMessage":"unexpected result from %s: %v","messagePattern":"unexpected result from (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/vreplicator.go","lineNumber":527,"sourceCode":"\t\t// transitions Replicate() relies on. See #20012.\n\t\tvr.stats.State.Store(settings.State.String())\n\t}\n\treturn settings, numTablesToCopy, err\n}\n\nfunc (vr *vreplicator) readSettings(ctx context.Context, dbClient *vdbClient) (settings binlogplayer.VRSettings, numTablesToCopy int64, err error) {\n\tsettings, err = binlogplayer.ReadVRSettings(dbClient, vr.id)\n\tif err != nil {\n\t\treturn settings, numTablesToCopy, fmt.Errorf(\"error reading VReplication settings: %v\", err)\n\t}\n\n\tquery := fmt.Sprintf(\"select count(distinct table_name) from _vt.copy_state where vrepl_id=%d\", vr.id)\n\tqr, err := vr.dbClient.ExecuteFetch(query, maxRows)\n\tif err != nil {\n\t\treturn settings, numTablesToCopy, err\n\t}\n\tif len(qr.Rows) == 0 || len(qr.Rows[0]) == 0 {\n\t\treturn settings, numTablesToCopy, fmt.Errorf(\"unexpected result from %s: %v\", query, qr)\n\t}\n\tnumTablesToCopy, err = qr.Rows[0][0].ToCastInt64()\n\tif err != nil {\n\t\treturn settings, numTablesToCopy, err\n\t}\n\treturn settings, numTablesToCopy, nil\n}\n\nfunc (vr *vreplicator) setMessage(message string) (err error) {\n\tmessage = binlogplayer.MessageTruncate(message)\n\tvr.stats.History.Add(&binlogplayer.StatsHistoryRecord{\n\t\tTime:    time.Now(),\n\t\tMessage: message,\n\t})\n\tbuf := sqlparser.NewTrackedBuffer(nil)\n\tbuf.Myprintf(\"update _vt.vreplication set message=%s where id=%s\", encodeString(message), strconv.Itoa(int(vr.id)))\n\tquery := buf.ParsedQuery().Query\n\tif _, err := vr.dbClient.Execute(query); err != nil {","sourceCodeStart":509,"sourceCodeEnd":545,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/vreplicator.go#L509-L545","documentation":"After counting tables to copy with 'select count(distinct table_name) from _vt.copy_state where vrepl_id=<id>', readSettings requires exactly one cell in the result. If the query returns zero rows or a row with zero columns, the result is structurally unexpected and the code raises this error rather than guessing a count.","triggerScenarios":"The count query executes successfully but returns an empty row set or an empty first row — an internal inconsistency from the target MySQL or a proxy/filter between tablet and MySQL that strips result columns.","commonSituations":"A misbehaving intermediate proxy or vitess-to-vitess VReplication target returning malformed results; corrupted copy_state table; unusual MySQL versions/responses.","solutions":["Log/inspect the query shown in the message and run it manually against _vt.copy_state for this vrepl_id; a plain MySQL should always return one row with one integer.","Check _vt.copy_state table integrity (CHECK TABLE) and that no proxy rewrites queries.","Confirm no vitess-to-vitess VReplication (or other intermediary) is mangling the result shape.","If persistent, restart the tablet so the vreplicator reloads state cleanly."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Manually verify the count query returns one row/column:\n// SELECT COUNT(DISTINCT table_name) FROM _vt.copy_state WHERE vrepl_id = <id>;\n// Any result other than a single integer cell indicates a broken intermediary.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Avoid custom proxies between tablet and mysqld that rewrite results.","Run CHECK TABLE on _vt.copy_state if errors persist.","Keep vitess and MySQL versions compatible (check release notes).","Restart the tablet if result-shape errors persist after backend checks."],"tags":["vreplication","mysql","query-result"],"backgroundTag":"unexpected-query-result-shape","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}