Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop OffsetStore when stopping the connector #12457

Merged
merged 2 commits into from Oct 24, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we put the flush and close in the same try-catch block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hangc0276 in that case exception from flush prevent close(). We do want to close the producer.

} 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