-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
UDP receiver async - fix panic during shutdown (async mode only) #29121
UDP receiver async - fix panic during shutdown (async mode only) #29121
Conversation
Merge from main
Merge from main
The changes make sense to me, is there a way to write a test to reproduce the issue? |
|
Hello @hovavza, can you update the PR description with the following line?
This will allow GitHub to properly link this to the issue it's fixing. |
@crobert-1 done |
@djaglowski @crobert-1 @atoulme , can we complete this PR? |
…n-telemetry#29121) **Description:** Link to tracking Issue: Fixes open-telemetry#29120 Fixing a bug - panic happens during stop method in async mode only (didn't affect the default non-async mode). When stop is called, it closes the messageQueue channel, signaling to processMessagesAsync to stop running. However, readMessagesAsync sometimes tries to write into the closed channel (depends whether the method is currently reading from the closed connection or currently trying to write to the channel), and as a result, panic error happens. Separated between wg (waitGroup that serves non-async code and processMessagesAsync) & the new wg_reader (waitGroup serving readMessagesAsync only). This allows us to first stop readMessagesAsync, wait for it to finish, before closing the channel. Instead, stop (in async mode) should do the following: 1. Close the connection - signaling readMessagesAsync to stop - the messageQueue channel will remain open until that method is done so there's no risk of panic (due to writing to a closed channel). 2. Wait for readMessagesAsync to finish (wait for new wg_reader). 3. Close messageQueue channel (signaling processMessagesAsync to stop) 4. Wait for processMessagesAsync to finish (wait sg). **Link to tracking Issue:** 29120 **Testing:** Unitests ran. Ran concrete strato, stopped & restarted multiple times, didn't see any panic (and stop completed successfully as expected) **Documentation:** None.
Description:
Link to tracking Issue: Fixes #29120
Fixing a bug - panic happens during stop method in async mode only (didn't affect the default non-async mode).
When stop is called, it closes the messageQueue channel, signaling to processMessagesAsync to stop running. However, readMessagesAsync sometimes tries to write into the closed channel (depends whether the method is currently reading from the closed connection or currently trying to write to the channel), and as a result, panic error happens.
Separated between wg (waitGroup that serves non-async code and processMessagesAsync) & the new wg_reader (waitGroup serving readMessagesAsync only). This allows us to first stop readMessagesAsync, wait for it to finish, before closing the channel.
Instead, stop (in async mode) should do the following:
Link to tracking Issue: 29120
Testing: Unitests ran. Ran concrete strato, stopped & restarted multiple times, didn't see any panic (and stop completed successfully as expected)
Documentation: None.