Repository navigation
Description
Summary
Unsloth Studio (Windows desktop) floods the Windows Recycle Bin with *.db-wal / *.db-shm files every second while a training run is active. In ~90 minutes of training it wrote well over 10,000 entries (~40 MB) into C:\$Recycle.Bin\<SID>\. The behaviour looks like malware-style file thrashing, but it is Unsloth Studio's own temporary-file cleanup deleting sidecar files into the Recycle Bin instead of unlinking them.
Environment
- OS: Windows 11 x64, local install
- Studio backend: many instances of
unsloth.exe studio --api-only -H 127.0.0.1 -p 8888..8908 - Packages: unsloth / unsloth_zoo installed in Studio's venv at
C:\Users\ANGEL\.unsloth\studio\unsloth_studio - Reproduced during an active training job (trainer summary written every second, step ~268/3357, ETA ~85 min)
Reproduction
- Start any training run in Studio that touches a sqlite-backed component (knowledge / RAG index).
- Watch
C:\$Recycle.Bin\<SID>\while training runs: roughly every second a new$R*.db-wal(0 bytes) +$R*.db-shm(32 KB) pair appears with its$Imetadata.
Evidence (decoded $I metadata, Win10 v2 format)
- Original path recorded in
$I:C:\Users\ANGEL\.unsloth\... - Deleted-at timestamps: batches all stamped per-second during training (e.g. 2026-10-27 13:10:34)
- 1,299
$Ifiles present in one sample; measured +~50 files per 30 s while training was live - The files are not removed permanently — they are recoverable-deleted into the Recycle Bin, which is exactly the bug: Studio's cleanup path sends temporary sqlite WAL/SHM sidecars to the Recycle Bin instead of a permanent unlink.
Root-cause hypothesis
A sqlite database under .unsloth is opened/closed repeatedly during training (likely the studio knowledge/RAG index). SQLite WAL mode creates <db>-wal / <db>-shm sidecars on each connection; a Studio cleanup path treats them as deletable and removes them via the Recycle Bin (recoverable delete) rather than unlink(). At per-second churn this explodes the Recycle Bin and adds double I/O per step.
Code search notes: the unsloth package has no trash-API hits; the studio package only mentions $Recycle.Bin in a protection list (library.py:1766), so the actual move-to-trash call is likely in a helper or the Tauri/Rust side.
Impact
- Recycle Bin grows by tens of thousands of entries per training run; when the per-volume cap is hit, older (possibly user-recoverable) items get silently purged.
- Unnecessary disk I/O on every training step.
- Antivirus / EDR may flag the mass-delete pattern as ransomware behaviour.
Suggested fixes
- Delete temp sqlite sidecars (and other temp files the app itself creates) with
os.remove()/ unlink — only user-initiated deletions should be recoverable. - Keep the sqlite connection open for the whole run instead of per-step open/close, or use
journal_mode=DELETE/:memory:for transient data. - At minimum, skip the Recycle Bin for anything under the app's own temp/staging directories.
Workaround for affected users
A scheduled task that empties Recycle Bin entries whose original path is under .unsloth every few minutes stops the growth; manually deleted files under other paths can still be kept with a retention window. This is a stopgap, not a fix.
Activity
fr303388 commentedon Oct 27, 2026
danielhanchen commentedon Oct 28, 2026
Sorry will fix this asap
fr303388 commentedon Oct 28, 2026
Title: Read-Only Flag on rag.db — Why and What It Does
Context
database also creates two companion files:
during normal use; when they are cleaned up (or the app is restarted),
Windows treats each deletion as "send to Recycle Bin", which floods the
Recycle Bin with junk entries.
What was done
Effect (temporary)
write transactions can start.
repeated "delete → Recycle Bin" debris is produced.
Important notes
present; read-only on the .db does not remove them.
(last modified 2026-10-28 16:50), so the files are not guaranteed to
stay untouched while any process merely opens the DB.
clear the Read-only attribute first, otherwise writes will fail.
Status check (verified 2026-10-28)
danielhanchen commentedon Oct 28, 2026
Fixed! Each idle Studio backend opened and closed its knowledge-base database (rag.db) several times every 30 seconds, and every close made SQLite delete and recreate rag.db-wal and rag.db-shm. With many backends running, that turned into a delete every second or so, and your system sent each one to the Recycle Bin. Studio now keeps one quiet connection open, so those files stay in place instead of being thrown away and remade. Fixed in #15719.
To update: Unsloth Desktop will have an update banner. For Studio, use
unsloth studio update. For Docker, usedocker exec <container> unsloth-studio-update. Reopen if it still happens.Keep RAG WAL sidecars between database operations (unslothai#15719)