alibaba/canal · error · IllegalArgumentException

!! Unknown MYSQL_TYPE_GEOMETRY packlen =

Error message

!! Unknown MYSQL_TYPE_GEOMETRY packlen = 

What it means

Thrown while decoding a MYSQL_TYPE_GEOMETRY column. Geometry is stored as a blob with a 1-4 byte length prefix (meta). The switch handles meta 1-4; otherwise it throws. The code then reads raw bytes and maps to java.sql.Types.BINARY with a warning that the column type is unsupported for interpretation. So the throw only fires on a corrupt length-prefix meta, not on 'geometry is unsupported' — raw bytes are accepted when meta is valid.

Source

Thrown at dbsync/src/main/java/com/taobao/tddl/dbsync/binlog/event/RowsLogBuffer.java:1098

            case LogEvent.MYSQL_TYPE_GEOMETRY: {
                /*
                 * MYSQL_TYPE_GEOMETRY: copy from BLOB or TEXT
                 */
                switch (meta) {
                    case 1:
                        len = buffer.getUint8();
                        break;
                    case 2:
                        len = buffer.getUint16();
                        break;
                    case 3:
                        len = buffer.getUint24();
                        break;
                    case 4:
                        len = (int) buffer.getUint32();
                        break;
                    default:
                        throw new IllegalArgumentException("!! Unknown MYSQL_TYPE_GEOMETRY packlen = " + meta);
                }
                /* fill binary */
                byte[] binary = new byte[len];
                buffer.fillBytes(binary, 0, len);
                // Warning unsupport cloumn type
                // logger.warn(String.format("!! Unsupport column type MYSQL_TYPE_GEOMETRY:
                // meta=%d (%04X), len = %d", meta,meta, len));
                javaType = Types.BINARY;
                value = binary;
                length = len;
                break;
            }
            case LogEvent.MYSQL_TYPE_BOOL:
            case LogEvent.MYSQL_TYPE_INVALID:
            default:
                logger.error(
                    String.format("!! Don't know how to handle column type=%d meta=%d (%04X)", type, meta, meta));
                javaType = Types.OTHER;

View on GitHub (pinned to 87be50e876)

Solutions

  1. Verify the GEOMETRY column definition on the master.
  2. Inspect the binlog with mysqlbinlog --hexdump at the failing position.
  3. Upgrade Canal to match the master version.
  4. Filter the table via canal.instance.filter.regex if spatial data is not needed downstream.
Defensive patterns

Strategy: validation

Validate before calling

boolean isValidGeometryPacklen(int meta) {
    return meta >= 1 && meta <= 4;
}

Try / catch

try {
    buffer.fetchValue(name, index, type, meta, isBinary);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("!! Unknown MYSQL_TYPE_GEOMETRY packlen")) {
        logger.warn("Corrupt GEOMETRY packlen meta={} in tableId={}, skipping column", meta, tableId);
    } else throw e;
}

Prevention

When it happens

Trigger: A Table_map_event declares a GEOMETRY column with length-prefix meta outside 1-4. Corrupt event or mis-encoded metadata.

Common situations: Binlog corruption; replicating spatial columns from a MySQL version Canal's parser mishandles; truncation of the table-map event.

Related errors


AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14). Data as JSON: /api/errors/249b81f9fa2781ae. Report an issue: GitHub.