vitessio/vitess · error
can't parse RAND_EVENT: %v, event data: %#v
Error message
can't parse RAND_EVENT: %v, event data: %#v
What it means
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.
Source
Thrown at go/vt/binlog/binlog_streamer.go:390
case ev.IsXID(): // XID_EVENT (equivalent to COMMIT)
if err = commit(ev.Timestamp()); err != nil {
return pos, err
}
case ev.IsIntVar(): // INTVAR_EVENT
typ, value, err := ev.IntVar(format)
if err != nil {
return pos, fmt.Errorf("can't parse INTVAR_EVENT: %v, event data: %#v", err, ev)
}
statements = append(statements, FullBinlogStatement{
Statement: &binlogdatapb.BinlogTransaction_Statement{
Category: binlogdatapb.BinlogTransaction_Statement_BL_SET,
Sql: fmt.Appendf(nil, "SET %s=%d", mysql.IntVarNames[typ], value),
},
})
case ev.IsRand(): // RAND_EVENT
seed1, seed2, err := ev.Rand(format)
if err != nil {
return pos, fmt.Errorf("can't parse RAND_EVENT: %v, event data: %#v", err, ev)
}
statements = append(statements, FullBinlogStatement{
Statement: &binlogdatapb.BinlogTransaction_Statement{
Category: binlogdatapb.BinlogTransaction_Statement_BL_SET,
Sql: fmt.Appendf(nil, "SET @@RAND_SEED1=%d, @@RAND_SEED2=%d", seed1, seed2),
},
})
case ev.IsQuery(): // QUERY_EVENT
// Extract the query string and group into transactions.
q, err := ev.Query(format)
if err != nil {
return pos, fmt.Errorf("can't get query from binlog event: %v, event data: %#v", err, ev)
}
switch cat := getStatementCategory(q.SQL); cat {
case binlogdatapb.BinlogTransaction_Statement_BL_BEGIN:
begin()
case binlogdatapb.BinlogTransaction_Statement_BL_ROLLBACK:
// Rollbacks are possible under some circumstances. Since the streamView on GitHub (pinned to 01a25a7d17)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// before starting the stream, validate binlog files: // mysqlbinlog --verify-binlog-checksum <binlog-file> // ensure no truncated RAND_EVENT entries
Try / catch
err := streamer.Stream(ctx, signals)
if err != nil && strings.Contains(err.Error(), "can't parse RAND_EVENT") {
// restart stream from a clean position after the corrupt event
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- can't get query from binlog event: %v, event data: %#v
- stream error @ (including the GTID we failed to process) %v:
- send reply error: %v
- SBR mode unsupported for streaming: %s
- GetPreviousGTIDs: previous GTIDs not found
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/e2429d1ba947e74d.
Report an issue: GitHub.