Skip to content
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 resource group concurrency for multi coordinator #16956

Merged

Conversation

swapsmagic
Copy link
Contributor

@swapsmagic swapsmagic commented Nov 8, 2021

When a burst of traffic comes to coordinator, it ended up running more than allowed queries.
Two reasons for that:

  1. In multi coordinator, we were not stamping last running query for non leaf resource groups, which lead to
    shouldWaitForResourceManagerUpdate to return always true for non leaf resource groups. So if the traffic is coming from
    lot of different resource groups, coordinator end up running less than allowed in each resource group but at root level it
    ends up running more.
  2. ResourceManagerResourceGroupService cache end up having stale resource group info which also end up allowing coordinators
    to run more than allowed queries at a cluster level.
    As part of this diff we are fixing 1 by stamping last running query to all it's parent resource groups. And to address 2, making
    cache refresh rate and expiration configerable.

Test plan - Unit test + regression test on verifier cluster

== RELEASE NOTES ==

General Changes
* Fix resource group concurrency for multi coordinator

@swapsmagic swapsmagic force-pushed the fix_resource_group_concurrency branch 2 times, most recently from 840cf32 to 9f6a51a Compare November 8, 2021 21:30
When a burst of traffic comes to coordinator, it ended up running more than allowed queries.
Two reasons for that:
1. In multi coordinator, we were not stamping last running query for non leaf resource groups, which lead to
   shouldWaitForResourceManagerUpdate to return always true for non leaf resource groups. So if the traffic is coming from
   lot of different resource groups, coordinator end up running less than allowed in each resource group but at root level it
   ends up running more.
2. ResourceManagerResourceGroupService cache end up having stale resource group info which also end up allowing coordinators
   to run more than allowed queries at a cluster level.
As part of this diff we are fixing 1 by stamping last running query to all it's parent resource groups. And to address 2, making
cache refresh rate and expiration configerable.
@@ -152,7 +152,7 @@
private final CounterStat timeBetweenStartsSec = new CounterStat();

@GuardedBy("root")
private AtomicLong lastRunningQueryStartTime = new AtomicLong();
private AtomicLong lastRunningQueryStartTime = new AtomicLong(currentTimeMillis());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you help me understand why initializing with currentTimeMillis() is important?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason for this is: internal resource groups created as and when needed, and this make sure lastRunningQueryStartTime for the newly created resource group won't be set to 0. This helps make sure we won't end up letting resource group to run more than allowed queries in case RM updates are delayed and we wait for the RM update before running more queries on the resource group.

@tdcmeehan tdcmeehan merged commit 48fadf1 into prestodb:master Nov 10, 2021
@varungajjala varungajjala mentioned this pull request Nov 23, 2021
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants