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

close producer during cleanup #137

Merged
merged 3 commits into from
Jul 14, 2023
Merged

close producer during cleanup #137

merged 3 commits into from
Jul 14, 2023

Conversation

nlu90
Copy link
Collaborator

@nlu90 nlu90 commented Jul 12, 2023

Motivation

fix #136

Currently, producers will stay connected with a broker after each micro-batch, thus causing a broker-side producer spam issue and eventually affecting the broker's performance.

Modifications

call producer.close() when clean up

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

  • This change is a trivial rework / code cleanup without any test coverage.

  • This change is already covered by existing tests, such as:

  • This change added tests and can be verified as follows:

Documentation

Check the box below.

Need to update docs?

  • doc-required
  • no-need-doc
  • doc

@nlu90 nlu90 requested a review from a team as a code owner July 12, 2023 18:18
@github-actions github-actions bot added the no-need-doc This pr does not need any document label Jul 12, 2023
if (singleProducer != null) {
singleProducer.close()
} else {
topic2Producer.foreach(_._2.close())
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to handle exception here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If the exception happens, we will let it propagate.

And it will be catched here: https://github.com/streamnative/pulsar-spark/blob/master/src/main/scala/org/apache/spark/sql/pulsar/PulsarSinks.scala#L153

Copy link
Contributor

@chaoqin-li1123 chaoqin-li1123 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@nlu90 nlu90 merged commit 6ee8bd8 into master Jul 14, 2023
3 checks passed
@delete-merged-branch delete-merged-branch bot deleted the neng/fix-producer-leak branch July 14, 2023 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-need-doc This pr does not need any document
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] - Pulsar Producer leak
3 participants