[SPARK-58369][CONNECT][TESTS] Introduce a way to SparkConnectServiceKeepAliveSuite to wait until unbinding a port is complete - #57560
Open
sarutak wants to merge 3 commits into
Conversation
Member
Author
|
Both PRs take a different approach. Personally, I prefer this one because it's simpler, but I'll leave it up to the reviewers to decide which solution to adopt. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What changes were proposed in this pull request?
This PR introduce
stopSparkConnectServiceAndUnbind()toSparkConnectServiceKeepAliveSuiteas a way to wait until unbinding a port is complete.Why are the changes needed?
SparkConnectServiceKeepAliveSuite sometimes flakily fails. #57342 tried to fix it but it but it still happens.
https://github.com/apache/spark/actions/runs/30041141074/job/89325300649
The root cause of the issue is that
SparkConnectService.stop()may return before unbinding the port is complete in Linux environment even thoughio.grpc.Server#awaitTermination()is called withinSparkConnectService.stop().We can see this behavior with the following code. With this code,
SparkConnectService.start()may throwBindException.We use Netty in
SparkConnectServiceso the socket is closed inAbstractChannel#doClose(), more specifically in AbstractEpollChannel#doClose() in Linux.doClose()is also called from AbstractChannel#doClose0()In Linux environment,
doClose0()is called asynchronously here becauseEpollSocketChannelUnsafeoverrides prepareToClose() and closeExecutor will be non-null.On the other hand, I don't see
prepareToClose()overridden in any class underio.netty.channel.kqueue. So the flakiness should not affect in Mac environment.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Confirmed that the following code doesn't throw
BindException.Was this patch authored or co-authored using generative AI tooling?
No.