#16191·thingsboard

Device recreated with the same id (unassigned from and re-assigned to an Edge) never receives downlink again: TenantActor.deletedDevices is never cleared

Author: luka-medicCreated Sep 24, 2026Updated Sep 25, 2026

Describe the bug

After a device is unassigned from an Edge and assigned back to the same Edge, the Edge silently drops every downlink message addressed to that device — shared-attribute updates, attribute-request replies, firmware (fw_*) pushes and RPC — until the tb-edge process is restarted. Uplink (telemetry from the device) keeps working, so it looks like a partial outage and is easy to miss.

Cause (application/src/main/java/org/thingsboard/server/actors/tenant/TenantActor.java, identical in CE and Edge from v4.3.1.1 through v4.3.1.5 / 4.3.1.4EDGE, lts-4.3, release-4.4 and master):

java
// onComponentLifecycleMsg
if (msg.getEntityId().getEntityType() == EntityType.DEVICE && ComponentLifecycleEvent.DELETED == msg.getEvent() && isMyPartition(msg.getEntityId())) {
    DeviceId deviceId = (DeviceId) msg.getEntityId();
    onToDeviceActorMsg(new DeviceDeleteMsg(tenantId, deviceId), true);
    deletedDevices.add(deviceId);          // added on DELETED ...
}

// onToDeviceActorMsg
if (deletedDevices.contains(msg.getDeviceId())) {
    log.debug("RECEIVED MESSAGE FOR DELETED DEVICE: {}", msg);   // ... and never removed
    return;
}

deletedDevices only ever grows. That is harmless while a deleted device can never come back, but a device can come back with the same UUID:

  • Edge: unassigning a device from an Edge makes the Edge delete it locally (UNASSIGNED_FROM_EDGE → ENTITY_DELETED_RPC_MESSAGE → DeviceCloudProcessor.deleteDevice). Assigning it back recreates it with the same id (BaseDeviceProcessor → clusterService.onDeviceUpdated(savedDevice, null) → ComponentLifecycleMsg with CREATED). From then on every DeviceAwareMsg for it is dropped (debug log only).
  • CE: a Version Control restore also recreates a device with the same UUID (see #14164), so the same path applies there.

To Reproduce (Edge)

  1. Assign a device to an Edge; connect the device to the Edge over MQTT; confirm a shared-attribute change reaches it.
  2. Unassign the device from the Edge, then assign it to the same Edge again (no tb-edge restart in between).
  3. Reconnect the device to the Edge and change a shared attribute (or send an RPC / start an OTA).
  4. Nothing reaches the device. Telemetry from the device still arrives. systemctl restart tb-edge restores delivery.

Expected behavior A device recreated with the same id receives messages again.

Proposed fix (small; keeps the Set's purpose — stray messages cannot revive an actor for a device that stays deleted):

java
if (msg.getEntityId().getEntityType() == EntityType.DEVICE && ComponentLifecycleEvent.CREATED == msg.getEvent()) {
    deletedDevices.remove((DeviceId) msg.getEntityId());
}

No partition guard on the removal: removing an id is harmless, and the partition may have moved since the delete. We carry this as a patch on 4.3.1.5 / 4.3.1.4EDGE with a TenantActorTest case (DELETED, then CREATED for the same id, then a DeviceAwareMsg → delivered; DELETED alone → still dropped). Happy to open a PR against lts-4.3 and master.

Your Server Environment

  • own setup — monolith, deb, Community Edition
  • ThingsBoard CE v4.3.1.1 and v4.3.1.5 (server), ThingsBoard Edge 4.3.1.1EDGE and 4.3.1.4EDGE
  • Debian 13 (aarch64)

Your Device

  • Connectivity: MQTT over TLS to the Edge
  • Device vendor and model: ESP32-S3 based device