[SPARK-58020][PYTHON][TESTS][4.1] Fix flaky test_data_source_writer_with_logging#57100
Open
gaogaotiantian wants to merge 1 commit into
Open
Conversation
…ith_logging The test always expected exactly 2 'TestJsonWriter.write: abort test' logs, but that count is not guaranteed: when the first partition is aborted, the executor cancels the remaining tasks, so whether the second partition logs before cancellation is time sensitive. Split the assertion so abort logs are checked with dropDuplicates, tolerating either 1 or 2 abort logs. This isolates the test-only fix from SPARK-55799 (which also included a worker_io.py change and a simple-worker test suite not backported here).
HyukjinKwon
approved these changes
Jul 8, 2026
dongjoon-hyun
approved these changes
Jul 8, 2026
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 is a test-only fix that isolates the flake fix from SPARK-55799 for
branch-4.1.test_data_source_writer_with_loggingasserted exactly two"TestJsonWriter.write: abort test"log rows. That count is not guaranteed: when the first partition is aborted, the executor cancels the remaining tasks, so whether the second partition logs before cancellation is time sensitive. The assertion is split so abort logs are matched withdropDuplicates(["msg"]), tolerating either 1 or 2 abort logs.Note: SPARK-55799 on master also changed
python/pyspark/logger/worker_io.pyand added aPythonDataSourceTestsWithSimpleWorkersuite. Those are intentionally not included here -- the simple-worker suite depends on theworker_io.pychange, and this PR is scoped to just de-flaking the existing test onbranch-4.1.Why are the changes needed?
The test is flaky on
branch-4.1(e.g. this run failed with[DIFFERENT_ROWS], missing the second abort log). master and branch-4.2 already carry the fix via SPARK-55799; branch-4.1 was never backported.Does this PR introduce any user-facing change?
No.
How was this patch tested?
Existing
test_data_source_writer_with_logginginpyspark.sql.tests.test_python_datasource. The revised assertion passes whether the race produces 1 or 2 abort logs.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 4.8)