forked from Azure/iotedge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Delay frequent twin pulls on reconnect (Azure#5148)
Agent pulls twin on reconnect, so desired property changes will be learned if those happened while the device was disconnected. In certain circumstances it can happen that a device keeps connecting/disconnecting. One particular case is when two edge devices use the same identity and when one device connects, the other gets disconnected. In turn the disconnected device try to connect back and this makes the first device get disconnected. This fight over the connection can result in several twin pulls per seconds. This solution delays subsequent twin pulls if those happen within a certain time window. The throttling applies only on connection, so if for some reason iothub sends frequent desired property changes, those are not throttled. The solution below has a flaw: if the delay is e.g. 30 seconds (which is now and it is hardcoded), then if there was a pull 29 seconds ago and a new one comes in, that will be delayed by 30 seconds, giving an 59 second window. I was considering calculating the windows size dynamically, e.g. removing the time elapsed from the previous twin pull giving a more steady 30 sec delay windows, however weighting the frequency of the occurrence this protection is needed and the additional complexity of the code, I chose the simpler code.
- Loading branch information
Showing
2 changed files
with
194 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.