Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
DBZ-604 Making sure connector cleanly shuts down also if records are …
Browse files Browse the repository at this point in the history
…produced after polling loop has stopped
  • Loading branch information
gunnarmorling authored and jpechane committed Nov 23, 2018
1 parent 2fd16a6 commit 62fe7d1
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,17 @@ public void start() {
@Override
public void stop() {
try {
// Emptying the queue so to make sure that enqueue() won't block indefinitely when adding records after
// poll() isn't called anymore but before the binlog reader is stopped; note there's still a tiny chance for
// this to happen if enough records are added again between here and the call to disconnect(); protecting
// against it seems not worth though it as shouldn't happen for any practical queue size
List<SourceRecord> unsent = new ArrayList<>();
records.drainTo(unsent);
logger.info("Discarding {} unsent record(s) due to the connector shutting down", unsent.size());
doStop();
running.set(false);
} finally {
}
finally {
if (failure.get() != null) {
// We had a failure and it was propagated via poll(), after which Kafka Connect will stop
// the connector, which will stop the task that will then stop this reader via this method.
Expand Down

0 comments on commit 62fe7d1

Please sign in to comment.