-
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
support to show running queries and cancel query by id #9171
Conversation
d3dc5b2
to
3192574
Compare
Codecov Report
@@ Coverage Diff @@
## master #9171 +/- ##
============================================
- Coverage 70.01% 68.72% -1.30%
- Complexity 4762 4999 +237
============================================
Files 1856 1857 +1
Lines 98923 99079 +156
Branches 15042 15066 +24
============================================
- Hits 69263 68089 -1174
- Misses 24754 26116 +1362
+ Partials 4906 4874 -32
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
3192574
to
2d73d8e
Compare
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
Show resolved
Hide resolved
} | ||
boolean done = future.isDone(); | ||
if (!done) { | ||
future.cancel(true); |
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.
In a query that is long running, this cancel may not have much effect? The check for isInterrupted only happens in the base class when we go to a new operator. So if we're already past that check, and doing a long running op, we'll still have to wait?
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.
Good question. I think operators either finish their compute quickly or wait for sth (like the blockingQueue.poll). The waits can be interrupted.
A compute operator might miss the isInterrupted flag at the beginning but should end itself quickly. Or better refactor it to check the flag more often during the compute.
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.
Hey, we plan to use the same cancellation mechanism for cpu time/memory usage based query pre-emption. Do you think the current frequency of checking on if (Thread.interrupted())
at each nextBlock()
is insufficient to preempt a query in timely manner @npawar ?
36bc407
to
5bb9111
Compare
LGTM. Don't see any obvious conflict with the in progress query killing work. |
a606273
to
4d660eb
Compare
pinot-broker/src/main/java/org/apache/pinot/broker/api/resources/PinotClientRequest.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandler.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Outdated
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Show resolved
Hide resolved
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/BaseBrokerRequestHandler.java
Show resolved
Hide resolved
b232015
to
2a4aeed
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.
We should also check the code path on the server side when an interrupt is sent. I believe the query can be cancelled, but the exception message will be quite confusing because we didn't expect getting interruption. This can be done with a separate PR.
...roker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pinot/broker/requesthandler/BrokerRequestHandlerDelegate.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/config/InstanceUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/config/InstanceUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/config/InstanceUtils.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java
Show resolved
Hide resolved
pinot-server/src/main/java/org/apache/pinot/server/api/resources/QueryResource.java
Outdated
Show resolved
Hide resolved
pinot-server/src/main/java/org/apache/pinot/server/api/resources/QueryResource.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/query/scheduler/QueryScheduler.java
Outdated
Show resolved
Hide resolved
2a4aeed
to
1405535
Compare
acd3e33
to
de4c666
Compare
de4c666
to
637ad89
Compare
Let's add this new feature into the documentation |
This PR adds the support to list running queries and cancel a query as needed.
As context, Pinot is typically used for low latency + high QPS scenario, so query cancellation hasn't been really needed. But as more and more data gets kept in Pinot, users might start to run exploratory queries over long time window, which may take minutes to finish. Query cancel support makes life easier to Iterate those kinda queries. Timeout is less handy here, as setting it too low aborts the query too soon; setting it too high might let query run off, if the query is not written properly (which often happens while exploring the data).
The key change is the extension in QueryScheduler to track map<queryId, queryFuture>. Essentially, the running query is cancelled by calling queryFuture.cancel(), which firstly interrupts task running on pqr thread, which then interrupts tasks running on pqw threads.
The other changes are for adding
GET /queries
andDELETE /query/<queryId>
rest APIs on broker, which callsDELETE /query/<queryId>
on servers via the MultiHttpMethod util to cancel the query that may be running on multiple servers.In this PR, each broker tracks the running queries submitted to it, and not knowing the queries tracked by other brokers. So as next step, may also add the two rest APIs on controller, so that users can have cluster wide view of the running queries and cancel them from controller.
Release Notes
A new config to turn on and off the query cancellation feature on server and broker side