You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] State database grows without bound: no way to delete threads, and free space is never reclaimed #46035
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
Use T3 for a long time, or run many delegated tasks (each subagent run becomes its own thread).
Watch the size of ~/.t3/userdata/statev2.sqlite over days or weeks.
Settle or archive old threads.
Check the file size again, and the share of free pages: sqlite3 statev2.sqlite 'PRAGMA page_count; PRAGMA freelist_count;'
Expected behavior
Old threads can be deleted, deleting them frees disk space, and the database does not keep growing until the disk is full. Free pages are reclaimed automatically.
Actual behavior
Threads cannot be deleted. Settle and archive only hide them, and their events, messages, turn items and search index rows stay in the database, including those of finished subagent threads.
The file never shrinks. Free pages stay inside it (no VACUUM or auto_vacuum), and they can be a large share of the file.
v1 tables and an old state.sqlite can stay on disk after the v2 migration.
With heavy delegated-task use the database reaches tens of gigabytes and can fill the disk. T3 then fails in other places, for example Workspace preparation failed during provision worktree: Git command failed in GitVcsDriver.createWorktree.
Impact
Blocks work completely
Version or commit
No response
Environment
No response
Logs or stack traces
Screenshots, recordings, or supporting files
No response
Workaround
Stop T3, back up the file, then run: sqlite3 statev2.sqlite 'PRAGMA wal_checkpoint(TRUNCATE); PRAGMA integrity_check; VACUUM;'
This recovers only the free pages. The database starts growing again right away.
Suggested fix:
Delete threads in the UI and through the MCP tools, one at a time and in bulk ("delete archived/settled threads older than N days"), including all of their data and child subagent threads.
A retention setting for finished delegated-task threads (keep only the final summary in the parent).
auto_vacuum = INCREMENTAL with incremental_vacuum after deletes, or VACUUM on startup when free pages go over a threshold.
Drop the v1 tables and the old state.sqlite once the v2 import has been verified.
Show the database size in settings or diagnostics.
Freed pages are never returned to disk. Once rows are deleted (for example after the [Bug]: Deleting a thread says it permanently clears its history, but V2 keeps every event and projection row #17845 fix), statev2.sqlite keeps the freed pages, because nothing runs VACUUM and auto_vacuum is off. On a heavily used install about a third of the file was free pages. A fix could be auto_vacuum = INCREMENTAL plus incremental_vacuum after deletes, or a VACUUM on startup when free pages go over a threshold.
No bulk deletion or retention for finished delegated-task threads. These threads make up most of the data on orchestration-heavy installs.
If (1) counts as a bug and (2) as a feature request, I will move (2) to Discussions.
Activity
juliusmarminge commentedon Nov 30, 2026
This is the same problem as #17845, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.
manstfu commentedon Nov 30, 2026
statev2.sqlitekeeps the freed pages, because nothing runsVACUUMandauto_vacuumis off. On a heavily used install about a third of the file was free pages. A fix could beauto_vacuum = INCREMENTALplusincremental_vacuumafter deletes, or aVACUUMon startup when free pages go over a threshold.If (1) counts as a bug and (2) as a feature request, I will move (2) to Discussions.