fix(coderd/x/chatd): hoist system prompt fetch out of chat creation transaction (#24369)#24415
Merged
ethanndickson merged 1 commit intorelease/2.32from Apr 16, 2026
Conversation
…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.
deansheather
approved these changes
Apr 16, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Partial backport of #24369 to
release/2.32.Only the
CreateChatfix incoderd/x/chatd/chatd.goapplies here — the second call site insubagent.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
resolveDeploymentSystemPromptcall out of theInTxclosure so the transaction doesn't hold one DB connection while the helper tries to check out another viap.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.