Skip to content

Commit

Permalink
Stop OffsetStore when stopping the connector (#12457)
Browse files Browse the repository at this point in the history
### Motivation

Source connectors based on KCA (all debezium ones) don't stop properly on error / don't restart.
#12441 fixes one problem, this PR fixes another: ofsetStore is not closed on connector stop() and producer/consumer aren't closed too, preventing the connector from shutting down.

### Modifications

Closing offset store on connector stop.

(cherry picked from commit 63454e9)
  • Loading branch information
dlg99 authored and eolivelli committed Nov 9, 2021
1 parent f5730b7 commit 9941edb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Expand Up @@ -180,6 +180,12 @@ public synchronized Record<T> read() throws Exception {
public void close() {
if (sourceTask != null) {
sourceTask.stop();
sourceTask = null;
}

if (offsetStore != null) {
offsetStore.stop();
offsetStore = null;
}
}

Expand Down
Expand Up @@ -158,20 +158,30 @@ public void start() {

@Override
public void stop() {
log.info("Stopping PulsarOffsetBackingStore");
if (null != producer) {
try {
producer.flush();
} catch (PulsarClientException pce) {
log.warn("Failed to flush the producer", pce);
}
try {
producer.close();
} catch (PulsarClientException e) {
log.warn("Failed to close producer", e);
}
producer = null;
}
if (null != reader) {
try {
reader.close();
} catch (IOException e) {
log.warn("Failed to close reader", e);
}
reader = null;
}

// do not close the client, it is provided by the sink context
}

@Override
Expand Down

0 comments on commit 9941edb

Please sign in to comment.