Repository navigation
test: fix flaky fork-safety test caused by leaked writable connections - #763
Merged
Merged
Conversation
The fork tests in `test_discarding.rb` failed intermittently when a writable connection leaked by an earlier test was still reachable at fork time. `GC.start` cannot free a reachable connection, so the child emitted the fork-safety warning. Close leaked writable connections before each fork test opens its own. ref: https://github.com/sparklemotion/sqlite3-ruby/actions/runs/31534307777/job/93923543997
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.
Motivation
test_close_does_not_discard_readonly_connectionsfailed intermittently onarm-linux-musl 4.0: the forked child emitted the fork-safety warning, and the test asserts that it does not (test/test_discarding.rb:144).The child warns when any tracked writable connection is still open at fork time (
lib/sqlite3/fork_safety.rb:39). Some tests leave writable connections open, and the fork tests callGC.start(test/test_discarding.rb:125) to free them before forking.GC.startfrees only unreachable objects, so a leaked connection that is still referenced, even conservatively from the machine stack, stays open.Details
Replace
GC.startin the fork tests with a helper that closes every leaked writableSQLite3::Databasebefore the test opens its own connections.