Repository navigation
Description
Describe the bug
When clients connect faster than Zilla can answer (#3305), some of them give up waiting
for CONNACK and close their connection. From that moment, Zilla stops completing any MQTT session: no further
CONNACKs, to queued or brand-new clients, for as long as we watched (5+ minutes). Zilla keeps running, logs no error,
and Kafka is idle. Already-connected clients stay connected.
To Reproduce
Same setup as #3305 (Zilla 2.7.2-rc1 on c6i.8xlarge with 31 workers, single Kafka broker,
two emqtt-bench load generators with 50,000 MQTT 3.1.1 publishers each). Connect faster than ~180 CONNACKs/s, for
example 250/s in total:
docker run --network host emqx/emqtt-bench:0.6.3 pub -h <zilla-ip> -p 7183 -V 4 -k 300 -C true \
-c 50000 -R 125 -n <1 | 50001> --prefix <run>-p- -t 'device/%i' -q 1 -s 1024 -I 1000 -F 1 -w trueemqtt-bench gives up on a CONNECT after about 60 s (connack_timeout).
Actual behavior
The last CONNACK and the first client timeout fall in the same second, in both runs:
| Requested rate | Last CONNACK from Zilla | First client connack_timeout |
Connected | Timed out |
|---|---|---|---|---|
| 5,000/s | 10:19:14.55 | 10:19:14.42 | 10,279 | 89,721 |
| 250/s | 10:37:24.78 | 10:37:24.73 | 40,564 | 59,436 |
CONNACKs per minute in the 250/s run: 3,669 (partial), 11,151, 10,884, 10,608, 4,252, then 0.
After the stall:
- A new
mosquitto_pub -V mqttv311 -q 1from a load-generator host got no CONNACK ("Keepalive exceeded"). - Zilla: running, about 52% CPU of 3,200% (each worker thread about 7%), no exceptions in the log.
- Zilla's connections to Kafka: most idle, but 2–3 of them had about 24,650 bytes of unread data in the receive queue
(ssRecv-Q on Zilla's side) that stayed there, as if Zilla stopped reading those Kafka connections. - Kafka: 2.5% CPU, no errors or warnings in its log.
mqtt-sessions: 121,692 records for 40,564 connected clients.
At 100 connections/s no client timed out, and all 100,000 connected without a stall.
Expected behavior
A client abandoning its CONNECT only affects that client. Zilla keeps completing sessions for everyone else.
Notes
- The exact coincidence with the first
connack_timeoutsuggests that a client closing its connection while its
session is still being set up leaves something stuck (the session stream, or flow control on a shared Kafka
connection), which then blocks every later session. - emqtt-bench closes the TCP connection on
connack_timeout(it doesn't send DISCONNECT, since it never got CONNACK).
Environment
ghcr.io/aklivity/zilla:2.7.2-rc1(sha256:0dce0a7d...),start -e -w 31- Kafka
apache/kafka:4.1.1, single broker, KRaft - AWS c6i.8xlarge × 2 (Zilla, Kafka), c6i.2xlarge × 2 (emqtt-bench 0.6.3), Ubuntu 22.04
Activity
fix(binding-kafka): abort an api request that ends before its body is…