Skip to content

v2.6.6

Choose a tag to compare

@github-actions github-actions released this 16 Oct 02:43
· 19 commits to main since this release
5d9d8e5

What's Changed

PR Title Category
#174 Fix Inflight resend deadlock, quota overshoot and resend ordering fix (critical)
#172 Config: merge environment variable overrides on top of YAML feat
#173 Fix routing table lost on raft snapshot restore fix
#175 Helm chart 0.5.0: extraEnv passthrough for COMQTT_* chore(helm)
#169 #170 Fix ACL bypass via prefix topic matching (CVSS 4.3) security
#171 Fix raft log typos chore

Details

#174 fix: Inflight resend deadlock, quota overshoot and resend ordering

Three concurrency/correctness defects in mqtt/inflight.go, all found while load-testing many QoS 1 publishers against one slow subscriber.

  • Deadlock (the serious one). NextImmediate() took RLock and then called GetAll(), which took RLock again. Go's RWMutex blocks new readers as soon as a writer is queued, so a publisher's Set landing between the two read locks left the goroutine holding the first lock forever. processPacket hits that path on every packet when inflight is non-empty (server.go:714), so a single client could wedge permanently — no PUBACK processing, unbounded inflight growth, goroutine leak. Reproduced reliably before the fix; passes in ~0.2s after.
  • Quota overshoot. The helpers did load-then-add (if Load() > 0 { Add(-1) }), which is not atomic. Concurrent publishers could push the send quota below zero or past maximumSendQuota, transiently over-running the client's ReceiveMaximum. Now CAS loops, so 0 <= quota <= max actually holds.
  • Resend ordering. GetAll sorted by uint16(Created), but Created is an int64 unix timestamp. The truncation wraps every ~18 hours and scrambled resend order across the boundary. Now compares the int64s directly.

+138/−11 across mqtt/inflight.go and mqtt/inflight_test.go, with regression tests for all three.

#172 feat: environment variable overrides on top of YAML

config.Load now applies COMQTT_* environment variables on top of the YAML baseline, so operators can override scalar values at deploy time without rewriting the config file — e.g. injecting a dynamic Kubernetes pod IP into cluster.bind-addr with Hashicorp Raft. Refs #119.

  • Naming rule: COMQTT_ + the dotted yaml path, uppercased, - → _ (e.g. mqtt.tcp → COMQTT_MQTT_TCP)
  • Structure-aware reflection walk; supports string, int/uint and bool
  • Slices and maps (e.g. cluster.members) are not overridable and keep their YAML value
  • An unset variable leaves the YAML value untouched; an empty string explicitly clears it
  • Documented in the README under "Environment variable overrides"

+328/−3, with 13 test cases covering baseline-unchanged, override, supply-a-missing-value, empty-string-clearing, unset-leaves-untouched, and the #119 bind-addr scenario.

#173 fix: routing table lost on raft snapshot restore

Since d5c33e1, KV.GetAll() returns a copy — so both restore paths (hashicorp Fsm.Restore and etcd recoverFromSnapshot) were decoding snapshots into a throwaway map. A node that installed a snapshot ended up with an empty routing table: remote subscriptions stopped receiving forwarded publishes until they re-subscribed. Silent failure, high diagnostic cost.

Adds KV.Restore, which decodes into a fresh map and swaps it in under the lock, replacing prior state as raft snapshot semantics require. Covered by new tests for both backends, including a corrupt snapshot.

#175 chore(helm): extraEnv passthrough, chart 0.4.0 → 0.5.0

#172's env overrides were unreachable from Helm: the chart only injected its own seven hardcoded variables and exposed no way to pass anything else. Adds an extraEnv list rendered into the broker container in both single and cluster modes, appended after the chart's downward-API variables. Defaults to [], so existing releases render unchanged.

Also bumps appVersion 2.6.0 → 2.6.6. Chart version is independent of the broker version; this is the fourth chart release.

#169 #170 security: ACL bypass via prefix topic matching (CVSS 4.3)

Two separate authorisation defects in MatchTopic (mqtt/hooks/auth/ledger.go). Reported by Team Atlanta.

  • Prefix bypass. MatchTopic returned true after exhausting filter parts without checking whether topic parts remained, so a literal ACL filter such as allowed also matched publishes to allowed/secret. Matching now requires len(topicParts) == len(filterParts).
  • # wildcard non-compliance. The bounds check returned false before testing whether the filter part was #, so the multi-level wildcard could not match zero sublevels as MQTT 4.7 requires. Now MatchTopic('a/#', 'a') is true while MatchTopic('a/+', 'a') stays false.

#171 chore: raft log typos

Eight message corrections in the etcd backend (dnapshot → snapshot, failed ti listen → failed to listen, listeing → listening, membe → member, snapshit → snapshot). Contributed by @mattfiocca.

⚠️ Action required: ACL rule behaviour change

The # zero-sublevel fix changes how existing ACL rules resolve. A rule written as sensors/# previously did not match the topic sensors; it now does.

If you rely on that distinction — for example a write-only rule devices/# that must not grant read on devices itself — review your rules and, where needed, split them into an exact rule plus a wildcard rule. Re-run your rule set through MatchTopic before upgrading if you are unsure.

Helm chart

Version Broker Contents
0.4.0 2.6.0–2.6.5 OCI publishing to GHCR, Gateway API (HTTPRoute/TCPRoute)
0.5.0 2.6.6 Adds extraEnv passthrough for COMQTT_* overrides
helm repo add comqtt oci://ghcr.io/wind-c/charts
helm upgrade --install comqtt comqtt/comqtt --version 0.5.0

Note that image.tag falls back to Chart.appVersion, so upgrading the chart without pinning image.tag rolls pods onto the 2.6.6 image. Pin image.tag beforehand if you need to stage the rollout.

Contributors

Thanks to everyone who contributed to this release:

Upgrade notes

  • Binary and image users: pull ghcr.io/wind-c/comqtt:2.6.6 (or the floating v2.6 tag).
  • No config file schema changes; existing YAML keeps working as-is.
  • Cluster operators on >= 2.6.0 should note the raft snapshot restore fix: nodes that have already restored a broken snapshot are still running with an empty routing table and will stay that way until they re-subscribe or restart with the new binary.

Full Changelog: v2.6.5...v2.6.6