Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-1699

MySQL connector fails to parse trigger DDL

    Details

      Description

      After installing a trigger/SP in a MySQL 5.7.12 (Aurora) the MySQL connector started to fail parsing the binlog.

      SQL:

      BEGIN
      DECLARE i, n INT DEFAULT 0;
      SET n = JSON_LENGTH(CAST(CONVERT(NEW.write_keys USING utf8mb4) AS JSON));
      WHILE i < n DO
      INSERT INTO source_id_write_key_mapping (source_id, write_key)
      VALUES (NEW.id, JSON_UNQUOTE(JSON_EXTRACT(CAST(CONVERT(NEW.write_keys USING utf8mb4) AS JSON), CONCAT('$[', i, ']'))))
      ON DUPLICATE KEY UPDATE
              source_id  = NEW.ID,
              write_key  = JSON_UNQUOTE(JSON_EXTRACT(CAST(CONVERT(NEW.write_keys USING utf8mb4) AS JSON), CONCAT('$[', i, ']')));
      SET i = i + 1;
      END WHILE;
      END
      

      Connector binlog exception:

      org.apache.kafka.connect.errors.ConnectException: no viable alternative at input 'CREATE DEFINER=`ctlplane`@`%` TRIGGER `write_key_add` AFTER INSERT ON `sources` FOR EACH ROW BEGIN\nDECLARE i, n INT DEFAULT 0;\nSET n = JSON_LENGTH(CAST(CONVERT(NEW.write_keys USING utf8mb4) AS JSON'
              at io.debezium.connector.mysql.AbstractReader.wrap(AbstractReader.java:230)
              at io.debezium.connector.mysql.AbstractReader.failed(AbstractReader.java:207)
              at io.debezium.connector.mysql.BinlogReader.handleEvent(BinlogReader.java:536)
              at com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1095)
              at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:943)
              at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:580)
              at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:825)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: io.debezium.text.ParsingException: no viable alternative at input 'CREATE DEFINER=`ctlplane`@`%` TRIGGER `write_key_add` AFTER INSERT ON `sources` FOR EACH ROW BEGIN\nDECLARE i, n INT DEFAULT 0;\nSET n = JSON_LENGTH(CAST(CONVERT(NEW.write_keys USING utf8mb4) AS JSON'
              at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:40)
              at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)
              at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:544)
              at org.antlr.v4.runtime.DefaultErrorStrategy.reportNoViableAlternative(DefaultErrorStrategy.java:310)
              at org.antlr.v4.runtime.DefaultErrorStrategy.reportError(DefaultErrorStrategy.java:136)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:1094)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:828)
              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:68)
              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:41)
              at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:80)
              at io.debezium.connector.mysql.MySqlSchema.applyDdl(MySqlSchema.java:306)
              at io.debezium.connector.mysql.BinlogReader.handleQueryEvent(BinlogReader.java:729)
              at io.debezium.connector.mysql.BinlogReader.handleEvent(BinlogReader.java:519)
              ... 5 more
      Caused by: org.antlr.v4.runtime.NoViableAltException
              at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2026)
              at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:467)
              at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:393)
              at io.debezium.ddl.parser.mysql.generated.MySqlParser.sqlStatements(MySqlParser.java:902)
              ... 12 more
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                ccranfor Chris Cranford
                Reporter:
                collinvandyck76 Collin Van Dyck
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: