Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19423

Fix ArrayIndexOutOfBoundsException when executing DELETE statement in JDBC upsert sink

    XMLWordPrintableJSON

    Details

      Description

      We found  that the primary key position can cause  ArrayIndexOutOfBoundsException

      the sink like that( the primary key select the position of 1, 3):

      CREATE TABLE `test`(
        col1 STRING, 
        col2 STRING, 
        col3 STRING, 
        PRIMARY KEY (col1, col3) NOT ENFORCED ) WITH (
        'connector' = 'jdbc',
        ...
      )

      when the DELETE (cdc message) come , it will raise ArrayIndexOutOfBoundsException:

      Caused by: java.lang.RuntimeException: Writing records to JDBC failed.    ... 10 moreCaused by: java.lang.ArrayIndexOutOfBoundsException: 2    at org.apache.flink.table.data.GenericRowData.getString(GenericRowData.java:169)    at org.apache.flink.table.data.RowData.lambda$createFieldGetter$245ca7d1$1(RowData.java:310)    at org.apache.flink.connector.jdbc.table.JdbcDynamicOutputFormatBuilder.getPrimaryKey(JdbcDynamicOutputFormatBuilder.java:216)    at org.apache.flink.connector.jdbc.table.JdbcDynamicOutputFormatBuilder.lambda$createRowKeyExtractor$7(JdbcDynamicOutputFormatBuilder.java:193)    at org.apache.flink.connector.jdbc.table.JdbcDynamicOutputFormatBuilder.lambda$createKeyedRowExecutor$3fd497bb$1(JdbcDynamicOutputFormatBuilder.java:128)    at org.apache.flink.connector.jdbc.internal.executor.KeyedBatchStatementExecutor.executeBatch(KeyedBatchStatementExecutor.java:71)    at org.apache.flink.connector.jdbc.internal.executor.BufferReduceStatementExecutor.executeBatch(BufferReduceStatementExecutor.java:99)    at org.apache.flink.connector.jdbc.internal.JdbcBatchingOutputFormat.attemptFlush(JdbcBatchingOutputFormat.java:200)    at org.apache.flink.connector.jdbc.internal.JdbcBatchingOutputFormat.flush(JdbcBatchingOutputFormat.java:171)    ... 8 more
      

       

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jark Jark Wu
                Reporter:
                limbo limbo
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: