Skip to content

[SPARK-58020][PYTHON][TESTS][4.1] Fix flaky test_data_source_writer_with_logging#57100

Open
gaogaotiantian wants to merge 1 commit into
apache:branch-4.1from
gaogaotiantian:SPARK-58020-flaky-datasource-writer-logging
Open

[SPARK-58020][PYTHON][TESTS][4.1] Fix flaky test_data_source_writer_with_logging#57100
gaogaotiantian wants to merge 1 commit into
apache:branch-4.1from
gaogaotiantian:SPARK-58020-flaky-datasource-writer-logging

Conversation

@gaogaotiantian

Copy link
Copy Markdown
Contributor

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_logging asserted 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 with dropDuplicates(["msg"]), tolerating either 1 or 2 abort logs.

Note: SPARK-55799 on master also changed python/pyspark/logger/worker_io.py and added a PythonDataSourceTestsWithSimpleWorker suite. Those are intentionally not included here -- the simple-worker suite depends on the worker_io.py change, and this PR is scoped to just de-flaking the existing test on branch-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_logging in pyspark.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)

…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants