Skip to content

mqtt-kafka: retained replay filter bookkeeping is not aligned with the per-filter flags of the messages stream #3172

Closed

Description

@jfallows

Problem

The messages stream of the subscribe proxy keeps one flags entry per filter, aligned with the Kafka filter order, so shared and generated subscription identifiers and several filters in one SUBSCRIBE resolve independently. The retained stream (the replay path) still keeps a de-duplicated list of subscription ids (retainedSubscriptionIds) and indexes its filter bitmask over that list. When several filters of one SUBSCRIBE share a subscription identifier, or filters carry different Retain As Published or No Local options, the retained replay resolves flags and identifiers differently from the live path.

Found while implementing the RETAIN flag semantics change; the retained stream was left unchanged there to avoid conflicts with the retained filter-change fix. Whether the difference produces a wrong delivery for a concrete scenario has not been shown.

MQTT 5.0 sections 3.3.1.3 (RETAIN, Retain As Published), 3.8.3.1 (subscription options) and 3.3.2.3.8 (Subscription Identifier): each retained message sent as a result of a subscription carries the flags and identifiers of the subscription filters it matched.

Expected

  • The retained stream uses the same per-filter flags and identifier resolution as the messages stream, with one implementation of the logic.
  • A retained replay for a SUBSCRIBE with several filters (shared identifier, different options) carries the same flags and identifiers a live message would.

Test plan (test-first)

Scripts through mqtt-kafka: retained replay for a SUBSCRIBE with several filters that share one subscription identifier and carry different Retain As Published and No Local options, and a later filter change on an open retained stream. The first commit contains the scripts that fail; if no script can show a wrong delivery, record the analysis on this issue and stop, since a refactor with no observable difference is not justified by this issue.

Notes

Follow-up from the RETAIN flag semantics change. Part of the MQTT conformance work under #512.

Activity

  1. self-assigned this
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions