mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5612] Boot-time gallery recovery loads every chat with images into memory #3110
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#3110
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 28, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5612
Originally assigned to: @kolacheee on GitHub.
What happens
recoverGalleryImages(packages/server/src/services/image/gallery-recovery.ts:19-60, called at boot fromapp.ts:23) walks every chat directory underdata/gallery/and runs achat_imagesquery scoped to that chat. Each query is perfectly scoped — but loading any row for a chat pulls that chat's entire storage unit into memory (all 17 lazy tables' shards for it). So on an install where most chats have generated images, boot loads nearly every chat unit back into memory, quietly reproducing the eager-boot behavior #5592 removed. Eviction then has to claw it all back down afterward (and can't, for anything pinned or above the cap during the scan).This never shows up in a query audit because no individual query is wrong — the problem is that the scan visits every chat.
Try it yourself
On an install with images in many chats, set
MARINARA_MAX_RESIDENT_CHATS=8and watch memory during startup: it climbs to roughly the old eager-boot level while the gallery scan runs, before eviction trims it back.Possible directions (whichever fits best)
filePaths per directory, which could come from a small on-disk index instead of loading chat units.Found during the residual-lease audit for #5611 / #5592.
@kolacheee commented on GitHub (Aug 29, 2026):
Taking this one (kolacheee, agent-assisted) — PR incoming.