alibaba/canal · error · CanalParseException
apply failed caused by : {errorMessage}
Error message
apply failed caused by : {errorMessage} What it means
Thrown as CanalParseException by DatabaseTableMeta.applySnapshotToDB() when inserting a MetaSnapshotDO fails with a non-duplicate-key exception. This occurs during the snapshot persistence phase after a successful table meta comparison between memory and the live DB.
Source
Thrown at parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java:520
// applySnapshotToDB");
// }
// BeanUtils.populate(snapshotDO, content);
MetaSnapshotDO snapshotDO = new MetaSnapshotDO();
snapshotDO.setDestination(destination);
snapshotDO.setBinlogFile(position.getJournalName());
snapshotDO.setBinlogOffest(position.getPosition());
snapshotDO.setBinlogMasterId(String.valueOf(position.getServerId()));
snapshotDO.setBinlogTimestamp(position.getTimestamp());
snapshotDO.setData(JSON.toJSONString(schemaDdls, JSONWriter.Feature.LargeObject));
try {
metaSnapshotDAO.insert(snapshotDO);
} catch (Throwable e) {
if (isUkDuplicateException(e)) {
// 忽略掉重复的位点
logger.info("dup apply snapshot use position : " + position + " , just ignore");
} else {
throw new CanalParseException("apply failed caused by : " + e.getMessage(), e);
}
}
return true;
} else {
logger.error("compare failed , check log");
}
return false;
}
private boolean compareTableMetaDbAndMemory(MysqlConnection connection, MemoryTableMeta memoryTableMeta,
final String schema, final String table) {
TableMeta tableMetaFromMem = memoryTableMeta.find(schema, table);
TableMeta tableMetaFromDB = new TableMeta();
tableMetaFromDB.setSchema(schema);
tableMetaFromDB.setTable(table);
String createDDL = null;
try {View on GitHub (pinned to 87be50e876)
Solutions
- Check the cause exception for the database error message.
- If 'Data too long for column', increase the data column type to LONGTEXT or MEDIUMTEXT in the TSDB schema.
- Reduce the number of tracked tables by tightening canal.instance.filter.regex to exclude unnecessary tables.
- Verify TSDB database connectivity and permissions.
- If snapshot is too large, consider periodic snapshot cleanup.
Defensive patterns
Strategy: try-catch
Try / catch
try {
tableMeta.apply(position, schema, ddl, extra);
} catch (CanalParseException e) {
if (e.getMessage().contains("apply failed") && isSnapshotContext()) {
Throwable cause = e.getCause();
// check if data-too-long or connection issue
}
} Prevention
- Use LONGTEXT for the data column in the meta_snapshot table to handle large snapshots.
- Tighten canal.instance.filter.regex to reduce snapshot size.
- Monitor TSDB database disk space to prevent write failures.
When it happens
Trigger: metaSnapshotDAO.insert() fails with a non-UK-duplicate error. The snapshot data field contains JSON.toJSONString of all schema DDLs (with LargeObject feature), so this can fail if the data column cannot hold the serialized snapshot.
Common situations: The snapshot JSON is too large for the data column (many tables/schemas); TSDB database connection lost during snapshot insert; TSDB schema not migrated to support the LargeObject JSON format; database deadlock during concurrent snapshot attempts.
Related errors
- apply history to db failed caused by : {errorMessage}
- [fixed timestamp] can't found begin/commit position before w
- apply to memory is failed
- apply failed
- not support for memory
AI-assisted analysis of alibaba/canal@87be50e876 (2026-08-14).
Data as JSON: /api/errors/a7a27e731cbc1229.
Report an issue: GitHub.