Skip to content

[Bug]: Remote updates under a pre-Oct-14 protocol-3 launcher still time out at 120 s and roll back in a loop on large databases #38526

Open

Description

@vitalyiegorov

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

  1. Install the background service on a build before 0.0.46-nightly.20261014.3105 (here: t3 service install on 0.0.46-nightly.20261003.2610). The systemd unit is ExecStart=~/.t3/runtime/versions/0.0.46-nightly.20261003.2610/t3 __service-launcher, and that launcher speaks protocol 3.
  2. Only update through the client after that (desktop "Update server" for the remote environment). Remote updates replace only the child, so the launcher stays at 0.0.46-nightly.20261003.2610 indefinitely. Recent children (0.1.10) still run under it because protocol 3 stays supported (apps/server/src/cloud/serviceProtocol.ts:9).
  3. Let statev2.sqlite grow large (here 21 GB: 5,246,110 pages, 1,311,893 on the freelist).
  4. From the client, update the server to a release whose migrations take more than about 2 minutes on that database: 0.1.10-nightly.20261115.4723 → 0.1.11-nightly.20261117.4814. That release runs migration 95_TurnItemInlineWorkOutput, which took 90 s on its own when run offline.

Expected behavior

The trial gets the 30-minute prepared deadline that #19311 introduced, so the migration finishes and the update commits. If the installed launcher cannot give it that deadline, the update should be refused up front with the existing "update the launcher on the server machine" guidance, not attempted.

Actual behavior

The old launcher still has PREPARED_TIMEOUT_MS = 12e4 (confirmed in the installed binary's bundled serviceLauncher). The trial is killed partway through migration 95, the snapshot is restored, and the service returns to 0.1.10:

{ "protocol": 3, "activeVersion": "0.1.10-nightly.20261115.4723",
  "update": { "targetVersion": "0.1.11-nightly.20261117.4814",
              "status": "rolled-back", "reason": "prepared-timeout" } }

The client still offers the update, so each retry repeats the whole cycle. Over Nov 16–18 this happened 6 times (5 for this target, 1 for 0.1.10-nightly.20261116.4761). Each attempt cost:

  • About 3–3.5 minutes with nothing listening on :3773. The relay logs dial tcp 127.0.0.1:3773: connect: connection refused for the whole window.
  • Every live provider session stopped. Shutdown reconciliation reported stoppedSessions: 19 and stoppedSessions: 50 on two of the attempts.
  • A full snapshot of the 21 GB database, and the same migration work again on the next try. docs/internals/server-updates.md names this cost ("the retry pays the same cost again"), but with a 120 s deadline a retry can never succeed.

The client shows only "The t3@{version} update rolled-back." It gives no reason and no action, so nothing tells the user that the launcher is the problem.

Root cause: #19311 (shipped in 0.0.46-nightly.20261014.3105) raised the deadline in the launcher, and the client now waits 32 minutes (SERVER_UPDATE_RESUME_TIMEOUT). A remote update never replaces the launcher, and protocol 3 is still accepted. So every service installed before Oct 14 and updated only from clients keeps the 120 s deadline, and heavy migrations have become common since then. Preflight checks only the protocol number (apps/server/src/cloud/servicePreflight.ts:46), and both kinds of protocol-3 launcher (120 s and 30 min) report the same number.

Impact

Major degradation or frequent failure

Version or commit

Launcher 0.0.46-nightly.20261003.2610 (protocol 3); server 0.1.10-nightly.20261115.4723 → 0.1.11-nightly.20261117.4814; code read on main @ 316c325

Environment

Omarchy (Arch Linux), kernel 7.1.8, systemd user service, btrfs, used remotely through the desktop app over T3 Connect. statev2.sqlite is 21 GB. The unit also has a MemoryHigh=6G drop-in, which throttles the trial, but the migration took 90 s even unthrottled, which leaves no margin under 120 s.

Logs or stack traces

# boot-service.log, one cycle (all six look the same)
[10:21:09.295] INFO Server update prepared; handing off to the service launcher.
    targetVersion: '0.1.11-nightly.20261117.4814'
[10:21:14.843] INFO V2 orchestration shutdown reconciliation completed { stoppedSessions: 50 }
[10:21:42.045] INFO Running database migrations
[10:21:42.049] INFO Upgrading database  migration: 95_TurnItemInlineWorkOutput  progress: 1 of 2
# no further output from the trial; launcher times it out and restores 0.1.10
[10:24:43.543] INFO Listening on http://0.0.0.0:3773      # back on 0.1.10

# same migration run by hand with no deadline (0.1.11 `t3 serve`, service stopped)
[10:28:02.720] INFO Upgrading database  migration: 95_TurnItemInlineWorkOutput  progress: 1 of 2
[10:29:32]          migration: 96_RepairStaleTitleRegeneration  progress: 2 of 2
[10:29:33.115] INFO Listening on http://127.0.0.1:3774

$ strings ~/.t3/runtime/versions/0.0.46-nightly.20261003.2610/t3 | grep PREPARED_TIMEOUT_MS
	PREPARED_TIMEOUT_MS = 12e4;

Workaround

Run the migration once with no deadline, then select the new runtime:

  1. systemctl --user stop t3code.service, then take a reflink backup of statev2.sqlite.
  2. T3CODE_HOME=~/.t3 ~/.t3/runtime/versions/<target>/t3 serve --host 127.0.0.1 --port 3774 --no-browser. Wait for Listening, then stop it.
  3. Set service-state.json to activeVersion: <target> (update status: "committed") and start the service.

A local t3 update that replaces the launcher should avoid the problem for later updates too.

Suggested fix (smallest first):

  • Refuse instead of looping. In preflight, read the launcher runtime version from the unit's ExecStart (already parsed in serviceProtocol.ts). If it predates 0.0.46-nightly.20261014.3105, refuse the remote update with the existing "requires a newer service launcher; run t3 update on the server machine" path, at least when the target has pending migrations.
  • Make the rollback actionable. When the outcome is rolled-back with reason prepared-timeout, the client should say so, suggest updating the launcher locally, and stop re-offering the same target to that environment.

Activity

  1. added
    vouch:trusted
    on Nov 18, 2026
  2. f4llenz commented on Dec 1, 2026

    @f4llenz
    Contributor

    Same bug on another host, still present in 0.1.14-nightly.20261201.5550:

    • Launcher 0.0.46-nightly.20261003.2610 (installed with t3 service install, then updated only from the desktop), Linux systemd user unit, statev2.sqlite 15 GB.
    • 0.1.9-nightly.20261111.4501 → 0.1.12-nightly.20261125.5230 rolled back on Nov 25, and 0.1.9 → 0.1.14-nightly.20261201.5550 rolled back three times on Dec 1, all with "status": "rolled-back", "reason": "prepared-timeout". Each trial was killed at migration 8 of 42 (88_TurnItemTypeStatusIndex), 120 s after spawn. One rollback's recovery reported stoppedSessions: 97.
    • The 0.1.14 preflight still accepted the protocol-3 launcher, so the desktop kept offering the update.
    • t3 update --yes on the host rewrote ExecStart to the 0.1.14 launcher (protocol 4). All 42 migrations then finished in 5 min 20 s. Going straight from the 0.0.46 launcher to the 0.1.14 one did not crash-loop here, unlike the report in [Bug]: In-app update keeps rolling back when the service launcher predates #19311 #41668.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions