-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add cluster configuration to allow limiting the number of multi-stage queries running concurrently #14574
Add cluster configuration to allow limiting the number of multi-stage queries running concurrently #14574
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #14574 +/- ##
============================================
+ Coverage 61.75% 64.02% +2.27%
- Complexity 207 1605 +1398
============================================
Files 2436 2706 +270
Lines 133233 149013 +15780
Branches 20636 22828 +2192
============================================
+ Hits 82274 95411 +13137
- Misses 44911 46607 +1696
- Partials 6048 6995 +947
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some comments, mainly on code style. Anyway we need to discuss whether we want to use these config options or some other
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQuerySemaphore.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQuerySemaphore.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQuerySemaphore.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/broker/helix/BaseBrokerStarter.java
Outdated
Show resolved
Hide resolved
...ker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java
Show resolved
Hide resolved
… queries running concurrently
38ba313
to
ea16de2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed offline, I've made some changes to make the cluster config a "per server" value and also renamed it to indicate that it's "beta" and subject to change or even removal in future releases.
...ker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQuerySemaphore.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQueryThrottler.java
Outdated
Show resolved
Hide resolved
* the server. This would allow for more fine-grained control over the number of queries being executed concurrently | ||
* (but there are some limitations around ordering and blocking that need to be solved first). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we are merging two different things here. In my mind there are 3 options:
- Broader broker check, the one we are implementing, which simplifies the check by assuming evenly distributed queries across brokers and servers.
- Ask servers if they can execute queries, where the broker ask the servers whether they can execute more queries or not (probably this should be done while workers/plan fragments are assigned). A server needs to be able to execute all the associated workers of the query atomically. This means that a query that spawns a lot of workers on a single server may consume a lot of threads in the server.
- Ask servers if they can execute workers. This is what implies there could be blocks if we don't care about ordering.
The difference between 2 and 3 is that queries that require tons of workers may end up consuming a lot of threads in 2, while in 3 we would execute only the some workers and once they finish the other will start to run. In order to do so we need to execute the dag in a consistent manner (and probably buffer some data).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I was assuming that for the 2nd option the check would happen before dispatch instead of during planning. Either way, this is just a rough sketch for a future idea so I've just removed this part of the Javadoc to avoid confusion. This PR can always be re-visited for more context in the future.
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQueryThrottler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageQueryThrottler.java
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/concurrency/AdjustableSemaphore.java
Show resolved
Hide resolved
+1 |
Q1
is formed by stagesS11
andS12
, whereS11
depends on data fromS12
.Q2
is formed by stagesS21
andS22
, whereS21
depends on data fromS22
Q1
andQ2
arrive at the same time and:Srv1
receivesQ1
first, starts executingS11
and ends up waiting for serverSrv2
to executeS12
Srv2
receivesQ2
first, starts executingS21
and ends up waiting for serverSrv1
to executeS22
Srv1
receivesQ2
and would executeS22
, but sees that it has reached max number of concurrent queries, so it waits.Srv2
receivesQ1
and would executeS12
, but sees that it has reached max number of concurrent queries, so it waits.6
and there are 2 brokers and 3 servers in the cluster, each broker will be able to execute 9 multi-stage queries concurrently. If there are already 9 queries currently executing on a broker, any subsequent incoming queries will wait for a slot to open up.protected
access. We need to use this method in order to be able to reduce the total number of permits for the semaphore without blocking.