Skip to content

fix(coderd/x/chatd): hoist system prompt fetch out of chat creation transaction (#24369)#24415

Merged
ethanndickson merged 1 commit intorelease/2.32from
ethan/fix-create-chat-pool-starvation-2.32
Apr 16, 2026
Merged

fix(coderd/x/chatd): hoist system prompt fetch out of chat creation transaction (#24369)#24415
ethanndickson merged 1 commit intorelease/2.32from
ethan/fix-create-chat-pool-starvation-2.32

Conversation

@ethanndickson
Copy link
Copy Markdown
Member

@ethanndickson ethanndickson commented Apr 16, 2026

Partial backport of #24369 to release/2.32.

Only the CreateChat fix in coderd/x/chatd/chatd.go applies here — the second call site in subagent.go (createChildSubagentChatWithOptions) doesn't exist on this branch since the child-subagent-chat creation path was added after the branch cut.

The fix hoists the resolveDeploymentSystemPrompt call out of the InTx closure so the transaction doesn't hold one DB connection while the helper tries to check out another via p.db. Under concurrent chat creation load this pattern can cause pool starvation.

This is not urgent enough to warrant an immediate patch release — the bug only manifests under high concurrent chat creation load. It should be fine to ride along with the next scheduled 2.32.x patch.

…ransaction

Backport of the CreateChat fix from #24369.

resolveDeploymentSystemPrompt was called inside the InTx closure in
CreateChat. That method uses p.db (the root store) internally, which
requires a second DB pool checkout while the transaction already holds
one connection. Under concurrent chat creation load this causes pool
starvation.

Move the system prompt fetch before the transaction so the InTx
closure only uses the tx handle.
@ethanndickson ethanndickson marked this pull request as ready for review April 16, 2026 05:26
@ethanndickson ethanndickson changed the title fix(coderd/x/chatd): hoist system prompt fetch out of chat creation transaction fix(coderd/x/chatd): hoist system prompt fetch out of chat creation transaction (#24369) Apr 16, 2026
@ethanndickson ethanndickson merged commit 6219191 into release/2.32 Apr 16, 2026
52 of 54 checks passed
@ethanndickson ethanndickson deleted the ethan/fix-create-chat-pool-starvation-2.32 branch April 16, 2026 06:39
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants