Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- On Windows, have a
state.sqlitefrom before 0.1.0 next tostatev2.sqlitein%USERPROFILE%\.t3\userdata. - Stop the server, so nothing else has either database open.
- Run
t3 doctorand select Delete the database from before 0.1.0.
Expected behavior
Doctor deletes state.sqlite and its -wal and -shm files.
Actual behavior
The step fails with LegacyDatabaseRemoveError caused by EBUSY: resource busy or locked, unlink '...\state.sqlite'. The file stays on disk, and t3 doctor --dry-run keeps offering the repair.
No other process had the file open. Right after doctor exited, [IO.File]::Open(path, 'Open', 'ReadWrite', 'None') on state.sqlite succeeded, and Remove-Item deleted it.
The lock comes from doctor itself. removeLegacyDatabase in apps/server/src/persistence/DatabaseMaintenance.ts runs lockExclusively(legacy), then fs.remove(legacy + suffix), all inside Effect.provide(NodeSqliteClient.layer({ filename: legacy })). The SQLite connection, with locking_mode = EXCLUSIVE, stays open while the file is removed. POSIX allows unlinking an open file, so this works on Linux. Windows refuses, because SQLite does not open the file with FILE_SHARE_DELETE.
On Linux the same repair works. On two Linux machines on the same nightly, the reclaim step and --dry-run behave as expected.
Impact
Minor bug or occasional failure
Version or commit
0.1.3-nightly.20261023.3566. The code is unchanged on main @ 30a405b.
Environment
Windows 11, desktop app T3 Code (Nightly), t3 CLI from t3 update --channel nightly.
Logs or stack traces
Reclaiming database space. This can take several minutes...
Done: 2.85 GiB -> 2.76 GiB, 175 superseded events removed.
ERROR (#2): LegacyDatabaseRemoveError: Could not delete the database from before 0.1.0. Check that this user can write to the data directory.
at DatabaseMaintenance.removeLegacyDatabase (file:///C:/Users/<user>/.t3/runtime/versions/0.1.3-nightly.20261023.3566/t3.exe:120242:23)
at runDoctor (file:///C:/Users/<user>/.t3/runtime/versions/0.1.3-nightly.20261023.3566/t3.exe:120253:10)
[cause]: PlatformError: Busy: FileSystem.remove (C:\Users\<user>\.t3\userdata\state.sqlite)
[cause]: Error: EBUSY: resource busy or locked, unlink 'C:\Users\<user>\.t3\userdata\state.sqlite'The error message also points the wrong way. It says to check write permission, but the cause is doctor's own open handle.
Workaround
After doctor exits, delete state.sqlite, state.sqlite-wal, and state.sqlite-shm by hand with the server stopped.
Activity
juliusmarminge commentedon Nov 9, 2026
Thanks for the detailed report! #27629 fixes the Windows deletion failure by closing the doctor’s SQLite connection before unlinking, in 1d626d0.