t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: On Linux the service writes its log file synchronously, so a slow disk freezes the server for up to 36 s

Open lingolooper-simon opened this issue 1 week ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On Linux, run t3 service install. The user unit sends stdout and stderr to a file: StandardOutput=append:…/userdata/logs/boot-service.log.
  2. Keep the T3 home on a disk under heavy write load (here btrfs on dm-crypt, on a DRAM-less QLC NVMe that agents' builds keep busy).
  3. Use T3 from another device and watch userdata/logs/event-loop-stalls.ndjson.

Expected behavior

Writing a log line never holds up the server.

Actual behavior

The remote apps keep showing "… is reconnecting". In 8.5 hours the stall log recorded 48 freezes of 2 s or more, the longest 35.7 s.

Kernel stacks taken during a 36.7 s freeze all show the main thread in one 63-byte write() to fd 1, which is boot-service.log:

write(1, …, 63)
 → btrfs_buffered_write → prepare_one_folio
 → __filemap_get_folio_mpol → folio_wait_writeback

Node writes stdout synchronously when it is a file, and the server logs to stdout. btrfs makes an append wait while the file's last page is under writeback.

After a drop-in that sends stdout and stderr to the journal, the main thread no longer blocks in write(): 1 freeze of 2 s or more in the next hour, against 48 in the 8.5 hours before. The freezes left are in fork (#31422).

Impact

Major degradation or frequent failure

Version or commit

0.1.11

Environment

Linux 7.2.15, headless t3 serve as the systemd user service. btrfs (zstd:3, discard=async) on LUKS, DRAM-less QLC NVMe at 90% full.

Logs or stack traces

See the stack under Actual behavior.

Workaround

# ~/.config/systemd/user/t3code.service.d/stdout.conf
[Service]
StandardOutput=journal
StandardError=journal

then systemctl --user daemon-reload && systemctl --user restart t3code.

Hint: the unit lines are in apps/server/src/cloud/bootService.ts:140-141, and serviceProtocol.ts:95 reads the log path back from them. Related: #15707 (same btrfs wait, then from database commits), #34886.

Drafted with Claude Opus 5.5 (Claude Code) on behalf of @lingolooper-simon.

lingolooper-simon avatar Nov 20 '26 18:11 lingolooper-simon