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

Flink JDBC Sink may lose data in left join

    XMLWordPrintableJSON

Details

    Description

      The JDBC sink will lose some data while using TableBufferReducedStatementExecutor and left join.

      Here are a snippet of executeBatch.

          @Override
          public void executeBatch() throws SQLException {
              for (Map.Entry<RowData, Tuple2<Boolean, RowData>> entry : reduceBuffer.entrySet()) {
                  if (entry.getValue().f0) {
                      upsertExecutor.addToBatch(entry.getValue().f1);
                  } else {
                      // delete by key
                      deleteExecutor.addToBatch(entry.getKey());
                  }
              }
              upsertExecutor.executeBatch();
              deleteExecutor.executeBatch();
              reduceBuffer.clear();
          }
      

      Left join will generate a DETETE row before upsert row and the executeBatch will excute them in a wrong order.Whitch may causes data lose.

      Attachments

        Activity

          People

            Unassigned Unassigned
            Kenyore Kenyore
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: