开发者社区> 问答> 正文

ArrayIndexOutOfBoundsException: 0

manager日志中报如下错误:

pid:49 nid:8 exception:canal:cn8:com.alibaba.otter.canal.parse.exception.CanalParseException: java.lang.ArrayIndexOutOfBoundsException: 0 Caused by: java.lang.ArrayIndexOutOfBoundsException: 0 at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parseTableName(SimpleDdlParser.java:163) at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parseDdl(SimpleDdlParser.java:115) at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parse(SimpleDdlParser.java:80) at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parseQueryEvent(LogEventConvert.java:150) at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parse(LogEventConvert.java:99) at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parse(LogEventConvert.java:62) at com.alibaba.otter.canal.parse.inbound.AbstractEventParser.parseAndProfilingIfNecessary(AbstractEventParser.java:323) at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3$1.sink(AbstractEventParser.java:176) at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.dump(MysqlConnection.java:124) at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:209) at java.lang.Thread.run(Thread.java:745)

查看node日志: 2015-04-28 09:36:30.977 [destination = 8 , address = /..**.:* , EventParser] ERROR c.a.otter.canal.parse.inbound.mysql.MysqlEventParser - dump address /..**.:* has an error, retrying. caused by com.alibaba.otter.canal.parse.exception.CanalParseException: java.lang.ArrayIndexOutOfBoundsException: 0 java.lang.ArrayIndexOutOfBoundsException: 0 at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parseTableName(SimpleDdlParser.java:163) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parseDdl(SimpleDdlParser.java:115) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.SimpleDdlParser.parse(SimpleDdlParser.java:80) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parseQueryEvent(LogEventConvert.java:150) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parse(LogEventConvert.java:99) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.dbsync.LogEventConvert.parse(LogEventConvert.java:62) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser.parseAndProfilingIfNecessary(AbstractEventParser.java:323) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3$1.sink(AbstractEventParser.java:176) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.mysql.MysqlConnection.dump(MysqlConnection.java:124) ~[canal.parse-1.0.19.jar:na] at com.alibaba.otter.canal.parse.inbound.AbstractEventParser$3.run(AbstractEventParser.java:209) ~[canal.parse-1.0.19.jar:na] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]

SQL比较长(110行),是关于存储过程的: use sc*1; CREATE DEFINER=sc*me@% PROCEDURE SC_CORE_NODE_SAVE(IN sc_mePassportId CHAR(32), INOUT nodeId CHAR(32), IN nodeName VARCHAR(255), IN nodeType VARCHAR(255), IN columnId CHAR(32), IN title VARCHAR(512), IN browse TINYINT(1), IN comment TINYINT(1), IN promote TINYINT(1), IN moderate TINYINT(1), IN sticky TINYINT(1), IN translate TINYINT(1), IN nodePartNames LONGTEXT, IN nodePartTitles LONGTEXT, IN sequences LONGTEXT, IN keywords LONGTEXT, IN tags LONGTEXT, IN contents LONGTEXT, IN langCode VARCHAR(200), OUT success INT,OUT info VARCHAR(128)) BEGIN SET @TimeNow = NOW(); IF nodeId IS NULL OR nodeId='' THEN SET @nodeid = NULL; SET @columnNodeId=UUID32(); SELECT node.ID INTO @nodeid FROM sc_core_node node WHERE node.NAME = nodeName AND node.TYPE=nodeType LIMIT 1; IF @nodeid IS NULL THEN SET @nodeid=UUID32(); INSERT INTO sc_core_node (ID, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, NAME, TYPE, REVISION_ID, AUTHOR, BROWSE, COMMENT, PROMOTE, MODERATE, STICKY, TRANSLATE, DISABLED) VALUES (@nodeid, sc_mePassportId, @TimeNow, sc**_mePassportId, @TimeNow, nodeName, nodeType, NULL, sc**_mePassportId, browse, comment, promote, moderate, sticky, translate, 0);

    IF columnId IS NOT NULL AND columnId<>'' THEN
        INSERT INTO `sc_col_column_node` (`ID`, `CREATE_BY`, `CREATE_TIME`, `UPDATE_BY`, `UPDATE_TIME`, `NODE_ID`, `COLUMN_ID`)
            VALUES (@columnNodeId, sc***mePassportId, @timeNow, sc***mePassportId, @timeNow, @nodeId, columnId);
    END IF;
