vitessio/vitess · error

failed to SHOW BINARY LOGS: %v

Error message

failed to SHOW BINARY LOGS: %v

What it means

findFileBeforeTimestamp runs "SHOW BINARY LOGS" on the primary to list all binlog files so it can walk backwards to find the file containing the event just before a requested timestamp. If that query fails, the file cannot be located and this wrapped error is returned. It is a metadata-listing failure, not a streaming failure.

Source

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

	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()
		default:
		}

		filename := row[0].ToString()
		blTimestamp, err := bc.getBinlogTimeStamp(filename)
		if err != nil {
			return "", err
		}
		if blTimestamp < timestamp {
			// The binlog timestamp is older: we've found a good starting point.

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Read the wrapped %v detail and fix the underlying query error (auth, connection, or server-side).
  2. Grant the replication user the privileges needed for SHOW BINARY LOGS (REPLICATION CLIENT).
  3. Reconnect and retry — transient failures during primary failover are common here.
  4. Confirm the server actually has binary logging enabled (log_bin=ON); otherwise the statement may fail or return nothing.
Defensive patterns

Strategy: retry

Validate before calling

// preflight: verify binary logging and listing privileges
qr, err := conn.ExecuteFetch("SHOW BINARY LOGS", 1, false)
if err != nil {
	return fmt.Errorf("SHOW BINARY LOGS preflight failed (privileges/log_bin?): %w", err)
}

Try / catch

e, c, err := bc.StartBinlogDumpFromBinlogBeforeTimestamp(ctx, ts)
if err != nil && strings.Contains(err.Error(), "failed to SHOW BINARY LOGS") {
	// check grants, verify log_bin=ON, reconnect and retry
}

Prevention

When it happens

Trigger: StartBinlogDumpFromBinlogBeforeTimestamp internally calls findFileBeforeTimestamp, whose ExecuteFetch("SHOW BINARY LOGS") returns an error — server error, lost connection, or insufficient privileges.

Common situations: Replication user missing privileges to list binary logs; server under failover when the query is issued; purged/rebuilding relay state causing server-side errors; version-specific statement differences on non-MySQL flavors.

Related errors


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