You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky test: test_delete_object_failure_is_swallowed fails on Python 3.12.13 CI runners #5245
The pyamber test TestCleanupFailedUpload::test_delete_object_failure_is_swallowed fails intermittently on CI. It is timing/GC-dependent, so it passes locally but trips on CI runners under load.
The test expects delete_object to be called once after a simulated upload failure, but on the failing run it's called twice:
AssertionError: Expected 'delete_object' to be called once. Called 2 times.
Root cause is cross-test state leakage, not a Python version regression. The preceding test, test_write_after_upload_error_raises_error, creates a LargeBinaryOutputStream, triggers an upload-thread failure, and does not close the stream. When that leaked stream is garbage-collected, IOBase.del invokes our close(), which calls _cleanup_failed_upload, which does a fresh large_binary_manager._get_s3_client() lookup. If GC happens to fire while test_delete_object_failure_is_swallowed's patch.object(...) is active, the leaked stream's cleanup invokes delete_object on that test's mock_s3. The victim test then runs its own close() and calls delete_object a second time on the same mock assert_called_once_with fails.
This blocks CI nondeterministically on PRs (observed on a docs-only branch that touches no Python code).
FAILED test_large_binary_output_stream.py::TestCleanupFailedUpload::test_delete_object_failure_is_swallowed
AssertionError: Expected 'delete_object' to be called once. Called 2 times.
Calls: [call(Bucket='test-bucket', Key='path/to/object'),
call(Bucket='test-bucket', Key='path/to/object')].
Runner: /opt/hostedtoolcache/Python/3.12.13/x64
Activity
Ma77Ball commentedon May 27, 2026
/take
test: close stream in upload-error test to prevent finalizer leak acr…
fix: keep failed-upload cleanup inside the upload worker (apache#5249)
test: close stream in upload-error test to prevent finalizer leak acr…
fix: keep failed-upload cleanup inside the upload worker (apache#5249)