{"record":{"id":"ef0359f478b58886","repo":"vitessio/vitess","slug":"sbr-mode-unsupported-for-streaming-s","errorCode":null,"errorMessage":"SBR mode unsupported for streaming: %s","messagePattern":"SBR mode unsupported for streaming: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/keyrange_filter.go","lineNumber":50,"sourceCode":"// passed into the Streamer: bls.Stream(file, pos, sendTransaction) ->\n// bls.Stream(file, pos, keyRangeFilterFunc(keyrange, sendTransaction))\nfunc keyRangeFilterFunc(keyrange *topodatapb.KeyRange, callback func(*binlogdatapb.BinlogTransaction) error) sendTransactionFunc {\n\treturn func(eventToken *querypb.EventToken, statements []FullBinlogStatement) error {\n\t\tmatched := false\n\t\tfiltered := make([]*binlogdatapb.BinlogTransaction_Statement, 0, len(statements))\n\t\tfor _, statement := range statements {\n\t\t\tswitch statement.Statement.Category {\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_SET:\n\t\t\t\tfiltered = append(filtered, statement.Statement)\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_DDL:\n\t\t\t\tlog.Warn(fmt.Sprintf(\"Not forwarding DDL: %s\", statement.Statement.Sql))\n\t\t\t\tcontinue\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_INSERT,\n\t\t\t\tbinlogdatapb.BinlogTransaction_Statement_BL_UPDATE,\n\t\t\t\tbinlogdatapb.BinlogTransaction_Statement_BL_DELETE:\n\t\t\t\tif statement.KeyspaceID == nil {\n\t\t\t\t\tupdateStreamErrors.Add(\"KeyRangeStream\", 1)\n\t\t\t\t\treturn fmt.Errorf(\"SBR mode unsupported for streaming: %s\", statement.Statement.Sql)\n\t\t\t\t}\n\t\t\t\tif !key.KeyRangeContains(keyrange, statement.KeyspaceID) {\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tfiltered = append(filtered, statement.Statement)\n\t\t\t\tmatched = true\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_UNRECOGNIZED:\n\t\t\t\tupdateStreamErrors.Add(\"KeyRangeStream\", 1)\n\t\t\t\tlog.Error(fmt.Sprintf(\"Error parsing keyspace id: %s\", statement.Statement.Sql))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t\ttrans := &binlogdatapb.BinlogTransaction{\n\t\t\tEventToken: eventToken,\n\t\t}\n\t\tif matched {\n\t\t\ttrans.Statements = filtered\n\t\t}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/keyrange_filter.go#L32-L68","documentation":"During keyrange-filtered binlog streaming, an INSERT/UPDATE/DELETE statement has no KeyspaceID attached, meaning it came from statement-based replication (SBR) or lacked row metadata. Keyrange filtering requires row-based replication so each row's keyspace ID can be compared against the requested keyrange.","triggerScenarios":"Streaming a binlog to a KeyRange while the source MySQL uses binlog_format=STATEMENT, or a DML statement carries no KeyspaceID in the BinlogTransaction statement.","commonSituations":"Mixed RBR/SBR deployments where some statements fall back to SBR (e.g. statements that MySQL can't replicate row-based, or binlog_format not set to ROW on the source).","solutions":["Set binlog_format=ROW on the source MySQL server and restart/repick the streamer.","Identify and rewrite the offending statement (shown in the error) so it replicates row-based.","If the statement is intentionally SBR, do not request keyrange-filtered streaming for that workload."],"exampleFix":"-- before\nSET GLOBAL binlog_format = 'STATEMENT';\n-- after\nSET GLOBAL binlog_format = 'ROW';","handlingStrategy":"validation","validationCode":"// require RBR before keyrange streaming\nout, _ := exec.Command(\"mysql\", \"-e\", \"SELECT @@binlog_format\").Output()\nif !strings.Contains(string(out), \"ROW\") {\n\treturn errors.New(\"binlog_format must be ROW for keyrange streaming\")\n}","typeGuard":null,"tryCatchPattern":"if err := bls.StreamKeyRange(ctx, ...); err != nil {\n\tif strings.Contains(err.Error(), \"SBR mode unsupported\") {\n\t\treturn fmt.Errorf(\"switch source to binlog_format=ROW: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Always run binlog_format=ROW on replication sources used for keyrange streaming.","Avoid SBR-fallback statements (e.g. some DDL-ish/DML mixes) on streamed tables.","Audit statements flagged in the error and rewrite them for row-based replication."],"tags":["binlog","streaming","sbr","keyrange"],"backgroundTag":"sbr-streaming-unsupported","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}