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

SAMZA-1539: KafkaProducer potential hang on close() when task.drop.pr… #390

Closed
wants to merge 5 commits into from

Conversation

jmakes
Copy link
Contributor

@jmakes jmakes commented Dec 20, 2017

…oducer.errors==true

@jmakes
Copy link
Contributor Author

jmakes commented Dec 20, 2017

@prateekm @nickpan47 @vjagadish1989 for review

if (isFatalException) {
fatalException.compareAndSet(null, producerException)
// Prevent each callback from closing and nulling producer for the same failure.
if (currentProducer == producerRef.get()) {

Choose a reason for hiding this comment

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

If both currentProducer and producerRef.get() are null here, it can have null pointer exception. I would recommend to have a null check to make the code more robust.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. The java doc specifies that currentProducer must not be null
  2. If currentProducer was null, the right thing to do is throw an exception because we can't properly handle the exception, so then the debate is NPE or other exception. I don't see the value.

if (producer != null) {
producer.close // Also performs the equivalent of a flush()
}
stopped = true

Choose a reason for hiding this comment

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

would it make more sense to put stopped = true after stop is done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. The flag is used to prevent subsequent producer creations. That should happen immediately when stop() is invoked.

Choose a reason for hiding this comment

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

Yeah, the logic makes sense. It might be better to call it stopTriggered or something else instead of stopped, to avoid the confusion, but that's minor and optional.

if (currentProducer == null) {
if (dropProducerExceptions) {
// No producer to flush, but we're ignoring exceptions so just return.
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 a WARN here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be useful. Added it.

@asfgit asfgit closed this in ef1c962 Dec 22, 2017
atoomula pushed a commit to atoomula/samza that referenced this pull request Mar 27, 2018
…oducer.errors==true

Author: Jacob Maes <jmakes@apache.org>

Reviewers: Boris Shkolnik <boryas@apache.org>

Closes apache#390 from jmakes/samza-1539
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants