Skip to content

fix(bigquery): [WIP] add gc.collect before socket leak test to reduce flakiness - #17949

Closed
chalmerlowe wants to merge 1 commit into
mainfrom
fix/bigquery-socket-leak-gc-fix
Closed

fix(bigquery): [WIP] add gc.collect before socket leak test to reduce flakiness#17949
chalmerlowe wants to merge 1 commit into
mainfrom
fix/bigquery-socket-leak-gc-fix

Conversation

@chalmerlowe

Copy link
Copy Markdown
Contributor

Problem

The system test test_dbapi_connection_does_not_leak_sockets can be flaky, failing with assertions that more sockets are open at the end than at the start. This is often caused by non-deterministic garbage collection of sockets from previous tests running in the same process, which are finally collected during the test execution, or background noise that wasn't cleaned up before the test started.

Solution

Added gc.collect() explicitly at the very beginning of test_dbapi_connection_does_not_leak_sockets, before taking the initial socket count (conn_start). This ensures a cleaner baseline and reduces false positives caused by delayed cleanup from other tests.

Notes to Reviewers

This is a standard pattern for stabilizing process-wide socket count assertions in noisy test environments (like parallel execution with pytest-xdist). It complements the previous fixes that ensured explicit closure of channels and releasing of references.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a garbage collection call (gc.collect()) at the start of the test_dbapi_connection_does_not_leak_sockets test to clean up resources from previous tests and prevent false positives during socket leak detection. There are no review comments, and I have no additional feedback to provide.

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.

1 participant