Repository navigation
fix(binding-mqtt-kafka): remove the retained message on a zero-byte retained publish - #3146
Merged
jfallows merged 3 commits intoNov 12, 2026
Conversation
jfallows
force-pushed
the
fix/3132-mqtt-kafka-retained-tombstone
branch
from
November 12, 2026 20:30
50a4a3b to
2f309d0
Compare
Contributor
Author
|
CI on 2f309d0 is red, and the failure is not from this PR's changes.
Why it isn't this PR's:
Nothing to fix on this branch. It needs restacking onto the updated PR below it, after which CI will run again. Generated by Claude Code |
The k3po zilla extension can read a null data value but cannot write one, so a script cannot play a peer that sends a data frame with a null payload. Register write zilla:data.null with a WriteNullDataHandler, let the target flush a null buffer that carries no extension, and cover it with a write/read round trip in each direction in DuplexIT. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWUyUFdeUruH6smCc8
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWUyUFdeUruH6smCc8
…etained publish A retained PUBLISH with a zero-length payload now writes a null value (tombstone) keyed by the topic to the retained topic, and retained replay skips null and empty values, including empty-valued records written by older versions. The record on the messages topic is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SiHVoWUyUFdeUruH6smCc8
jfallows
force-pushed
the
fix/3132-mqtt-kafka-retained-tombstone
branch
from
November 12, 2026 21:10
2f309d0 to
18b0225
Compare
This was referenced Nov 12, 2026
fix(binding-mqtt-kafka): apply qos and no local conditions to retained replay on filter change
#3159
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A PUBLISH with RETAIN=1 and a zero-byte payload must remove the retained message for that topic: MQTT 5.0 section 3.3.1.3 and [MQTT-3.3.1-7], and MQTT 3.1.1 [MQTT-3.3.1-10] and [MQTT-3.3.1-11].
MqttKafkaPublishFactorywrote the retained-topic record with the payload as received, so a zero-length payload became an empty value rather than a Kafka tombstone (null value). The retained topic is log-compacted and keyed by the MQTT topic name, so compaction kept the empty value as the latest record, and a later subscriber's retained replay could be sent a zero-length message.What changes:
MqttKafkaPublishFactory: a retained publish with a null or zero-length payload writes a null value (tombstone) keyed by the topic to the retained topic. The record on the messages topic is unchanged, so live subscribers still receive a normal zero-length message.MqttKafkaSubscribeFactory(KafkaRetainedProxy.onKafkaData): retained replay skips a single-frame null or empty value, including empty-valued records already present in a retained topic written by older versions. It sits before the seconds-based expiry computation and does not change it.The compacted retained topic keyed by topic name is the existing design and is unchanged.
Fixes #3132
Stack
Test evidence
Test-first: the scripts were committed before the fix.
MqttKafkaPublishProxyIT.shouldPublishEmptyRetainedMessageAsTombstonematched every step up to the finalread zilla:data.nullonmqtt-retainedand then never saw it, because the unfixed proxy wrote an empty value.publish.empty.retained.message,subscribe.retained.tombstone,subscribe.retained.empty.value,subscribe.skip.removed.retained.message. The publish scenario publishes a retained message, then a retained zero-byte message, and asserts the normal record on the messages topic and a null value on the retained topic. The subscribe scenarios assert that a subscriber after the removal receives no retained message, and that replay skips a null value and an empty value.KafkaIT+3,MqttIT+2,MqttKafkaPublishProxyIT+1,MqttKafkaSubscribeProxyIT+2,DuplexIT+2.Verify on the current head, clean, with
-am:./mvnw clean verify -pl runtime/engine,specs/binding-kafka.spec,specs/binding-mqtt.spec,runtime/binding-mqtt,specs/binding-mqtt-kafka.spec,runtime/binding-mqtt-kafka -amwrite zilla:data.empty, run as the other module consuming the shared k3po extension): 0 failures. In this last run the engine and binding-kafka.spec modules were restored from the build cache because their inputs had not changed since an earlier uncached run, which also passed: a cleaninstallofruntime/engine(310 unit tests, 264 ITs, skips are existing@Ignores).Engine test-extension change (first commit)
The k3po zilla extension could read a null data value (
read zilla:data.null) but could not write one, so a script could not play a peer that sends a data frame with a null payload. This PR addswrite zilla:data.null:WriteNullDataHandler, registered inZillaBehaviorSystemand listed among the write configs inZillaTypeSystem, mirroring the empty-data write handler and the null-data read handler.ZillaTargetnow flushes a null buffer that carries no extension; previously it only flushed one that carried an extension.DuplexIT, next to the empty-data ones.The change is confined to the engine test tree; there is no production engine code.
Notes and follow-ups
KafkaITandMqttITconflicted with PR 3 only because both appended methods at the end of the class; both sets of tests are kept. The stack was later restacked onto PR 3's new head without conflicts.🤖 Generated with Claude Code
https://claude.ai/code/session_01SiHVoWUyUFdeUruH6smCc8