Repository navigation
test(plugins): wait for the orphaned session to drop the provision lock - #5218
Merged
Merged
Conversation
- The old backend releases the advisory lock only when it exits, which happens after the client hangs up. Until then, reacquiring the lock right after Close could fail and make the test flaky. - Before the test reacquires the lock, it now blocks on pg_advisory_lock (5s timeout) and then unlocks.
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
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.
Problem
Related issue: N/A
Validation tasks: none
Other clients: N/A (no client-visible change)
TestProvisionWriterOrphanedSessionDBininternal/pluginsfails intermittently in theci / Go DB pinsjob. It failed on main atdde5ed21c4withwaiting to reacquire the provisioning writer lock. The race is in the test. The provisioning writer code works correctly.The test closes an orphaned connection that holds the provisioning advisory lock, then expects the writer to take the lock straight back.
Closereturns once the client hangs up, but PostgreSQL releases a session advisory lock only when that connection's backend process exits, which happens a moment later. On a busy runner the writer's retry can arrive before the backend exits and find the lock still held.Approach
When the orphan closes, the test now calls a small helper. The helper takes a pool connection, calls
pg_advisory_lockon the same key, and releases the lock as soon as it has it. That call blocks inside PostgreSQL until the old backend gives up the lock, so the test waits for the real state and doesn't poll. The helper has a 5-second timeout so a lock that's never released fails the test rather than hanging it. Nothing else in the test changes.I didn't use a sleep-and-retry loop because the repository's
forbidigorule banstime.Sleepin tests.Validation
-count=50) against a local Postgres test database.make lint-changed: 0 issues.gofmt: clean.Evidence
Nothing visible changes. To check the fix, I ran the provision writer DB tests 50 times in a row on the branch head (
eba82791e2) against a local Postgres test database, and every run passed (ok github.com/Silo-Server/silo-server/internal/plugins). Then I ranmake lint-changed, which reported0 issues.Risks
None identified. The change only touches a test.
Checklist
AI Disclosure
Note
Make
TestProvisionWriterOrphanedSessionDBwait for provision lock releaseAdds a
waitForProvisionLockReleasehelper in provision_hold_writer_db_test.go that blocks until a PostgreSQL session releases the provisioning advisory lock. It uses a pool connection with a five-second context timeout and reports an error if acquisition fails.TestProvisionWriterOrphanedSessionDBnow waits for the orphaned session to drop the lock before retrying acquisition.Macroscope summarized eba8279.