ELSE
    UPDATE `sc_core_node` SET `UPDATE_BY` = sc***mePassportId, `UPDATE_TIME` = @timeNow, `NAME` = nodeName, `REVISION_ID` = NULL, `AUTHOR` = sc***mePassportId, `BROWSE` = browse, `COMMENT` = `comment`, `PROMOTE` = promote, `MODERATE` = moderate, `STICKY` = sticky, `TRANSLATE` = translate WHERE `ID` = @nodeId;
END IF;
CALL SC_RES_RESOURCE_SAVE('sc_core_node', @nodeId, 'TITLE', langCode, title);

ELSE SET @nodeId = nodeId; UPDATE sc_core_node SET UPDATE_BY = sc***mePassportId, UPDATE_TIME = @timeNow, NAME = nodeName, REVISION_ID = NULL, AUTHOR = sc***mePassportId, BROWSE = browse, COMMENT = comment, PROMOTE = promote, MODERATE = moderate, STICKY = sticky, TRANSLATE = translate WHERE ID = @nodeId; CALL SC_RES_RESOURCE_SAVE('sc_core_node', @nodeId, 'TITLE', langCode, title);

DELETE FROM `sc_kwd_node_keyword` WHERE `NODE_ID` = nodeId;

END IF; SET @numbers=0; IF keywords IS NOT NULL THEN SET @i=1; SET @numbers = FN_GET_ELEMENTS_COUNT(keywords, '|'); WHILE @i <= @numbers DO SET @keyword = FN_FIND_ELEMENT_BYINDEX(keywords, '|', @i); SET @keywordId = NULL; SELECT nodeKeyword.ID INTO @keywordId FROM sc_kwd_keyword nodeKeyword WHERE nodeKeyword.ID = @keyword; IF @keywordId IS NOT NULL THEN SET @nodeKeywordId = UUID32(); INSERT INTO sc_kwd_node_keyword (ID, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, KEYWORD_ID, NODE_ID) VALUES(@nodeKeywordId, sc***mePassportId, @timeNow, sc***mePassportId, @timeNow, @keywordId, @nodeId); END IF; SET @i = @i + 1; END WHILE; END IF; IF tags IS NOT NULL THEN SET @i=1; SET @numbers = FN_GET_ELEMENTS_COUNT(tags, '|'); WHILE @i <= @numbers DO SET @tag = FN_FIND_ELEMENT_BYINDEX(tags, '|', @i); SET @tagId = NULL; SELECT nodeTag.ID INTO @tagId FROM sc_kwd_keyword nodeTag WHERE nodeTag.ID = @tag; IF @tagId IS NOT NULL THEN SET @nodeTagId = UUID32(); INSERT INTO sc_kwd_node_keyword (ID, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, KEYWORD_ID, NODE_ID) VALUES(@nodeTagId, sc***mePassportId, @timeNow, sc***mePassportId, @timeNow, @tagId, @nodeId); END IF; SET @i = @i + 1; END WHILE; END IF; IF contents IS NOT NULL THEN SET @i=1; SET @numbers = FN_GET_ELEMENTS_COUNT(contents,''); SET @nodePartNameStr = ''; WHILE @i <= @numbers DO SET @content = FN_FIND_ELEMENT_BYINDEX(contents,'',@i); IF nodePartNames IS NULL THEN SET @nodePartName = @i; ELSE SET @nodePartName = FN_FIND_ELEMENT_BYINDEX(nodePartNames,'',@i); END IF; SET @nodePartNameStr = CONCAT(@nodePartNameStr,','',@nodePartName,'''); IF nodePartTitles IS NULL THEN SET @nodePartTitle = title; ELSE SET @nodePartTitle = FN_FIND_ELEMENT_BYINDEX(nodePartTitles,'',@i); END IF; IF sequences IS NULL THEN SET @sequence = 0; ELSE SET @sequence = FN_FIND_ELEMENT_BYINDEX(sequences,'',@i); END IF; SET @content = FN_FIND_ELEMENT_BYINDEX(contents,'',@i);

    SELECT COUNT(nodePart.ID) INTO @nodePartNum FROM sc_core_node_part nodePart WHERE nodePart.PART_NAME=@nodePartName AND nodePart.NODE_ID=@nodeId;
    IF @nodePartNum<1 THEN
        SET @nodePartId = UUID32();
        INSERT INTO `sc_core_node_part` (`ID`, `CREATE_BY`, `CREATE_TIME`, `UPDATE_BY`, `UPDATE_TIME`, `PART_NAME`, `REVISION_ID`, `AUTHOR`, `NODE_ID`, `SEQUENCE`, `DISABLED`)
            VALUES(@nodePartId, sc***mePassportId, @timeNow, sc***mePassportId, @timeNow, @nodePartName, NULL, sc***mePassportId, @nodeId, @sequence, 0);
    ELSE
        SELECT nodePart.ID INTO @nodePartId FROM sc_core_node_part nodePart WHERE nodePart.PART_NAME=@nodePartName AND nodePart.NODE_ID=@nodeId;
    END IF; 
    CALL SC_RES_RESOURCE_SAVE('sc_core_node_part', @nodePartId, 'TITLE', langCode, @nodePartTitle);
    CALL SC_RES_RESOURCE_SAVE('sc_core_node_part', @nodePartId, 'CONTENT', langCode, @content);
    SET @i = @i + 1;
