Repository navigation
Description
Describe the bug
On develop (e5d8347), the first QoS 2 PUBLISH from an MQTT 5 client stops the Zilla engine. The client gets CONNACK 0 and sends
the PUBLISH, but no PUBREC comes back and the connection is lost. Zilla logs an AgentTerminationException caused by
NoSuchElementException in MqttKafkaPublishFactory$KafkaOffsetCommitStream.onKafkaWindow, then ENGINE_STOPPED.
It happened on every QoS 2 publish we tried, on freshly created stacks: 6 crashes in 6 attempts. The message itself
is written to Kafka (one record), but the client never gets a PUBREC, so a real client would resend it after
reconnecting. QoS 0 and QoS 1 publishes work, and so do QoS 2 subscriptions fed by QoS 1 publishers.
To Reproduce
- Start
examples/mqtt.kafka.proxyfrom scratch with adevelopimage
(docker compose down -v && docker compose up -d). Wait forENGINE_STARTED. - Publish one QoS 2 message:
docker run --rm --network zilla-mqtt-kafka-proxy_default eclipse-mosquitto:2.0 \ mosquitto_pub -d -h zilla.examples.dev -p 7183 -V mqttv5 -i "q2-$(date +%s)$RANDOM" -q 2 -t device/q2 -m one - Check the Zilla log:
docker compose logs zilla | grep -E 'AgentTerminationException|ENGINE_STOPPED'
Expected behavior
PUBREC, PUBREL and PUBCOMP (reason 0), and one record in mqtt-devices with key device/q2.
Actual behavior
Client:
Client q2-179489646331129 sending CONNECT
Client q2-179489646331129 received CONNACK (0)
Client q2-179489646331129 sending PUBLISH (d0, q2, r0, m1, 'device/q2', ... (3 bytes))
Error: The connection was lost.
Zilla:
org.agrona.concurrent.AgentTerminationException: java.util.NoSuchElementException
at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.doWork(EngineWorker.java:1053)
...
Caused by: java.util.NoSuchElementException
at java.base/java.util.LinkedList.removeFirst(LinkedList.java:282)
at java.base/java.util.LinkedList.remove(LinkedList.java:697)
at io.aklivity.zilla.runtime.binding.mqtt.kafka/io.aklivity.zilla.runtime.binding.mqtt.kafka.internal.stream.MqttKafkaPublishFactory$KafkaOffsetCommitStream.onKafkaWindow(MqttKafkaPublishFactory.java:2136)
at io.aklivity.zilla.runtime.binding.mqtt.kafka/io.aklivity.zilla.runtime.binding.mqtt.kafka.internal.stream.MqttKafkaPublishFactory$KafkaOffsetCommitStream.onOffsetCommitMessage(MqttKafkaPublishFactory.java:2062)
at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.handleReadInitial(EngineWorker.java:1696)
at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.handleRead(EngineWorker.java:1627)
at io.aklivity.zilla.runtime.common.agrona/io.aklivity.zilla.runtime.common.agrona.concurrent.ManyToOneRingBuffer.readEx(ManyToOneRingBuffer.java:316)
at io.aklivity.zilla.runtime.engine/io.aklivity.zilla.runtime.engine.internal.registry.EngineWorker.doWork(EngineWorker.java:1039)
... 4 more
engine:events [17/Nov/2026:06:21:04 +0000] [0000000000000000d] ENGINE_STOPPED Engine Stopped.
The crash comes within the same second as the client's BINDING_MQTT_CLIENT_CONNECTED event. Afterwards
mqtt-devices holds one record with key device/q2. With the example's restart: unless-stopped, Zilla restarts, and
the next QoS 2 publish crashes it again.
Notes
- Line 2136 is
unfinishedKafkas.remove()in thewasOpenbranch ofonKafkaWindow. It looks like the offset-commit
stream received a WINDOW after it was already open while no commit was queued, for example a credit-only update,
andremove()on the empty queue throws. - Since 2.7.0,
MqttKafkaPublishFactorychanged in fix(binding-mqtt-kafka): acknowledge qos1 publish only as far as kafka has acknowledged it #3295 (which reworked how the publish stream passes on Kafka
credit) and fix(binding-mqtt-kafka): keep a trailing empty topic level when splitting topic names and filters #3274.binding-kafkaalso changed (fix(binding-kafka): batch records that have no producer id #3300, fix(binding-kafka): wrap group assignment userdata at buffer start #3292, fix(binding-kafka): rejoin group when topic metadata is updated after joining #3294, fix(binding-kafka): retry init producer id on retriable errors #3104, fix(binding-kafka): restart api client reconnect back-off after a connection opens #3268, fix(binding-kafka): release waiting streams on the first refresh or when the last meta stream is gone #3276). We have not bisected. - This blocks every QoS 2 publish scenario in our MQTT benchmark.
Environment
- Zilla
ghcr.io/aklivity/zilla:develop-SNAPSHOT, built locally on 2026-11-17 (imageff8b619b4cd1, arm64),start -e,
unmodifiedexamples/mqtt.kafka.proxyzilla.yaml - Kafka
apache/kafka:4.1.1, single node - Docker Desktop (Engine 29.8.1) on an Apple Silicon Mac, 10 CPUs and 8 GB for Docker
- Client:
eclipse-mosquitto:2.0(mosquitto_pub, MQTT 5)
Activity
Add QoS 2 scenarios, probe and delivery check (#2)
fix(binding-mqtt-kafka): complete a qos2 offset commit when kafka ack…
test(binding-mqtt-kafka): complete a qos2 publish only after kafka ac…
fix(binding-mqtt-kafka): complete a session offset commit when kafka …
fix(binding-mqtt-kafka): complete a session offset commit when kafka …