Skip to content

bug(store): engram serve takes 26 s to 8 min to bind its port on Windows with an 845 MB store and a 268 MB uncheckpointed WAL #2400

Closed

Description

@ardelperal

Existing Issue Search

  • I searched existing issues and will add evidence to a canonical tracker when applicable.

Closest: #1967 (concurrent store opens serialize and stall engram serve). This report differs: the server is not yet listening at all, the delay is between process start and HTTP server listening, and it happens at logon when serve is the first process to open the store. #1967 also notes that its WAL checkpointed normally, while here the WAL had grown to 268 MB. If maintainers judge it the same root cause, I will move this evidence there.

📝 Observed Consequence

After a Windows logon, engram serve 7437 runs for a long time before it binds the port. During that window every client gets connection refused, so agent sessions start without memory or, in the case of Gentle Shell, sit on a blank terminal until the endpoint appears. On the worst occurrence the gap was 8 minutes.

Separately, the WAL file had grown to 268 MB next to an 845 MB database and was still that size after a clean shutting down..., so it was not being checkpointed during normal operation or at shutdown.

🔄 Steps to Reproduce

I do not have a synthetic reproduction; these are field observations from one machine (observed).

Setup: Windows 11, engram serve 7437 started at logon by a supervisor script with ENGRAM_CLOUD_AUTOSYNC=0 and ENGRAM_NO_UPDATE_CHECK=1. Clients: Pi through gentle-engram, plus engram mcp processes from other agents.

  1. Use a store of about 845 MB with a WAL of about 268 MB.
  2. Log on (or restart the server) and record the time between process start and the HTTP server listening log line.

Start-to-listening times from the supervisor log:

Date Process start Listening Gap
2026-11-18 11:50:27 11:51:43 76 s
2026-11-19 17:38:22 17:38:48 26 s
2026-11-20 10:12:58 10:14:11 73 s
2026-11-20 11:07:29 11:15:34 8 min 4 s
2026-11-20 (after checkpoint, see below) 11:20:40 11:20:43 3 s

During the 8 minute start the process was mostly idle rather than reading: at 431 s of age it had used 8.4 s of CPU and read 149 MB in total, with 12 MB of working set. Other engram processes started at 11:15:27 read the same roughly 330 MB in a few seconds.

What I did before the last row: stopped the server, took a copy through the SQLite backup API, ran PRAGMA wal_checkpoint(TRUNCATE) (WAL went to 0 bytes, PRAGMA quick_check returned ok), and started the server again.

✅ Expected Behavior

  • engram serve binds its port within a few seconds of starting, or binds early and reports "not ready" until the store is verified, so clients can tell "starting" from "absent".
  • The WAL is checkpointed during normal operation and at clean shutdown, so it does not grow to hundreds of megabytes.

❌ Actual Behavior

  • 26 s to 8 min between process start and listening, with connection refused for the whole window.
  • WAL at 268 MB after a clean shutdown.

hypothesis, not proven: that the large WAL is what makes the start slow. The 3 s start happened after the checkpoint, but it also happened on an idle machine, while the slow starts all happened right after logon with other software starting at the same time. I have one data point per condition, so I cannot separate the two. I also cannot rule out a lock wait: the process being idle for most of the 8 minutes looks more like waiting than like recovery work.

Operating System

Windows 11 Pro (build 26300), x64, NVMe SSD

Release Version (Report Context)

engram 3.7.2. gentle-engram 0.5.1 (Pi client).

Agent / Client

Pi through Gentle Shell (gentle-pi 4.8.0-main.a9d3f5661621, Pi 1.5.2), plus engram mcp processes started by Claude Code sessions.

📋 Relevant Logs

2026/11/20 11:05:42 [engram] shutting down...
[20/11/2026 11:07:01,92] supervisor starting
[20/11/2026 11:07:29,98] endpoint not ready; starting engram serve 7437
2026/11/20 11:15:34 [engram] HTTP server listening on 127.0.0.1:7437

Store files at 11:14 (server started 11:07:30, not yet listening):
engram.db       885,473,280 bytes   modified 11:05:42
engram.db-wal   281,519,632 bytes   modified 11:05:34
engram.db-shm        32,768 bytes   modified 11:08:22

After stop + backup + PRAGMA wal_checkpoint(TRUNCATE) + quick_check ok:
[20/11/2026 11:20:40,40] endpoint not ready; starting engram serve 7437
2026/11/20 11:20:43 [engram] HTTP server listening on 127.0.0.1:7437

💡 Additional Context

  • What works and should keep working: the /compatibility ready contract and server reuse by clients once the endpoint is up; a store copied through the backup API and checkpointed manually passed quick_check.
  • Microsoft Defender real-time protection was on for the first three rows; the Engram data directory and engram.exe were excluded before the 8 minute start, so antivirus scanning does not explain that one.
  • Happy to run a specific diagnostic on the next slow start if you tell me what to capture (for example a goroutine dump or a trace flag).

Activity

  1. added
    status:needs-review
    type:bug
    on Nov 20, 2026
  2. added
    status:approved
    and removed
    status:needs-review
    on Nov 22, 2026
  3. self-assigned this
    on Nov 22, 2026
  4. dnlrsls commented on Nov 23, 2026

    @dnlrsls
    Member

    Closing as completed in main at dbbd08d78d8c8b94e37b1763fc8351f505b47690. This is the integrated source revision. The latest public release, v3.7.2, predates these fixes.

    • In a native Windows run with actual identity and migration locks on a disposable store, GET /health first returned the explicit startup 503 after 0.361 s. It returned ready 200 with the store's identity at 9.236 s, after both locks had cleared. Early listener · Windows client handling
    • In a separate native Windows comparison using a disposable WAL of 282,969,872 bytes, the old build retained that allocation after checkpoint, reuse, and orderly shutdown. Main retained the frames a pinned reader needed, reclaimed the file to 64 MiB on safe reuse after the reader released, and then reduced it to zero bytes when the last Engram connection closed. Committed data remained present in a main-file-only copy and passed the integrity check. WAL reclamation

    The cause of the original eight-minute Windows logon occurrence remains unconfirmed. Main includes opt-in phase diagnostics with ENGRAM_STARTUP_PHASES=1 for a recurrence. Startup diagnostics · CI for the verified main revision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status:approvedtype:bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions