mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3546] [CLOSED] serve: a cached image file is never deleted while a request still needs it #4682
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4682
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?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3546
Author: @usakim97
Created: 10/21/2026
Status: ❌ Closed
Base:
main← Head:f-vision-cache-evict📝 Commits (1)
509e161serve: a cached image file is never deleted while a request still needs it📊 Changes
3 files changed (+157 additions, -5 deletions)
View changed files
📝
serve/server.py(+28 -4)📝
serve/test_server.py(+1 -1)➕
serve/test_vision_cache.py(+128 -0)📄 Description
The failure
A request that sends images encodes them under the FIFO turn, then copies the cached
.svefiles into one combined file after the turn is released. Another request cantake the turn in between, encode enough pictures to evict the first request's entries
(the cache keeps 64), and unlink those files. The first request's
write_temporary(combined, ...)then raisesFileNotFoundErroronread_bytes().Nothing catches it: the handler dies before writing a response, so the client sees a
dropped connection — behind a reverse proxy,
502with an empty body. It reproduceswith a long conversation that resends 30+ frames per turn: measured on a 140k-token
session, every request failed in 2.7 s while the same server answered 200 to curl with
146k-token prompts, 41 MB bodies, images, tools, streaming and h2.
The fix
Vision.hold(paths)/Vision.release(paths): a request holds the files it hasencoded from inside the turn that encoded them until its combined file is written.
Eviction skips held files. This closes the window completely: no request can evict a
file another request has not copied yet.
encode()checkspath.is_file()andencodes the picture again instead of returning a path the caller cannot read (a
Windows temp cleaner can also remove one;
_ensure_diralready covers the wholedirectory disappearing).
release()ends the hold, so the next eviction may take the file.Tests
serve/test_vision_cache.py— 6 tests, no GPU, a fake encoder writes the.sve:a hit is reused; a hit whose file is gone re-encodes; a held file survives 199 evictions
and is evicted after release; a request keeps its own files while it encodes 100
pictures; the map stays at 64; the combined file holds every picture.
serve.test_server.VisionCacheEvictionkeeps passing (its helper gains the newin_usefield). Fullservesuite: 899 tests, the only failure istest_fatal_recovery.test_http_health_and_next_request_recovery, which fails the sameway on unmodified
mainon this machine.Note, not changed here
The 64-entry cache is small for a frame-review session: every turn re-encodes its
pictures. Correctness no longer depends on the size, so this PR leaves the bound alone.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.