{"record":{"id":"a7a27e731cbc1229","repo":"alibaba/canal","slug":"apply-failed-caused-by-errormessage","errorCode":null,"errorMessage":"apply failed caused by : {errorMessage}","messagePattern":"apply failed caused by : (.+?)","errorType":"exception","errorClass":"CanalParseException","httpStatus":null,"severity":"error","filePath":"parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java","lineNumber":520,"sourceCode":"            // applySnapshotToDB\");\n            // }\n            // BeanUtils.populate(snapshotDO, content);\n\n            MetaSnapshotDO snapshotDO = new MetaSnapshotDO();\n            snapshotDO.setDestination(destination);\n            snapshotDO.setBinlogFile(position.getJournalName());\n            snapshotDO.setBinlogOffest(position.getPosition());\n            snapshotDO.setBinlogMasterId(String.valueOf(position.getServerId()));\n            snapshotDO.setBinlogTimestamp(position.getTimestamp());\n            snapshotDO.setData(JSON.toJSONString(schemaDdls, JSONWriter.Feature.LargeObject));\n            try {\n                metaSnapshotDAO.insert(snapshotDO);\n            } catch (Throwable e) {\n                if (isUkDuplicateException(e)) {\n                    // 忽略掉重复的位点\n                    logger.info(\"dup apply snapshot use position : \" + position + \" , just ignore\");\n                } else {\n                    throw new CanalParseException(\"apply failed caused by : \" + e.getMessage(), e);\n                }\n            }\n            return true;\n        } else {\n            logger.error(\"compare failed , check log\");\n        }\n        return false;\n    }\n\n    private boolean compareTableMetaDbAndMemory(MysqlConnection connection, MemoryTableMeta memoryTableMeta,\n                                                final String schema, final String table) {\n        TableMeta tableMetaFromMem = memoryTableMeta.find(schema, table);\n\n        TableMeta tableMetaFromDB = new TableMeta();\n        tableMetaFromDB.setSchema(schema);\n        tableMetaFromDB.setTable(table);\n        String createDDL = null;\n        try {","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/alibaba/canal/blob/87be50e87686a3e8af08c368d0e1ffd1f59eb04a/parse/src/main/java/com/alibaba/otter/canal/parse/inbound/mysql/tsdb/DatabaseTableMeta.java#L502-L538","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    tableMeta.apply(position, schema, ddl, extra);\n} catch (CanalParseException e) {\n    if (e.getMessage().contains(\"apply failed\") && isSnapshotContext()) {\n        Throwable cause = e.getCause();\n        // check if data-too-long or connection issue\n    }\n}","preventionTips":["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."],"tags":["tsdb","snapshot","database","dao","canal-parse"],"backgroundTag":null,"analyzedSha":"87be50e87686a3e8af08c368d0e1ffd1f59eb04a","analyzedAt":"2026-08-14T04:30:11.918Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}