vitessio/vitess · error

can't parse INTVAR_EVENT: %v, event data: %#v

Error message

can't parse INTVAR_EVENT: %v, event data: %#v

What it means

INTVAR_EVENTs carry SET statements for internal variables (LAST_INSERT_ID, INSERT_ID). parseEvents decodes them with ev.IntVar(format); a failure means the event body doesn't match the expected intvar layout, so the equivalent SET statement cannot be reconstructed and the stream aborts.

Source

Thrown at go/vt/binlog/binlog_streamer.go:379

			}
		case ev.IsGTID(): // GTID_EVENT: update current GTID, maybe BEGIN.
			var hasBegin bool
			gtid, hasBegin, _, _, err = ev.GTID(format)
			if err != nil {
				return pos, fmt.Errorf("can't get GTID from binlog event: %v, event data: %#v", err, ev)
			}
			pos = replication.AppendGTID(pos, gtid)
			if hasBegin {
				begin()
			}
		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),
				},
			})

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Run mysqlbinlog on the affected binlog file to check for corruption
  2. Restore a healthy binlog source (fail over to a replica with intact logs) and restart the stream from the last good GTID
  3. Check disk/filesystem health on the primary producing these binlogs
  4. Bypass any proxies or intermediaries that may truncate binlog dump packets
Defensive patterns

Strategy: try-catch

Try / catch

if err := streamer.Stream(ctx); err != nil {
	if strings.Contains(err.Error(), "INTVAR_EVENT") {
		// corrupt intvar event: verify with mysqlbinlog, fail over, restart from last good GTID
	}
}

Prevention

When it happens

Trigger: During Stream/parseEvents, ev.IsIntVar() is true and ev.IntVar(format) errors because the event body is shorter than 9 bytes or otherwise malformed relative to the format's header size.

Common situations: Binlog files corrupted or truncated mid-event; replication through a proxy that drops bytes; binlog written by an unusual server build; disk issues on the primary.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/c68c872ef4912fc9. Report an issue: GitHub.