{"record":{"id":"7c73825d9dedb07f","repo":"vitessio/vitess","slug":"unknown-tableid-v-in-writerows-event","errorCode":null,"errorMessage":"unknown tableID %v in WriteRows event","messagePattern":"unknown tableID (.+?) in WriteRows event","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/binlog/binlog_streamer.go","lineNumber":521,"sourceCode":"\t\t\tif bls.extractPK {\n\t\t\t\ttce.pkNames = make([]*querypb.Field, len(tce.ti.PKColumns))\n\t\t\t\ttce.pkIndexes = make([]int, len(tce.ti.Fields))\n\t\t\t\tfor i := range tce.pkIndexes {\n\t\t\t\t\t// Put -1 as default in here.\n\t\t\t\t\ttce.pkIndexes[i] = -1\n\t\t\t\t}\n\t\t\t\tfor i, c := range tce.ti.PKColumns {\n\t\t\t\t\t// Patch in every PK column index.\n\t\t\t\t\ttce.pkIndexes[c] = i\n\t\t\t\t\t// Fill in pknames\n\t\t\t\t\ttce.pkNames[i] = tce.ti.Fields[c]\n\t\t\t\t}\n\t\t\t}\n\t\tcase ev.IsWriteRows():\n\t\t\ttableID := ev.TableID(format)\n\t\t\ttce, ok := tableMaps[tableID]\n\t\t\tif !ok {\n\t\t\t\treturn pos, fmt.Errorf(\"unknown tableID %v in WriteRows event\", tableID)\n\t\t\t}\n\t\t\tif tce.ti == nil {\n\t\t\t\t// Skip cross-db statements.\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tsetTimestamp := &binlogdatapb.BinlogTransaction_Statement{\n\t\t\t\tCategory: binlogdatapb.BinlogTransaction_Statement_BL_SET,\n\t\t\t\tSql:      fmt.Appendf(nil, \"SET TIMESTAMP=%d\", ev.Timestamp()),\n\t\t\t}\n\t\t\tstatements = append(statements, FullBinlogStatement{\n\t\t\t\tStatement: setTimestamp,\n\t\t\t})\n\n\t\t\trows, err := ev.Rows(format, tce.tm)\n\t\t\tif err != nil {\n\t\t\t\treturn pos, err\n\t\t\t}\n","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/binlog/binlog_streamer.go#L503-L539","documentation":"A WriteRowsEvent carries rows identified only by a numeric table_id that must have been declared by a preceding TABLE_MAP_EVENT. If tableMaps has no entry for that ID, the streamer cannot identify the table and aborts the stream.","triggerScenarios":"In parseEvents, ev.IsWriteRows() yields a tableID not present in the tableMaps built from prior TABLE_MAP events — the map event was skipped (wrong db filter), lost, or the rows event is corrupt/misaligned.","commonSituations":"Stream started mid-transaction so the TABLE_MAP was missed; binlog file corruption causing event misalignment; custom binlog emitters writing rows without a matching table map; cross-database replication where the map event was filtered out.","solutions":["Restart the stream from a clean transaction boundary (a GTID/position before the transaction) so TABLE_MAP and rows events stay paired","Validate the binlog file with mysqlbinlog to find corruption or missing table-map events","If filtering databases, ensure filtering never drops TABLE_MAP events whose rows events are still streamed","Fix custom event generators to emit TABLE_MAP before rows events"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// ensure stream starts at a transaction boundary:\n// mysqlbinlog --start-position=<pos> <file> | head -50\n// confirm a Table_map event precedes the Write_rows event","typeGuard":null,"tryCatchPattern":"err := streamer.Stream(ctx, signals)\nif err != nil && strings.Contains(err.Error(), \"unknown tableID\") {\n    // restart from a clean GTID/transaction boundary\n}","preventionTips":["Start streams at transaction boundaries, not mid-transaction","Never filter TABLE_MAP events out of row-based streams","Validate binlog files with mysqlbinlog","Avoid manual edits to binlog/relay files"],"tags":["binlog","row-replication","table-map"],"backgroundTag":"unknown-table-id-in-binlog","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}