[mysql-cdc] Fix race condition between split and coordinator thread that async exception might not be caught

pull/2020/head
JasonLee 2 years ago committed by GitHub
parent fe5ee766d5
commit a968a64efa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -276,9 +276,9 @@ public class MySqlSnapshotSplitAssigner implements MySqlSplitAssigner {
@Override
public Optional<MySqlSplit> getNext() {
checkSplitterErrors();
waitTableDiscoveryReady();
synchronized (lock) {
checkSplitterErrors();
if (!remainingSplits.isEmpty()) {
// return remaining splits firstly
Iterator<MySqlSchemalessSnapshotSplit> iterator = remainingSplits.iterator();
@ -496,7 +496,8 @@ public class MySqlSnapshotSplitAssigner implements MySqlSplitAssigner {
private void splitChunksForRemainingTables() {
try {
// restore from a checkpoint and start to split the table from the previous checkpoint
// restore from a checkpoint and start to split the table from the previous
// checkpoint
if (chunkSplitter.hasNextChunk()) {
LOG.info(
"Start splitting remaining chunks for table {}",
@ -509,13 +510,13 @@ public class MySqlSnapshotSplitAssigner implements MySqlSplitAssigner {
splitTable(nextTable);
}
} catch (Throwable e) {
if (uncaughtSplitterException == null) {
uncaughtSplitterException = e;
} else {
uncaughtSplitterException.addSuppressed(e);
}
// Release the potential waiting getNext() call
synchronized (lock) {
if (uncaughtSplitterException == null) {
uncaughtSplitterException = e;
} else {
uncaughtSplitterException.addSuppressed(e);
}
// Release the potential waiting getNext() call
lock.notify();
}
}

Loading…
Cancel
Save