[Bug]: Orchestrator V2 event writes stall the server on a high-latency disk (156 ms fsync), environment flips Offline #15707
Before submitting#
- I searched existing issues. #14701 covers the same stall mechanism on a slow read path. This report is about the write path and commit latency on slow storage.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Steps to reproduce#
- Run 0.0.46-nightly.20261004.2644 with ~/.t3/userdata on a disk with high fsync latency. On this machine that is the root disk: Toshiba HDWD110 (7200 RPM), crypto_LUKS, btrfs with compress=zstd:3. Measured fsync: 156 ms average over 200 4K writes. The same test on tmpfs: ~0 ms.
- Start several concurrent runs. I had four opencode runs and one claudeAgent session.
- After about an hour the desktop and Android clients cycle between Connected and "connect to the environment".
Expected behavior#
The server keeps answering keepalives while agents stream, or degrades without dropping clients.
Actual behavior#
Orchestrator V2 (the OrchestrationV2 migration; tables prefixed orchestration_v2_) persists each provider stream delta as an event. The server process sat in uninterruptible I/O wait for long stretches. Sampled wchan values: btrfs_btree_wait_writeback_range, write_all_supers, folio_wait_bit_common, wait_log_commit. SQLite transactions reached 1.98 s. Trace segments were dominated by orchestrationV2.EventSink.write spans of 40 to 500 ms each. Clients reported:
- ConnectionTransientError: Remote environment endpoint http://127.0.0.1:3773/.well-known/t3/environment timed out after 10000ms
- EnvironmentRpcUnavailableError: omarchy is not connected
The server log shows repeated SessionStore.markConnected and markDisconnected cycles. The Android client stayed logged in and showed the same offline state.
Event volume: 10,835 events were appended between 15:50 and 16:15 UTC, about 5,500 in the worst ten minutes, so roughly nine writes per second. In the last 5,000 rows there were 416 distinct node IDs, and one node ID appeared 405 times within 2,000 rows. This matches the mechanism in #14701: one synchronous SQLite connection on the main thread, so a slow commit blocks every other request, and each reconnect repeats the work.
Earlier builds with several concurrent runs did not show this on the same machine.
Impact#
Major degradation or frequent failure. T3 Code is unusable while agents run on this machine.
Version or commit#
0.0.46-nightly.20261004.2644 (Arch package t3code-nightly-bin 0.0.46_nightly.20261004.2644-1)
Environment#
Arch Linux, Wayland. Root and /home on crypto_LUKS + btrfs over a Toshiba HDWD110 HDD, compress=zstd:3. Desktop and Android clients on the same account.
What I tried#
- Moved ~/.t3/userdata to a btrfs directory with chattr +C (no COW, no compression). No change. The cost is commit latency on the disk, not COW.
- Aborted the runs through the opencode API. Each parent recorded MessageAbortedError, and the server kept inserting node.updated rows for about a minute.
- Terminated the provider processes and restarted the app. Stalls returned with the next concurrent runs.
Workaround#
Reverting to the previous nightly, 0.0.45_nightly.20260930.2468, which predates the Orchestrator V2 event store. state.sqlite is intact, so this restores normal operation on this hardware. I will update after running it for a while.
Open questions#
- I have not tested on an SSD. The trigger appears to be commit latency, so SSD users are probably unaffected or far less affected. I cannot confirm either way.
- Machines with fast storage may still hit #14701 through the read path.
Logs or stack traces#
Happy to attach server trace segments, the wchan samples, and the fsync benchmark script if useful.
Related#
#14701, #15609, #15442, #14871
Submitted with an opencode agent 🤖
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
Trace data from a second stall, as requested.
Setup: same machine and build as the report. Two opencode runs started at 16:32 UTC, and the environment flapped again while they streamed. The trace files cover 16:38 to 17:13 UTC.
Event mix, 16:32 to 17:13 UTC, from orchestration_events:
event type count node.updated 18,171 turn-item.updated 2,847 provider-thread.updated 490 message.updated 163 provider-turn.updated 52 node.updated by kind: reasoning 16,549 (91.1%), tool_call 1,448 (8.0%), assistant_message 158 (0.9%), root_turn 12.
By provider: opencode 18,116 (99.7%), claudeAgent 55.
Most-updated native items, all OpenCode reasoning nodes:
- prt_107c694da001... 1,049 updates
- prt_107cdb427001... 715 updates
- prt_107ca6c7a001... 638 updates
- prt_107cf4ab4001... 579 updates
Worst minute, 17:10:00 to 17:11:00 UTC, from server.trace.ndjson:
- orchestrationV2.EventSink.write: 487 spans, 106,295 ms total
- sql.transaction: 514 spans, 108,681 ms total
- 106.3 s of commit time in a 60 s minute is 177% saturation on the single-threaded writer
- durations: p50 100 ms, p95 1,125 ms, max 3,314 ms
- busy time per second stayed mostly above 1,000 ms, so the queue never drained
The pattern holds across every minute of the incident. All 37 minutes in the trace show 104 to 112 s of transaction time per minute.
The first incident showed the same mix: 15:50 to 16:15 UTC had 7,619 node.updated, of which 6,022 (79%) were reasoning and 1,475 (19.4%) were tool_call, with opencode responsible for 7,554 (99.1%).
Artifacts in this gist: https://gist.github.com/deepontology/ac5bdb621948c59bebde99efae4768da
- trace-slice.jsonl: every span in the worst minute, fields are ts, span, ms, status, trace. 4,501 rows. Attributes, IDs, and payloads stripped.
- per-minute.csv: sink and transaction counts and busy time for 16:38 to 17:13 UTC.
- per-second-worst-minute.csv: per-second commit count and busy time for 17:10 UTC.
This matches your triage. OpenCode reasoning deltas dominate, that path has no coalescing, and the commits serialize on the one connection.
Submitted with an opencode agent 🤖
Another data point, on fast storage, focused on how much this writes rather than fsync latency.
Setup:
t3 serve0.0.46-nightly.20261005.2689 as a systemd user service, Debian 13, Crucial P3 NVMe, btrfs (compress=zstd:3), 16 GB RAM. Mostly Claude agents, often 5 to 10 at once, plus Codex delegated tasks.statev2.sqliteis 1.3 GB with 0 free pages. Growth oforchestration_eventsby day (MB ofpayload_json):Day Events MB 09-20 to 10-02, typical 2k to 18k 1 to 15 10-03 (V2 in use from here) 36,883 84 10-04 40,742 151 10-05 39,984 114 By type, all time:
event_type count MB turn-item.updated46,778 250 thread.activity-appended64,191 113 node.updated29,967 31 provider-turn.updated13,084 15 turn-item.updatedstores the whole item on each update, so long tool outputs are written again on every update. Singleorchestration_v2_projection_turn_itemsrows reach 680 KB, and that table is another 200 MB. One long-running thread with its subagents holds 264 MB of events and items. Nothing prunes events, including those of archived threads.Read side (#14701 territory), from the trace: a
message.dispatchtransaction took 6.1 s, of which 3.4 s wasSELECT payload_json FROM orchestration_v2_projection_turn_items WHERE thread_id = ?for a thread of 1,769 items (3.4 MB). The host was under swap pressure, so pages were cold, but the query loads every item of the thread on the main thread. The server logs "event loop stalled" of 2 to 8 s several times a day, once 41 s, and remote clients drop and resync on each.Coalescing tool
turn_item.updatedwrites as you suggested would cut most of this volume. A retention rule for events of archived or old threads would bound the rest; I can open an Ideas discussion for that if it helps.I’m seeing similar Offline/Reconnecting symptoms on Windows desktop with a WSL2 backend, using a newer V2 nightly. I captured the server’s main thread waiting in
fsync()for an ext4 journal commit while T3 was showing Offline/Reconnecting.Environment
Desktop and backend:
0.0.46-nightly.20261005.2702WSL distribution: Ubuntu 24.04
“WSL only” enabled
Local backend:
http://127.0.0.1:3773~/.t3resolves inside the WSL home directoryFilesystem:
/dev/sdf, ext4, mounted at/Mount options:
rw,relatime,discard,errors=remount-ro,data=ordered
Filesystem capacity:
Filesystem Size Used Avail Use% Mounted on /dev/sdf 1007G 386G 570G 41% /Physical drive details and Windows host free space have not been collected. I have not independently verified the live database’s exact path.
Workload and symptoms
I started a coordinator with four ordinary worker threads through T3’s thread-management tools. Multiple Flutter compilation/test processes were running as part of their work.
The environment showed Offline/Reconnecting while Claude and build/test processes remained alive. This is the first occurrence I have observed in my setup.
Process and I/O evidence
At approximately 18:34 UTC+7 on October 6, the T3 server process showed:
PID PPID STAT WCHAN COMMAND 1674 1673 Dsl+ folio_wait_bit_common node-MainThreadSix visible Claude processes had PID
1674as their parent.The four interval samples from
Sample | Blocked processes (b) | I/O wait (wa) | CPU idle (id) -- | -- | -- | -- 1 | 10 | 38% | 53% 2 | 8 | 24% | 61% 3 | 7 | 27% | 67% 4 | 8 | 27% | 59%vmstat 1 5, excluding the first since-boot report, showed:Swap usage was approximately 1.4 GiB. Three Dart frontend processes held approximately 4.65 GiB of resident memory combined.
The server still owned port 3773. Its listening socket’s Recv-Q was 7 at 18:34 and 1 at 18:44.
Kernel stack captured while T3 was still Offline/Reconnecting
At approximately 18:44–18:45 UTC+7:
sudo cat /proc/1674/stack[<0>] jbd2_log_wait_commit+0xb4/0x130 [<0>] jbd2_complete_transaction+0x73/0xb0 [<0>] ext4_fc_commit+0x64b/0x9f0 [<0>] ext4_sync_file+0x1e4/0x2b0 [<0>] vfs_fsync_range+0x49/0x90 [<0>] do_fsync+0x40/0x90 [<0>] __x64_sys_fsync+0x17/0x20 [<0>] x64_sys_call+0x1729/0x20f0 [<0>] do_syscall_64+0x73/0x990 [<0>] entry_SYSCALL_64_after_hwframe+0x76/0x7e
This captures a synchronous filesystem commit wait in the server’s main thread. It does not identify the file being synchronized or measure the duration of that operation, so I cannot yet confirm that SQLite is the caller or that this has the same root cause.
Would specific T3 traces or further storage diagnostics help distinguish the V2 event-write path from WSL storage contention caused by concurrent builds/tests?
Another data point: an NVMe SSD on ext4, where the trigger is other processes writing heavily rather than a slow disk. On SSH-managed environments the stall also ends up killing running agents.
Setup#
0.0.46-nightly.20261007.2774, started by the desktop app as an SSH-managed environment (~/.t3/ssh-launch/…/run-t3.sh)- NixOS, kernel 6.18.55, 58 GB RAM, no swap
~/.t3on ext4 (defaultdata=ordered), Crucial P3 4 TB NVMe (CT4000P3SSD8, firmwareP9CR30A)statev2.sqliteis 2.3 GB- Workload: several Claude agents, each building a Rust workspace in its own worktree (
cargo build/cargo nextest,debuginfo=2)
Numbers#
- fsync of a 4 KB file in
~/.t3/userdata: 26–45 ms normally, spiking to 5.5 s while the builds were writing about 60 MB/s. - At the worst point there were 8.7 GB of dirty pages and
/proc/pressure/ioshowedfull avg10=81. Memory pressure was 0, so tools like btop showed nothing wrong. server.eventLoop.stallreached 15–16 s several times. CPU use during the stalls was low (utilization0.2–0.5, a few tens of ms of CPU), so the main thread was waiting, not computing.- Trivial statements took seconds:
UPDATE auth_sessions SET last_connected_at = ?took 4.2 s andSELECT * FROM scheduled_tasks WHERE enabled = 1 …took 7.5 s. Onesql.transactiontook 23.6 s. - The only PRAGMAs in the traces are
journal_mode = WAL,busy_timeout = 5000,foreign_keys = ONandjournal_size_limit. That matches triage:synchronousis left atFULL.
With ext4
data=ordered, a journal commit can wait for other files' dirty data to be written out first. So a small WAL fsync gets queued behind the build output, even on an SSD. This probably answers the WSL comment's question: concurrent builds and tests are enough to trigger it without a slow disk.What it does to SSH-managed environments#
The stall gets worse than "Offline" here:
- The event loop blocks for 10–16 s.
- The desktop's SSH session drops, the client reconnects, and the launcher starts a new server. That happened 6 times in about 20 minutes.
- Startup recovery then ends whatever was running, e.g.
V2 orchestration recovery completed { terminalizedRuns: 3, stoppedSessions: 4 }at 18:22:51.
Each restart kills in-flight agent turns and their child processes. Inside the agents the builds show up as exit 137, and the agents reported this to me as "out of memory", even though there was no kernel or oomd kill and about 50 GB of RAM was free.
A second
t3 serveon the same~/.t3(the #5749 / #6097 situation) makes this worse. Each slow commit holds the database lock for seconds, and the other server fails withLockTimeoutError: database is lockedoncebusy_timeoutruns out.Mitigations on my side#
Fewer concurrent builds, lower
vm.dirty_bytes/vm.dirty_background_bytes, anddebug = "line-tables-only"for dev builds. These shrink the spikes but don't remove them.PRAGMA synchronous=NORMALin WAL mode, or moving the writer off the main thread, as suggested in triage, would fix it at the source.Trace segments covering the stalls and restarts are available if useful.
Investigated and written by Claude Opus 5.5 running in Claude Code (via T3 Code).
Another data point: the same disconnect cycle on fast storage. My fsync latency is about 30 times lower than in the original report, so slow disks aren't the only trigger.
Setup#
0.0.46-nightly.20261005.2702(Arch,t3code-nightly-bin), desktop app, local environment only- Omarchy (Arch), kernel 7.2.5, 32 cores, 125 GB RAM
~/.t3on btrfs (compress=zstd:3) on LUKS, Samsung 990 PRO 2 TB NVMe- fsync of a 4 KB write in
~/.t3/userdata: 5.0 ms average (p50 4.9 ms, max 5.6 ms, 50 samples) - Workload: Claude agents only (
claudeAgent)
Symptoms#
The add-project flow showed "Environment unavailable – omarchy is not connected", and the connection kept dropping and coming back. In
server.trace.ndjson, top-levelEnvironmentRpc.subscribespans were cut short again and again between 18:03 and 18:13 UTC, each lasting 5 to 133 seconds (8.4 s, 16 s, 48 s, 93 s, 133 s, 60 s, …). The busiest minute of event writes, 18:11 UTC with 719 events, falls inside that window. The rotated server trace files filled up quickly: 10 MB in about 4 minutes, mostlysql.execute,db.transaction.commit,orchestrationV2.EventSink.writeandThreadSettlementServiceV2.settleThread.The desktop process had been running for 7h40m with a 9.6 GB memory peak (reported by systemd for the app's scope). A full relaunch fixed it for now.
Database#
statev2.sqlite: 564 MB, 0 free pages. The legacystate.sqlite(253 MB) is still on disk.- Largest tables:
orchestration_events265 MB,orchestration_v2_projection_turn_items101 MB,projection_thread_activities91 MB orchestration_v2_eventsis empty. Every event is written toorchestration_events.
Events by type, all time:
event_type count MB turn-item.updated12,046 99.5 thread.activity-appended20,567 89.5 node.updated6,720 6.0 message.updated4,166 3.3 provider-turn.updated3,960 3.6 turn-item.updatedaverages about 8.3 KB per event, which looks like the full item rewritten on every update rather than only what changed.Daily growth:
Day Events MB 10-05 639 0.6 10-06 17,528 86.2 10-07 (partial) 7,991 29.2 With fast storage, disk speed doesn't explain the stalls. The large database, plus the read-path blocking from #14701, seems to be enough to block the main thread even at 5 ms per commit.
I have a small patch ready for the first option in the triage comment:
PRAGMA synchronous = NORMALinlayerSetup(apps/server/src/persistence/Sqlite.ts), next to the other pragmas. It is one line plus a test that the pragma is applied.Before opening a PR, can a maintainer confirm this direction? It changes a default: in WAL mode,
NORMALstops fsyncing the WAL on every commit. After an OS crash or power loss the last few committed transactions can be lost. An application crash is safe, and WAL withNORMALcannot corrupt the database. Checkpoints still fsync.A quick measurement on an NVMe disk (Windows,
node:sqlite, WAL, 1000 single-row transactions): 0.431 ms per commit atFULL, 0.050 ms atNORMAL. That is a fast disk, so it does not reproduce the 156 ms case from the report. I can't confirm that this alone stops the Offline flapping, and it does not touch event volume or moving the writer off the main thread.If this direction is fine, I'll open the PR with disk-backed timings. If you would rather go another way, I'll leave it.
Another data point on fast storage (NVMe + btrfs + LUKS), with disk-backed
FULLvsNORMALtimings from the same disk.Setup#
0.0.46_nightly.20261006.2735(Arch,t3code-nightly-bin), desktop app, local environment only- Omarchy, kernel 7.2.8, 16 GB RAM
~/.t3on btrfs (compress=zstd:3) on LUKS, XPG GAMMIX S70 BLADE 1 TB NVMe (SMART clean, 4% used, 0 media errors)- Workload: Claude, Codex and OpenCode, with delegated tasks across providers
Stall evidence#
A watcher polled
/.well-known/t3/environmentevery 30 s and captured system state when it failed. It recorded 11 stalls, each a 5 s timeout, while the UI showed reconnecting:- The server main thread was in
Dstate with wchanfolio_wait_bitorwait_log_commit. /proc/pressure/ioshowedsome avg10between 17 and 42, while CPU and memory pressure were about 0.- In 8 of the 11 snapshots, the T3 server was the only userspace process in
Dstate.
During one stall (16:50 to 16:53 local time), queries that are normally fast stretched out:
span median max SELECT * FROM scheduled_tasks …0 ms 23.4 s getLimitRecoveryCandidates3 ms 23.4 s orchestrationV2.EventSink.write— 1 to 6 s client ConnectionDriver.connect— 10 s Write volume#
- With agents running, the server process wrote 64 MB to disk in 30 s, across 26,598 write syscalls (
/proc/<pid>/io). statev2.sqliteis 2.5 GB.orchestration_eventsholds 1.46 GB in 467k rows.payload_jsonper day: 10-05 39 MB, 10-06 42 MB, 10-07 161 MB, 10-08 230 MB.- 10-08 to 10-09 by type:
turn-item.updated39,535 rows (182 MB),node.updated88,396 rows (141 MB).
NOCOW does not fix it#
This confirms the original report. Rewriting
statev2.sqliteas achattr +Cfile cut it from 157,192 extents to 92. Stalls returned within 40 minutes, with the same wchan values.FULLvsNORMALon this disk#Test conditions:
node:sqliteon Node v26.11.1, SQLite 3.53.4, WAL, file on the same btrfs/LUKS volume as~/.t3/userdata. Each run is 1000 single-row transactions (BEGIN IMMEDIATE+ insert of a ~4.6 KB payload +COMMIT), roughly oneturn-item.updatedeach. The disk was idle.p50 p99 max total raw 4 KB write + fsync 1.56 ms 2.12 ms (p95) 2.26 ms — synchronous=FULL1.71 ms 3.03 ms 6.66 ms 1.75 s synchronous=NORMAL0.03 ms 0.13 ms 8.80 ms 0.08 s On an idle disk,
FULLalready costs about one fsync per event. Under load the stall snapshots show those waits growing to seconds, and every one happens on the main thread.NORMALremoves the per-commit wait, leaving only checkpoint syncs. That is themaxoutlier in theNORMALrow.@Sypher760-gif, happy to run your patch on this machine and report whether the stalls stop under the same workload.
Note
gpt-6.1-sol · Codex running in T3Code, responding on behalf of Max.
Another occurrence on an NVMe-backed Linux VM, with 104–122 second main-thread stalls during one-event V2 writes, plus further stalls after the competing emulator workload stopped.
This supports the responsiveness failure tracked here. It does not establish that T3 caused the underlying storage slowdown or that the SSD is defective.
Observed behavior and impact#
On 2026-10-09 the macOS client showed:
T3 Connect · Reconnecting: Could not connect relay environment.
The server process remained alive, but even local HTTP requests timed out. Remote access recovered without a restart when disk pressure fell, then additional long stalls appeared. This prevented reliable interaction with running work in the remote environment.
Expected: storage contention can delay persistence, but a blocked database operation should not freeze the main HTTP/WebSocket event loop and cause the entire environment to disappear behind a generic relay error.
Environment#
- Running server:
0.0.46-nightly.20261009.2861, Linux x64, systemd user service; kernel6.8.0-146-generic. The matching release tag points to3b6af0bd1600f034b0466e1b8ff017fbabeba910. - Remote connection: T3 Connect with managed cloudflared
2026.10.0, accessed from the macOS desktop app. The desktop version was not collected. - Linux VM: 6 vCPUs, 6 GB allocated RAM (5,919 MiB visible), ext4 on LVM; root filesystem about 94% used with about 31 GB available during diagnosis. About 2 GB of swap was occupied during the severe incident. Swap occupancy alone does not establish active swapping as the cause.
- Live V2 database:
~/.t3/userdata/statev2.sqlite, approximately 12 GiB by roundedls -lhat 13:03 UTC; oldstate.sqliteapproximately 7.4 GiB. The V2 WAL was approximately 13 MiB at that snapshot. These are file sizes, not measured event payload totals or growth rates. - Storage route: guest ext4/LVM → virtio raw virtual disk (
cache=writeback,discard=unmap) → Unraid/mnt/userFUSE (fuse.shfs) → ZFS cache pool → Crucial CT500P2SSD8 NVMe SSD. The image physically resides on the cache SSD pool. No explicit QEMU IOThread was configured. - Hypervisor: about 16 GB RAM total; sampled available memory about 3 GB, ZFS ARC about 2 GB. These host measurements were after the worst stall.
Correlated trace evidence#
All times below are UTC on 2026-10-09. The first column identifies the end of the correlated activity, not its start. Durations come from T3's trace; stall duration is the event-loop span's
delayMaxMsattribute, not the tiny duration of the monitoring span itself.End time sql.transactionorchestrationV2.EventSink.writeEvent count on write Event-loop delay 12:20:05 104,464.394 ms 104,467.450 ms 1 104,495 ms 12:23:21 122,614.470 ms 122,616.425 ms 1 122,480 ms 12:57:09–10 69,038.483 ms and a separate 44,107.001 ms transaction 44,108.285 ms 1 69,800 ms The later row contains overlapping spans, not one transaction attributed wholly to one event. A
sql.executeSELECT span ending at 12:57:09 lasted 69,060.493 ms. Its elapsed time can include waiting for the shared connection, so this does not establish a 69-second query execution cost.The monitor reported relatively little CPU use over the long sampled intervals:
Stall User CPU System CPU RSS Major page faults 104,495 ms 2,501 ms 2,544 ms 506 MiB 158 122,480 ms 785 ms 727 ms 535 MiB 28 69,800 ms 1,867 ms 1,193 ms 548 MiB 56 These counters cover the monitor's sample interval, not an isolated native SQLite call. High event-loop utilization here must not be read as high CPU utilization.
A redacted scan of retained trace files, collected at 13:06 UTC and covering span endings from 12:18:04 to 13:05:15, contained:
- 23
server.eventLoop.stallrecords. - 7,100
sql.transactionspans. - 4,591
orchestrationV2.EventSink.writespans. - 43,258
sql.executespans. - 9,446
ThreadSettlementServiceV2.settleThreadspans; several reached about 123 seconds during the severe stall.
These are trace span counts, not unique database events, physical write counts, or additive time on disk. The retained window is incomplete before 12:18 due to log rotation. Long-lived subscription spans were excluded from interpreting request latency.
Process, kernel, HTTP and relay evidence#
During the severe incident:
- The server's main thread was sampled in
Dstate, then with wait channeljbd2_log_wait_commit, an ext4 journal-commit wait. No complete native stack or syscall-to-file attribution was captured. /proc/pressure/io:some avg10=96.47%,full avg10=87.10%.vmstatinterval samples: 47–61% CPU I/O wait, six blocked tasks; load average 33.14 on six vCPUs.- HTTP on
127.0.0.1:3773timed out after four seconds. The public environment endpoint timed out after five seconds from the VM and fifteen seconds from the Mac. - Cloudflared reported canceled
/api/t3-connect/healthand/api/t3-connect/mint-credentialrequests and QUIC inactivity timeouts. Local HTTP failure means this was not solely a relay/network outage. - No relevant kernel warning was found in the checked 20-minute window.
Around 12:24:24, without restarting or changing configuration, local HTTP returned 200 in 83 ms and the public endpoint returned 200 in 163 ms. I/O PSI fell to
some avg10=1.10%,full avg10=0.87%; the connector then reported connected/fresh. This was temporary recovery, not a demonstrated fix.Competing workload and storage health#
An Android emulator started at 12:11:47, used about 2.3 GB RSS, and
/proc/<pid>/ioshowed about 17.1 GB written after roughly twelve minutes. Its QA workload deliberately tested Android guest storage exhaustion using approximately 5.6 GB filler writes and flushes.The fault was confined to the emulator's
/datavirtual filesystem. The probe retained a 24 GiB reserve on the Linux VM filesystem. The final probe recorded 118,784 bytes free inside Android before the test, then removed the filler and restored approximately 5.6 GB free. This was not evidence that T3's filesystem ran out of space. The workload is strongly correlated with the early incident but was not isolated in a controlled A/B test.The emulator was absent by the 12:40 check and again at the follow-up process check. The 69.8-second stall at 12:57 therefore shows that stopping it did not eliminate all pauses. Remaining workload, delayed writeback, database read cost, memory pressure, and storage queueing have not been separated.
After recovery, SSD SMART showed PASSED, critical warning 0, zero media/data-integrity errors, 46°C and 5% used. ZFS was ONLINE with no known data errors; the pool had about 154 GB free. Historical ZFS averages showed approximately 237 ms total write wait versus 3 ms device write wait and 604 ms synchronous queue wait, but these were not measurements from the exact outage. Idle follow-up samples were about 2 ms total write wait and very low NVMe utilization. This suggests investigating queueing through the storage stack; it does not prove FUSE caused the stall or rule out SSD latency under load.
Relevant code in this exact release#
I checked the matching release source, rather than relying only on current main:
nodeSqliteClient.ts: connection construction opensNodeSqlite.DatabaseSync. Statement execution directly invokesstatement.all()/statement.run()inside the Effect runtime. An Effect wrapper does not move these native synchronous calls to another thread.- The same adapter uses a one-permit semaphore around one connection and keeps it for transactions; writable transactions use
BEGIN IMMEDIATE. Sqlite.tsalready enables WAL, setsbusy_timeout=5000, foreign keys, and a 32 MiBjournal_size_limit. It does not explicitly setsynchronous. I did not query the server connection's live effective synchronous mode; it must not be claimed as independently measured here. WAL is already enabled, and a lock busy timeout does not bound filesystem flush latency.ProviderEventIngestor.ingestNormalizedforwards normalized provider events to the event sink.EventSink.writeappends events, applies projections, and enqueues effects throughcommitThenPublish's transaction. The captured worst writes each had one event; this report does not identify their provider or payload type.
Together, the source and aligned traces strongly support synchronous persistence exposing the main event loop to storage stalls. They do not isolate whether the slow native operation was a COMMIT flush, checkpoint, page read, or another operation inside the transaction.
Fix areas and useful verification#
- Isolate synchronous database work, including writes and checkpoints, from the HTTP/WebSocket event loop with a bounded worker queue and explicit backpressure. Requests needing persisted state may still wait; event-loop scheduling and keepalives should remain responsive.
- Measure queue wait separately from native statement, transaction commit, and checkpoint duration. Include effective connection PRAGMAs and redacted event type/count/size so elapsed SELECT spans are not mistaken for query execution time.
- Review provider/tool update coalescing and transaction batching. The existing traces include
ThreadLiveEventCoalesceractivity, so this report does not claim coalescing is universally absent. No event-type histogram or T3-specific physical-write amplification measurement was collected. - Evaluate WAL
synchronous=NORMALonly as an explicit durability decision. It can reduce commit sync work but does not remove synchronous reads or all checkpoint I/O. SQLite documents that recent committed transactions can be lost after power loss with NORMAL. See SQLite WAL and synchronous. - Add a controlled regression test with slow database I/O while agents produce updates: assert health/keepalive scheduling, bounded pending writes, preserved ordering and final content, and persistence/error recovery. Reproduce on a disposable disk-backed database, not by filling a user's daily-driver filesystem.
#14701 covers the related read path. PR #14703 is still open as checked on October 9 and proposes moving selected reads to a worker; it would not by itself isolate these writes.
Diagnostic scope and limitations#
Diagnostics used
t3 trace summary,t3 connect status,t3 service status, retained server traces and boot logs, live connector status, process wait channels, PSI/vmstat, VM XML, ZFS and SMART checks.t3 connect statusdescribes saved setup, not live health. The PATH CLI was older (0.0.44-nightly.20260929.2456) than the running service; the later trace summary was run with the exact installed2861executable.No database maintenance, PRAGMA change, T3 restart/update, VM storage-path change, or forced stop of another workload was performed by this investigation. A direct cache-pool image path is only a proposed infrastructure mitigation, not an A/B result. No destructive stress reproduction or CI was run. No failure screenshot is attached; the report is based on recorded timing and process evidence.
Apart from the requested first name in the attribution notice, identifying details are omitted: no personal names, usernames, email addresses, private repository names, environment IDs, thread/project IDs, hostnames, public or private network addresses, hardware serial numbers, absolute home paths, credentials, message contents, or private query parameters. The loopback address, generic application paths, hardware model, software versions, and diagnostic timestamps remain because they describe the failure without naming the user or machine. The raw database and unredacted traces are not attached. A local redacted trace summary has been retained for follow-up.
- Running server:
Before/after numbers for
PRAGMA synchronous = NORMALon a live server under the same workload. This answers the open question in the last patch comment: the setting alone stops the stalls here.Setup#
t3 serve0.0.46-nightly.20261010.2908 as a systemd user service, accessed from a remote browser- Ubuntu, kernel 7.0, ext4 (
data=ordered) on LVM, consumer NVMe - Workload: 4 to 5 Claude agents building Rust workspaces in their own worktrees, plus Codex
- 150 to 360 commits per minute in
server.trace.ndjson, before and after
Symptoms before#
- The browser showed "devsrv is reconnecting" several times an hour.
- "Codex provider status: Timed out while checking Codex app-server". The 30 s skills probe timed out, while
codex app-serveransweredskills/listfor the same worktree in 10 ms. GET /api/auth/sessionwith a valid token hung for 8 to 30 s, every 20 to 30 s.- A 4 KB
dd oflag=dsyncwrite took 6 to 100 ms. jbd2 averaged 14 ms per commit, almost all of them fsync-requested.
Change#
The pinned nightly tag, rebuilt with one line added to
layerSetupinapps/server/src/persistence/Sqlite.ts:yield* sql`PRAGMA synchronous = NORMAL;`;Only the
t3binary was swapped.client/andnode_modules/stayed from the release.Results#
FULL (release) NORMAL (patched) fsync calls by t3 servein 60 s (strace -f -T)195 17 Wall time in fsync in 60 s 17.6 s 0.4 s Slowest single fsync 6.7 s 0.25 s Main thread in Dstate (0.1 s samples,/proc/<pid>/task/<pid>/stat)55% 1.5 to 11% of that in jbd2_log_wait_commit34% 0.2% Slowest /api/auth/session30.5 s 6.2 s The remaining waits are mostly
folio_wait_bit_common. In the first 6 minutes after the switch there was no reconnect and no Codex probe timeout.@hilman2's numbers answer the caveat in my earlier comment:
PRAGMA synchronous = NORMALalone cut fsync wall time from 17.6 s to 0.4 s per minute on a live server and stopped the reconnects and Codex probe timeouts there.The patch is ready on current
main(50647de0): one line inlayerSetupinapps/server/src/persistence/Sqlite.ts, plus a test that the setup appliessynchronous = 1. The test fails without the line and passes with it, and lint and format are clean.It changes a durability default, so I'll hold the PR until a maintainer says whether this direction is wanted. In WAL mode with
NORMAL, an OS crash or power loss can drop the last few committed transactions, but it cannot corrupt the database, and an app crash loses nothing.A durability note on the
PRAGMA synchronous = NORMALoption, with measurements from a different setup.What
NORMALcan lose here. In WAL mode, an OS crash or power loss restores the database to its last synced state, which can be older than the last commit. I found no server code that setswal_autocheckpointor runs a checkpoint, so SQLite's default of 1,000 pages applies. The unsynced stretch is bounded by that checkpoint interval, and a checkpoint held up by long readers could stretch it. I did not measure frames per commit. The database cannot be corrupted and an app crash loses nothing, as noted above.Why this matters more than lost rows. Effects run outside the database file.
EventSink.writeEffectcommits the events, projection rows and outbox rows in one transaction. Only after the commit does it callnotifyAvailableand publish. Workers claim outbox rows after that.- A provider turn, or a git or file action, can therefore finish while its commit is still unsynced. After a crash the restored database has no event, outbox row or command receipt for work that already ran. The receipt that deduplicates a retried command is inserted in the same transaction (
commitCommand), so a retry with the same command ID is accepted as new. - The effects are idempotent only against database state.
provider-turn.startskips itself once the run has leftstarting(ProviderTurnStartService.ts, "The effect is idempotent once the run has advanced or terminalized"). A rollback resets exactly that state. I did not trace any deduplication on the provider side. orchestration_events.sequenceisAUTOINCREMENTand its counter is written in the same transaction, so rolled-back sequence numbers can go to new events. Clients ignore events at or below the newest sequence they applied (shellReducer.ts,threadLifecycle.ts).- Resume sends a full snapshot when a client is ahead of the server, for both the shell stream (
canReplayPersistedRange) and the thread stream (afterSequence > highWater,ws.ts). That guard fires only if the client is ahead. If new events have already pushed the server's head past the client's last sequence by the time it reconnects, the client's applied history looks valid and no snapshot is sent. This comes from reading the code, and I have not reproduced it.
A narrower variant. Keep
FULLfor transactions that enqueue outbox effects, and useNORMALfor the rest. In the last 120,000 events on one install (1.14 days), 1,896 of 105,269 write transactions, about 1.8%, enqueued an outbox effect. I counted distinct outboxcreated_atvalues, because event and outbox timestamps do not match one to one. The effects were mostlyprovider-turn.start(906) andcheckpoint.capture(897). Most writes are streaming updates (turn-item.updated,node.updated,provider-turn.updated), so most of the saving would stay. The second trace above shows the same shape: 16,549 of 21,723 events were reasoningnode.updatedwrites.PRAGMA synchronousis per connection and can change between transactions, and writes already go through a single-permit semaphore. Another option is to checkpoint beforenotifyAvailable, so an effect starts only after its commit is durable. I have not tried either.Measurements on a local ext4 disk. I used Node's bundled SQLite 3.53.4 in WAL mode. Each commit wrote one 3,000-character row plus an index. Each run made 1,000 commits, and five runs alternated settings in fresh processes.
Setting Median commit, µs Range of run medians, µs FULL1,169.7 1,162.1 to 1,319.1 NORMAL13.4 12.8 to 14.3 That is about 87 times lower per commit. On the same install, the median write transaction held 1 event, the 99th percentile 5 and the maximum 11. On that single-user workload, batching queued events into one transaction would save little. The workloads reported above, at about nine writes per second, differ.
Another data point on the fsync stalls, from a Linux host where the trigger was not the write volume but the filesystem's online
discard.Setup. Linux 7.2.9 (WSL2, x86_64), ext4 root on a virtual disk mounted with
discard,0.0.46-nightly.20261011.2955, a 14 GBstatev2.sqlite, 6 to 10 agents running. The desktop app's WebSocket to the server dropped and reconnected every 1.5 to 13 minutes while the server process stayed up.What blocked the loop. I sampled the server's main thread every 50 ms for 240 s (
/proc/<pid>/task/<pid>/statandwchan):- It sat in uninterruptible disk wait for 26.8% of the samples. The longest unbroken waits were 20.7 s, 15.5 s and 7.9 s, in
jbd2_log_wait_commit,rq_qos_waitandfolio_wait_bit_common. - A 150 s
bpftraceof that thread's syscalls over 200 ms found 7fsynccalls onstatev2.sqlite-wal(up to 2.8 s each) and a 0.5 spreadonstatev2.sqlite. - The server trace logged stalls of 2 to 18 s over the same period. Two of the three logged inside the sampling window fall within the longest waits.
The
discardmount option was the trigger here. ext4 withdiscardissues the TRIM for freed blocks as part of each journal commit, and everyfsyncwaits for that commit. The block device counters since boot showed about 2.4 TiB discarded and an average write latency near 100 ms against 0.5 ms for reads.Remounting at runtime with
mount -o remount,nodiscard /and sampling again, twice:Main thread, 240 s Samples in disk wait Waits of 1 s or more discard, run 126.8% 17 discard, run 216.8% 4 nodiscard, run 10.6% 0 nodiscard, run 20.8% 0 The trace had no "event loop stalled" lines during the
nodiscardruns, and I/O pressure went from 66% to 0. Lowering the kernel's dirty-page limits did not help (disk wait 16.8%, worst wait 14.9 s), so I put that back.Caveats. Two 4-minute runs under a lighter load than the earlier ones, so this is evidence and not proof. The server still fsyncs the WAL on the main thread, so a slow disk for any other reason will still stall it.
PRAGMA synchronous = NORMALand moving the writer off the main thread remain the real fixes. This only removes one common cause of slow commits.For others on ext4:
findmnt -no OPTIONS /shows whetherdiscardis set. Withnodiscard, freed space is returned by a periodicfstriminstead.- It sat in uninterruptible disk wait for 26.8% of the samples. The longest unbroken waits were 20.7 s, 15.5 s and 7.9 s, in
Slow-disk numbers for
PRAGMA synchronous = NORMAL, from the machine in the original report.The state directory sits on the 7200 RPM LUKS + btrfs disk that measured 156 ms per raw fsync. Node 26.7.0
node:sqlite, WAL mode. Each transaction inserts one ~2 KBorchestration_eventsrow and upserts one projection row, mirroring theEventSink.writecommit shape. Fresh database per run.Two runs per mode, 200 commits each, alternating:
setting median commit p95 max mean FULL 41.8 / 49.9 ms 66.7 / 100.1 ms 208 / 442 ms 48.3 / 56.4 ms NORMAL 0.05 / 0.05 ms 0.07 ms 114 / 139 ms 0.9 / 1.0 ms A longer NORMAL run, 3000 commits, to see what the checkpoints cost:
- median 0.03 ms, p95 0.06 ms, p99 41.7 ms, max 451 ms
- 16 commits over 100 ms, none over 500 ms
- the slow ones cluster, consistent with WAL checkpoints (indices 581, 768, 951, then 1508, 2069, 2446, 2831)
On this disk the cost moves from every event to every few hundred commits. The remaining pauses run 200 to 450 ms here, well under the 5 s keepalive.
Earlier measurements of this pragma were on NVMe. This is the slow-disk case where the report started, and the commit cost mostly disappears.
Caveats: synthetic, single process, no server, no competing load. This does not replace @hilman2's live numbers. It closes the slow-disk case: the machine that started this report behaves like a normal one with the pragma.
Reproduce with: https://gist.github.com/deepontology/e382276fdbba974011dd08bbf1f2b6c9 (
node bench-pragma.mjs FULL 200 /path/on/target/disk)If and when the pragma PR opens, I can run a live A/B on this machine and post reconnect counts.
Submitted with an opencode agent 🤖
Another data point, from a shared server where other processes' writes are the trigger.
Setup:
0.0.46-nightly.20261007.2787as a systemd service on Linux 7.0, 16 cores.~/.t3is on ext4 (data=ordered, nofast_commit, 1 GiB journal) on a two-NVMe RAID1.statev2.sqliteis 16 GB, with 5–7 Claude agents running at once. The same filesystem also hosts headless browsers, a VM and other SQLite users.46-minute live capture of the server process:
- The main thread was in D state in 70% of 1 s samples. 73% of those kernel stacks were
ext4_sync_file → jbd2_log_wait_commit; 0.2% were swap-in. - COMMIT spans took 1,748 s of the 2,760 s. 98–99% of that came from
orchestrationV2.EventSink.write, at 150–1,260 commits/min. - bpftrace on the main thread found 570 fsyncs taking 21.8 s in one minute. The longest single fsync was 1,803 ms, and the trace span for the same commit was 1,804 ms.
- 54 of the 68
server.eventLoop.stallspans were commit fsyncs, and 10 were cold page reads in the shell-projection query. None came fromgh, network or swap. - I timed
/.well-known/t3/environmentevery 5 s: 315 of 547 responses took over 1 s, the slowest 31.9 s. - Statements that execute in milliseconds, such as
scheduled_tasks WHERE enabled = 1on an empty table, showed 10–56 s wall time while queued behind the blocked loop.
Per-minute fsync latency followed the filesystem's write await (13–1,363 ms), driven by the other writers' journal commits, not by T3's own write volume. When write await fell under 20 ms, commits dropped to 16–34 ms and the server recovered.
On a shared disk, T3 has no control over that latency.
synchronous = NORMALwould take the per-event fsync off the event loop, which supports the first option in the triage.One more detail from the same host: the main thread calls
fsync, notfdatasync, on its SQLite files (111fsyncand 0fdatasyncin 10 s, by syscall tracepoint). So each commit also journals the WAL file's mtime change, which forces an ext4 journal commit even though the 32 MiB WAL is overwritten in place. That ties every T3 commit to everyone else's journal traffic. Withsynchronous = NORMALthe per-commit sync goes away. InFULLmode, building SQLite withHAVE_FDATASYNCwould at least avoid the journal commit.- The main thread was in D state in 70% of 1 s samples. 73% of those kernel stacks were
Follow-up to my earlier comment. Two more causes on this machine, both outside T3: the SSD was never trimmed, and the database shared a disk with the agents' builds.
All numbers below are from the same patched build:
synchronous = NORMAL, pluscache_size = -65536andtemp_store = MEMORY. The last two made no measurable difference in an earlier load test.Trim#
- The disk is a DRAM-less consumer NVMe (WPBSN4M8-2TGP, 2 TB). Agents building Rust wrote 4.8 TB to it in five days, mostly
target/files that were deleted again. - Ubuntu's
fstrim.timerruns weekly. It had not run once yet, so the SSD treated almost every block as in use. - A manual
fstrim -v /took 6 minutes and released 1.1 TiB. - The timer now runs hourly. Each run trims 0.2 to 21 GiB on
/.
Weekly trim is too rare for this write volume. Online
discardis no fix either, see @bompus's comment above.Separate disk for the database#
statev2.sqlitestayed on the old SSD. Everything else moved to a second NVMe (ext4):/homeincluding worktrees andtarget/,/tmp, Docker and swap. T3's logs and attachments moved too.Results#
60 s each, 3 to 4 agents working. The main thread state was sampled every 0.1 s,
/api/auth/sessionwas requested every 0.3 s.patched, untrimmed after trim after trim, DB on its own disk Main thread in Dstate47% 10% 0.7% /api/auth/sessionp999.1 s 0.68 s 0.02 s Slowest /api/auth/session11.6 s 0.99 s 0.11 s IO pressure someavg30019.7 27.7 1.8 On its own disk, reads of the database averaged 1 ms while the build disk took 284 writes in 10 s.
synchronous = NORMALstill matters: withFULL, every commit waits for the disk regardless. But on a shared, untrimmed disk it is not enough on its own.- The disk is a DRAM-less consumer NVMe (WPBSN4M8-2TGP, 2 TB). Agents building Rust wrote 4.8 TB to it in five days, mostly
Three more measurements came in today and they point the same way. On the disk from the original report, deepontology measured a median commit of 41.8 and 49.9 ms with
FULLagainst 0.05 ms withNORMAL. Luzivog saw the main thread in disk wait for 70% of samples on a shared server. hilman2 traced part of theirs to an untrimmed SSD, which T3 can't fix. I'm still holding the PR forsynchronous = NORMALbecause it changes a durability default. Could a maintainer say whether you want that direction? If so, I'll open it scoped to the pragma and describe the checkpoint-bound loss window.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks for the fsync numbers, trace spans, and event counts, @deepontology. That made this very concrete.
What I found#
I checked
v0.0.46-nightly.20261004.2644and currentmain(4ee6bfd50e). The write path is the same in both. The only SQLite change since your nightly is #15488, which switches transactions toBEGIN IMMEDIATEbut still commits on the same connection.apps/server/src/persistence/Layers/Sqlite.tsopens a singlenode:sqliteDatabaseSyncin WAL mode. It never setsPRAGMA synchronous, so SQLite runs atFULLand fsyncs the WAL on every commit.packages/shared/src/nodeSqliteClient.tsputs that connection behind a one-permit semaphore and runs statements and commits on the main thread. A slow fsync therefore blocks the event loop and every other statement.ProviderEventIngestor.ingestNormalizedcallsEventSink.write, which appends the event, applies projections, and commits in one transaction. At about 156 ms per fsync, the disk can do roughly six commits a second. Your stretches at about nine events a second line up with the I/O wait you saw.paragraphstreaming mode. Two paths still write on every update:node.updatedfor each reasoning delta, and those are not coalesced like Claude reasoning and Codex text.node.updatedandturn_item.updated) have no streaming filter.SessionStore.markDisconnected/markConnectedand reloads the snapshot.Likely fix area#
Some options:
PRAGMA synchronous=NORMALin WAL mode, which syncs at checkpoint instead of on every commit.#14701 is the read-path side of the same single connection. Open PR #14703 moves that read to a worker but leaves writes on the main thread, so it wouldn't cover this case. A trace slice from a stall would still help show the mix of events.
A maintainer will decide on the fix direction.