END WHILE;
IF CHAR_LENGTH(@nodePartNameStr)>0 THEN
    SET @nodePartNameStr = SUBSTRING(@nodePartNameStr,2);
ELSE
    SET @nodePartNameStr = '\'\'';
END IF;
SET @listPost=CONCAT('DELETE FROM sc_core_node_part WHERE NODE_ID=? AND PART_NAME NOT IN (',@nodePartNameStr,')');
PREPARE _stmt FROM @listPost;
EXECUTE _stmt USING @nodeId;
DEALLOCATE PREPARE _stmt;

END IF; SET nodeId=@nodeId; SET success = 1; END

原提问者GitHub用户 ghqaz3633

展开
收起
大圣东游 2023-06-21 17:21:52 78 0
2 条回答
写回答
取消 提交回答
  • 重置位点可能没成功 下个位点还有同样sql语句

    原回答者GitHub用户agapple

    2023-06-21 18:29:29
    赞同 展开评论 打赏
  • 北京阿里云ACE会长

    您在Canal中发现了一个ArrayIndexOutOfBoundsException异常,这个异常可能是由于Canal解析binlog时出现错误导致的。

    为了解决这个问题,您可以尝试以下解决方案:

    检查binlog格式:检查MySQL数据库的binlog格式是否正确。Canal只支持ROW格式的binlog,如果您的MySQL数据库使用了其他格式的binlog,可能会导致Canal解析失败。

    检查Canal配置:检查Canal的配置是否正确。您可以检查Canal的配置文件,确保Canal的连接信息、过滤规则、同步规则等参数配置正确。

    检查Canal版本:检查您所使用的Canal版本是否正确。根据Canal官方文档,不同版本的Canal可能对MySQL版本和binlog格式的要求不同,您需要选择正确的Canal版本进行使用。

    检查MySQL版本:检查您所使用的MySQL版本是否支持Canal。根据Canal官方文档,Canal只支持MySQL 5.1、5.5、5.6、5.7版本,如果您使用了其他版本的MySQL,可能会导致Canal无法正常工作

    2023-06-21 18:06:04
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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