Remove sync request on edge customer id update - #238
Open
AndriiLandiak wants to merge 1 commit into
Open
Conversation
AndriiLandiak
force-pushed
the
fix/remove-sync-on-customer-id-update
branch
from
August 18, 2026 14:44
cdfe52c to
a0770fb
Compare
AndriiLandiak
force-pushed
the
fix/remove-sync-on-customer-id-update
branch
from
August 18, 2026 15:16
a0770fb to
ae4a136
Compare
AndriiLandiak
force-pushed
the
fix/remove-sync-on-customer-id-update
branch
from
August 18, 2026 15:16
ae4a136 to
08c0797
Compare
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.
Problem
On every
EdgeConfigurationdownlink the edge compares its customer id and, if it changed, requests a full sync from the cloud:That request is both redundant and harmful.
Redundant
Assigning or unassigning an edge already emits its own edge event.
EdgeEntityProcessor.convertEdgeEventToDownlinkturns it into the config downlink:So the edge is already told about the new owner. The sync re-fetches every entity type to arrive at the same state.
Harmful
That config downlink is the last message of the assignment flow, and reacting to it with a sync cancels the delivery of that very flow:
EdgeConfigurationannouncing the new owner - last in linestartSyncProcess->interruptGeneralProcessingOnSync()->stopCurrentSendDownlinkMsgsTask(true):isInitialized() && !isSyncInProgress()Both directions stall until the sync completes, and anything that was in flight when
cancel(true)fired waits for the re-sync instead of arriving.Change
Remove the sync request. Keep the
setOrUpdateCustomerIdcall:BaseEdgeConfigurationHandleris the only writer ofedgeInfo.customerId, and that value is passed into everyprocessDownlinkMsg(...). Dropping the call entirely would leave the edge processing downlinks against a stale customer id.Why now
The trigger has been dormant for months.
onConfigurationUpdateused to compare the edge against itself:Because it never returned early,
EdgeUpdateMsgwas always sent; its edge-side handler pre-updated the customer id, sosetOrUpdateCustomerIdlater returnedfalseand no sync fired. That guard is now correct (stateCustomerIdcaptured beforestate.setEdge(edge)), which suppressed the duplicate and exposed the trigger.Verification
Verified on the PE counterpart, where the same code lives (this file is byte-identical between
thingsboard-edgeandthingsboard-edge-pebelow the license header). Built cloud and edge images locally and ran the full black-box suite:Log signature across 25 ownership changes:
One sync instead of 26, and the edge still observed every ownership transition (40 config messages alternating between customer-owned and tenant-owned) with entity access granted and revoked correctly.
CE is affected less severely than PE because CE's
doSyncwalks a fixed fetcher list, while PE's grows the cursor by two fetchers per entity group - but the redundant blocking sync is the same on both.Downstream
thingsboard-edge-pePRs #121 (master) and #122 (lts-4.3) carry the same change; they will be reconciled with this one so PE takes it via the normal CE merge.