Repository navigation
test(pool): idle-sweep tests wait for the sweep to finish before they end - #310
Merged
Merged
Conversation
… end A sweep publishes HibernateSnap under m.mu, then commits claims.json and appends the usage event outside it, so a test that stopped at hibernated == 1 could return while those writes ran and race the TempDir cleanup (CI: "unlinkat ...: directory not empty"). sweepIdle runs one sweep and waits for its goroutine to exit, which follows every write.
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.
A hibernate publishes
HibernateSnapunderm.mu, and only then commitsclaims.jsonand appends the usage event, outside the lock. Tests that ended onwaitFor(hibernated(m) == 1)could therefore return while those writes were still running, racing thet.TempDircleanup. CI on #309 hit this once:TempDir RemoveAll cleanup: unlinkat .../001: directory not emptyinTestHeldConnectionBlocksIdleSweep.sweepIdle(t, m)runs one sweep and waits for its goroutine to exit, and that goroutine exits after every write the sweep makes. AllidleOncecall sites in the pool tests now use it. The tests that expect a hibernate assert it after the sweep has finished.Test-only; no production change.
go test -race ./pool,make go-lint(10 x0 issues.), andaslon darwin and linux are green. The race needs CI-level CPU contention to show and did not reproduce locally (600 runs on mac, 400 in a 2-CPU linux container), so the fix rests on the ordering inhibernateLocked:commitTransitioncomes first, thenrecordHibernate, thendisarmEgressanddropStale, all inside the sweep goroutine.