Skip to content

test(plugins): wait for the orphaned session to drop the provision lock - #5218

Merged
Quick104 merged 1 commit into
mainfrom
fix/ci-failure
Nov 23, 2026
Merged

Quick104 merged 1 commit into
mainfrom
fix/ci-failure

Conversation

@Quick104

@Quick104 Quick104 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: N/A (no client-visible change)

TestProvisionWriterOrphanedSessionDB in internal/plugins fails intermittently in the ci / Go DB pins job. It failed on main at dde5ed21c4 with waiting 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. Close returns 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_lock on 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 forbidigo rule bans time.Sleep in tests.

Validation

  • Provision writer DB tests: passed 50 consecutive runs (-count=50) against a local Postgres test database.
  • make lint-changed: 0 issues.
  • gofmt: clean.
  • Local reproduction: not possible. The old test passed 300 of 300 local runs, so the race only shows under CI load. The fix relies on how PostgreSQL releases session advisory locks. CI staying green on this test is the real confirmation.

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 ran make lint-changed, which reported 0 issues.

Risks

None identified. The change only touches a test.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

AI Disclosure

  • Harness: Claude Code
  • Tool(s): Claude Code
  • Model(s): claude-opus-5-5
  • Involvement: AI-assisted
  • Adversarial review: n/a

Note

Make TestProvisionWriterOrphanedSessionDB wait for provision lock release

Adds a waitForProvisionLockRelease helper 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. TestProvisionWriterOrphanedSessionDB now waits for the orphaned session to drop the lock before retrying acquisition.

Macroscope summarized eba8279.

- 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-triage silo-triage Bot added the size/S 0–49 added + deleted lines (all files); change volume, not priority. label Nov 23, 2026
@silo-kody

silo-kody Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.

Reviewing changes in Silo
  • Include the related issue, expected behavior, and validation steps in the PR description.
  • For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
  • For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
  • Follow this repository's AGENTS.md and CONTRIBUTING.md.
  • Request another review with @kody start-review in a PR comment.
  • React with 👍 or 👎 to give feedback on individual suggestions.
Review settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T17:08:15.027800Z eba8279 PR opened
🔒 Security Review ✅ Completed 2026-11-23T17:09:39.032826Z eba8279 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Quick104
Quick104 merged commit a2ec409 into main Nov 23, 2026
13 of 14 checks passed
@Quick104
Quick104 deleted the fix/ci-failure branch November 23, 2026 17:07
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S 0–49 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant