fix: Resolve flaky TestStore_Integration spurious failures #742
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.
Summary
Fixes a race condition in
TestStore_Integration
that was causing spurious test failures at exactly 10.01s.Root Cause
The test has a goroutine race condition where the insert goroutine calls
t.Errorf()
after the main test has completed:done
channelt.Context()
t.Context()
gets cancelledt.Errorf()
after test completionIn Go 1.14+, calling testing methods from a goroutine after the test has finished causes the test to fail.
Evidence
store_test.go:150: insert error: database is locked (5) (SQLITE_BUSY)
Solution
done
channel is closed before treating errors as failuresdefer
to check error channel on any test exit pathdone
closes) are ignored as expectedTest Results
The fix eliminates spurious failures while still catching legitimate insert errors that occur during normal test execution.
Changes
insertErr
channel to capture errors from insert goroutinedefer
to ensure error checking happens on any test exitreturn
statements🤖 Generated with Claude Code