fix(runtime): avoid bounded dispatch channel stalls#5015
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
Code Review: fix(runtime): avoid bounded dispatch channel stalls Overview This PR converts 12 bounded Transaction channels (Postgres + RocksDB) — correct fix Each transaction command is paired with a one-shot response channel, so the caller already blocks waiting for the reply before issuing the next command. Natural backpressure exists at the application level, so the bounded channel served no real purpose and only introduced a deadlock surface if the transaction task was busy and the queue filled up. Unbounded is right here. Pegboard gateway message forwarding — acceptable, with a note The in-flight request channels were bounded at 128. Converting to unbounded means that if a WebSocket client is slow (network congestion, backpressure from the browser), tunnel messages pile up with no limit. The UDB changelog entry channel — most concerning The old bound was 10,000 entries. This channel sits between a reader task (fast: scanning FDB changelog) and a writer task (slower: re-applying entries in txn-bounded batches). If the writer falls behind on a large replay, entries now accumulate without bound. For large datasets this could cause significant memory pressure. A semaphore-based permit system could cap in-flight entries while still avoiding blocking. Minor issues
CLAUDE.md notes that actor-owned dispatch producers should use Summary
The core fix (avoiding blocked sends on full bounded channels) is sound. The main gap is the UDB entry channel having no memory bound during replays. |

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: