[Coordinator throttling] Scheduling Policies for Admission Control based on worker load #25689
Conversation
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
8e02c17 to
16d9b55
Compare
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
16d9b55 to
79b52b7
Compare
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
79b52b7 to
841928b
Compare
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
1 similar comment
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Pull Request resolved: prestodb#25689 Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
841928b to
af5ae30
Compare
|
Can you share these documents as an RFC in our repo? https://github.com/prestodb/rfcs |
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Pull Request resolved: prestodb#25689 Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
af5ae30 to
5aa384e
Compare
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
5aa384e to
3c02dea
Compare
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Pull Request resolved: prestodb#25689 Admission control scheduling policy **Logic** Gather worker overload data from the added end point in D76357677 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** Design doc and rational for the change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.bdc9ugryon9z Also some follow up questions on the design review / future directions after this change - https://docs.google.com/document/d/16pEkXPzsP09ZpZ8RxqJ-n-c5kx3TFel0b8Ubx7l6v-I/edit?tab=t.0#heading=h.afichcgpu3fe **ODS Metrics on queuing due to this feature:** Right now Queued Queries ODS could be correlated with worker overload to see if this feature is getting activated. Also we log the warn logs when cluster is overloaded. I will add specific metrics for this feature before rollout as well to make debugging easy. **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
3c02dea to
add0507
Compare
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
…sed on worker load (prestodb#25689) Summary: Pull Request resolved: prestodb#25689 Admission control scheduling policy **Logic** Gather worker overload data from the added end point in PR - prestodb#25687 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** RFC PR: prestodb/rfcs#42 **Metrics on queuing due to this feature:** Added following JMX metrics - ClusterOverloadDuration - ClusterOverloadCount **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
8b2f287 to
1ec71e9
Compare
Done added a RG config to bypass admission throttling. |
|
|
||
| public AdmissionControlBypassConfig() | ||
| { | ||
| //SelectionCriteria c = new SelectionCriteria(true, "pgolash", Optional.empty(), new HashSet<>(), new ResourceEstimates(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty()), Optional.of(QueryType.DATA_DEFINITION).map(Enum::name), Optional.empty(), Optional.empty(), Optional.empty()); |
There was a problem hiding this comment.
Remove commented out code.
There was a problem hiding this comment.
Please add documentation for new config in https://prestodb.io/docs/current/admin/resource-groups.html#resource-group-properties
| query.setResourceGroupQueryLimits(perQueryLimits); | ||
| if (canRun && queuedQueries.isEmpty()) { | ||
| startInBackground(query); | ||
| if (shouldBypassAdmissionControl || (canRun && queuedQueries.isEmpty())) { |
There was a problem hiding this comment.
I don't think it's a good idea to bypass admission control. Instead, just let users configure the resource group to very high values. For example, let the default overload policy be set to a hard count, and let per resource group be the max value for an integer, i.e., set it to an impossibly high number so it effectively doesn't queue.
There was a problem hiding this comment.
Can you please explain more. This config is just to bypass the control if the query type in the RG is DDL etc which we discussed. Right now we have cluster level and RG level check in canRunMore. This bypass both of them. I am not sure if I understand about passing very high value as if cluster is loaded it will still get queued.
|
@sourcery-ai review |
Reviewer's GuideThis PR implements coordinator-side query admission control based on worker load. It introduces cluster overload detection with configurable count- or percentage-based policies, integrates throttling into resource groups, and adds a bypass mechanism for special queries. The changes weave the new ClusterResourceChecker and overload policies into InternalResourceGroup and InternalResourceGroupManager, extend node managers to fetch per-node load metrics, and update tests and configuration modules to wire in the new components. Sequence diagram for query admission control with cluster overload and bypasssequenceDiagram
participant Q as actor QuerySubmitter
participant RG as InternalResourceGroup
participant CRC as ClusterResourceChecker
participant ACBC as AdmissionControlBypassConfig
Q->>RG: run(query)
RG->>ACBC: shouldBypassAdmissionControl(selectionCriteria)
ACBC-->>RG: true/false
alt Admission control bypassed
RG->>RG: startInBackground(query, true)
else Admission control required
RG->>CRC: isClusterCurrentlyOverloaded()
CRC-->>RG: true/false
alt Cluster overloaded
RG->>RG: enqueueQuery(query)
else Not overloaded
RG->>RG: startInBackground(query, false)
end
end
Class diagram for new and updated cluster overload control classesclassDiagram
class ClusterResourceChecker {
- ClusterOverloadPolicy clusterOverloadPolicy
- ClusterOverloadConfig config
- InternalNodeManager nodeManager
+ boolean isClusterCurrentlyOverloaded()
+ void addListener(ClusterOverloadStateListener listener)
+ void removeListener(ClusterOverloadStateListener listener)
}
class ClusterOverloadPolicy {
<<interface>>
+ boolean isClusterOverloaded(InternalNodeManager nodeManager)
+ String getName()
}
class CpuMemoryOverloadPolicy {
+ boolean isClusterOverloaded(InternalNodeManager nodeManager)
+ String getName()
}
class ClusterOverloadPolicyFactory {
+ Optional<ClusterOverloadPolicy> getPolicy(String name)
+ ClusterOverloadPolicy getDefaultPolicy()
+ Map<String, ClusterOverloadPolicy> getPolicies()
}
class ClusterOverloadStateListener {
<<interface>>
+ void onClusterEnteredOverloadedState()
+ void onClusterExitedOverloadedState()
}
class ClusterOverloadConfig {
+ boolean isClusterOverloadThrottlingEnabled()
+ double getAllowedOverloadWorkersPct()
+ double getAllowedOverloadWorkersCnt()
+ String getOverloadPolicyType()
}
ClusterResourceChecker --> ClusterOverloadPolicy
ClusterResourceChecker --> ClusterOverloadConfig
ClusterResourceChecker --> InternalNodeManager
ClusterResourceChecker --> ClusterOverloadStateListener
CpuMemoryOverloadPolicy --|> ClusterOverloadPolicy
ClusterOverloadPolicyFactory --> ClusterOverloadPolicy
ClusterResourceChecker --> ClusterOverloadPolicyFactory
ClusterResourceChecker --> ClusterOverloadStateListener
ClusterOverloadStateListener <|.. InternalResourceGroupManager
ClusterOverloadStateListener <|.. InternalResourceGroup
Class diagram for resource group admission control and bypass configclassDiagram
class InternalResourceGroup {
- AdmissionControlBypassConfig admissionControlPolicyByPassConfig
- ClusterResourceChecker clusterResourceChecker
+ void setAdmissionControlPolicyByPassConfig(AdmissionControlBypassConfig config)
+ AdmissionControlBypassConfig getAdmissionControlPolicyByPassConfig()
+ void run(ManagedQueryExecution query)
}
class AdmissionControlBypassConfig {
+ boolean shouldBypassAdmissionControl(SelectionCriteria selectionCriteria)
+ AdmissionControlBypassConfig setByPassAdmissionControlRules(List<SelectionCriteria> rules)
}
class SelectionCriteria {
+ Optional<String> getQueryType()
// ... other selection fields
}
InternalResourceGroup --> AdmissionControlBypassConfig
AdmissionControlBypassConfig --> SelectionCriteria
Class diagram for node stats and node manager changesclassDiagram
class InternalNodeManager {
+ Optional<NodeLoadMetrics> getNodeLoadMetrics(String nodeIdentifier)
}
class DiscoveryNodeManager {
- ConcurrentHashMap<String, RemoteNodeStats> nodeStats
+ Optional<NodeLoadMetrics> getNodeLoadMetrics(String nodeId)
}
class RemoteNodeStats {
<<interface>>
+ Optional<NodeStats> getNodeStats()
+ void asyncRefresh()
}
class HttpRemoteNodeStats {
+ Optional<NodeStats> getNodeStats()
+ void asyncRefresh()
}
class ThriftRemoteNodeStats {
+ Optional<NodeStats> getNodeStats()
+ void asyncRefresh()
}
DiscoveryNodeManager --> RemoteNodeStats
RemoteNodeStats <|.. HttpRemoteNodeStats
RemoteNodeStats <|.. ThriftRemoteNodeStats
InternalNodeManager <|.. DiscoveryNodeManager
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- The onClusterEnteredOverloadedState handler is currently empty, so resource groups won’t re-evaluate eligibility when the cluster first becomes overloaded; consider invoking updateEligibilityRecursively there to enforce throttling immediately.
- AdmissionControlBypassConfig.shouldBypassAdmissionControl only matches on queryType today but ignores user, source, clientTags, etc.; either extend the matching logic to cover all rule fields or trim the API to only expose supported criteria.
- This PR introduces a lot of functionality (cluster overload policies, node stats endpoints, admission bypass, SPI extensions), so you may want to break it into smaller focused changes to simplify review and testing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The onClusterEnteredOverloadedState handler is currently empty, so resource groups won’t re-evaluate eligibility when the cluster first becomes overloaded; consider invoking updateEligibilityRecursively there to enforce throttling immediately.
- AdmissionControlBypassConfig.shouldBypassAdmissionControl only matches on queryType today but ignores user, source, clientTags, etc.; either extend the matching logic to cover all rule fields or trim the API to only expose supported criteria.
- This PR introduces a lot of functionality (cluster overload policies, node stats endpoints, admission bypass, SPI extensions), so you may want to break it into smaller focused changes to simplify review and testing.
## Individual Comments
### Comment 1
<location> `presto-main-base/src/main/java/com/facebook/presto/execution/resourceGroups/InternalResourceGroup.java:828` </location>
<code_context>
}
- private void startInBackground(ManagedQueryExecution query)
+ private void startInBackground(ManagedQueryExecution query, boolean shouldBypassAdmissionControl)
{
checkState(Thread.holdsLock(root), "Must hold lock to start a query");
synchronized (root) {
- runningQueries.add(query);
InternalResourceGroup group = this;
- while (group.parent.isPresent()) {
- group.parent.get().descendantRunningQueries++;
- group.parent.get().dirtySubGroups.add(group);
- group = group.parent.get();
+ if (!shouldBypassAdmissionControl) {
+ runningQueries.add(query);
+ while (group.parent.isPresent()) {
</code_context>
<issue_to_address>
startInBackground does not update runningQueries for bypassed queries.
By not updating runningQueries and counters for bypassed queries, resource group statistics and eligibility calculations may become inaccurate. Please review whether bypassed queries should be included in these metrics.
</issue_to_address>
### Comment 2
<location> `presto-main-base/src/test/java/com/facebook/presto/execution/resourceGroups/TestResourceGroups.java` </location>
<code_context>
+ @Test(timeOut = 10_000)
+ public void testAdmissionControlBypass()
</code_context>
<issue_to_address>
Consider adding a test for bypass rules with multiple criteria.
Please add a test case with multiple bypass rules (e.g., DDL and CONTROL) to ensure queries matching any rule are properly bypassed.
</issue_to_address>
### Comment 3
<location> `presto-main-base/src/test/java/com/facebook/presto/execution/resourceGroups/TestResourceGroups.java:1118` </location>
<code_context>
+ root.run(regularQuery2);
+ assertEquals(regularQuery2.getState(), QUEUED);
+
+ // Now run a DDL query - should bypass admission control and run immediately
+ MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION));
+ ddlQuery.startWaitingForPrerequisites();
+ root.run(ddlQuery);
+ assertEquals(ddlQuery.getState(), RUNNING);
+
+ // Verify we now have 2 running queries (regular + DDL)
</code_context>
<issue_to_address>
Missing negative test for bypass with non-matching query type.
Add a test where a query type not covered by bypass rules is submitted, and confirm it remains subject to admission control.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
// Now run a DDL query - should bypass admission control and run immediately
MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION));
ddlQuery.startWaitingForPrerequisites();
root.run(ddlQuery);
assertEquals(ddlQuery.getState(), RUNNING);
// Verify we now have 2 running queries (regular + DDL)
assertEquals(root.getInfo().getNumRunningQueries(), 1);
assertEquals(root.getInfo().getNumQueuedQueries(), 1);
=======
// Now run a DDL query - should bypass admission control and run immediately
MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION));
ddlQuery.startWaitingForPrerequisites();
root.run(ddlQuery);
assertEquals(ddlQuery.getState(), RUNNING);
// Negative test: run a query type not covered by bypass rules (e.g., ANALYZE)
MockManagedQueryExecution analyzeQuery = new MockManagedQueryExecution(Optional.of(QueryType.ANALYZE));
analyzeQuery.startWaitingForPrerequisites();
root.run(analyzeQuery);
// Should be queued, not running
assertEquals(analyzeQuery.getState(), QUEUED);
// Verify we now have 2 running queries (regular + DDL) and 2 queued queries (regular2 + analyze)
assertEquals(root.getInfo().getNumRunningQueries(), 1);
assertEquals(root.getInfo().getNumQueuedQueries(), 2);
>>>>>>> REPLACE
</suggested_fix>
### Comment 4
<location> `presto-main-base/src/test/java/com/facebook/presto/execution/scheduler/clusterOverload/TestClusterResourceChecker.java` </location>
<code_context>
+ @Test
+ public void testIsClusterCurrentlyOverloaded()
</code_context>
<issue_to_address>
Consider testing listener notification on overload state change.
Add a test that registers a ClusterOverloadStateListener and checks it is notified when the cluster exits the overloaded state to confirm correct listener behavior.
</issue_to_address>
### Comment 5
<location> `presto-main-base/src/test/java/com/facebook/presto/execution/scheduler/clusterOverload/TestCpuMemoryOverloadPolicy.java` </location>
<code_context>
+ @Test
+ public void testIsClusterOverloadedBothMetricsOverloaded()
</code_context>
<issue_to_address>
Consider adding a test for nodes with missing metrics.
Add a test where getNodeLoadMetrics returns Optional.empty() for some nodes, and confirm these nodes are not counted as overloaded by the policy.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| SelectionCriteria selectionCriteria = new SelectionCriteria(query.getSession().getIdentity().getPrincipal().isPresent(), query.getSession().getUser(), query.getSession().getSource(), query.getSession().getClientTags(), query.getSession().getResourceEstimates(), query.getSession().getQueryType().map(Enum::name), query.getSession().getClientInfo(), query.getSession().getSchema(), query.getSession().getIdentity().getPrincipal().map(Principal::getName)); | ||
| boolean shouldBypassAdmissionControl = admissionControlPolicyByPassConfig.shouldBypassAdmissionControl(selectionCriteria); | ||
|
|
||
| if (!shouldBypassAdmissionControl) { |
There was a problem hiding this comment.
issue (bug_risk): startInBackground does not update runningQueries for bypassed queries.
By not updating runningQueries and counters for bypassed queries, resource group statistics and eligibility calculations may become inaccurate. Please review whether bypassed queries should be included in these metrics.
| MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION)); | ||
| ddlQuery.startWaitingForPrerequisites(); | ||
| root.run(ddlQuery); | ||
| assertEquals(ddlQuery.getState(), RUNNING); |
There was a problem hiding this comment.
suggestion (testing): Consider adding a test for bypass rules with multiple criteria.
Please add a test case with multiple bypass rules (e.g., DDL and CONTROL) to ensure queries matching any rule are properly bypassed.
| // Now run a DDL query - should bypass admission control and run immediately | ||
| MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION)); | ||
| ddlQuery.startWaitingForPrerequisites(); | ||
| root.run(ddlQuery); | ||
| assertEquals(ddlQuery.getState(), RUNNING); | ||
|
|
||
| // Verify we now have 2 running queries (regular + DDL) | ||
| assertEquals(root.getInfo().getNumRunningQueries(), 1); | ||
| assertEquals(root.getInfo().getNumQueuedQueries(), 1); |
There was a problem hiding this comment.
suggestion (testing): Missing negative test for bypass with non-matching query type.
Add a test where a query type not covered by bypass rules is submitted, and confirm it remains subject to admission control.
| // Now run a DDL query - should bypass admission control and run immediately | |
| MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION)); | |
| ddlQuery.startWaitingForPrerequisites(); | |
| root.run(ddlQuery); | |
| assertEquals(ddlQuery.getState(), RUNNING); | |
| // Verify we now have 2 running queries (regular + DDL) | |
| assertEquals(root.getInfo().getNumRunningQueries(), 1); | |
| assertEquals(root.getInfo().getNumQueuedQueries(), 1); | |
| // Now run a DDL query - should bypass admission control and run immediately | |
| MockManagedQueryExecution ddlQuery = new MockManagedQueryExecution(Optional.of(QueryType.DATA_DEFINITION)); | |
| ddlQuery.startWaitingForPrerequisites(); | |
| root.run(ddlQuery); | |
| assertEquals(ddlQuery.getState(), RUNNING); | |
| // Negative test: run a query type not covered by bypass rules (e.g., ANALYZE) | |
| MockManagedQueryExecution analyzeQuery = new MockManagedQueryExecution(Optional.of(QueryType.ANALYZE)); | |
| analyzeQuery.startWaitingForPrerequisites(); | |
| root.run(analyzeQuery); | |
| // Should be queued, not running | |
| assertEquals(analyzeQuery.getState(), QUEUED); | |
| // Verify we now have 2 running queries (regular + DDL) and 2 queued queries (regular2 + analyze) | |
| assertEquals(root.getInfo().getNumRunningQueries(), 1); | |
| assertEquals(root.getInfo().getNumQueuedQueries(), 2); |
| assertFalse(clusterResourceChecker.isClusterOverloaded()); | ||
|
|
||
| // Stop the periodic task | ||
| clusterResourceChecker.stop(); |
There was a problem hiding this comment.
suggestion (testing): Consider testing listener notification on overload state change.
Add a test that registers a ClusterOverloadStateListener and checks it is notified when the cluster exits the overloaded state to confirm correct listener behavior.
|
|
||
| // Two nodes are overloaded, but allowed count is 1, so overloaded | ||
| InternalNodeManager nodeManager = createNodeManager(ImmutableSet.of(createNode("node1", true, false), createNode("node2", false, true), createNode("node3", false, false))); | ||
| assertTrue(policy.isClusterOverloaded(nodeManager)); |
There was a problem hiding this comment.
suggestion (testing): Consider adding a test for nodes with missing metrics.
Add a test where getNodeLoadMetrics returns Optional.empty() for some nodes, and confirm these nodes are not counted as overloaded by the policy.
…sed on worker load (prestodb#25689) Summary: Pull Request resolved: prestodb#25689 Admission control scheduling policy **Logic** Gather worker overload data from the added end point in PR - prestodb#25687 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** RFC PR: prestodb/rfcs#42 **Metrics on queuing due to this feature:** Added following JMX metrics - ClusterOverloadDuration - ClusterOverloadCount **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
1ec71e9 to
f3fca15
Compare
steveburnett
left a comment
There was a problem hiding this comment.
Thanks for the doc! Some suggestions.
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in PR - prestodb#25687 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** RFC PR: prestodb/rfcs#42 **Metrics on queuing due to this feature:** Added following JMX metrics - ClusterOverloadDuration - ClusterOverloadCount **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
f3fca15 to
a816c3b
Compare
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
rschlussel
left a comment
There was a problem hiding this comment.
Per offline discussion, the next PR will address adding a configuration for resource groups to admit queries even when the cluster is overloaded #25987
Remaining comments will be addressed as part of #25987
…he worker load metrics (prestodb#25688) Summary: Changes for DiscoveryManager to use the new end point added in the underlying diff Logic 1. Boiler plate code for fetching / refreshing the node stats similar to NodeState -> NodeStats. 2. Consuming NodeState from the new response Once we clean up the NodeState endpoint, we can get rid of `RemoteNodeState` and `HttpRemoteNodeState`. Differential Revision: D76911853
…sed on worker load (prestodb#25689) Summary: Admission control scheduling policy **Logic** Gather worker overload data from the added end point in PR - prestodb#25687 Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries **Background** RFC PR: prestodb/rfcs#42 **Metrics on queuing due to this feature:** Added following JMX metrics - ClusterOverloadDuration - ClusterOverloadCount **Feature flag:** Right now feature is disabled. We can use coordinator configs to enable / add thresholds Differential Revision: D79470181
|
This pull request was exported from Phabricator. Differential Revision: D79470181 |
|
@prashantgolash Can you please add/provide release notes for this PR? Looks like this is something we want to add. |
Admission control scheduling policy
Logic
Gather worker overload data from the added end point in PR - https://github.com/prestodb/presto/pull/25687
Based on configured policies (cnt of overloaded workers or pct of overloaded workers) and cluster overload, queue the queries
Background
RFC PR: https://github.com/prestodb/rfcs/pull/42
Metrics on queuing due to this feature:
Added following metrics
Feature flag:
Right now feature is disabled. We can use coordinator configs to enable / add thresholds
Summary by Sourcery
Add cluster overload-based admission control scheduling policy and supporting infrastructure to throttle queries based on worker load.
New Features:
Enhancements:
Tests:
Chores: