vitessio/vitess · error

failed to send the ComBinlogDump command: %v

Error message

failed to send the ComBinlogDump command: %v

What it means

StartBinlogDumpFromBinlogBeforeTimestamp writes the raw ComBinlogDump command to the MySQL server after locating the right binlog file (position 4, skipping the file header). If writing that command fails on the socket, the dump cannot start and this error is returned. It means the replication dump request never reached (or was rejected by) the server.

Source

Thrown at go/vt/binlog/binlog_connection.go:225

//
// The stream will continue in the background, waiting for new events if
// necessary, until the connection is closed, either by the source or
// by canceling the context.
//
// Note the context is valid and used until eventChan is closed.
func (bc *BinlogConnection) StartBinlogDumpFromBinlogBeforeTimestamp(ctx context.Context, timestamp int64) (<-chan mysql.BinlogEvent, <-chan error, error) {
	ctx, bc.cancel = context.WithCancel(ctx)

	filename, err := bc.findFileBeforeTimestamp(ctx, timestamp)
	if err != nil {
		return nil, nil, err
	}

	// Start dumping the logs. The position is '4' to skip the
	// Binlog File Header. See this page for more info:
	// https://dev.mysql.com/doc/internals/en/binlog-file.html
	if err := bc.WriteComBinlogDump(bc.serverID, filename, 4, 0); err != nil {
		return nil, nil, fmt.Errorf("failed to send the ComBinlogDump command: %v", err)
	}
	e, c := bc.streamEvents(ctx)
	return e, c, nil
}

func (bc *BinlogConnection) findFileBeforeTimestamp(ctx context.Context, timestamp int64) (filename string, err error) {
	// List the binlogs.
	binlogs, err := bc.ExecuteFetch("SHOW BINARY LOGS", 1000, false)
	if err != nil {
		return "", fmt.Errorf("failed to SHOW BINARY LOGS: %v", err)
	}

	// Start with the most recent binlog file until we find the right event.
	for _, row := range slices.Backward(binlogs.Rows) {
		// Exit the loop early if context is canceled.
		select {
		case <-ctx.Done():
			return "", ctx.Err()

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Re-establish the binlog connection (NewBinlogConnection) and retry the timestamp-based dump; treat it as transient if the socket was closed.
  2. Increase MySQL wait_timeout / net_write_timeout and proxy idle timeouts for long-running replication connections.
  3. Check network gear between Vitess and MySQL for aggressive idle-connection teardown.
  4. Inspect MySQL error log for Aborted clients or connection kills around the failure time.
Defensive patterns

Strategy: retry

Validate before calling

// preflight: ensure the connection is alive right before the dump
if err := bc.Ping(); err != nil {
	return fmt.Errorf("binlog connection dead before dump: %w", err)
}

Try / catch

e, c, err := bc.StartBinlogDumpFromBinlogBeforeTimestamp(ctx, ts)
if err != nil && strings.Contains(err.Error(), "failed to send the ComBinlogDump command") {
	// re-dial via NewBinlogConnection and retry with backoff
}

Prevention

When it happens

Trigger: Calling StartBinlogDumpFromBinlogBeforeTimestamp when bc.WriteComBinlogDump returns an error — broken/dead connection, write timeout, or server closed the socket before the command was sent.

Common situations: Long findFileBeforeTimestamp scan let the connection time out before the dump command; firewall/NAT dropped the idle replication socket; MySQL server killed the connection (wait_timeout); network partition during a reshard/backup stream.

Related errors


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