Issue Description
Twice within ~15 hours, Stalwart v0.16.27 got a Tokio worker thread stuck at 100 % CPU right after two simultaneous inbound SMTP connections from the same client with the same EHLO name. The stuck worker never recovers. Once every worker is stuck (this host has 2 vCPUs → 2 workers), the whole server stops responding – SMTP, scheduled tasks and logging – until restarted. It looks like a race: the same client opened such concurrent pairs 573 times between 2026-10-16 and 2026-10-23 and only 2 of them triggered it (~1 in 290).
Expected Behavior
Two concurrent SMTP sessions from the same client with the same EHLO name are handled independently: each gets its SPF EHLO check result (smtp.spf-ehlo-fail / spf.none for this domain), proceeds to STARTTLS and finishes. This is what happens in 571 of 573 cases:
2026-10-23T07:32:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 43304, domain = "data.X.cz"
2026-10-23T07:32:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 43316, domain = "data.X.cz"
2026-10-23T07:32:37Z INFO SPF EHLO check failed (smtp.spf-ehlo-fail) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 43316, domain = "data.X.cz", result = No SPF record (spf.none), elapsed = 0ms
2026-10-23T07:32:37Z INFO SPF EHLO check failed (smtp.spf-ehlo-fail) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 43304, domain = "data.X.cz", result = No SPF record (spf.none), elapsed = 5ms
2026-10-23T07:32:37Z INFO TLS handshake (tls.handshake) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 43316, version = "TLSv1_3", details = "TLS13_AES_256_GCM_SHA384"
Even if one session runs into a problem, it should time out or fail without blocking a runtime worker and without affecting other sessions.
Actual Behavior
Occasionally (2 of 573 concurrent pairs) both sessions stop right after smtp.ehlo – no SPF result, no TLS handshake – and one tokio-runtime-worker thread goes to ~100 % CPU permanently.
- Incident 1 (2026-10-22): first worker stuck at 17:24:37Z; the server kept working on the second worker until the next probe pair at ~17:40:37Z, after which nothing was logged at all. The server then accepted TCP (via the proxy) but never sent the
220banner (tested from two different networks, waited up to 190 s); the 5-minutecalculateMetricstask stopped too.top -Hshowed both worker threads at ~96 % CPU each, main thread idle, load average 2.0, RSS ~128 MB, no kernel/OOM messages. This lasted 12.5 hours until a manual restart. - Incident 2 (2026-10-23), ~1.5 h after that restart: first worker stuck at 07:48:37Z; caught at 07:55Z with one worker at 95 % and the other idle (server still answering). Restarted before the next probe pair.
Reproduction Steps
The hang is probabilistic (~1 in 290 attempts here), so these steps need to be repeated:
- Use a client host whose EHLO name has no SPF record (A record + matching PTR, no TXT/SPF, DNSSEC-signed zone).
- Open two TCP connections to the Stalwart SMTP listener on port 25 at the same instant (in our setup they pass through a PROXY-protocol-v2).
- On both, wait for the banner and send
EHLOat the same time. - On both, send
STARTTLSand do a TLS handshake (one RSA-only, one ECDSA-only signature algorithms - probably irrelevant, as the hang happens before the SPF result is logged), thenQUIT. - Repeat every few seconds and watch
top -H -p <stalwart pid>for atokio-runtime-workerthread that stays at 100 %, and the log for an EHLO pair without the followingsmtp.spf-ehlo-*lines.
Opening the two connections one after the other instead of concurrently avoids the problem.
Relevant Log Output
Incident 1 – complete log around the event (nothing omitted):
2026-10-22T17:24:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 42878, domain = "data.X.cz"
2026-10-22T17:24:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 42872, domain = "data.X.cz"
2026-10-22T17:25:17Z INFO Task scheduled for future execution (task-manager.task-scheduled) due = 2026-10-22T17:30:16Z, id = "calculateMetrics"
2026-10-22T17:25:17Z INFO Metrics collected (telemetry.metrics-collected) elapsed = 3ms
[... normal operation on the remaining worker ...]
2026-10-22T17:39:22Z INFO Blocked IP address (security.ip-blocked) listenerId = "submissions", localPort = 465, remoteIp = 62.60.134.142, remotePort = 32702
2026-10-22T17:40:17Z INFO Task scheduled for future execution (task-manager.task-scheduled) due = 2026-10-22T17:45:16Z, id = "calculateMetrics"
2026-10-22T17:40:17Z INFO Metrics collected (telemetry.metrics-collected) elapsed = 2ms
[no further log output until the restart at 2026-10-23T06:19Z; next probe pair was due at 17:40:37Z]
Incident 2:
2026-10-23T07:48:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 39342, domain = "data.X.cz"
2026-10-23T07:48:37Z INFO SMTP EHLO command (smtp.ehlo) listenerId = "smtp", localPort = 25, remoteIp = 161.35.22.X, remotePort = 39358, domain = "data.X.cz"
2026-10-23T07:48:38Z INFO Blocked IP address (security.ip-blocked) listenerId = "submissions", localPort = 465, remoteIp = 62.60.134.142, remotePort = 61254
2026-10-23T07:49:09Z INFO Task scheduled for future execution (task-manager.task-scheduled) due = 2026-10-23T07:54:08Z, id = "calculateMetrics"
2026-10-23T07:49:09Z INFO Metrics collected (telemetry.metrics-collected) elapsed = 2ms
Trace-level logs are not available for these incidents (log level was INFO); I can enable trace and report back if it reoccurs.
Stalwart Version
v0.16.x
Installation Method
Docker
Database Backend
PostgreSQL
Blob Storage
S3-compatible
Search Engine
PostgreSQL
Directory Backend
SQL
Additional Context
- Stalwart v0.16.27, image
ghcr.io/stalwartlabs/stalwart:v0.16(digestsha256:c429b311c93db5606598abc1c68225a85a6953183848ae01bee9c6a98885836c), aarch64, 2 vCPU, 4 GB RAM (Hetzner) - Podman 5.4.2 (Quadlet), rootful; container in a podman network
- Data store: PostgreSQL (external)
- DNS: container
/etc/resolv.conf→ podman aardvark-dns (172.20.0.1) - SMTP arrives through a TCP proxy that adds PROXY protocol v2
- Log level INFO; no recent configuration changes; image unchanged since 2026-10-19
I have reviewed the documentation and FAQ and confirm that my issue is NOT addressed there.
on
I have searched this support forum (open and closed topics) and confirm this is not a duplicate.
on
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
on