GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix(server): a locked database no longer leaves a thread stuck in "starting" by ReneFr81 · Pull Request #26626 · pingdotgg/t3code Conversation
|
| effect | status | attempts | created | completed |
|---|---|---|---|---|
provider-runtime.continue (source run 2507) |
succeeded | 2 | 15:57:19 | 17:03:34, after the next restart |
provider-turn.start run 2508 |
cancelled, never claimed | 0 | 15:58:16 | 16:59:02, "interrupted before its provider turn started" |
provider-turn.start run 2516 |
cancelled, never claimed | 0 | 16:59:03 | 17:03:18, server shutdown |
provider-turn.start run 2517 |
succeeded | 1 | 17:03:35 | 17:03:48 |
Run 2508 stayed starting from 15:58:16 until it was stopped at 16:59. Eight more runs (2509–2516) queued behind it. After the stop, the next one to start, run 2516, stalled the same way. The second restart requeued the stranded continuation, and the thread worked again. The same day, a second server showed the same symptom after an upgrade restart, and a further restart cleared it there too.
Regression test keeps requeueing a failed claim while the database is locked in apps/server/src/orchestration-v2/EffectWorker.test.ts mirrors this sequence: execution fails, the next three outbox writes return LockTimeoutError, and the fourth succeeds.
vp test run src/orchestration-v2/EffectWorker.test.ts gives Tests 1 failed | 11 passed (12); AssertionError: expected false to be true because the row was never requeued.60511c1 passed all 12 tests. The shutdown regression interrupts $name settlement retries when the worker shuts down covers both requeue and terminalize: interrupt the real daemon while fallback writes remain locked, and require shutdown within 100 ms of test-clock time, before releasing the lock. With EffectWorker.ts restored to 60511c1, vp test run src/orchestration-v2/EffectWorker.test.ts -t 'settlement retries when the worker shuts down' gives Tests 2 failed | 12 skipped (14), both at the shutdown assertion. With this follow-up fix, both cases pass.apps/server, vp test run src/orchestration-v2/EffectWorker.test.ts: Tests 14 passed (14), including the original lock regression, which also checks that immediate failures are spaced before eventual recovery.apps/server, vp test run src/orchestration-v2/EffectWorker.test.ts src/orchestration-v2/FoundationPersistence.test.ts src/orchestration-v2/RestartContinuation.test.ts: Test Files 3 passed (3), Tests 104 passed (104).vp run check:changed: format, lint, both knip passes, GraphQL generation, typecheck (3 packages) and tests all pass.Two servers built from source, base 9e09926d and this branch 60511c1, each with the same seeded thread whose previous run needs a restart continuation, and the Replay provider (no model calls). A separate process held a real write lock on statev2.sqlite, timed by a test preload hook to overlap the worker's settle and requeue of the continuation, so both builds hit genuine SQLITE_BUSY failures. The lock was then released and a new message sent.
Before (9e09926d) |
After (60511c1) |
|
|---|---|---|
| Thread | ![]() |
![]() |
Outbox and runs (read-only sqlite3) |
![]() |
![]() |
Not checked: what held the writer lock for over 15 s after startup in the original incident.
Door: two-way. A revert restores the old give-up behaviour, and no data or schema changes.
Blast radius: narrow. The fallback settlement writes keep one worker occupied until the lock clears or shutdown interrupts it. The 100 ms spacing adds a short delay after each lock failure. Shutdown may leave its row running; startup reconciliation already handles that state. Claim ordering and lease semantics are unchanged.
None.
retry, succeed and fail writes still give up on the first lock timeout before handing off to these fallbacks. That costs one more 5 s wait and the original backoff delay, but no row is stranded.Written with Claude Opus 5.5 in Claude Code; live reproduction, screenshots and shutdown retry fix with GPT-6.1 Sol in Codex.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
… stalls its thread When an effect fails and the worker's write to requeue it hits SQLite's lock timeout, the worker logged the error and dropped the claim. The row stayed `running`, and a running row blocks every later effect on its thread, so the next run's provider-turn.start was never claimed and the thread sat in "starting" until the server restarted again. The fallback requeue and terminalize writes now retry while the failure is a lock timeout. Only the claiming worker can settle its row, and each lock timeout has already waited out busy_timeout.
| delayMs: 0, | ||
| }) | ||
| .pipe( | ||
| retryWhileLocked, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🟠 High orchestration-v2/EffectWorker.ts:665
If settlement fails while the lock remains busy, retryWhileLocked in both requeueClaim and terminalizeClaim keeps retrying after shutdown interrupts the worker, so the daemon's worker group can hang until the lock clears. The Cause.hasInterruptsOnly(cause) checks only the original failure; make these retries interruptible or otherwise bound their shutdown lifetime.
In file @apps/server/src/orchestration-v2/EffectWorker.ts around line 665:
If settlement fails while the lock remains busy, `retryWhileLocked` in both `requeueClaim` and `terminalizeClaim` keeps retrying after shutdown interrupts the worker, so the daemon's worker group can hang until the lock clears. The `Cause.hasInterruptsOnly(cause)` checks only the original failure; make these retries interruptible or otherwise bound their shutdown lifetime.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Confirmed: Effect's onError handlers run uninterruptibly, so the original failure's interrupt check did not protect a later settlement retry. In bcba32c, the shared retry helper explicitly restores interruption, so shutdown can stop both fallback paths while the lock is still held. The regression interrupts $name settlement retries when the worker shuts down fails for both requeue and terminalize on 60511c1 and passes with the fix; it interrupts the real daemon and requires it to stop within 100 ms of test-clock time before releasing the lock.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
ApprovabilityVerdict: Needs Human Approval Macroscope's review found this PR requires human approval — The change retries database-lock failures during effect settlement so threads can recover from contention. The unresolved finding identifies retries that can hold up worker shutdown until the lock clears; their shutdown lifetime needs resolution. Needs human approval because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Retry settlement after lock timeouts apps/server/src/orchestration-v2/EffectWorker.ts, apps/server/src/orchestration-v2/EffectWorker.test.ts |
EffectWorker retries requeue and terminalization settlement operations after SQL lock timeouts. Tests cover repeated requeue timeouts and interruption of in-flight settlement retries during worker shutdown. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related PRs
Suggested reviewers: juliusmarminge, t3dotgg, macroscopeapp
bcba3Settlement retries are interruptible, and no merge-blocking issue was identified.
Explanation
The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the failure mode, implementation, scope rationale, regression tests, live reproduction, limitations, and merge impact.
Comment @coderabbitai help to get the list of available commands.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
apps/server/src/orchestration-v2/EffectWorker.ts-604-605: 1
604-605:Major · Performance & Scalability · Quick win
⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.Add a delay between lock-timeout retries.
If SQLite returns a lock error without waiting,
Effect.retryimmediately repeats the settlement write. SQLite can bypass its busy handler when waiting could cause a deadlock. A sustained lock can therefore make this worker issue rapid database writes. Add a retry schedule with a delay; keep the lock-timeout predicate. (sqlite.org)
007cfb6f-b413-4e3f-9f61-a303fc4cd5deapps/server/src/orchestration-v2/EffectWorker.test.tsapps/server/src/orchestration-v2/EffectWorker.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Error cleanup masks interruption, so settlement retries could keep the worker group alive until SQLite released its lock. Restore interruption and space lock retries by 100 ms to avoid spinning on immediate errors.
|
Added 100 ms spacing between lock-timeout retry attempts, keeping the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.