flink-cdc icon indicating copy to clipboard operation
flink-cdc copied to clipboard

[cdc-connector][mysql][hotfix] Fix NullPointerException when currentReader is null.

Open loserwang1024 opened this issue 1 year ago • 2 comments

In current com.ververica.cdc.connectors.mysql.source.reader.MySqlSplitReader#pollSplitRecords, if currentReader == null(for example, there is no split), NullPointerException will be thrown here:

 private MySqlRecords pollSplitRecords() throws InterruptedException {
        Iterator<SourceRecords> dataIt;
        if (currentReader == null) {
            // (1) Reads binlog split firstly and then read snapshot split
            if (binlogSplits.size() > 0) {
                // the binlog split may come from:
                // (a) the initial binlog split
                // (b) added back binlog-split in newly added table process
                MySqlSplit nextSplit = binlogSplits.poll();
                currentSplitId = nextSplit.splitId();
                currentReader = getBinlogSplitReader();
                currentReader.submitSplit(nextSplit);
            } else if (snapshotSplits.size() > 0) {
                MySqlSplit nextSplit = snapshotSplits.poll();
                currentSplitId = nextSplit.splitId();
                currentReader = getSnapshotSplitReader();
                currentReader.submitSplit(nextSplit);
            } else {
                LOG.info("No available split to read.");
            }
            dataIt = currentReader.pollSplitRecords();
          
}

loserwang1024 avatar Jan 22 '24 12:01 loserwang1024

@leonardBang , @ruanhang1993 , @Shawn-Hx , CC

loserwang1024 avatar Jan 22 '24 12:01 loserwang1024

@ruanhang1993 , CC

loserwang1024 avatar Jan 30 '24 02:01 loserwang1024

This pull request has been automatically marked as stale because it has not had recent activity for 60 days. It will be closed in 30 days if no further activity occurs.

github-actions[bot] avatar Jul 17 '24 00:07 github-actions[bot]