[Backport 2.x] Fix Dispatchers.IO starvation deadlock in notification send path - #1251
Open
opensearch-ci-bot wants to merge 1 commit into
Open
Conversation
…nsearch-project#1248) * Fix Dispatchers.IO starvation deadlock in notification send path SendMessageActionHelper used runBlocking inside code already running on a Dispatchers.IO coroutine (PluginBaseAction launches every transport request on CoroutineScope(Dispatchers.IO)). The parent coroutine parked its dispatcher thread while awaiting child async(Dispatchers.IO) sends that need threads from the same pool. Under sustained concurrent sends to a slow destination (e.g. a webhook that times out), parents eventually occupy all 64 Dispatchers.IO slots. At that point no child can ever be scheduled and no parent can ever complete: a permanent dispatcher deadlock. Because all Notifications transport actions share the same scope, every plugin API (e.g. GET /_plugins/_notifications/features) hangs until the node is restarted. Replace runBlocking with structured concurrency: the send-path functions become suspend functions and use coroutineScope { ... } + awaitAll(), so waiting parents suspend and release their dispatcher threads instead of parking them. All call chains already terminate in suspend transport-action methods, so no additional bridging is needed. Reproduced by flooding 200 concurrent send requests at a webhook channel that responds after 30s: before this change the node's notifications APIs deadlock permanently (64 threads parked in runBlocking at sendMessagesInParallel, zero threads performing sends); after this change all sends complete and APIs remain responsive. Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> * Add comment explaining why sendMessageToChannel is a suspend function Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> --------- Signed-off-by: Surya Sashank Nistala <snistala@amazon.com> (cherry picked from commit 70804cb) Signed-off-by: opensearch-ci-bot <opensearch-infra@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport 70804cb from #1248.