mailmind Source hangs forever when Mail Mind restarts mid-call (no client timeout) #45
Labels
No labels
bug
enhancement
epic
needs-info
needs-triage
ready-for-agent
ready-for-human
svd:fire
svd:go
svd:hold
svd:respec
svd:skip
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
dev/people-mind-mcp#45
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The mailmind Source can hang forever.
_fetchbuildsClient(_transport(...))with notimeout, and_transportsets none either. If the Mail Mind server restarts while acall_toolis in flight, the call never returns.run_passthen never writes async_logrow or a checkpoint, and the worker thread stays blocked until the pod restarts./healthz/syncreportsstale, but nothing recovers the worker.A second weakness makes the hang expensive: a pass saves progress only at pass end or on a fetch failure. The
mail_evidencephase keeps its results in memory, so any failure there repeats every evidence call on the next pass.Evidence
Local reproduction with the pinned dependencies (fastmcp 3.4.11, mcp 1.30.0, httpx 0.28.1): a FastMCP HTTP server with one tool that sleeps 60 s, killed with SIGKILL 5 s into the call.
Client(transport)(as in_fetch)timeout)Client(transport, timeout=20)McpErrorat 20.0 sProduction observation on rc.6 (codes and counts only):
apicontainer restarted about 28 minutes later.sync_logrow and no mail log line for more than 9 hours, sync container CPU near 0, no open connection to Mail Mind. The two CardDAV Sources logged 36 passes each in the same period.Ruled out: the per-page rebuild of the sorted pending map. At this checkpoint size it costs about 71 ms per page locally, about 90 s CPU across a full pass.
Proposed fix
Clientin_fetch(configurable, for examplerequest_timeout_seconds, default 60). The existingexcept Exceptionalready maps the resultingMcpError/ timeout toSourceError("mailmind-unavailable"), so the pass fails, checkpoints, and retries on the next interval._fetchraiseSourceErrorwithin the timeout.Earlier failures (not this bug)
The
mailmind-protocolfailures before rc.4 were #39: one malformed envelope address failed every pass at the same page.c611a19fixed it and shipped in rc.4; nomailmind-protocolrow has been written since. The rc.4 pod then ran for about 7 hours without writing a mailsync_logrow either. The Mail Mind Deployment was scaled to zero for a backup in that window, which fits this hang, but that pass was not traced.Agent Brief
Category: bug
Summary: Give the mailmind Source a per-request timeout so a Mail Mind restart mid-call fails the pass instead of hanging the sync worker forever.
Current behavior:
MailmindSource._fetchopens a fastmcpClientover aStreamableHttpTransportwith no timeout. When the Mail Mind server dies while acall_toolis in flight, the call never returns. The pass writes nosync_logrow and no checkpoint, and the worker stays blocked until the pod restarts.Triage reproduced this with the pinned dependencies (fastmcp 3.4.11). A FastMCP HTTP server with one tool that sleeps 60 s was killed with SIGKILL 5 s into the call:
Client(transport): still waiting at the 45 s cap.Client(transport, timeout=10): raisedMcpErrorat 10.0 s.Desired behavior:
Every Mail Mind request has a bounded wait. A request that exceeds it fails the pass with the value-free code
mailmind-unavailable. The pass then follows the existing fetch-failure path: it writes async_logrow, saves the resumable checkpoint (cursor and pending map), and retries on the next interval. Nothing else about the pass changes.Key interfaces:
MailmindSourceConfig: addrequest_timeout_seconds, a positive number with default 60. Validate it like the other numeric fields (gt=0).Clientbuilt inMailmindSource._fetch: pass the configured value astimeout. fastmcp 3.4.11Client.__init__acceptstimeout.except Exceptionin_fetchalready maps the resultingMcpError/ timeout toSourceError("mailmind-unavailable"). Keep that mapping. Do not let exception text reach the error code or the logs.Acceptance criteria:
MailmindSourceConfigacceptsrequest_timeout_seconds, defaults to 60, and rejects zero and negative values._fetchraisesSourceErrorwith codemailmind-unavailablewithin a bounded wall-clock time.mail_changespage leaves the source state at the last accepted checkpoint, so the next pass resumes without refetching. Reuse the shape of the existing failed-pass checkpoint tests.Out of scope:
mail_evidencephase resumable (fix step 3 in the issue body). Persisting evidence results in the checkpoint conflicts with ADR 0003 §2 (no mail text stored) and §8 (Forget removes everything about a person). It needs its own design decision and a separate issue.⏸ SVD architect gate: dev/people-mind-mcp#45 mailmind-source-hangs-forever-when-mail-mind-restarts-mid-ca
Status: CLEAN after 1 rework round(s) · 0 blocking defect(s) · 0 lens(es) INCONCLUSIVE (could not run) · 0 lens(es) DEGRADED (deterministic denial) · complexity
standard· dispatch effortmediumRun:
20261102T234709Z-9372eab3Held because: CLEAN but 3 open risk(s) (1 verification · 2 decision) — HOLD-ALL parks everything. The risks, verbatim:
Open risks:
Change: Add
request_timeout_seconds: float = Field(default=60.0, gt=0)afterrate_per_secondin MailmindSourceConfig (config.py:146). Pass it astimeout=toClient(...)in MailmindSource._fetch (mailmind.py:179). Leave_transportalone. The resulting McpError falls through the existingexcept Exception: raise SourceError("mailmind-unavailable") from None(mailmind.py:260-261), so no new except branch is needed. Append tests to tests/test_mailmind.py using an asyncstalling_mailFastMCP helper, mirroring test_mailmind_rate_per_second_config (:946-951) and the checkpoint tests at :413-465 and :495-541. Document the field in README.md: a prose sentence at line 117 andrequest_timeout_seconds = 60after line 126 inside the TOML fence at 119-127, re-checked at2289943602. Add a commented line to deploy/k8s/overlays/example/config.toml:33-39.Files:
src/people_mind_mcp/config.py·src/people_mind_mcp/sources/mailmind.py·tests/test_mailmind.py·README.md·deploy/k8s/overlays/example/config.tomlDecision: accept the 3 open risk(s) above and dispatch this spec (
svd:go), or park (svd:skip) / re-spec (svd:respec)?Your call (when this issue is held at the gate via
svd:hold):svd:go— approve; Half-B dispatch accepts exactly this spec (open risks accepted)svd:firebesidesvd:go— approve AND authorise the Half-B fire from the phone; never on its ownsvd:skip— park it; dispatch refuses it and the issue stays for a humansvd:respec— discard this spec; the next Half-A run re-produces it with this record as prior-attempt contextSpec:
/Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mailmind-source-hangs-forever-when-mail-mind-restarts-mid-ca.md— next:codex-svd dispatch --args '<same-json>' --approved-spec-path /Users/piers/.local/state/exhaust/groupthink/specs/2026-11-02-mailmind-source-hangs-forever-when-mail-mind-restarts-mid-ca.mdspec-verify-dispatch Half B for dev/people-mind-mcp#45 mailmind-source-hangs-forever-when-mail-mind-restarts-mid-ca completed integration verify.
090f28518ecodex-svd ship --run-id 20261103T000545Z-5cc1378c --confirm-merge)piers referenced this issue2026-11-03 21:03:51 +00:00