Skip to content

GH-50037: [Python] test_table_uses_memory_pool flaky on macOS 14 job - #50045

Merged
raulcd merged 2 commits into
apache:mainfrom
tadeja:50037-gc.collect
Jun 8, 2026
Merged

GH-50037: [Python] test_table_uses_memory_pool flaky on macOS 14 job#50045
raulcd merged 2 commits into
apache:mainfrom
tadeja:50037-gc.collect

Conversation

@tadeja

@tadeja tadeja commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Rationale for this change

Fixes #50037

What changes are included in this PR?

Add gc.collect() before prior_allocation = pa.total_allocated_bytes() in test_table_uses_memory_pool
and also add to _check_to_pandas_memory_unchanged helper with the same pattern.
Same fix as #44793

Are these changes tested?

Not reproduced locally yet.

Are there any user-facing changes?

No.

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #50037 has been automatically assigned in GitHub to PR creator.

@tadeja tadeja changed the title GH-50037: [Python][CI] test_table_uses_memory_pool flaky on macOS 14 job GH-50037: [Python] test_table_uses_memory_pool flaky on macOS 14 job Jun 3, 2026
@tadeja

tadeja commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator Author

@tadeja
tadeja force-pushed the 50037-gc.collect branch from 3f56ab5 to f8b2a2a Compare June 4, 2026 19:42
@tadeja

tadeja commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator Author

Root cause + deterministic repro

Scanned the suite with Opus and found the "polluter" is parquet/test_dataset.py. Its dataset/filter tests leave small cyclic buffers (64–768 B) reclaimed only gc.collect(), which accumulate in the xdist worker. Occasionally a remnant survives auto-GC into test_table_uses_memory_pool. THere gc.collect() frees it so final total drops below the baseline at start of the test causing AssertionError in CI. Since pa.total_allocated_bytes() is process-global, the fix is to take the baseline after a gc.collect(), same as test_array_uses_memory_pool and #44793.

Repro (disabling auto-GC just removes the rarity, mechanism is unchanged)
File nogc.py:

import gc
def pytest_configure(config): gc.disable()
python -m pytest -n0 -q -p nogc \
  pyarrow/tests/parquet/test_dataset.py \
  pyarrow/tests/test_pandas.py::test_table_uses_memory_pool

--
On main (no fix):

FAILED ../pyarrow/tests/test_pandas.py::test_table_uses_memory_pool - assert 0 == 4736
1 failed, 56 passed, 6 skipped, 1 xfailed in 0.75s

With this PR fix (gc.collect() also before the baseline) makes baseline 0 and tests pass:
57 passed, 6 skipped, 1 xfailed in 0.66s

@tadeja
tadeja marked this pull request as ready for review June 5, 2026 17:49
@tadeja
tadeja requested review from AlenkaF, raulcd and rok as code owners June 5, 2026 17:49

@AlenkaF AlenkaF left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this @tadeja!
I think this is worth merging and keeping track if any more flaky failures happen.

@raulcd any thoughts?

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jun 8, 2026

@raulcd raulcd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I think this is reasonable. Thanks @tadeja

@raulcd
raulcd merged commit bfc9cdb into apache:main Jun 8, 2026
19 checks passed
@raulcd raulcd removed the awaiting committer review Awaiting committer review label Jun 8, 2026
@github-actions github-actions Bot added the awaiting merge Awaiting merge label Jun 8, 2026
@conbench-apache-arrow

Copy link
Copy Markdown

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit bfc9cdb.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 1 possible false positive for unstable benchmarks that are known to sometimes produce them.

@tadeja
tadeja deleted the 50037-gc.collect branch June 9, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python][CI] test_table_uses_memory_pool flaky on macOS 14 job

3 participants