Repository navigation
fix(pools): read a pool's capabilities under the lock in Supports - #134
Merged
Merged
Conversation
Supports looked the entry up under the read lock, then read e.caps after releasing it, while Refresh's probe goroutines rewrite caps under the write lock. Copy the adapter and capabilities before unlocking. The other Manager methods already read entry fields under the lock; e.adapter is set only when an entry is created, so Refresh's unlocked read of it is safe. TestSupportsDuringRefresh fails under -race without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jalil <reachjalil@gmail.com>
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.
What
Manager.Supportslooked the pool entry up underm.mu.RLock(), then reade.capsafter releasing it.Refresh's probe goroutines writee.caps(and capacity/health fields) underm.mu.Lock(), so the two raced. It showed up intermittently ingo test -race -tags experimental_adapters ./internal/loadsim/under load (TestKeptSandboxesHibernateAndWake,TestDisableAPoolLive, viaScheduler.ReleasesSlot).Supportsnow copies the adapter and capabilities before unlocking; the fallbackCapabilitiescall still runs unlocked. The otherManagermethods already read entry fields under the lock.e.adapteris set only when an entry is created and never mutated, soRefresh's unlocked read of it is safe.Proof
TestSupportsDuringRefreshrunsRefreshandSupportsconcurrently: it reportsDATA RACEand fails without the fix, and passes with it (-race -count=20).go test -race -count=3 -tags experimental_adapters ./internal/loadsim/passes.make verifypasses (includesinternal/serveracceptance tests).make test-postgres(no change tointernal/storeorinternal/server).🤖 Generated with Claude Code