mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2331] [Issue]: Bulk ST import SSE route runs synchronous work via tokio::spawn instead of spawn_blocking, starving the server runtime #1159
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#1159
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 @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2331
Originally assigned to: @Xelvanis on GitHub.
Summary
Severity: Low — Concurrency (server runtime). On the Axum server runtime,
POST /api/import/st-bulk/runspawns the fully-synchronous bulk importer with plaintokio::spawninstead ofspawn_blocking. The importer does fs reads, JSON/PNG decode, and storage writes for potentially hundreds of files with zero.await, so it blocks the tokio worker thread it lands on for the entire (multi-second to multi-minute) import, starving other async tasks. The sibling profile-import route usesspawn_blockingcorrectly, so this is an inconsistency.Expected behavior
Synchronous import work should run inside
tokio::task::spawn_blocking(asprofile_import_upload_streamdoes), forwarding SSE events through the channel, so it does not block an async worker thread.Actual behavior
src-tauri/src/http_server.rs:901-908(import_st_bulk_run_stream):import_stream_callback(imports/service.rs:500) is a plain non-asyncfn→bulk_imports::run_st_bulk_import_*, which has zero.await/spawn_blockingand does fs::read/JSON/image decode + storage writes scaling with file count.marinara-server.rsuses multi-threaded#[tokio::main], so the blocked closure ties up one worker for the import's full duration; genuinely-async peers (e.g.llm_stream) can be starved. The siblingprofile_import_upload_stream(http_server.rs:662) correctly wraps its importer intokio::task::spawn_blocking.Steps to reproduce
POST /api/import/st-bulk/runon a large SillyTavern data dir./apirequests during the import → degraded/stalled until it finishes.Impact area
Environment
b0e5561dLogs, screenshots, or video
Static source audit; cited to file:line above.
Regression notes
Found via static audit of the refactor branch; not verified against main. Admin-gated, server-only (opt-in), and on a multi-core box only 1 worker is blocked; transient availability degradation, no data loss, hence low.
Additional context
Suggested fix: run the synchronous body inside
tokio::task::spawn_blocking, forwarding emitted events through the existing unbounded channel from within the blocking closure — mirroringprofile_import_upload_streamat line 662. Keep the channel send / keep-alive on the async side.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: