Gateway Mesh: Border silently drops relayed uplinks after a Relay restart (uplink_id restarts at 1 and collides with the dedup cache)

Viewed 12

Summary

After a Relay Gateway restarts, the Border Gateway silently discards the relayed uplinks it receives from that Relay until the Relay's uplink_id counter goes past the values still held in the Border's payload cache. Nothing is logged at INFO level, and Relay heartbeats keep passing, so the Relay looks healthy while all relayed device traffic is lost. Restarting chirpstack-gateway-mesh on the Border (which clears the cache) fixes it immediately.

We reproduced it several times, and it behaved exactly as predicted from the code (details below).

Setup

  • Border: RAK7268v2, ChirpStack Gateway OS 4.12.0, chirpstack-gateway-mesh 4.1.3, chirpstack-concentratord 4.7.1, chirpstack-mqtt-forwarder (mesh instance) to ChirpStack over MQTT
  • Relay: Raspberry Pi 4 + RAK5146, ChirpStack Gateway OS 4.12.0 (base), chirpstack-gateway-mesh 4.1.3, no internet
  • Region AU915 (sub-band 2, au915_1), mesh frequencies 916.8 / 917.0 / 917.2 MHz, SF7/125 kHz, max_hop_count = 1
  • border_gateway_ignore_direct_uplinks = true on the Border (to make sure the traffic goes through the Relay)
  • One test end-device (OTAA), ~5 min uplink interval, placed next to the Relay

Steps to reproduce

  1. Run Border + Relay normally until the Relay has relayed some uplinks (e.g. uplink_id 1..10). Do not restart the Border.
  2. Power-cycle the Relay.
  3. Wait for the Relay's startup heartbeat, then send uplinks from the device.

Expected

The Border unwraps the relayed uplinks and forwards them to ChirpStack.

Actual

The Relay relays the uplinks (with uplink_id 1, 2, …). The Border receives the mesh frames but never unwraps them. Only the heartbeat goes through.

Relay (after restart):

gateway-mesh: Sending heartbeat event
gateway-mesh: Frame received - [uplink_id: 2189317490, freq: 917200000, rssi: -52, snr: 10.75, mod: [LORA - sf: 7, bw: 125000]]
gateway-mesh: Relaying uplink LoRa frame, uplink_id: 2189317490, downlink_id: 3837852813, mesh_packet: [Uplink hop_count: 1, uplink_id: 1, relay_id: f156d6a7, ...]
gateway-mesh: Frame received - [uplink_id: 2178315584, freq: 918000000, rssi: -52, snr: 14.25, mod: [LORA - sf: 7, bw: 125000]]
gateway-mesh: Relaying uplink LoRa frame, uplink_id: 2178315584, downlink_id: 3986034349, mesh_packet: [Uplink hop_count: 1, uplink_id: 2, relay_id: f156d6a7, ...]

Border (same time window). The startup heartbeat is unwrapped, but the two relayed uplinks are received and silently dropped (no Unwrapping relayed uplink, nothing forwarded):

21:38:26 concentratord: Frame received, freq: 917000000, dr: SF7
21:38:26 gateway-mesh: Unwrapping relay event packet, mesh_packet: [Event hop_count: 1, ..., relay_id: f156d6a7]
21:39:23 concentratord: Frame received, freq: 917200000, dr: SF7     <- device uplink (direct, ignored as configured)
21:39:23 concentratord: Frame received, freq: 917200000, dr: SF7     <- relayed uplink_id 1, dropped
21:39:39 concentratord: Frame received, freq: 918000000, dr: SF7     <- device uplink (direct, ignored as configured)
21:39:39 concentratord: Frame received, freq: 916800000, dr: SF7     <- relayed uplink_id 2, dropped

Before the Relay restart, the same Border had accepted uplink_id 1..10 from the previous Relay session. After /etc/init.d/chirpstack-gateway-mesh restart on the Border, the next relayed uplink is unwrapped and forwarded immediately.

Root cause (from reading the source)

  • src/mesh.rs: static UPLINK_ID: Mutex<u16> = Mutex::new(0);. The counter starts at 0 on every process start, so the first relayed uplink after a Relay restart is always uplink_id: 1, then 2, 3… (wrapping at 4095).
  • src/mesh.rs: PAYLOAD_CACHE = Cache::new(64).
  • src/cache.rs: the cache is a FIFO of 64 entries with no time-based expiry. An entry only leaves when 64 newer entries push it out. PayloadCache equality is (p_type, uplink_id, timestamp, relay_id), and for Uplink/Downlink packets timestamp is 0. So for uplinks the key is effectively (Uplink, uplink_id, relay_id).

So after a Relay restart, its new uplinks reuse (Uplink, 1..N, relay_id) keys that are still in the Border's cache from the previous session, and the Border treats them as duplicates. With low traffic (few devices, only heartbeats every 5 min), it can take a long time for 64 new entries to evict the old ones. In the meantime all relayed uplinks from that Relay are lost.

This is likely to happen in the field: solar-powered Relays that brown out at night, power cuts, watchdog reboots, or firmware updates.

It would also help if the drop were logged at INFO or DEBUG, not only at TRACE (we saw 4.1.4 adds the uplink_id to the dropped-packet trace), so that this is visible in normal operation.

Note

We saw one additional drop (a relayed uplink_id that should not have been in the cache yet) that we could not fully explain. All other observations match the analysis above, including a prediction we made before power-cycling the Relay.

Happy to provide more logs or test a fix.

0 Answers