-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Remove SqlQueryScheduler#abort method #13416
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,20 +201,6 @@ private SqlQueryExecution( | |
| tableExecuteContextManager.unregisterTableExecuteContextForQuery(stateMachine.getQueryId()); | ||
| }); | ||
|
|
||
| // when the query finishes cache the final query info, and clear the reference to the output stage | ||
| AtomicReference<SqlQueryScheduler> queryScheduler = this.queryScheduler; | ||
| stateMachine.addStateChangeListener(state -> { | ||
| if (!state.isDone()) { | ||
| return; | ||
| } | ||
|
|
||
| // query is now done, so abort any work that is still running | ||
| SqlQueryScheduler scheduler = queryScheduler.get(); | ||
| if (scheduler != null) { | ||
| scheduler.abort(); | ||
| } | ||
| }); | ||
|
|
||
| this.remoteTaskFactory = new MemoryTrackingRemoteTaskFactory(requireNonNull(remoteTaskFactory, "remoteTaskFactory is null"), stateMachine); | ||
| this.typeAnalyzer = requireNonNull(typeAnalyzer, "typeAnalyzer is null"); | ||
| this.coordinatorTaskManager = requireNonNull(coordinatorTaskManager, "coordinatorTaskManager is null"); | ||
|
|
@@ -530,13 +516,6 @@ private void planDistribution(PlanRoot plan) | |
| taskDescriptorStorage); | ||
|
|
||
| queryScheduler.set(scheduler); | ||
|
|
||
| // if query was canceled during scheduler creation, abort the scheduler | ||
| // directly since the callback may have already fired | ||
| if (stateMachine.isDone()) { | ||
| scheduler.abort(); | ||
| queryScheduler.set(null); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So was this a race between
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I doubt there any. It looked very weird. Later on there's another check where the scheduler is not getting nullified: https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/execution/SqlQueryExecution.java#L423. |
||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
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.
Do we have test for aborting? Can it be that this listener covers some flow that is not covered by
SqlQueryScheduler?Uh oh!
There was an error while loading. Please reload this page.
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.
Today the
SqlQueryScheduleris responsible of attaching the listeners that terminate the scheduling process upon query completion (due to a failure / cancellation or early finish): https://github.com/trinodb/trino/blob/master/core/trino-main/src/main/java/io/trino/execution/scheduler/SqlQueryScheduler.java#L303.SqlQuerySchedulerattaches the listener before the scheduling process starts and uses an internal lock to prevent race conditions.These listeners do exactly what the abort method does. Having an external listener calling the
abortmethod is not necessary and might be confusing for the readers.