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
Conversation
…oducer.errors==true
@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()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The java doc specifies that currentProducer must not be null
- 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
…oducer.errors==true Author: Jacob Maes <jmakes@apache.org> Reviewers: Boris Shkolnik <boryas@apache.org> Closes apache#390 from jmakes/samza-1539
…oducer.errors==true