[PR #3372] [CLOSED] [Engine] serve: recreate the vision encoder's work dir when a temp cleaner removed it #4596

Closed
opened 2026-11-07 15:37:43 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3372
Author: @smallmj
Created: 10/20/2026
Status: ❌ Closed

Base: main ← Head: fix/vision-workdir-recreate


📝 Commits (1)

  • 698f3af serve: recreate the vision encoder's work dir on a start when a temp cleaner removed it

📊 Changes

2 files changed (+62 additions, -0 deletions)

View changed files

📝 serve/server.py (+5 -0)
➕ serve/test_vision_dir.py (+57 -0)

📄 Description

[Engine] — the title above starts with the area.

Problem and result

An idle encoder's work dir (%TEMP%\strata-vision-*) sits empty and unheld in the temp directory for as long as the model stays unloaded, and Windows' Storage Sense (or any temp cleaner) removes it there. Every later start then failed on the encoder's cwd with [WinError 267] The directory name is invalid, on every client retry, until the whole server was restarted: work_dir() runs once at the server's start and restart() reuses the stale path.

After the fix, Vision._start() recreates the dir (and drops the encoded-image cache, whose files lived in it) before either the GPU or the CPU-fallback reader is spawned, so an unload/load cycle survives an external removal of the directory.

#3370 (the full evidence chain: production timeline, ruled-out causes, minimal reproduction).

Approach

The check lives in _start, the wrapper, so both the GPU reader and the CPU fallback start against an existing dir. The cache is dropped along with the dir because the cache-hit branch of encode() returns paths without checking they exist — stale entries would hand the engine paths into a directory that no longer exists. No compatibility effects outside the broken case: a dir that exists is left untouched, and work_dir() is the same #480-selected space-free path as before.

Validation

Passed:

  • python3 -m serve.test_vision_dir — both cases (removed dir recreated + cache dropped; intact dir kept with its cache), at e88ee39d + this patch, Ubuntu, CPython 3.12
  • python3 -m serve.test_vision_busy — the existing vision-start tests, no regression (4/4)
  • the equivalent one-line fix has run on the affected production machine (Windows 11, RTX 3090, engine 0.1.45) since 2026-10-20: py_compile clean; the load-after-idle path had been failing daily before the fix

Failed:

  • none observed

Not run:

  • a real GPU encoder start against a removed dir on Windows (the production machine has the fix and has not hit the condition since; the unit test covers the logic with the spawn mocked)
  • CUDA / HIP / SYCL / Metal builds of the engine — the change is serve-side Python only

Limits

The recreated dir is a new directory: anything holding a path into the old one goes stale. The server itself holds no such paths (the cache is dropped with the recreation), and the encoder is spawned fresh in the new dir — so nothing inside the server can observe the switch.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3372 **Author:** [@smallmj](https://github.com/smallmj) **Created:** 10/20/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/vision-workdir-recreate` --- ### 📝 Commits (1) - [`698f3af`](https://github.com/Niko1221/Strata/commit/698f3af02c6021f47b96d72d6006edddf8a1f73c) serve: recreate the vision encoder's work dir on a start when a temp cleaner removed it ### 📊 Changes **2 files changed** (+62 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `serve/server.py` (+5 -0) ➕ `serve/test_vision_dir.py` (+57 -0) </details> ### 📄 Description **[Engine] — the title above starts with the area.** ## Problem and result An idle encoder's work dir (`%TEMP%\strata-vision-*`) sits empty and unheld in the temp directory for as long as the model stays unloaded, and Windows' Storage Sense (or any temp cleaner) removes it there. Every later start then failed on the encoder's cwd with `[WinError 267] The directory name is invalid`, on every client retry, until the whole server was restarted: `work_dir()` runs once at the server's start and `restart()` reuses the stale path. After the fix, `Vision._start()` recreates the dir (and drops the encoded-image cache, whose files lived in it) before either the GPU or the CPU-fallback reader is spawned, so an unload/load cycle survives an external removal of the directory. ## Related discussion #3370 (the full evidence chain: production timeline, ruled-out causes, minimal reproduction). ## Approach The check lives in `_start`, the wrapper, so both the GPU reader and the CPU fallback start against an existing dir. The cache is dropped along with the dir because the cache-hit branch of `encode()` returns paths without checking they exist — stale entries would hand the engine paths into a directory that no longer exists. No compatibility effects outside the broken case: a dir that exists is left untouched, and `work_dir()` is the same #480-selected space-free path as before. ## Validation **Passed:** - `python3 -m serve.test_vision_dir` — both cases (removed dir recreated + cache dropped; intact dir kept with its cache), at e88ee39d + this patch, Ubuntu, CPython 3.12 - `python3 -m serve.test_vision_busy` — the existing vision-start tests, no regression (4/4) - the equivalent one-line fix has run on the affected production machine (Windows 11, RTX 3090, engine 0.1.45) since 2026-10-20: `py_compile` clean; the load-after-idle path had been failing daily before the fix **Failed:** - none observed **Not run:** - a real GPU encoder start against a removed dir on Windows (the production machine has the fix and has not hit the condition since; the unit test covers the logic with the spawn mocked) - CUDA / HIP / SYCL / Metal builds of the engine — the change is serve-side Python only ## Limits The recreated dir is a new directory: anything holding a path into the old one goes stale. The server itself holds no such paths (the cache is dropped with the recreation), and the encoder is spawned fresh in the new dir — so nothing inside the server can observe the switch. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:37:43 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4596
No description provided.