{"record":{"id":"1fcf8f23652b101d","repo":"vitessio/vitess","slug":"failed-to-show-binary-logs-v","errorCode":null,"errorMessage":"failed to SHOW BINARY LOGS: %v","messagePattern":"failed to SHOW BINARY LOGS: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlog_connection.go","lineNumber":235,"sourceCode":"\tif err != nil {\n\t\treturn nil, nil, err\n\t}\n\n\t// Start dumping the logs. The position is '4' to skip the\n\t// Binlog File Header. See this page for more info:\n\t// https://dev.mysql.com/doc/internals/en/binlog-file.html\n\tif err := bc.WriteComBinlogDump(bc.serverID, filename, 4, 0); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to send the ComBinlogDump command: %v\", err)\n\t}\n\te, c := bc.streamEvents(ctx)\n\treturn e, c, nil\n}\n\nfunc (bc *BinlogConnection) findFileBeforeTimestamp(ctx context.Context, timestamp int64) (filename string, err error) {\n\t// List the binlogs.\n\tbinlogs, err := bc.ExecuteFetch(\"SHOW BINARY LOGS\", 1000, false)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to SHOW BINARY LOGS: %v\", err)\n\t}\n\n\t// Start with the most recent binlog file until we find the right event.\n\tfor _, row := range slices.Backward(binlogs.Rows) {\n\t\t// Exit the loop early if context is canceled.\n\t\tselect {\n\t\tcase <-ctx.Done():\n\t\t\treturn \"\", ctx.Err()\n\t\tdefault:\n\t\t}\n\n\t\tfilename := row[0].ToString()\n\t\tblTimestamp, err := bc.getBinlogTimeStamp(filename)\n\t\tif err != nil {\n\t\t\treturn \"\", err\n\t\t}\n\t\tif blTimestamp < timestamp {\n\t\t\t// The binlog timestamp is older: we've found a good starting point.","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlog_connection.go#L217-L253","documentation":"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.","triggerScenarios":"StartBinlogDumpFromBinlogBeforeTimestamp internally calls findFileBeforeTimestamp, whose ExecuteFetch(\"SHOW BINARY LOGS\") returns an error — server error, lost connection, or insufficient privileges.","commonSituations":"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.","solutions":["Read the wrapped %v detail and fix the underlying query error (auth, connection, or server-side).","Grant the replication user the privileges needed for SHOW BINARY LOGS (REPLICATION CLIENT).","Reconnect and retry — transient failures during primary failover are common here.","Confirm the server actually has binary logging enabled (log_bin=ON); otherwise the statement may fail or return nothing."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// preflight: verify binary logging and listing privileges\nqr, err := conn.ExecuteFetch(\"SHOW BINARY LOGS\", 1, false)\nif err != nil {\n\treturn fmt.Errorf(\"SHOW BINARY LOGS preflight failed (privileges/log_bin?): %w\", err)\n}","typeGuard":null,"tryCatchPattern":"e, c, err := bc.StartBinlogDumpFromBinlogBeforeTimestamp(ctx, ts)\nif err != nil && strings.Contains(err.Error(), \"failed to SHOW BINARY LOGS\") {\n\t// check grants, verify log_bin=ON, reconnect and retry\n}","preventionTips":["Grant the streaming user REPLICATION CLIENT.","Confirm log_bin is enabled on the source server.","Retry around planned failovers rather than streaming through them."],"tags":["mysql","replication","binlog"],"backgroundTag":"binlog-listing-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}