-
Notifications
You must be signed in to change notification settings - Fork 14k
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
MINOR: improve RecordCollectorImpl #17185
Conversation
@@ -81,7 +81,7 @@ public class RecordCollectorImpl implements RecordCollector { | |||
private final Sensor droppedRecordsSensor; | |||
private final Map<String, Sensor> producedSensorByTopic = new HashMap<>(); | |||
|
|||
private final AtomicReference<KafkaException> sendException; | |||
private final AtomicReference<KafkaException> sendException = new AtomicReference<>(null); |
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.
There is no reason to get this from StreamsProducer
so pulling it into this class.
@@ -529,7 +528,7 @@ private void checkForException() { | |||
final KafkaException exception = sendException.get(); | |||
|
|||
if (exception != null) { | |||
sendException.set(null); | |||
sendException.compareAndSet(exception, null); |
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.
I believe this is actually fixing a race condition... with set()
we might overwrite (and thus drop) and exception which is set after we called get()
(even if I am not 100% sure how bad it is if we drop it, give that we throw exception;
below anyway...?
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... not sure that part makes a difference. But I guess there is nothing wrong with it?
The rest of PR makes sense to me
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.
LGTM, thanks!
After re-thinking, the test we remove because it failed actually exposed that the original idea of this PR is incorrect. We need to keep |
2d4277e
to
74f1042
Compare
Found this while working on #17169, but did not want to piggy-back this change to the other PR but isolate as it's unrelated cleanup.