-
Notifications
You must be signed in to change notification settings - Fork 590
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
Fix issues in otelsarama.WrapAsyncProducer #754
Conversation
Codecov Report
@@ Coverage Diff @@
## main #754 +/- ##
=======================================
+ Coverage 78.8% 79.0% +0.1%
=======================================
Files 62 62
Lines 2707 2726 +19
=======================================
+ Hits 2135 2154 +19
Misses 440 440
Partials 132 132
|
instrumentation/github.com/Shopify/sarama/otelsarama/producer.go
Outdated
Show resolved
Hide resolved
After great tips from @MadVikingGod it ended almost in a rewrite Careful review is needed... |
@Aneurysm9 @MadVikingGod Ready for review |
otelsarama.WrapAsyncProducer
otelsarama.WrapAsyncProducer
otelsarama.WrapAsyncProducer
instrumentation/github.com/Shopify/sarama/otelsarama/producer.go
Outdated
Show resolved
Hide resolved
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 haven't finished, but so far it looks good. The producers of the channels are the ones closing them, There is overall good hygiene around the close semantics. I will try and get to the tests later but consider this a soft +1.
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
instrumentation/github.com/Shopify/sarama/otelsarama/producer_test.go
Outdated
Show resolved
Hide resolved
* Fix deadlocks and data race in WrapAsyncProducer * Refine changelog * Improve TestAsyncProducer_ConcurrencyEdgeCases * Add TestWrapAsyncProducer_DrainsSuccessesAndErrorsChannels * Refine WrapAsyncProducer to not depend on its implementation details * Restore message metadata for errors * Update changelog * Remove empty line * Remove empty line * Refactor spans cleanup * Update producer_test.go Co-authored-by: Tyler Yahn <[email protected]>
* Fix deadlocks and data race in WrapAsyncProducer * Refine changelog * Improve TestAsyncProducer_ConcurrencyEdgeCases * Add TestWrapAsyncProducer_DrainsSuccessesAndErrorsChannels * Refine WrapAsyncProducer to not depend on its implementation details * Restore message metadata for errors * Update changelog * Remove empty line * Remove empty line * Refactor spans cleanup * Update producer_test.go Co-authored-by: Tyler Yahn <[email protected]>
Replace sdktrace.WithResourceAttributes() with WithResource()
Why
Usage of current Sarama instrumentation can lead to deadlocks and data races. These issues are not present if the instrumentation is not applied (created tests for deadlock scenarios).
The messages returned by the
Errors()
channel do not contain originalMetadata
. (I can make it as a separate PR if needed)What
Fix deadlocks by changing the concurrency design.
input
channel.Restore messages
Metadata
for the wrappedErrors
channel.Important Notice
Kudos to @MadVikingGod for a lot of help and for having concerns with the initial fixes 👍 🥇
Still very careful review is needed.
Example deadlock
Reproducing a sample deadlock: