Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,18 @@ private SplitReadResult prepareStreamSplit(
Map<String, Object> offsetMeta, JobBaseRecordRequest baseReq) throws Exception {
Tuple2<SourceSplitBase, Boolean> splitFlag = createStreamSplit(offsetMeta, baseReq);
this.streamSplit = splitFlag.f0.asStreamSplit();

// Close previous stream reader to release resources (e.g. PG replication slot)
// before creating a new one. This prevents connection leaks when a cancelled
// task's reader is still active while a new task arrives.
if (this.streamReader != null) {
LOG.info(
"Closing previous stream reader before creating new one for job {}",
baseReq.getJobId());
closeReaderInternal(this.streamReader);
this.streamReader = null;
}

this.streamReader = getBinlogSplitReader(baseReq);

LOG.info("Prepare stream split: {}", this.streamSplit.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,18 @@ private SplitReadResult prepareBinlogSplit(
Map<String, Object> offsetMeta, JobBaseRecordRequest baseReq) throws Exception {
Tuple2<MySqlSplit, Boolean> splitFlag = createBinlogSplit(offsetMeta, baseReq);
this.binlogSplit = (MySqlBinlogSplit) splitFlag.f0;

// Close previous binlog reader to release resources before creating a new one.
// This prevents connection leaks when a cancelled task's reader is still active
// while a new task arrives.
if (this.binlogReader != null) {
LOG.info(
"Closing previous binlog reader before creating new one for job {}",
baseReq.getJobId());
this.binlogReader.close();
this.binlogReader = null;
}

this.binlogReader = getBinlogSplitReader(baseReq);

LOG.info("Prepare binlog split: {}", this.binlogSplit.toString());
Expand Down
Loading