[SPARK-59007][PYTHON][TESTS] Fix flaky Arrow grouped map worker logging tests - #58289
Closed
Yicong-Huang wants to merge 1 commit into
Closed
[SPARK-59007][PYTHON][TESTS] Fix flaky Arrow grouped map worker logging tests#58289Yicong-Huang wants to merge 1 commit into
Yicong-Huang wants to merge 1 commit into
Conversation
…ests to fix flakiness
zhengruifeng
approved these changes
Aug 26, 2026
uros-b
approved these changes
Aug 26, 2026
Member
|
Thank you @Yicong-Huang and @zhengruifeng! |
HyukjinKwon
approved these changes
Aug 27, 2026
Yicong-Huang
added a commit
that referenced
this pull request
Aug 27, 2026
…g tests ### What changes were proposed in this pull request? Wrap the log read-and-assert step of `ApplyInArrowTests.test_apply_in_arrow_with_logging` and `test_apply_in_arrow_iter_with_logging` in `eventually` so it polls until the asynchronously captured worker logs are visible. The `applyInArrow` call that produces the logs stays outside the poll so it runs once. ### Why are the changes needed? Observed on fork CI: the `pyspark-sql` job failed with `[DIFFERENT_ROWS]` (100%) where `spark.tvf.python_worker_logs()` returned no rows instead of the expected two WARNING rows, then re-ran green on the next attempt: https://github.com/Yicong-Huang/spark/actions/runs/32828898783/job/97748219772 Root cause: worker logs are captured asynchronously. Python workers emit log records on stdout; on the JVM side a per-worker `RedirectThread` (`PythonWorkerLogCapture`) drains stdout and only saves the log block to the `BlockManager` once it reads the trailing marker line. That drain runs independently of the query result, which returns over a separate socket channel, so `python_worker_logs()` invoked right after the query can observe zero blocks. Polling the read side waits out the race. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Built with `build/sbt -Phive package` and ran `python/run-tests --testnames 'pyspark.sql.tests.arrow.test_arrow_grouped_map'`; both logging tests and the full module pass. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #58289 from Yicong-Huang/flaky-worker-logs. Authored-by: Yicong Huang <17627829+Yicong-Huang@users.noreply.github.com> Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com> (cherry picked from commit 02cb44f) Signed-off-by: Yicong-Huang <17627829+Yicong-Huang@users.noreply.github.com>
Contributor
Author
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?
Wrap the log read-and-assert step of
ApplyInArrowTests.test_apply_in_arrow_with_loggingandtest_apply_in_arrow_iter_with_loggingin@eventuallyso it polls until the asynchronously captured worker logs are visible. TheapplyInArrowcall that produces the logs stays outside the poll so it runs once.Why are the changes needed?
Observed on fork CI: the
pyspark-sqljob failed with[DIFFERENT_ROWS](100%) wherespark.tvf.python_worker_logs()returned no rows instead of the expected two WARNING rows, then re-ran green on the next attempt: https://github.com/Yicong-Huang/spark/actions/runs/32828898783/job/97748219772Root cause: worker logs are captured asynchronously. Python workers emit log records on stdout; on the JVM side a per-worker
RedirectThread(PythonWorkerLogCapture) drains stdout and only saves the log block to theBlockManageronce it reads the trailing marker line. That drain runs independently of the query result, which returns over a separate socket channel, sopython_worker_logs()invoked right after the query can observe zero blocks. Polling the read side waits out the race.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Built with
build/sbt -Phive packageand ranpython/run-tests --testnames 'pyspark.sql.tests.arrow.test_arrow_grouped_map'; both logging tests and the full module pass.Was this patch authored or co-authored using generative AI tooling?
No.