{"record":{"id":"677c172a820a5ceb","repo":"alibaba/canal","slug":"unknown-bit-len","errorCode":null,"errorMessage":"!! Unknown Bit len = ","messagePattern":"!! Unknown Bit len = ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java","lineNumber":419,"sourceCode":"                            value = buffer.getBeUint24();\r\n                            break;\r\n                        case 4:\r\n                            value = buffer.getBeUint32();\r\n                            break;\r\n                        case 5:\r\n                            value = buffer.getBeUlong40();\r\n                            break;\r\n                        case 6:\r\n                            value = buffer.getBeUlong48();\r\n                            break;\r\n                        case 7:\r\n                            value = buffer.getBeUlong56();\r\n                            break;\r\n                        case 8:\r\n                            value = buffer.getBeUlong64();\r\n                            break;\r\n                        default:\r\n                            throw new IllegalArgumentException(\"!! Unknown Bit len = \" + len);\r\n                    }\r\n                } else {\r\n                    final int bit = buffer.getInt8();\r\n                    // value = (bit != 0) ? Boolean.TRUE : Boolean.FALSE;\r\n                    value = bit;\r\n                }\r\n                javaType = Types.BIT;\r\n                length = nbits;\r\n                break;\r\n            }\r\n            case LogEvent.MYSQL_TYPE_TIMESTAMP: {\r\n                // MYSQL DataTypes: TIMESTAMP\r\n                // range is '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07'\r\n                // UTC\r\n                // A TIMESTAMP cannot represent the value '1970-01-01 00:00:00'\r\n                // because that is equivalent to 0 seconds from the epoch and\r\n                // the value 0 is reserved for representing '0000-00-00\r\n                // 00:00:00', the “zero” TIMESTAMP value.\r","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java#L401-L437","documentation":"Thrown while decoding a MYSQL_TYPE_BIT column. The metadata word gives bit_len and bytes_in_rec; nbits is recomputed as ((meta>>8)*8)+(meta&0xff), and len is the byte length (nbits+7)/8. The switch reads big-endian integer values for byte lengths 1 through 8 only. MySQL BIT columns are capped at 64 bits (len <= 8), so a len outside 1-8 indicates a corrupt or maliciously crafted table-map metadata.","triggerScenarios":"A Table_map_event for a row event declares a BIT column whose computed byte length is 0 or exceeds 8 (i.e. > 64 bits), which MySQL itself cannot create. Caused by binlog corruption or a forged event.","commonSituations":"Binlog file corruption; replicating from a non-standard MySQL-compatible store that emits oversized BIT metadata; disk-level bit rot in the binlog.","solutions":["Verify the source table's BIT column width on the master (must be <= 64).","Run mysqlbinlog on the offending position to confirm the metadata is intact; reseed Canal from a valid position if corrupt.","Upgrade Canal in case a newer MySQL encoding of BIT metadata is misread by an older parser.","Exclude the affected table via canal.instance.filter.regex if the column is not needed."],"exampleFix":"// before\ndefault:\n    throw new IllegalArgumentException(\"!! Unknown Bit len = \" + len);\n// after: clamp instead of aborting replication\ndefault:\n    logger.warn(\"Unexpected BIT byte length {}, reading raw bytes\", len);\n    byte[] bits = new byte[len];\n    buffer.fillBytes(bits, 0, len);\n    value = bits;","handlingStrategy":"validation","validationCode":"static final int MAX_BIT_BYTES = 8; // 64 bits max\nboolean isValidBitLen(int meta) {\n    int nbits = ((meta >> 8) * 8) + (meta & 0xff);\n    int len = (nbits + 7) / 8;\n    return len >= 1 && len <= MAX_BIT_BYTES;\n}","typeGuard":null,"tryCatchPattern":"try {\n    buffer.fetchValue(name, index, type, meta, isBinary);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"!! Unknown Bit len\")) {\n        logger.warn(\"Corrupt BIT metadata meta={} in tableId={}, skipping column\", meta, tableId);\n    } else throw e;\n}","preventionTips":["Verify BIT column widths on the master are <= 64 bits.","Monitor for binlog corruption on the master's storage.","Keep Canal and master versions aligned."],"tags":["binlog","rows-buffer","column-type","bit","parsing"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}