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

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

XMLWordPrintable

    • False
    • None
    • False

      Debezium crashes while parsing this statement:

       

       

      // when subquery have union into round breckets (comment the lines) parser crashed
      
      -- case 1
      
      SELECT 		
      id		
      ,sum(col_1) as sum_col_1	
      FROM (
         ( -- this line
          SELECT
            id
           ,col_1
          FROM test_auto_inc
          
          UNION ALL
          
          SELECT
            id
           ,col_1
          FROM test_auto_inc tai
          ) -- and this line
           UNION ALL
          (
           SELECT
             id
            ,col_1
           FROM test_auto_inc tai
           )
        )sq
      GROUP BY 1
      ;
      
      -- case 2
      
      SELECT 
      id 
      ,sum(col_1) as sum_col_1 
      FROM ( 
         ( -- this line
         SELECT
           id
           ,col_1
         FROM test_auto_inc 
         UNION ALL 
         SELECT
           id
           ,col_1
         FROM test_auto_inc tai
         ) -- and this line
       )sq
      GROUP BY 1
      ;

       

      Bug report

      For bug reports, provide this information, please:

      What Debezium connector do you use and what version?

      2.4.1.Final and 2.5.0 SNAPSHOT (Build from main) 

      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-12-13 10:42:20,633] ERROR [bukmaker-connector-sandbox-avro-kraft-13|task-0] Error during binlog processing. Last offset stored = \{transaction_id=null, ts_sec=1702464096, file=mysql-bin.001773, pos=134635, gtids=2a9728ee-de91-11ed-96f3-6a32bf6e31c4:1-1736415, server_id=1, event=1}, binlog reader near position = mysql-bin.001773/134635 (io.debezium.connector.mysql.MySqlStreamingChangeEventSource:1161)
      [2023-12-13 10:42:20,634] ERROR [bukmaker-connector-sandbox-avro-kraft-13|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 `sandbox`.`test_union`( )
      BEGIN
      SELECT
      id
      ,sum(col_1) as sum_col_1
      FROM (
      
      (
      SELECT
      id
      ,col_1
      FROM test_auto_inc
      
      UNION ALL
      
      SELECT
      id
      ,col_1
      FROM test_auto_inc tai
      )
       
      UNION ALL
       
      (
      SELECT
      id
      ,col_1
      FROM test_auto_inc tai
      )
       
      )ss
      GROUP BY 1
      ORDER BY 1
      ;
      END'
      no viable alternative at input 'CREATE DEFINER=`peuser`@`%` PROCEDURE `sandbox`.`test_union`(\t)\nBEGIN\n\tSELECT \n\t\tid\n\t\t,sum(col_1) as sum_col_1\n\tFROM (\n\n\t\t(\n\t\tSELECT \n\t\t\tid\n\t\t\t,col_1\n\t\tFROM test_auto_inc\n\n\t\tUNION ALL\n\n\t\tSELECT\n\t\t\tid \n\t\t\t,col_1 \n\t\tFROM test_auto_inc tai \n\t\t)\n\t\t\n\t\tUNION'
      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-12-13 10:42:20,635] INFO [bukmaker-connector-sandbox-avro-kraft-13|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-12-13 10:42:21,021] ERROR [bukmaker-connector-sandbox-avro-kraft-13|task-0] WorkerSourceTask\{id=bukmaker-connector-sandbox-avro-kraft-13-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:212)
      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 `sandbox`.`test_union`( )
      BEGIN
      SELECT
      id
      ,sum(col_1) as sum_col_1
      FROM (
      
      (
      SELECT
      id
      ,col_1
      FROM test_auto_inc
      
      UNION ALL
      
      SELECT
      id
      ,col_1
      FROM test_auto_inc tai
      )
       
      UNION ALL
       
      (
      SELECT
      id
      ,col_1
      FROM test_auto_inc tai
      )
       
      )ss
      GROUP BY 1
      ORDER BY 1
      ;
      END'
      no viable alternative at input 'CREATE DEFINER=`peuser`@`%` PROCEDURE `sandbox`.`test_union`(\t)\nBEGIN\n\tSELECT \n\t\tid\n\t\t,sum(col_1) as sum_col_1\n\tFROM (\n\n\t\t(\n\t\tSELECT \n\t\t\tid\n\t\t\t,col_1\n\t\tFROM test_auto_inc\n\n\t\tUNION ALL\n\n\t\tSELECT\n\t\t\tid \n\t\t\t,col_1 \n\t\tFROM test_auto_inc tai \n\t\t)\n\t\t\n\t\tUNION'
      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-12-13 10:42:21,022] INFO [bukmaker-connector-sandbox-avro-kraft-13|task-0] Stopping down connector (io.debezium.connector.common.BaseSourceTask:284)
      [2023-12-13 10:42:21,089] INFO [bukmaker-connector-sandbox-avro-kraft-13|task-0] Finished streaming (io.debezium.pipeline.ChangeEventSourceCoordinator:273)
      

              Unassigned Unassigned
              nekkett Nikita Koposov (Inactive)
              ilyas ahsan (Inactive)
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: