vitessio/vitess · error

can't strip checksum from binlog event: %v, event data: %#v

Error message

can't strip checksum from binlog event: %v, event data: %#v

What it means

Before decoding event bodies, parseEvents calls ev.StripChecksum(format) to remove any trailing checksum bytes according to the format-description. If the event length doesn't match the expected layout, stripping fails and the stream aborts. This means the event is inconsistent with the negotiated binlog format.

Source

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

			continue
		}

		// We can't parse anything until we get a FORMAT_DESCRIPTION_EVENT that
		// tells us the size of the event header.
		if format.IsZero() {
			// The only thing that should come before the FORMAT_DESCRIPTION_EVENT
			// is a fake ROTATE_EVENT, which the primary sends to tell us the name
			// of the current log file.
			if ev.IsRotate() {
				continue
			}
			return pos, fmt.Errorf("got a real event before FORMAT_DESCRIPTION_EVENT: %#v", ev)
		}

		// Strip the checksum, if any. We don't actually verify the checksum, so discard it.
		ev, _, err = ev.StripChecksum(format)
		if err != nil {
			return pos, fmt.Errorf("can't strip checksum from binlog event: %v, event data: %#v", err, ev)
		}

		switch {
		case ev.IsPseudo():
			gtid, _, _, _, err = ev.GTID(format)
			if err != nil {
				return pos, fmt.Errorf("can't get GTID from binlog event: %v, event data: %#v", err, ev)
			}
			oldpos := pos
			pos = replication.AppendGTID(pos, gtid)
			// If the event is received outside of a transaction, it must
			// be sent. Otherwise, it will get lost and the targets will go out
			// of sync.
			if autocommit && !pos.Equal(oldpos) {
				if err = commit(ev.Timestamp()); err != nil {
					return pos, err
				}
			}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Check if binlog_checksum was changed on the server mid-stream; keep it consistent or restart the stream after changing
  2. Verify the binlog file integrity with mysqlbinlog
  3. Fail over to a replica with intact binlogs and resume from the last good GTID
  4. Ensure all servers in the topology run a supported, consistent MySQL version
Defensive patterns

Strategy: validation

Validate before calling

// keep binlog_checksum stable; verify before streaming
// mysql> SELECT @@global.binlog_checksum; -- don't change mid-stream

Try / catch

if err := streamer.Stream(ctx); err != nil {
	if strings.Contains(err.Error(), "can't strip checksum") {
		// checksum setting changed mid-stream: restart stream, keep binlog_checksum fixed
	}
}

Prevention

When it happens

Trigger: During Stream/parseEvents, ev.StripChecksum(format) returns an error because the event size doesn't correspond to the format's header/body/checksum layout — e.g. a new FORMAT_DESCRIPTION_EVENT changed checksum settings mid-stream and a subsequent event doesn't fit.

Common situations: Binlog checksum setting (binlog_checksum) changed on the server while streaming; corrupted or truncated event bytes; events from mixed MySQL versions after a log rotate.

Related errors


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