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

Debezium-ddl-parser crashes on parsing MySQL DDL statement (specific UNION)

XMLWordPrintable

    • False
    • None
    • False

      Debezium crashes while parsing this statement:

       

      -- If N-"select" into round brackets and next "select" without them - Parser crashed.
      
      -- 1 case
      
      CREATE PROCEDURE test_union()
      BEGIN 
      ( 
      SELECT
      id
      FROM test_auto_inc
      )
      UNION ALL
      SELECT
      id
      FROM test_auto_inc
      ;
      END
      
      -- 2 case
      
      CREATE PROCEDURE test_union()
      BEGIN				   
         (		
          SELECT
            id
          FROM test_auto_inc
         )
          UNION ALL
          SELECT
            id
          FROM test_auto_inc
          UNION ALL
           SELECT
            id
           FROM test_auto_inc
           ORDER BY id
          ;
      END
      
      
      -- 3 case
      
      CREATE PROCEDURE test_union()
      BEGIN 
      ( 
      SELECT
      id
      FROM test_auto_inc
      )
      UNION ALL
      (
      SELECT
      id
      FROM test_auto_inc
      )
      UNION ALL
      SELECT
      id
      FROM test_auto_inc
      ORDER BY id
      ;
      END
      -- table example
      CREATE TABLE `test_auto_inc` 
      (  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
       PRIMARY KEY (`id`)) 

      Bug report

      For bug reports, provide this information, please:

      What Debezium connector do you use and what version?

      2.4.0.Final

      What is the captured database version and mode of depoyment?

      (Percona (Mysql 5.7.41)

      Do you have the connector logs, ideally from start till finish?

      [2023-11-14 10:10:33,167] ERROR [bukmaker-connector-sandbox-136|task-0] Error during binlog processing. Last offset stored = {transaction_id=null, ts_sec=1699956629, file=mysql-bin.001374, pos=90749207, gtids=2a9728ee-de91-11ed-96f3-6a32bf6e31c4:1-733361, server_id=1, event=1}, binlog reader near position = mysql-bin.001374/90749207 (io.debezium.connector.mysql.MySqlStreamingChangeEventSource:1161)

      [2023-11-14 10:10:33,167] ERROR [bukmaker-connector-sandbox-136|task-0] Producer failure (io.debezium.pipeline.ErrorHandler:52)

      io.debezium.DebeziumException: Error processing binlog event

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:395)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$27(MySqlStreamingChangeEventSource.java:930)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1246)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1072)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:631)

              at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:932)

              at java.base/java.lang.Thread.run(Thread.java:829)

      Caused by: io.debezium.text.ParsingException: DDL statement couldn't be parsed. Please open a Jira issue with the statement 'CREATE DEFINER=`peuser`@`%` PROCEDURE `test_union`()

      BEGIN

                 (

                      SELECT

                              id

                      FROM test_auto_inc

                )

                              UNION ALL

              –       (

                      SELECT

                              id

                      FROM test_auto_inc

              –     ORDER BY id

              --      )

                                                      UNION ALL

                       (

                      SELECT

                              id

                      FROM test_auto_inc

                   ORDER BY id

                  )

                      ;

      END'

      no viable alternative at input 'CREATE DEFINER=`peuser`@`%` PROCEDURE `test_union`()\nBEGIN\t\t\t\n\t   (\n\t\tSELECT\n\t\t\tid\n\t\tFROM test_auto_inc\n\t  )\n\t\t\tUNION ALL\n\t--\t (\t\t\n\t\tSELECT'

              at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:43)

              at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)

              at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)

              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:1272)

              at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:988)

              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:74)

              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:46)

              at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:78)

              at io.debezium.connector.mysql.MySqlDatabaseSchema.parseDdl(MySqlDatabaseSchema.java:213)

              at io.debezium.connector.mysql.MySqlDatabaseSchema.parseStreamingDdl(MySqlDatabaseSchema.java:199)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleQueryEvent(MySqlStreamingChangeEventSource.java:593)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$15(MySqlStreamingChangeEventSource.java:901)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:375)

              ... 6 more

      Caused by: org.antlr.v4.runtime.NoViableAltException

              at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2028)

              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:1064)

              ... 15 more

      [2023-11-14 10:10:33,170] INFO [bukmaker-connector-sandbox-136|task-0] Error processing binlog event, and propagating to Kafka Connect so it stops this connector. Future binlog events read before connector is shutdown will be ignored. (io.debezium.connector.mysql.MySqlStreamingChangeEventSource:400)

      [2023-11-14 10:10:33,350] ERROR [bukmaker-connector-sandbox-136|task-0] WorkerSourceTask{id=bukmaker-connector-sandbox-136-0} Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted (org.apache.kafka.connect.runtime.WorkerTask:210)

      org.apache.kafka.connect.errors.ConnectException: An exception occurred in the change event producer. This connector will be stopped.

              at io.debezium.pipeline.ErrorHandler.setProducerThrowable(ErrorHandler.java:67)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:395)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$27(MySqlStreamingChangeEventSource.java:930)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.notifyEventListeners(BinaryLogClient.java:1246)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.listenForEventPackets(BinaryLogClient.java:1072)

              at com.github.shyiko.mysql.binlog.BinaryLogClient.connect(BinaryLogClient.java:631)

              at com.github.shyiko.mysql.binlog.BinaryLogClient$7.run(BinaryLogClient.java:932)

              at java.base/java.lang.Thread.run(Thread.java:829)

      Caused by: io.debezium.DebeziumException: Error processing binlog event

              ... 7 more

      Caused by: io.debezium.text.ParsingException: DDL statement couldn't be parsed. Please open a Jira issue with the statement 'CREATE DEFINER=`peuser`@`%` PROCEDURE `test_union`()

      BEGIN

                 (

                      SELECT

                              id

                      FROM test_auto_inc

                )

                              UNION ALL

              –       (

                      SELECT

                              id

                      FROM test_auto_inc

              –     ORDER BY id

              --      )

                                                      UNION ALL

                       (

                      SELECT

                              id

                      FROM test_auto_inc

                   ORDER BY id

                  )

                      ;

      END'

      no viable alternative at input 'CREATE DEFINER=`peuser`@`%` PROCEDURE `test_union`()\nBEGIN\t\t\t\n\t   (\n\t\tSELECT\n\t\t\tid\n\t\tFROM test_auto_inc\n\t  )\n\t\t\tUNION ALL\n\t--\t (\t\t\n\t\tSELECT'

              at io.debezium.antlr.ParsingErrorListener.syntaxError(ParsingErrorListener.java:43)

              at org.antlr.v4.runtime.ProxyErrorListener.syntaxError(ProxyErrorListener.java:41)

              at org.antlr.v4.runtime.Parser.notifyErrorListeners(Parser.java:543)

              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:1272)

              at io.debezium.ddl.parser.mysql.generated.MySqlParser.root(MySqlParser.java:988)

              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:74)

              at io.debezium.connector.mysql.antlr.MySqlAntlrDdlParser.parseTree(MySqlAntlrDdlParser.java:46)

              at io.debezium.antlr.AntlrDdlParser.parse(AntlrDdlParser.java:78)

              at io.debezium.connector.mysql.MySqlDatabaseSchema.parseDdl(MySqlDatabaseSchema.java:213)

              at io.debezium.connector.mysql.MySqlDatabaseSchema.parseStreamingDdl(MySqlDatabaseSchema.java:199)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleQueryEvent(MySqlStreamingChangeEventSource.java:593)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.lambda$execute$15(MySqlStreamingChangeEventSource.java:901)

              at io.debezium.connector.mysql.MySqlStreamingChangeEventSource.handleEvent(MySqlStreamingChangeEventSource.java:375)

              ... 6 more

      Caused by: org.antlr.v4.runtime.NoViableAltException

              at org.antlr.v4.runtime.atn.ParserATNSimulator.noViableAlt(ParserATNSimulator.java:2028)

              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:1064)

              ... 15 more

      [2023-11-14 10:10:33,351] INFO [bukmaker-connector-sandbox-136|task-0] Stopping down connector (io.debezium.connector.common.BaseSourceTask:284)

      Nov 14, 2023 10:10:33 AM com.github.shyiko.mysql.binlog.BinaryLogClient$5 run

      INFO: threadExecutor is shut down, terminating keepalive thread

              ywyuewei Harvey Yue (Inactive)
              nekkett Nikita Koposov (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: