开发者社区> 问答> 正文

ParserException 如何解决?

docker pull canal/canal-server:v1.1.1 安装的 出现下面的错误,怎么办?

2019-11-04 15:56:44.935 [destination = example , address = /192.168.133.62:3306 , EventParser] WARN c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - prepare to find start position just show master status 2019-11-04 15:57:37.958 [destination = example , address = /192.168.133.62:3306 , EventParser] WARN c.a.otter.canal.parse.inbound.mysql.tsdb.MemoryTableMeta - parse faield : CREATE TABLE loan ( id varchar(31) COLLATE utf8mb4_bin NOT NULL, user_id varchar(31) COLLATE utf8mb4_bin NOT NULL, application_id varchar(31) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '敶redit_application_id', type varchar(30) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'applicationId唾銵剁FIRST=credit_application, REPEAT=loan_request', product_id bigint(11) DEFAULT NULL, status varchar(31) COLLATE utf8mb4_bin NOT NULL DEFAULT 'INITIAL', product_type varchar(20) COLLATE utf8mb4_bin NOT NULL, amount decimal(10,2) NOT NULL COMMENT 'Disbursed amount', tenor int(11) NOT NULL, tenor_unit varchar(15) COLLATE utf8mb4_bin NOT NULL, installment_count int(11) NOT NULL, current_installment int(11) NOT NULL DEFAULT '1', payment_info json DEFAULT NULL COMMENT 'JSON: paymentAgent(enum), bankName(str), accountNumber(str)', repayment_info json DEFAULT NULL COMMENT 'JSON: expectedRepaymentAmount(decimal), actualRepaymentAmount(decimal)', interest_info json DEFAULT NULL COMMENT 'JSON: interestRate(decimal), preServiceFeeRate(decimal), overdueManageFeeRate(decimal), collectionFeeRate(decimal), overdueServiceFeeRate(decimal)', extra json DEFAULT NULL COMMENT 'JSON: all other strange/useless fields', issue_time timestamp(3) NULL DEFAULT NULL, disburse_time timestamp(3) NULL DEFAULT NULL, repay_time timestamp(3) NULL DEFAULT NULL, create_time timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), update_time timestamp(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3), version int(11) NOT NULL DEFAULT '0' COMMENT '撟嗅嗥砍, payment_transaction_id varchar(200) COLLATE utf8mb4_bin GENERATED ALWAYS AS (json_unquote(json_extract(payment_info,'$.paymentTransactionId'))) STORED COMMENT 'GENERATED', initial_repayment_amount decimal(20,2) GENERATED ALWAYS AS (json_unquote(json_extract(repayment_info,'$.initialRepaymentAmount'))) STORED COMMENT 'GENERATED', expected_repayment_amount decimal(20,2) GENERATED ALWAYS AS (json_unquote(json_extract(repayment_info,'$.expectedRepaymentAmount'))) STORED COMMENT 'GENERATED', actual_repayment_amount decimal(20,2) GENERATED ALWAYS AS (json_unquote(json_extract(repayment_info,'$.actualRepaymentAmount'))) STORED COMMENT 'GENERATED', actual_disburse_amount decimal(20,0) DEFAULT NULL, package_name varchar(100) COLLATE utf8mb4_bin DEFAULT NULL, source varchar(15) COLLATE utf8mb4_bin NOT NULL DEFAULT 'ANDROID' COMMENT 'source', channel varchar(100) COLLATE utf8mb4_bin DEFAULT NULL COMMENT 'channel', campaign varchar(255) COLLATE utf8mb4_bin DEFAULT NULL COMMENT '瘣餃撟踹', acquisition_code varchar(10) COLLATE utf8mb4_bin DEFAULT NULL, PRIMARY KEY (id), KEY idx_user_id (user_id), KEY idx_application_id (application_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin

com.alibaba.fastsql.sql.parser.ParserException: syntax error, error in :'COLLATE utf8mb4_bin GENERATED ALWAYS AS (json_unqu', expect ), actual null, pos 1703, line 24, column 62, token IDENTIFIER GENERATED at com.alibaba.fastsql.sql.parser.SQLParser.printError(SQLParser.java:363) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.parser.SQLParser.accept(SQLParser.java:371) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.dialect.mysql.parser.MySqlCreateTableParser.parseCreateTable(MySqlCreateTableParser.java:418) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.dialect.mysql.parser.MySqlStatementParser.parseCreate(MySqlStatementParser.java:265) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:224) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.SQLUtils.parseStatements(SQLUtils.java:525) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.repository.SchemaRepository.console(SchemaRepository.java:439) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.otter.canal.parse.inbound.mysql.tsdb.MemoryTableMeta.apply(MemoryTableMeta.java:73) ~[canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta.dumpTableMeta(DatabaseTableMeta.java:193) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta.rollback(DatabaseTableMeta.java:143) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.AbstractMysqlEventParser.processTableMeta(AbstractMysqlEventParser.java:87) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:190) [canal.parse-1.1.1.jar:na] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]

