[Bug]: Desktop starts a second backend against the background service database #6097
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
- Configure and start the background server with the default T3 home (for example,
t3 service install/t3 service start, listening on port 3773). - Launch the desktop app as the same OS user without overriding its T3 home.
- The desktop sees that port 3773 is occupied, selects 3774, and starts its embedded backend.
Expected behavior#
The desktop must not start a second backend against a database already owned by a running server. It should either reuse/pair with that environment or stop before opening the database and explain how to resolve the conflict.
Actual behavior#
The embedded desktop backend opens the same default database, ~/.t3/userdata/state.sqlite, as the background server. Two long-lived server processes then contend for one SQLite database. Authentication, orchestration, and thread creation intermittently fail with HTTP 500 and errors such as:
Primary environment request failed during fetch-session-state (HTTP 500).
database is locked
In the observed failure, the desktop app could not finish loading and the machine became severely resource constrained until it was restarted.
Root cause#
Desktop startup treats port ownership and data-directory ownership independently:
resolveDesktopBackendPortscans past occupied port 3773 and chooses another port.- The primary desktop bootstrap still passes the default
environment.baseDir(normally~/.t3) to the embedded backend. - Startup does not check the existing
server-runtime.jsonlease/descriptor before opening the same database.
SQLite WAL permits concurrent readers but does not make two independent long-lived server owners safe. A busy timeout may reduce transient SQLITE_BUSY errors (see #5099), but it does not address duplicate schedulers, WebSocket streams, command processors, or resource usage.
Suggested fix#
Before selecting another port or launching the embedded backend, inspect the runtime state for the selected T3 home and probe the advertised environment endpoint. If a live server already owns that home, fail closed before opening SQLite and show a specific recovery message (stop the background service, or use a separate T3 home and connect/pair with the existing environment). Ignore stale runtime state only after the probe confirms it is not live.
Add regression coverage proving that a live owner prevents embedded-backend startup while missing/stale runtime state preserves normal startup.
Impact#
- Desktop can fail to open.
- OAuth/session and orchestration writes return HTTP 500.
- Duplicate backends can consume substantial CPU/memory.
- Retrying or adding
busy_timeoutalone masks symptoms without enforcing single ownership.
Version or commit#
0.0.34-nightly.20260811.1064
Environment#
Linux desktop; background T3 service and desktop app running as the same user with the default T3 home.
Workaround#
Stop the background service before launching the desktop app, or launch the desktop with a separate T3 home and connect/pair to the background environment.
Yes, having some kind of thin client would be nice to have; I like having a service independent from the desktop app. Currently I'm using T3 code via T3 Connect in the browser, but hotkeys conflict with the browser, and some settings are broken or unavailable outside the app.
Another major symptom of this issue: T3 Connect / iOS remote access breaks#
I ran into this exact split-brain behavior on Linux (Fedora / KDE Wayland), and it causes a severe side-effect if you use T3 Connect (e.g. for the iOS app):
t3code.serviceruns in the background listening on127.0.0.1:3773with a provisioned Cloudflare tunnel for T3 Connect so the host can stay reachable while headless.- Launching the desktop AppImage finds port 3773 occupied, scans up to
127.0.0.1:3774, and starts a second server against the same~/.t3/userdata. - Because T3 Connect credentials are in
~/.t3/userdata/secrets, the secondary server reconciles the managed tunnel origin tohttp://127.0.0.1:3774and spawns a secondcloudflared. - Once the desktop AppImage is closed, the backend on 3774 dies, but the Cloudflare tunnel origin remains pointed to
3774. - The iOS client immediately fails with:
Relay could not reach environment endpoint (endpoint_request_failed)
Until the desktop client can attach as a thin client to an existing daemon, running both on the same machine completely breaks remote mobile access whenever the desktop app is opened and closed. A thin-client attach mode would resolve both the split-brain SQLite issues and the tunnel hijacking.
having some kind of thin client
yes, this is what my pr https://github.com/pingdotgg/t3code/pull/9376 is aimed at, but unfortunately its quite a large architectural change.
Adding a data point from macOS (T3 Code 0.0.42, Claude Code provider). Same "two servers, one T3 home" setup, but with a different and, I think, worse consequence than
database is locked: the second server resumes provider sessions that belong to the first one, so two agent processes run for one thread.Setup
- I ran
npx t3 connectto reach the machine from a phone. It offered and installed the background service (launchd,T3CODE_HOME=~/.t3) while the desktop app was already serving the same~/.t3. - Desktop server is on 3773, the service picked an ephemeral port, so the port-scan guard from #12241 would not have triggered. The service started 29 s after the desktop server, so a desktop-only check (#9376) would not cover this either.
t3 serveitself needs the ownership check.
Observed (generalized
ps)PID PPID COMMAND <d> 1 T3 Code (Alpha) # desktop main <ds> <d> .../apps/server/dist/bin.mjs --bootstrap-fd 3 # desktop server, :3773 <l> 1 (service launcher) <s> <l> ~/.t3/runtime/versions/0.0.42/t3 serve # service server <c1> <ds> claude --output-format stream-json ... --resume=<S> # original agent process <c2> <s> claude --output-format stream-json ... --resume=<S> # duplicate: same cwd, same session idThe duplicate appeared for four running threads within ~2 s, wrote to the same worktree and the same JSONL transcript, and was invisible in the desktop UI. Uninstalling the service made it stop. Consequences: one agent reverted another's uncommitted edits with
git checkout, and permission choices made in the visible thread do not apply to the invisible process.Why (from reading 0.0.42; the engine part is unchanged on current main)
OrchestrationEnginebuilds its command read model once at startup. After any failed dispatch,reconcileReadModelAfterDispatchFailurereadseventStore.readFromSequence(dispatchStartSequence)from the shared database and publishes every event persisted since then, including events written by the other process.- In the service,
ThreadSettlementReactor.sweeplists threads from the shared projection, dispatchesthread.auto-settlefor a thread its own read model has never seen, fails withThread '...' does not exist, and reconciles. The desktop'sthread.turn-start-requested/thread.user-input-response-requestedevents then reachProviderCommandReactorin the wrong process, which startsclaude --resume.
[12:12:57.429] WARN automatic thread settlement skipped { threadId: '<A>', cause: "... does not exist for command 'thread.auto-settle'" } [12:12:57.613] WARN provider command reactor failed to process event { eventType: 'thread.turn-start-requested', cause: "... Thread '<B>' does not exist for command 'thread.session.set'" } [13:27:26.492] WARN provider command reactor failed to process event { eventType: 'thread.user-input-response-requested', ... } [13:27:26.613] WARN provider runtime ingestion failed to process event { eventType: 'session.started', ... }The session had already been spawned at that point; only the ingestion into the service's read model failed, which is why the UI never shows it.
Suggestions on top of the fix proposed here
- Enforce single ownership in server startup itself (
t3 serve/ the service, not just desktop): probe the live owner fromserver-runtime.json, fail closed, and never let an exiting instance delete a record it does not own. - Events read back during reconcile that this process did not author should update the read model but not be published to reactors that start provider sessions.
t3 connect/t3 service installshould warn or refuse when a live server already owns that home. The docs point desktop hosts to Settings → Connections, but the CLI onboarding does not mention it.
Caveat: I have not reproduced this with an isolated test. The 12:12 replay follows directly from the settle failure in the log; the trigger of the 13:27 replay is not directly visible (trace files rotated).
- I ran
Another consequence of this same root cause, on a different axis than the SQLite contention: the desktop backend also takes over T3 Connect, and the background service never gets it back.
Environment: t3
0.0.42, macOS26.6.2arm64, cloudflared2026.7.3, background service installed, T3 Connect linked.Mechanism#
Because the embedded backend opens the same default
~/.t3/userdata, it also reads thet3 connect linkstate living there. On startup it re-registers the same environment with its own port, so the relay re-points the managed tunnel ingress at:3774. The daemon'scloudflaredpicks that routing up from Cloudflare automatically — the tunnel is remotely managed (TUNNEL_TOKEN), so there is no local config involved and nothing on the machine can correct it.On quit,
releaseManagedTunnelOnShutdownfails:environment.cloud.releaseManagedTunnelOnShutdown Failure EnvironmentHttpInternalServerError: T3 Connect: Relay internal error: upstream_unavailable.The tunnel therefore survives with its now-dead
:3774routing, and the daemon's own cloudflared keeps forwarding there indefinitely:ERR error="Unable to reach the origin service ... dial tcp 127.0.0.1:3774: connect: connection refused" originService=http://127.0.0.1:3774The daemon is listening on
:3773the whole time. It never re-claims, because it reconciles the link only at startup (T3 Connect desired link reconciled on startup).Measured#
Continuous probe of the relay URL across one open/quit cycle:
08:09:54 200 app open, 2 servers 08:09:55 app quit 08:10:00 502 broken within 4s 08:10:10 502 no recoveryIt stays 502 indefinitely. Only
t3 service restartrecovers it, after which the route takes ~60-140s to propagate (flapping 200/530) before settling.The user-visible part is that this is silent: throughout the outage
t3 service statusreportsinstalledandt3 connect statusreportsExposure: enabled / Environment link: provisioned. Both are saved-setup checks and neither validates that the tunnel reaches a live origin.Notes for the fix#
#9003 would resolve this symptom too, since it prevents the second backend from starting at all.
Worth flagging separately though: the daemon-side gap is real on its own. Even if the release had succeeded, the tunnel would be deleted with nothing to replace it, because only a server starting up reconciles the link. The same dead end is reachable without the desktop app — a stray
npx t3 serveclaims the link the same way, and an app crash releases nothing at all. Periodic reconciliation, or reconciliation on repeated origin-unreachable errors, would close all three.Workaround#
Launching the app against an isolated home avoids the takeover entirely, since its backend then generates its own
environment-idand registers as a separate environment:open -a "T3 Code" --env T3CODE_HOME="$HOME/.t3-desktop"Verified on this machine: with that in place the relay stayed
200across app open and quit, with exactly one cloudflared (daemon-owned) throughout. Note--envonly applies to that launch, so a Dock/Spotlight launch still hits the bug. The cost is a separate thread database for the app.Adding to @sergiolopez94's T3 Connect finding, because in my setup it explains how remote actions reached the stale server.
My order was the reverse of his: the desktop backend started first, the background service 29 s later. Every server calls
reconcileDesiredCloudLinkwith its own loopback origin at startup when the CLI desired link is set, and the last one wins. In my logs that was the service (T3 Connect desired link reconciled on startup, 38 s after the desktop backend started), which then held the tunnel for about 19 hours. The phone was talking to the server whose in-memory command model was stale, while the desktop showed the same threads.That adds a second trigger to the replay I described above. Besides the settlement sweep, any command a remote client sends for a thread that server has not seen fails in
requireThread, and the failure path (reconcileReadModelAfterDispatchFailure) replays the shared event store into its reactors. At 13:27 the replayed event was athread.user-input-response-requested, and the duplicates appeared for exactly the turns that had started since the previous replay and were still running.It also confirms the "even if the release had succeeded" case: when I uninstalled the service, it logged
Released the managed tunnel on shutdown. The desktop backend kept running and did not re-claim it, and remote access stayed dead until I re-linked from the desktop UI the next day.One caution about periodic reconciliation: with two live servers on one home, both would keep pointing the ingress at themselves and flap between them. Reconciling after repeated origin-unreachable errors is safe; periodic reconciliation only works together with single ownership of the state directory (#8442).
Another way to hit this, on Windows with a WSL backend. None of the open fixes except #8442 look like they cover it.
Setup: the Windows desktop app with its WSL backend enabled, plus
t3code.service(systemd user unit fromt3 service install) running inside the same distro. Both use the defaultT3CODE_HOME=~/.t3in the distro, so both open the samestate.sqlite. The desktop starts its WSL server throughwsl.exeon its own port and never checks whether a service already owns that home.Result was the same as @Hermanik's report: two Claude processes ran for one thread in the same worktree. The visible agent and the invisible one both acted on the same user answers. On 2026-09-26 both ran the same side-effecting script about 10 seconds apart. Disabling
t3code.servicestopped it.On the fix PRs:
- #9003 and #10360 only change
apps/desktop/src/app/DesktopApp.ts. They refuse the port fallback for the primary desktop backend, but the WSL backend's start path isn't touched, so I don't expect either to stop this case. I haven't tested it. - #8442 takes the lock in the server against the state directory, so it should catch this case regardless of which side starts second.
- #9376 (desktop as a client of an existing server) would give the behavior I'd expect: when a live service owns the distro's T3 home, the WSL backend connects to it instead of starting a second server.
Workaround for now: keep
t3code.servicedisabled and use the desktop's own server for remote access.- #9003 and #10360 only change
Follow-up to my earlier comment: #13295 fixes the duplicate-agent part of this. I reproduced it in isolation on Linux, outside my normal T3 home.
Two
t3 serveprocesses shared one throwaway--base-diron loopback. Server A created a project and a Claude thread and started a turn. Server B had already started and had never seen that thread. I then sent B athread.meta.updatefor the thread. B rejected it withThread 't-dup' does not exist, andreconcileReadModelAfterDispatchFailurereplayed the shared event store.Build Claude processes started by B projection_turnsrowsUser prompt in the Claude transcript 0.0.45-nightly.20261002.2561 (2 runs) 1 2, the extra one with pending_message_id = NULL2 main at 024d4952 (includes e0db2a5) 0 1 1 024d4952 with only the OrchestrationEngine.tschange from #13295 reverted1 2, the extra one with pending_message_id = NULL2 B's command failed in every run, so B's model really was out of date each time. The broken runs show the same signature as #13275.
Limits: I only exercised the failed-dispatch trigger. The settlement sweep @Hermanik described reaches the same reconcile path, but I didn't trigger it directly. I also didn't test the 0.0.46 preview line, since it runs the V2 orchestration engine. This issue stays open: two servers on one T3 home still contend for
state.sqliteand the T3 Connect tunnel, so #8442 or #9376 are still needed.Still reproduces on 0.0.45 (macOS arm64). With the background service on 3773, the desktop app started its embedded backend on 3774, launched its own
cloudflared, and took over the T3 Connect tunnel.A lasting workaround that keeps one database: turn off Settings → Connections → Local environment. The desktop app then skips its embedded backend, including for Dock and Spotlight launches, unlike the
T3CODE_HOMEoverride. Restart the service afterward (t3 service restart) so it reclaims the tunnel.It would help if the desktop app detected a live service-managed server in
server-runtime.jsonand offered this mode instead of starting a second backend.Still reproduces on 0.0.45 with the Linux
.deb(Debian 13), background service + T3 Connect. The desktop app ran against the shared~/.t3for about 80 seconds, and that was enough to:- re-register the managed tunnel origin to
127.0.0.1:3774(cloud-endpoint-confirmed-originnow names port 3774); - delete the service's
server-runtime.jsonon exit, sot3 pairreported "No running T3 Code server found" while the service was up.
The symptom that might help others find this: chat kept working remotely, but images in threads failed to load and attachment uploads failed. Thread traffic goes over the relay WebSocket, while assets and uploads go over HTTP through the tunnel, which now hit the wrong backend. The public URL's
/.well-known/t3/environmentreturned the desktop backend'senvironmentIdinstead of the service's.A workaround that doesn't interrupt running turns (
t3 service restartdoes): forward the stale port to the service, e.g. a systemd socket on127.0.0.1:3774runningsystemd-socket-proxyd 127.0.0.1:3773, until the next service restart re-registers the right origin.- re-register the managed tunnel origin to
Another symptom of this, on Linux (Pop!_OS, AppImage 0.0.45) with the background service + T3 Connect, Codex provider: mobile follow-ups alternate between working and
thread <id> already has an active writer.Each backend starts its own
codex app-server, and both share~/.codex/thread-writer-locks. Whichever opens the thread first takes the flock:$ grep <inode of 01a111cc-….lock> /proc/locks FLOCK ADVISORY WRITE 41089 … # codex app-server, child of `t3 serve` (service, :3773)Both
cloudflaredprocesses register the same tunnel ID, so mobile requests reach either backend. Quitting the desktop app moves the lock to the service's codex. Reopening the desktop app reverses it, and the error moves to the other client. Every retry failed until one backend was stopped. Deleting the lock isn't needed: it releases cleanly when the owning backend exits.Workaround confirmed: only one backend alive (Settings → Connections → Local environment off, per @praveenperera above).
Same here on macOS with 0.0.45. @praveenperera’s workaround worked for me. Remote access now keeps working after I quit the app.
The app still goes through T3 Connect even on the same Mac though. Could it just connect to the running service over localhost?
Hitting this on Linux (Fedora 44, kernel 7.2) with the 0.0.45 AppImage plus the
t3code.servicesystemd user unit (installed for T3 Connect / mobile access). The symptom that brought me here was Codex, not SQLite: every new Codex thread failed withthread <id> already has an active writer.State when it happened
t3 serve(service, ~23h uptime) on127.0.0.1:3773- desktop embedded backend (~21h uptime) on
0.0.0.0:3774, same default~/.t3 - 3
codex app-serverprocesses under the desktop backend, the oldest ~11h old
So two backends shared one data dir and both tried to drive the same Codex threads. Whichever one lost hit Codex's per-thread writer lock.
Workaround that worked (one backend, mobile still works)
- Set
"localEnvironmentEnabled": falsein~/.t3/userdata/desktop-settings.json. That's the same setting as Settings → Connections → Local environment. I also re-applied it after the app exited in case quitting wrote the old value back. - Fully quit the desktop app, then run
t3 service restart. Order matters: quitting the desktop deleted the service'sserver-runtime.json, which matches the report above. Restarting afterwards rewrites it and gives T3 Connect back to the service. - Pair the desktop to the service with
t3 pair --label desktop.
After relaunch, only
:3773is listening, there are no leftovercodex app-serverprocesses, and the desktop setting stuck.+1 for the desktop detecting a live service-owned
server-runtime.jsonand offering thin-client mode instead of starting a second backend. As it is, installing the service for mobile access silently breaks Codex in the desktop app.Confirmed this on T3 Code 0.0.45 on 2026-10-08. Disabling the desktop's local environment and connecting it to the existing background service resolved the duplicate-server setup.
Environment and deployment#
- OS: Omarchy 4.0.4 (Arch-based Linux), x86_64; kernel
7.2.5-3-omarchy. - Desktop: Linux AppImage, version 0.0.45, running under Hyprland/Wayland.
- Background server: version 0.0.45, managed by the user-level systemd unit
t3code.service, withT3CODE_HOME=~/.t3. - T3 Connect was configured on this machine.
- Triage was started with
npx t3 triage(Node v26.8.2).
What happened#
The background service had been running since October 5 on
127.0.0.1:3773. Launching the desktop AppImage on October 8 started another backend on0.0.0.0:3774. Process ancestry confirmed that the first belonged to the systemd service and the second to the desktop app.Both server processes had the same
~/.t3/userdata/state.sqliteand its WAL open, and each had its own managedcloudflaredchild. These were two instances of the same version, rather than two different installed server versions.An additional diagnostic inconsistency: the generated triage context reported “server process: not running” because
server-runtime.jsonwas missing, even though the background server was listening on 3773. We did not establish what removed that file.Workaround applied#
- Backed up
~/.t3/userdata/desktop-settings.jsonand gracefully quit the desktop app. - Set
"localEnvironmentEnabled": falsein that file (the Settings → Connections → Local environment setting). - Restarted the existing service with
systemctl --user restart t3code.serviceafter the desktop exited. - Relaunched the AppImage and, in Settings → Connections, added this machine's existing T3 Connect environment. The desktop then showed it as Connected. Existing saved connections were preserved.
This used the existing T3 Connect connection; no manual pairing token was needed. No source patch or direct database edit was made.
Validation#
- Desktop UI showed Local environment turned off and this machine's T3 Connect environment Connected.
t3code.servicewas active.- Only port 3773 remained listening; the desktop backend on 3774 was gone.
- Inspection of
/proc/*/fdfound only the background server holdingstate.sqliteopen.
This confirms the duplicate-owner problem and a working configuration workaround on 0.0.45. We did not independently confirm database-lock errors or data corruption in this session.
Prepared and posted with Codex (GPT-6 Astra) during local T3 triage.
- OS: Omarchy 4.0.4 (Arch-based Linux), x86_64; kernel
Another occurrence on Linux Mint, investigated on 10 October 2026. This appears to be an SSH/runtime-replacement variant of the same shared-home ownership problem, rather than the desktop starting its local backend.
Related: #17003 describes the startup/shutdown recovery effects when duplicate backends share one T3 home.
Observed state#
The desktop already had
localEnvironmentEnabled=false, andt3code.servicewas inactive. Two standalone server processes were still alive:PID Runtime Started, Australia/Sydney 414916 0.0.46-nightly.20261008.28499 October 2026, 12:09:42 AEDT 1036494 0.0.46-nightly.20261009.28739 October 2026, 23:49:50 AEDT Both had the same command shape:
<runtime>/t3 serve --host 127.0.0.1 --port 3773 --base-dir <home>/.t3Both were reparented to PID 1 and belonged to different login-session cgroups. Both stdout descriptors pointed to the same
~/.t3/ssh-launch/<host-key>/server.log.At inspection, only PID 1036494 owned the listening socket on
127.0.0.1:3773. The shared SSH-launch PID file anduserdata/server-runtime.jsonalso identified PID 1036494. The generated SSH runner selected build.20261009.2873, but the older process remained alive with provider and relay children.User-visible failure#
A Codex follow-up failed to start with:
Codex App Server process exited with code 0The server trace for that same app thread showed repeated
orchestrationV2.providerTurnStart.startfailures with stack paths under the older.20261008.2849runtime, although the reachable server was the newer runtime.Recovery and verification#
- Backed up the V2 database and runtime/settings files.
- Sent SIGTERM to the older, non-listening backend. It did not exit during the observation period, so it was subsequently stopped with SIGKILL.
- Left the newer backend running.
- Selected Codex again in the affected thread and submitted a diagnostic-only turn.
That turn successfully executed
pwd, produced an assistant reply, and reached durablecompletedstatus. The surviving server's discovery endpoint returned HTTP 200, and SQLitequick_checkreturnedok. No direct database edits were made.Attribution limits#
An SSH reconnect or runtime replacement leaving its predecessor alive is the suspected trigger, based on the shared launch directory and mixed runtime versions. We have not established the exact initiating operation or reproduced it in isolation. The recovery also changed the thread's provider selection, so it is not a controlled proof of the duplicate backend causing the Codex subprocess exit.
The screenshot additionally contained OpenCode
ECONNRESETerrors after switching providers. Those were traced separately to an unhealthy LAN LiteLLM service: a basic health request also reset. They should not be attributed to T3 networking.The confirmed defect is that two backends could remain active against the same T3 home, with the older runtime still attempting provider work while only the newer one was discoverable. Please include SSH-launched runtime replacement/reconnect in coverage for the exclusive-home ownership fix.
Prepared and posted with Codex during local investigation. Raw databases, provider transcripts, credentials, private hostnames and connection identifiers are omitted.
Another data point, macOS 27.0.1, Claude Code provider. Background service
t3 serve0.0.44 (launchd) plus desktop 0.0.45 embedded backend, both on the default~/.t3. The replay @Hermanik described re-sent already-completed turns from 1.5 days earlier into idle, settled threads, and an agent acted on the re-sent prompt with no user involvement.Trigger: PR sync. The service had started at sequence 19301 and never saw the desktop's later events. 37 h later its
PullRequestSyncReactordispatch failed:[16:54:08.734Z] WARN pull request sync skipped { threadId: 'bfc5bc1b…', key: 'github.com//#20' }
reconcileReadModelAfterDispatchFailurethen republished every event after 19301 (~1,700, all written by the desktop backend), and the service'sProviderCommandReactorre-ran everythread.turn-start-requestedin that range.Evidence (state.sqlite): immediately after seq 21038 (
thread.pull-request-synced, 16:54:08.066Z), server-authored events appear withoccurred_atcopied from the original turn starts:21039 thread.unsettled occurred_at=2026-10-08T05:39:48Z actor=server cmd=server:provider-session-set:… 21040 thread.session-set occurred_at=2026-10-08T05:39:48Z status=starting 21043 thread.session-set occurred_at=2026-10-08T06:29:14Z status=starting
- 30 turn starts replayed (seq 19304–20212, Oct 8 05:39Z to Oct 9 11:19Z) across 8 threads. 2 threads ran new turns, the other 6 got
provider-failure-activity. - In the Claude transcript, all three earlier user prompts of one thread arrive again at 16:54:09–28Z: one as a normal user message, two as
queued_commandattachments (absorbed_mid_turn). None appear as new messages in T3. - The agent reasoned "Since the user repeated their request after my concern, I'll treat that as their decision and proceed", then created a worktree and branch and opened a GitHub PR. The user never asked for any of it.
So with two servers, the risk isn't only duplicated running turns. Any later dispatch failure in the stale server can re-send old prompts in finished threads. That supports suggestion 2 above: events read back during reconcile that this process didn't author should never reach reactors that start provider sessions. #16102 would prevent this.
Filed by: Claude Code (claude-opus-5-5) following the
t3 triageplaybook.- 30 turn starts replayed (seq 19304–20212, Oct 8 05:39Z to Oct 9 11:19Z) across 8 threads. 2 threads ran new turns, the other 6 got
Confirmed the same ownership problem on an Apple Silicon M1 Mac on 2026-10-13, using the V2 database and nightly
0.0.46-nightly.20261013.3053. This adds a mixed-version update case, a third SSH-launched owner, and a verified workaround that preserves the existing threads.The desktop update succeeded, but an older background service kept running against the same T3 home. Later, three server processes had the same
statev2.sqliteopen.Observed owners#
Owner PID and parent Build Listener Background service 27791, parent 27784 0.0.46-nightly.20261013.3042127.0.0.1:3773Desktop backend 25140, parent 25089 0.0.46-nightly.20261013.3053*:3775SSH-launched standalone backend 41280, parent 1 0.0.46-nightly.20261013.3053127.0.0.1:3775The desktop and service both held the database and its WAL open. At 12:55:49 UTC,
server-runtime.jsonwas missing even though both servers were alive. By 13:04:13 UTC, the runtime descriptor identified the SSH-launched PID 41280, while the older two owners remained alive. I have not isolated the initiating operation that created this third owner or what removed the earlier descriptor.Redacted process, update trace, and database ownership evidence
These are selected captured fields and command output. Home paths, account names, connection identifiers, and application content are omitted or replaced. Timestamps are UTC unless marked otherwise.
Desktop update trace, 2026-10-13: 11:10:26.960692Z client Mac desktop.updates.installDownloadedUpdate Success 11:10:55.226892Z M1 host desktop.updates.installDownloadedUpdate Success 11:10:59.884695Z M1 host desktop.bootstrap Success event: selected backend port via sequential scan event: bootstrap backend start requested M1 service configuration captured at 12:55:49Z: Label: com.t3tools.t3code.service ProgramArguments: <HOME>/.t3/runtime/versions/0.0.46-nightly.20261013.3042/t3 __service-launcher runtimeDescriptorExists: false Earlier WAL handles, 12:55:49Z: T3\x20Cod 25140 <user> 27u REG 1,16 4416672 777712801 <HOME>/.t3/userdata/statev2.sqlite-wal t3 27791 <user> 17u REG 1,16 4416672 777712801 <HOME>/.t3/userdata/statev2.sqlite-wal lsof statev2.sqlite, 13:14:21Z: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME T3\x20Cod 25140 <user> 26u REG 1,16 138395648 774352582 <HOME>/.t3/userdata/statev2.sqlite t3 27791 <user> 16u REG 1,16 138395648 774352582 <HOME>/.t3/userdata/statev2.sqlite t3 41280 <user> 15u REG 1,16 138395648 774352582 <HOME>/.t3/userdata/statev2.sqlite Python 52816 <user> 3r REG 1,16 138395648 774352582 <HOME>/.t3/userdata/statev2.sqliteThe Python process was the read-only diagnostic connection. The other three were T3 servers. The identical inode verifies that these were not separate database copies.
Both Macs' installed desktop
app.asarfiles had the same SHA-256 and.3053version. The captured desktop update sequence was client first, M1 about 28 seconds later. The confirmed version mismatch was between M1's desktop and its still-running background service, not between the two desktop installations.Workaround applied and verified#
I kept M1's background service as the only owner, because the machine is used as a remote host.
Backed up the current and legacy databases, settings, connection catalog, service state, and launchd configuration. Both database backups passed SQLite
quick_check.Temporarily disabled the saved M1 SSH connection in the client desktop. Its SSH-launched server exited.
Gracefully stopped the known background service and desktop app. Verified that no server still held the database before changing the desktop settings.
Preserved the other desktop settings and set
"localEnvironmentEnabled": falsein~/.t3/userdata/desktop-settings.jsonwhile the desktop was stopped. This is the setting behind Settings > Connections > Local environment.Ran the supported update command on M1 to align the service and CLI with the installed desktop build:
~/.local/bin/t3 update 0.0.46-nightly.20261013.3053 --yesRe-enabled the client's saved M1 SSH connection. It showed Connected and reused the service. No additional database server appeared.
Redacted update and post-recovery verification
t3 update output: Switching T3 Code 0.0.46-nightly.20261013.3042 to 0.0.46-nightly.20261013.3053 Using the downloaded release... Restarting the background service... Installed T3 Code 0.0.46-nightly.20261013.3053 Background service restarted on 0.0.46-nightly.20261013.3053 t3 service status: Status: installed, t3@0.0.46-nightly.20261013.3053 Unit: <HOME>/Library/LaunchAgents/com.t3tools.t3code.service.plist CLI symlink and launchd ProgramArguments both select: <HOME>/.t3/runtime/versions/0.0.46-nightly.20261013.3053/t3 service-state.json: protocol: 3 activeVersion: 0.0.46-nightly.20261013.3053 server-runtime.json: pid: 57053 port: 3773 origin: http://127.0.0.1:3773 startedAt: 2026-10-13T13:19:16.394Z serviceManaged: true Final lsof check after the read-only verifier closed: t3 57053 <user> 16u REG 1,16 140857344 774352582 <HOME>/.t3/userdata/statev2.sqlite The same service PID owned the database before and after client reconnection. All previously identified server and provider subprocess PIDs had exited.Formatting and redaction normalize paths and punctuation in these excerpts. The values are from the captured commands, not a hypothetical example.
At 13:24:29 UTC, all 21 pre-existing V2 thread IDs and all 1,390 captured turn-item IDs were still present. Normal continued work increased the totals to 22 threads and 1,488 items. All five legacy projection thread IDs were also retained. No live database records were edited directly.
The one active M1 review thread interrupted by the handover automatically resumed at 13:19:16 UTC. Its new turn contained
T3 Code restarted and resumed this turn, a fresh assistant response, and a completed checkpoint. It finished at 13:19:35 UTC. The parent chat then continued, executed eight commands, and completed at 13:23:04 UTC. No manual duplicate continuation messages were sent.For subsequent updates, the M1 environment's server update action or
t3 update --yeson M1 now targets the background service. Updating the desktop application is a separate operation. M1's desktop local environment remains disabled, and its app was left closed. I verified the saved setting against the installed desktop bootstrap code, but did not test reopening that desktop app during this repair.Follow-up source analysis with Kimi K3#
An independent Kimi K3 analysis identified additional mechanisms, which Codex checked against the installed
.3053bundle and the matching release source. These are code-supported failure paths, not proof of the sequence that produced this incident.- The runtime descriptor is not an ownership lock. Each server writes the same file after activation. Its shutdown release calls an unconditional file removal, without comparing the current descriptor's PID or generation. An older owner's shutdown can therefore remove a newer owner's descriptor. A failed project-CLI snapshot request also clears the descriptor. We did not establish which path removed it here.
- The SSH launch path bypasses the existing startup guard. The guard requires
rejectRunningServer && mode === "web".t3 serve, which the SSH launcher invokes, does not enable it. Desktop mode is excluded too. A missing descriptor plus an available port is therefore insufficient evidence that the data directory is unowned. - Updating is not an owner census.
findForegroundServerinspects only the descriptor and returns no foreground owner if it is missing or markedserviceManaged. Version alignment alone cannot establish that hidden duplicate owners are gone. The workaround above checked process and database ownership separately.
Codex also checked the SSH replacement path.
wait_for_pid_exitwaits through at most 20 intervals of 0.1 seconds. The managed-server replacement branches clear the remembered PID and port afterward without requiring proof that the old process exited. A local simulation of the exact shell control flow, withkill,sleep, and readiness replaced by stubs, produced this result for both a changed runner and failed readiness:oldPidStillAlive=true replacementBranchEligible=true stopCalls=1 sleepCalls=20This validates the control-flow gap only. The simulation started no T3 server and signalled no process. It does not establish that a slow shutdown caused the third owner observed here.
Useful regression cases are an old owner exiting after a new descriptor is written, a failed project-CLI request while the owner remains alive, and an SSH-managed owner taking longer than two seconds to stop. Each should preserve exclusive database ownership and avoid clearing another live owner's descriptor.
Scope and related evidence#
This establishes duplicate ownership and a working configuration workaround. It does not establish database corruption or a
database is lockederror in this incident. No candidate ownership-lock patch was installed.The same investigation began with a separate client-Mac responsiveness incident. The full redacted SQLite stack, query traces, query-plan excerpts, and restart evidence are now posted in the companion report on #14701. That machine had a single desktop-owned server, a roughly 22.8 GB database, and substantial CPU and swap pressure. Selected redacted trace values were:
span end, UTC operation duration_ms 2026-10-13T12:12:08.838352Z turn-item history SELECT 26826.100416 2026-10-13T12:12:24.039006Z provider-thread history SELECT 14677.541916 2026-10-13T12:13:05.713221Z selectShellThreadRows SQL 23967.135416 2026-10-13T12:13:07.364461Z http.orchestration.loadShellSnapshot 25618.489583 Native sample at 12:12:14Z: 1,920 sampled main-thread stacks included node::sqlite::StatementSync::AllThese are observed wall-clock spans under load, not isolated query benchmarks. Restarting the client desktop restored responsiveness, and all nine interrupted chats later produced new assistant responses and command activity. The
/healthURL returned fallback application HTML, so its HTTP timings are not application-health or RPC proof. There is no established causal link from M1's duplicate owners to that client-side SQLite stall.Please include missing-runtime-descriptor recovery, SSH reconnect, and desktop/service version divergence in coverage for the ownership fix. The key invariant is one server per T3 data directory, regardless of available ports or which updater ran.
Prepared with Codex / GPT-6 from local process, trace, and read-only database evidence. Raw databases, credentials, private host addresses, thread content, and provider transcripts remain private.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Desktop app should probably detect the long running server and connect to it, behave as a thin client?
Ideally transparent to the user, or can be explicit
edit: would have to weigh the pros/cons vs just telling the user to open a full-window pwa instead... loses native integration;
t3://protocol handlers, tray, global shortcuts, native menus but, no version skew on server/ui, user can just drop desktop binary