Fix blocking resource groups when query queue full#18910
Merged
tdcmeehan merged 1 commit intoprestodb:masterfrom Jan 18, 2023
Merged
Conversation
005fdb0 to
892aadb
Compare
swapsmagic
approved these changes
Jan 11, 2023
tdcmeehan
requested changes
Jan 11, 2023
...o-main/src/main/java/com/facebook/presto/execution/resourceGroups/InternalResourceGroup.java
Outdated
Show resolved
Hide resolved
c659e4b to
b84a51d
Compare
When Presto Coordinator cannot run query nor queue query, it fails the error. And Coordinator does it under root resource group lock. Failing query triggers query state change that in particular triggers event listener handler that could be expensive. Doing it under resource group lock essentially blocks the resource group and severely degrades performance.
b84a51d to
5bf3073
Compare
tdcmeehan
approved these changes
Jan 18, 2023
12 tasks
Merged
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.
When Presto Coordinator cannot run query nor queue query, it fails the error. And Coordinator does it under root resource group lock. Failing query triggers query state change that in particular triggers event listener handler that could be expensive. Doing it under resource group lock essentially blocks the resource group and severely degrades performance.
Test plan - (Please fill in how you tested your changes)

I ran the coordinator without and with the change. Within 1 hour I sent around 60K queries to the cluster. Less than 2K queries successfully executed and all other failed. Around 75% of the queries failures were due to QUERY_QUEUE_FULL error. I recorded the sessions with Java Flight Recorder. Picture below shows selected threads that were locked on RootInternalResourceGroup lock.
Here, the yellow blocks depict the thread waiting on the lock.

The picture below demonstrate the same settings with applied this code change.
Overall, the locking time for RootInternalResourceGroup monitor type reduced from 3 hour 24 min to 1 min 11 sec and for InternalResourceGroupManager monitor type it reduced from 4 days 4 hour to 9 sec.
Fill in the release notes towards the bottom of the PR description.
See Release Notes Guidelines for details.