mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5097] Media generation has no global concurrency cap — batches can stampede local and paid providers #2820
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#2820
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Aug 15, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5097
Originally assigned to: @kolacheee on GitHub.
What happens
The media-generation queue serialises per connection, and only for callers that opt in: the very first branch of
runMediaGenerationRequestisif (!args.queue) { … return args.task(); }(packages/server/src/services/image/image-generation-queue.ts:43). A batch that fans out across connections — or any caller that doesn't passqueue: true— has no ceiling at all.Generating a batch of images (a zone's worth of tiles and sprites, a storyboard fan-out, a gallery bulk action) can therefore stampede a local ComfyUI/SwarmUI instance (GPU OOM) or fan out unbounded concurrent requests against a paid provider.
Try it yourself
Point image generation at a local ComfyUI and trigger several generations quickly across different surfaces: nothing above the per-connection FIFO (and only for opted-in callers) limits how many requests are in flight at once.
Suggested fix
A process-global concurrency semaphore applied in addition to the existing per-connection FIFO, with a conservative configurable default, admitting non-queued callers too (that is the point — but it is a behavior change for them and should be called out). Two invariants from the existing code must hold: acquire the global permit only AFTER waiting for the per-connection turn (never before, or the two queues can deadlock), and release in
finallyon every path including abort — a leaked permit hangs all generation app-wide with no error, which is the worst available failure mode. Deserves an abort-during-wait and task-throws regression plus a manual soak (storyboard + gallery batch concurrently).From the pixel-RPG exploration roadmap (PR-D3); pre-existing exposure that batch tile generation would make easy to hit. Verified against current
staging.@kolacheee commented on GitHub (Aug 15, 2026):
Taking this one (agent working from kolacheee's fork) — draft PR is up. Worth reading the PR body's review section: the pre-submission adversarial pass found that the naive semaphore would DEADLOCK on the video-fallback path (it re-enters the queue while holding a permit), so the design gained an AsyncLocalStorage re-entrancy guard — which in turn made it safe to enforce the cap inside generateImage itself, closing the gap where game assets/sprites/avatars/storyboards were never routed through the queue at all.