{"record":{"id":"1dc176695bc5ecb7","repo":"vitessio/vitess","slug":"show-binary-logs-returned-no-rows","errorCode":null,"errorMessage":"SHOW BINARY LOGS returned no rows","messagePattern":"SHOW BINARY LOGS returned no rows","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go","lineNumber":164,"sourceCode":"\t_, _ = conn.ExecuteFetch(\"rollback\", 1, false)\n\tconn.Conn.Close()\n}\n\nfunc mysqlConnect(ctx context.Context, cp dbconfigs.Connector) (*mysql.Conn, error) {\n\treturn cp.Connect(ctx)\n}\n\n// limitOpenBinlogSize will rotate the binary log if the current binary\n// log is greater than binlogRotationThreshold.\nfunc (conn *snapshotConn) limitOpenBinlogSize() (bool, error) {\n\trotatedLog := false\n\t// Output: https://dev.mysql.com/doc/refman/en/show-binary-logs.html\n\tres, err := conn.ExecuteFetch(\"SHOW BINARY LOGS\", -1, false)\n\tif err != nil {\n\t\treturn rotatedLog, err\n\t}\n\tif res == nil || len(res.Rows) == 0 {\n\t\treturn rotatedLog, errors.New(\"SHOW BINARY LOGS returned no rows\")\n\t}\n\t// the current log will be the last one in the results\n\tcurLogIdx := len(res.Rows) - 1\n\tcurLogSize, err := res.Rows[curLogIdx][1].ToInt64()\n\tif err != nil {\n\t\treturn rotatedLog, err\n\t}\n\tif curLogSize > atomic.LoadInt64(&vttablet.VStreamerBinlogRotationThreshold) {\n\t\tif _, err = conn.ExecuteFetch(\"FLUSH BINARY LOGS\", 0, false); err != nil {\n\t\t\treturn rotatedLog, err\n\t\t}\n\t\trotatedLog = true\n\t}\n\treturn rotatedLog, nil\n}\n\n// GetBinlogRotationThreshold returns the current byte size at which a VStreamer\n// will attempt to rotate the binary log before starting a GTID snapshot based","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vttablet/tabletserver/vstreamer/snapshot_conn.go#L146-L182","documentation":"limitOpenBinlogSize in snapshot_conn runs SHOW BINARY LOGS on the source MySQL to compute binlog sizes for a snapshot stream. If the query succeeds but returns no rows, it cannot identify the current binlog and fails with \"SHOW BINARY LOGS returned no rows\". A MySQL server always reports at least its current binlog when binary logging is enabled, so no rows indicates binlogs are unavailable.","triggerScenarios":"VStreamWithSnapshot against a MySQL server with binary logging disabled (log_bin=OFF), or a server where SHOW BINARY LOGS is inaccessible/empty (e.g. managed setups hiding binlogs, or wrong user privileges combined with no logs).","commonSituations":"Pointing a VReplication snapshot stream at an rdonly/replica tablet whose MySQL has log_bin disabled; cloud-managed MySQL instances without binary logs; MySQL restarted into a state without binlog files.","solutions":["Enable binary logging on the source MySQL (log_bin=ON) and restart mysqld.","Verify with `SHOW BINARY LOGS;` directly on the MySQL instance that rows are returned.","Ensure the connecting user has sufficient privileges (REPLICATION CLIENT) to see binlogs.","If the source is a managed instance without binlogs, snapshot streaming from it is unsupported — choose a different source."],"exampleFix":"// before (my.cnf)\n# log_bin not set -> SHOW BINARY LOGS empty\n// after (my.cnf)\nlog_bin = mysql-bin\nserver_id = 1","handlingStrategy":"validation","validationCode":"res, err := conn.ExecuteFetch(\"SHOW BINARY LOGS\", -1, false)\nif err != nil || res == nil || len(res.Rows) == 0 {\n  return errors.New(\"source MySQL has no binary logs; enable log_bin before snapshot streaming\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"SHOW BINARY LOGS returned no rows\") {\n  return fmt.Errorf(\"source %s must have binary logging enabled: %w\", alias, err)\n}","preventionTips":["Verify log_bin is enabled on every source MySQL used for snapshot streaming.","Grant the vttablet user REPLICATION CLIENT so binlogs are visible.","Pre-flight check `SHOW BINARY LOGS` when adding a new source tablet."],"tags":["vitess","mysql","binlog","snapshot"],"backgroundTag":"binary-logging-disabled","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}