{"record":{"id":"62f00e6d8cac9f0d","repo":"vitessio/vitess","slug":"can-t-get-query-from-binlog-event-v-event-data","errorCode":null,"errorMessage":"can't get query from binlog event: %v, event data: %#v","messagePattern":"can't get query from binlog event: (.+?), event data: %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlog_streamer.go","lineNumber":402,"sourceCode":"\t\t\t\t\tSql:      fmt.Appendf(nil, \"SET %s=%d\", mysql.IntVarNames[typ], value),\n\t\t\t\t},\n\t\t\t})\n\t\tcase ev.IsRand(): // RAND_EVENT\n\t\t\tseed1, seed2, err := ev.Rand(format)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, fmt.Errorf(\"can't parse RAND_EVENT: %v, event data: %#v\", err, ev)\n\t\t\t}\n\t\t\tstatements = append(statements, FullBinlogStatement{\n\t\t\t\tStatement: &binlogdatapb.BinlogTransaction_Statement{\n\t\t\t\t\tCategory: binlogdatapb.BinlogTransaction_Statement_BL_SET,\n\t\t\t\t\tSql:      fmt.Appendf(nil, \"SET @@RAND_SEED1=%d, @@RAND_SEED2=%d\", seed1, seed2),\n\t\t\t\t},\n\t\t\t})\n\t\tcase ev.IsQuery(): // QUERY_EVENT\n\t\t\t// Extract the query string and group into transactions.\n\t\t\tq, err := ev.Query(format)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, fmt.Errorf(\"can't get query from binlog event: %v, event data: %#v\", err, ev)\n\t\t\t}\n\t\t\tswitch cat := getStatementCategory(q.SQL); cat {\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_BEGIN:\n\t\t\t\tbegin()\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_ROLLBACK:\n\t\t\t\t// Rollbacks are possible under some circumstances. Since the stream\n\t\t\t\t// client keeps track of its replication position by updating the set\n\t\t\t\t// of GTIDs it's seen, we must commit an empty transaction so the client\n\t\t\t\t// can update its position.\n\t\t\t\tstatements = nil //nolint:prealloc\n\t\t\t\tfallthrough\n\t\t\tcase binlogdatapb.BinlogTransaction_Statement_BL_COMMIT:\n\t\t\t\tif err = commit(ev.Timestamp()); err != nil {\n\t\t\t\t\treturn pos, err\n\t\t\t\t}\n\t\t\tdefault: // BL_DDL, BL_SET, BL_INSERT, BL_UPDATE, BL_DELETE, BL_UNRECOGNIZED\n\t\t\t\tif q.Database != \"\" && q.Database != bls.cp.DBName() {\n\t\t\t\t\t// Skip cross-db statements.","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlog_streamer.go#L384-L420","documentation":"parseEvents reads a QUERY_EVENT and calls ev.Query(format) to extract the query string. If the event body cannot be decoded (bad lengths, truncated data, incompatible format description), the streamer stops and returns this error with the raw event bytes.","triggerScenarios":"A QUERY_EVENT in the binlog stream fails to decode inside parseEvents, e.g. truncated payload, corrupt log file, or format-description mismatch; Stream aborts at that position.","commonSituations":"Binlog files damaged in transit or on disk, mixing binlogs from different MySQL versions/flavors (MariaDB vs MySQL) that vitess cannot parse, or a synthetic binlog streamer (test/file streamer) emitting malformed events.","solutions":["Check the logged event data for truncation or garbage bytes","Confirm source MySQL flavor/version is supported by the vitess binlog parser","Re-establish the stream from a clean position or fresh backup of the binlogs","If running a custom/test streamer, fix the event payload it emits (correct query header and body)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// sanity-check the binlog before streaming:\n// mysqlbinlog <file> > /dev/null && echo ok","typeGuard":null,"tryCatchPattern":"err := streamer.Stream(ctx, signals)\nif err != nil && strings.Contains(err.Error(), \"can't get query from binlog event\") {\n    // inspect position returned, validate file, restart from clean GTID\n}","preventionTips":["Use mysqlbinlog to validate binlogs before use","Never mix MariaDB and MySQL binlogs in one stream","Avoid copying binlogs with rsync during writes","Stream from a GTID at transaction boundaries"],"tags":["binlog","streaming","event-parsing"],"backgroundTag":"binlog-event-parse-failed","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}