{"record":{"id":"e2429d1ba947e74d","repo":"vitessio/vitess","slug":"can-t-parse-rand-event-v-event-data-v","errorCode":null,"errorMessage":"can't parse RAND_EVENT: %v, event data: %#v","messagePattern":"can't parse RAND_EVENT: (.+?), event data: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlog_streamer.go","lineNumber":390,"sourceCode":"\t\tcase ev.IsXID(): // XID_EVENT (equivalent to COMMIT)\n\t\t\tif err = commit(ev.Timestamp()); err != nil {\n\t\t\t\treturn pos, err\n\t\t\t}\n\t\tcase ev.IsIntVar(): // INTVAR_EVENT\n\t\t\ttyp, value, err := ev.IntVar(format)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, fmt.Errorf(\"can't parse INTVAR_EVENT: %v, event data: %#v\", err, ev)\n\t\t\t}\n\t\t\tstatements = append(statements, FullBinlogStatement{\n\t\t\t\tStatement: &binlogdatapb.BinlogTransaction_Statement{\n\t\t\t\t\tCategory: binlogdatapb.BinlogTransaction_Statement_BL_SET,\n\t\t\t\t\tSql:      fmt.Appendf(nil, \"SET %s=%d\", mysql.IntVarNames[typ], value),\n\t\t\t\t},\n\t\t\t})\n\t\tcase ev.IsRand(): // RAND_EVENT\n\t\t\tseed1, seed2, err := ev.Rand(format)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, fmt.Errorf(\"can't parse RAND_EVENT: %v, event data: %#v\", err, ev)\n\t\t\t}\n\t\t\tstatements = append(statements, FullBinlogStatement{\n\t\t\t\tStatement: &binlogdatapb.BinlogTransaction_Statement{\n\t\t\t\t\tCategory: binlogdatapb.BinlogTransaction_Statement_BL_SET,\n\t\t\t\t\tSql:      fmt.Appendf(nil, \"SET @@RAND_SEED1=%d, @@RAND_SEED2=%d\", seed1, seed2),\n\t\t\t\t},\n\t\t\t})\n\t\tcase ev.IsQuery(): // QUERY_EVENT\n\t\t\t// Extract the query string and group into transactions.\n\t\t\tq, err := ev.Query(format)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, fmt.Errorf(\"can't get query from binlog event: %v, event data: %#v\", err, ev)\n\t\t\t}\n\t\t\tswitch cat := getStatementCategory(q.SQL); cat {\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_BEGIN:\n\t\t\t\tbegin()\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_ROLLBACK:\n\t\t\t\t// Rollbacks are possible under some circumstances. Since the stream","sourceCodeStart":372,"sourceCodeEnd":408,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlog_streamer.go#L372-L408","documentation":"During binlog streaming, parseEvents encounters a RAND_EVENT (used by MySQL to replicate SET SESSION seed values for RAND()). The event payload could not be decoded by ev.Rand(format), so the streamer aborts the stream at the current position and returns this wrapped error including the raw event data for diagnosis.","triggerScenarios":"Streaming row-based or statement-based binlogs where the replication stream contains a RAND_EVENT whose body is truncated, corrupted, or from an unsupported format version; parseEvents returns and Stream terminates.","commonSituations":"Corrupt or truncated relay/binlog files, binlog files copied across MySQL versions with incompatible event formats, a vreplication source whose binlog is damaged, or a fake/patched binlog producer emitting malformed RAND_EVENT bodies.","solutions":["Inspect the event data (%#v in the message) to confirm the event is truncated or malformed","Verify MySQL server version compatibility with the vitess binlog event parser","Re-point the stream to a valid binlog position past the corrupt event (SET POSITION / re-copy) or re-initialize the source with a fresh backup","Check disk integrity on the binlog host; if the binlog file is corrupt, fix replication source first"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before starting the stream, validate binlog files:\n// mysqlbinlog --verify-binlog-checksum <binlog-file>\n// ensure no truncated RAND_EVENT entries","typeGuard":null,"tryCatchPattern":"err := streamer.Stream(ctx, signals)\nif err != nil && strings.Contains(err.Error(), \"can't parse RAND_EVENT\") {\n    // restart stream from a clean position after the corrupt event\n}","preventionTips":["Verify binlog integrity (mysqlbinlog) before streaming","Keep source MySQL version within vitess's supported range","Monitor disk health on the binlog host","Re-copy binlogs after any suspected corruption"],"tags":["binlog","streaming","event-parsing"],"backgroundTag":"binlog-event-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}