{"record":{"id":"a8e2ecba5e8e846b","repo":"vitessio/vitess","slug":"could-not-set-message-v-v","errorCode":null,"errorMessage":"could not set message: %v: %v","messagePattern":"could not set message: (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletmanager/vreplication/controller.go","lineNumber":371,"sourceCode":"\t\t\t\treturn err // yes, err and not errSetState.\n\t\t\t}\n\t\t\tlog.Error(fmt.Sprintf(\"%s going into error state due to %+v\", ct.logPrefix(), err))\n\t\t\treturn nil // this will cause vreplicate to quit the workflow\n\t\t}\n\t\treturn err\n\t}\n\tct.blpStats.ErrorCounts.Add([]string{\"Invalid Source\"}, 1)\n\treturn errors.New(\"missing source\")\n}\n\nfunc (ct *controller) setMessage(dbClient binlogplayer.DBClient, message string) error {\n\tct.blpStats.History.Add(&binlogplayer.StatsHistoryRecord{\n\t\tTime:    time.Now(),\n\t\tMessage: message,\n\t})\n\tquery := fmt.Sprintf(\"update _vt.vreplication set message=%v where id=%v\", encodeString(binlogplayer.MessageTruncate(message)), ct.id)\n\tif _, err := dbClient.ExecuteFetch(query, 1); err != nil {\n\t\treturn fmt.Errorf(\"could not set message: %v: %v\", query, err)\n\t}\n\treturn nil\n}\n\n// pickSourceTablet picks a healthy serving tablet to source for\n// the vreplication stream. If the source is marked as external, it\n// returns nil.\nfunc (ct *controller) pickSourceTablet(ctx context.Context, dbClient binlogplayer.DBClient) (*topodatapb.Tablet, error) {\n\tif ct.source.GetExternalMysql() != \"\" {\n\t\treturn nil, nil\n\t}\n\tif ct.tpTs == nil {\n\t\treturn nil, fmt.Errorf(\"no tablet picker configured for %s/%s\", ct.source.Keyspace, ct.source.Shard)\n\t}\n\tlog.Info(fmt.Sprintf(\"%s trying to find an eligible source tablet in %s/%s\", ct.logPrefix(), ct.source.Keyspace, ct.source.Shard))\n\n\ttablet, err := ct.pickSourceTabletWithIgnoreList(ctx, dbClient)\n\t// If we failed to find any tablet and we specified an ignore list, then clear the ignore list so that","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletmanager/vreplication/controller.go#L353-L389","documentation":"setMessage records a human-readable status message for a vreplication stream by running `update _vt.vreplication set message=... where id=...` through the controller's dbClient. If that UPDATE fails, the query and underlying MySQL error are wrapped as `could not set message: <query>: <err>`.","triggerScenarios":"The `update _vt.vreplication set message=...` statement fails — e.g. the sidecar database or _vt.vreplication table is missing, the row for ct.id was deleted (stream stopped), or the MySQL connection used by dbClient is broken.","commonSituations":"vreplication row deleted concurrently by StopVCopy/UpdateVReplicationWorkflow while the controller is still running; sidecar schema not migrated; MySQL restart or failover dropping the connection; permissions revoked on the _vt database.","solutions":["Look at the embedded MySQL error after the second %v — it names the real cause (table missing, connection refused, etc.).","Verify the vreplication row still exists: `select id, message from _vt.vreplication where id=<ct.id>`.","Confirm the sidecar schema is up to date (`_vt.vreplication` table exists and is current).","Check tablet-to-MySQL connectivity and privileges on the _vt database."],"exampleFix":"// before (only generic wrap, hard to diagnose)\nreturn fmt.Errorf(\"could not set message: %v: %v\", query, err)\n// after — diagnose by inspecting the wrapped cause\nerr := fmt.Errorf(\"could not set message: %v: %v\", query, err)\n// then run on the tablet's MySQL:\n// select id from _vt.vreplication where id = <stream-id>;","handlingStrategy":"try-catch","validationCode":"// Before workflows, verify the stream row and table exist:\n// select id, workflow, message from _vt.vreplication where id = <stream-id>;\n// show tables in _vt like 'vreplication';","typeGuard":null,"tryCatchPattern":"if _, err := dbClient.ExecuteFetch(q, 1); err != nil {\n    if mysqlErr, ok := err.(*sqlexec.UnknownDatabaseError); ok { /* recreate sidecar */ }\n    return vterrors.Wrapf(err, \"could not set message for stream %d\", streamID)\n}","preventionTips":["Do not delete _vt.vreplication rows while a workflow is running; stop the workflow first.","Keep the sidecar schema migrated (upgrade runs schema upgrade steps).","Monitor tablet-to-MySQL connectivity and grant vt_dba privileges on _vt."],"tags":["mysql","vreplication","database"],"backgroundTag":"vreplication-status-update-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}