2019-11-04 15:57:38.104 [destination = example , address = /192.168.133.62:3306 , EventParser] WARN c.a.o.c.p.inbound.mysql.rds.RdsBinlogEventParserProxy - find start position : EntryPosition[included=false,journalName=bin.000002,position=13949238,serverId=1,gtid=,timestamp=1572603926000] 2019-11-04 15:57:38.136 [MultiStageCoprocessor-other-example-0] WARN c.a.otter.canal.parse.inbound.mysql.tsdb.MemoryTableMeta - parse faield : CREATE USER 'canal'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*E3619321C1A937C46A0D8BD1DAC39F93B27D4458' com.alibaba.fastsql.sql.parser.ParserException: syntax error, error in :'ord' AS '*E3619321C1A937C46A0D8BD1D, pos 66, line 1, column 64, token AS com.alibaba.fastsql.sql.parser.ParserException: syntax error, error in :'ord' AS '*E3619321C1A937C46A0D8BD1D, pos 66, line 1, column 64, token AS at com.alibaba.fastsql.sql.parser.SQLParser.printError(SQLParser.java:363) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:534) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.SQLUtils.parseStatements(SQLUtils.java:525) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.fastsql.sql.repository.SchemaRepository.console(SchemaRepository.java:439) ~[fastsql-2.0.0_preview_644.jar:2.0.0_preview_644] at com.alibaba.otter.canal.parse.inbound.mysql.tsdb.MemoryTableMeta.apply(MemoryTableMeta.java:73) ~[canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.tsdb.DatabaseTableMeta.apply(DatabaseTableMeta.java:120) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.TableMetaCache.apply(TableMetaCache.java:228) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parseQueryEvent(LogEventConvert.java:266) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parse(LogEventConvert.java:114) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlMultiStageCoprocessor$SimpleParserStage.onEvent(MysqlMultiStageCoprocessor.java:282) [canal.parse-1.1.1.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlMultiStageCoprocessor$SimpleParserStage.onEvent(MysqlMultiStageCoprocessor.java:237) [canal.parse-1.1.1.jar:na] at com.lmax.disruptor.BatchEventProcessor.processEvents(BatchEventProcessor.java:168) [disruptor-3.4.2.jar:na] at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:125) [disruptor-3.4.2.jar:na] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_181] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_181] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_181] at java.lang.Thread.run(Thread.java:748) [na:1.8.0_181]

原提问者GitHub用户esolve

展开
收起
Java工程师 2023-05-03 15:58:13 293 0
2 条回答
写回答
取消 提交回答
  • 随心分享,欢迎友善交流讨论:)

    这个错误是由于 Canal 无法解析 MySQL 表的创建语句,导致报错。具体地,错误信息中指出了解析错误的位置和原因:

    com.alibaba.fastsql.sql.parser.ParserException: syntax error, error in :'COLLATE utf8mb4_bin GENERATED ALWAYS AS (json_unqu', expect ), actual null, pos 1703, line 24, column 62, token IDENTIFIER GENERATED

    可以看到,错误出现在第 24 行的一个 GENERATED 关键字上,这可能是由于 Canal 所使用的 SQL 解析库无法解析该语法导致的。您可以尝试升级 Canal 版本,或者修改表的创建语句来避免该问题。

    另外,Canal 也提供了忽略解析错误的选项,您可以在 Canal 配置文件中添加以下行来开启该选项:

    canal.instance.tsdb.ignoreParseError=true

    开启该选项后,Canal 在解析表结构时遇到错误时将忽略该错误,但这可能会导致 Canal 在解析表结构时丢失一些信息。

    2023-05-05 14:05:15
    赞同 展开评论 打赏
  • 1、CREATE USER可以忽略

    2、canal可以升级到1.1.4,对DDL解析做了比较大的兼容性支持

    原回答者GitHub用户agapple

    2023-05-04 17:02:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载