-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-53339][CONNECT] Fix an issue which occurs when an operation in pending state is interrupted #52083
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
Open
sarutak
wants to merge
7
commits into
apache:master
Choose a base branch
from
sarutak:SPARK-53339
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[SPARK-53339][CONNECT] Fix an issue which occurs when an operation in pending state is interrupted #52083
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d4c7abd
Prevent from interruption when an operation status is pending
sarutak 223d608
Add test
sarutak bcb8a70
Modify the comment to be consistent with the change
sarutak b7430bd
Fix style
sarutak 14ed938
Protect status transition by lock
sarutak 029e3ef
Remove SparkConnectExecuteHolderSuite
sarutak 0173cf7
Merge branch 'master' of https://github.com/apache/spark into SPARK-5…
sarutak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../src/test/scala/org/apache/spark/sql/connect/service/SparkConnectExecuteHolderSuite.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.spark.sql.connect.service | ||
|
|
||
| import java.util.UUID | ||
|
|
||
| import org.scalatestplus.mockito.MockitoSugar | ||
|
|
||
| import org.apache.spark.SparkFunSuite | ||
| import org.apache.spark.connect.proto | ||
| import org.apache.spark.connect.proto.{ExecutePlanRequest, Plan, UserContext} | ||
| import org.apache.spark.sql.test.SharedSparkSession | ||
| import org.apache.spark.util.ManualClock | ||
|
|
||
| class SparkConnectExecuteHolderSuite | ||
| extends SparkFunSuite | ||
| with MockitoSugar | ||
| with SharedSparkSession { | ||
|
|
||
| val DEFAULT_CLOCK = new ManualClock() | ||
| val DEFAULT_USER_ID = "1" | ||
| val DEFAULT_USER_NAME = "userName" | ||
| val DEFAULT_SESSION_ID = UUID.randomUUID.toString | ||
| val DEFAULT_QUERY_ID = UUID.randomUUID.toString | ||
| val DEFAULT_CLIENT_TYPE = "clientType" | ||
|
|
||
| test("SPARK-53339: ExecuteHolder should ignore interruption when execute status is Pending") { | ||
| val executeHolder = setupExecuteHolder() | ||
| executeHolder.sessionHolder.eventManager.postStarted() | ||
|
|
||
| assert(executeHolder.eventsManager.status == ExecuteStatus.Pending) | ||
| assert(!executeHolder.interrupt()) | ||
|
|
||
| executeHolder.eventsManager.postStarted() | ||
| assert(executeHolder.eventsManager.status == ExecuteStatus.Started) | ||
| assert(executeHolder.interrupt()) | ||
| } | ||
|
|
||
| def setupExecuteHolder(): ExecuteHolder = { | ||
| val relation = proto.Relation.newBuilder | ||
| .setLimit(proto.Limit.newBuilder.setLimit(10)) | ||
| .build() | ||
|
|
||
| val executePlanRequest = ExecutePlanRequest | ||
| .newBuilder() | ||
| .setPlan(Plan.newBuilder().setRoot(relation)) | ||
| .setUserContext( | ||
| UserContext | ||
| .newBuilder() | ||
| .setUserId(DEFAULT_USER_ID) | ||
| .setUserName(DEFAULT_USER_NAME)) | ||
| .setSessionId(DEFAULT_SESSION_ID) | ||
| .setOperationId(DEFAULT_QUERY_ID) | ||
| .setClientType(DEFAULT_CLIENT_TYPE) | ||
| .build() | ||
|
|
||
| val sessionHolder = SessionHolder(DEFAULT_USER_ID, DEFAULT_SESSION_ID, spark) | ||
| val executeKey = ExecuteKey(executePlanRequest, sessionHolder) | ||
| new ExecuteHolder(executeKey, executePlanRequest, sessionHolder) | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
According to the function description,
falseis already occupied for the status where it was already interrupted.For the code change, according to the state transition, can we change the status to
ExecuteStatus.Canceledstatus directly from the currentExecuteStatus.Pendingbecause it's not started yet? In this case, we can returntrue.spark/sql/connect/server/src/main/scala/org/apache/spark/sql/connect/service/ExecuteEventsManager.scala
Lines 38 to 47 in 79a0ca7
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.
Actually, that was my first idea to solve this issue. But as I mentioned in the description, I found that didn't work because transitioning from
PendingtoCanceledcauses another issue.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.
Hmm, if it's OK to ignore interruption to a pending state operation and we need exactly tell
already interruptedfrominterruption failed, how about returning the exact interruption result rather thanboolean?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.
Got it. Thank you. As long as the code and description are consistent, I'm okay for both. (1) Updating the description by changing the meaning of
falseand (2) changing the return types.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.
Thank you for your suggestion. I'll simply update the description.