Repository navigation
Replies: 1 comment
|
Still there on main as of a8777e4. t3code/apps/server/src/orchestration-v2/EffectWorker.ts Lines 640 to 657 in a8777e4 went through the open prs to see if anything already covers this. closest ones:
none of them put a timeout on the start itself, so your fix 1 looks like the missing piece. fix 2 is separate from all of them too. are you planning to open the pr? if you don't have time i'm happy to pick up fix 1. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
A thread on my self-hosted server (
t3 serve, v0.1.7-sync.16, Claude Agent provider) stopped responding for about 5 hours. No error appeared anywhere. The UI showed the thread asstarting. Fifteen later messages piled up asqueuedbehind it, including hourly scheduled-task messages. Nothing in-process ever recovered it. I cleared it by hand witht3_thread_interrupt.I think this is a separate path from #16636, #17825 and #30193, and from the one PR #26626 fixes. Below are the timeline, the root cause as far as I can trace it, and some suggested fixes. Line numbers refer to
322f6544.What happened (UTC)
result success,command_lifecycle completed).thread-send.provider-turn.starteffect for run 229 is claimed (statusrunning, attempt 1).event-loop-stalls.ndjsonrecordsdelayMaxMs: 4377,rssMb: 1017.query.close, reason idle_timeout). Run 229 is stillstarting.queued.t3_thread_interrupt(withoutstop) on run 229 marks itinterruptedand cancels the effect. Run 230 starts at once.When I looked, the stuck
provider-turn.startrow was the only pending or running row inorchestration_v2_effect_outboxon the whole server. Effects on other threads kept succeeding throughout.Root cause
1.
provider-turn.starthas no timeout.EffectWorker.ts:785-791racesexecutor.execute(effect)only against cancellation.boundExecution(:581-602), covers onlydelegated-tasks.stop. Its own comment says a running effect "blocks later work on its thread and its lease is never reclaimed in-process".EffectOutbox.ts:325-331, arunningrow blocks every later effect on the same thread.ProviderTurnStartService.startnever returns, the thread is dead until the server restarts.2. Which await hung (inferred, not certain). The session was touched at about 02:10:55 and closed exactly 30 minutes later. That suggests
providerSessions.open()returned, and the hang falls betweenopen(ProviderTurnStartService.ts:798) andmarkBusyinstartTurn(ProviderSessionManager.ts:1834). None of the awaits in that window has a timeout: resume/load from provider, transcript state, history and handoff, and the event writes. This thread's Claude transcript is very large, about 420 MB, which fits the 4.4 s event-loop stall. A stall alone does not explain a hang that never ends, though, and the trace logs had already rotated.3. The idle release does not see a start that is still in progress.
releaseIfStillIdle(ProviderSessionManager.ts:1114-1185) checks only the in-memorybusyTurnsand the idle generation. A run instartinghas not calledmarkBusyyet, so the session was released while a turn for it was still mid-start.4. No in-process recovery.
ProviderRuntimeRecoveryServicereconciles stalestartingruns only at startup or shutdown (serverRuntimeStartup.ts:478and:544).ThreadSettlementServicesweep does not handle runs.RestartContinuationonly handles runs that haverestartContinuationOfRunId.Suggested fixes
provider-turn.start(and probablyprovider-turn.restart) inboundExecution, for example with a 5-minute limit. On timeout, fail the attempt so the existing retry runs. On the last attempt, terminalize the run the same way an interrupt-before-start does, so the queue moves on. ThewriteIfRunCurrentandisCurrentAttemptInStatusguards should already throw away a late result from the abandoned fiber.releaseIfStillIdle. For example, hold an in-flight counter fromopen()untilstartTurneither settles or fails.startingfor longer than N minutes while their effect lease is stale. This is a backstop for any other await that might hang.Notes on unsticking a thread by hand
thread.stopwithholdQueue: true(Orchestrator.ts:11948). It clears the stuck run but then holds the queue, so queued messages still don't run until the user resumes the queue. That is surprising when the goal is to get a stuck thread moving again.thread.interrupt.unresponsiveneeds a provider turn, so it does nothing for a run stuck instarting.t3 thread interrupt. I had to start a throwaway agent thread just to call thet3_thread_interruptMCP tool.I have a local patch in progress for fixes 1 and 2.
All reactions