[SPARK-54925][PYTHON] Add the capability to dump threads for pyspark #53705
+79
−2
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?
Add an optional capability to dump thread info of all pyspark processes. It is intentionally hidden now because it's not fully polished. It can be used as
python -m pyspark.threaddump -p <pid>. It requirespystackandpsutil. Without these libraries the command will fail.For now it was only used when test hangs. The result would be like:
Notice that it has not only the driver process, but also daemon and worker process. The plan is to incorporate this into our existing debug framework so
threaddumpbutton will return both JVM executor threads and python worker threads.Why are the changes needed?
We need insights into python worker/daemon.
We have some thread dump capability in our test, but that's not stable.
SIGTERMsometimes is hooked andfaulthandlercan't work properly. Also it can't dump the subprocesses.Does this PR introduce any user-facing change?
Yes, but it's hidden for now. A new command entry is introduced.
How was this patch tested?
Locally it works.
Was this patch authored or co-authored using generative AI tooling?
No.