Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Delay frequent twin pulls on reconnect #5188

Merged
merged 4 commits into from
Jul 19, 2021

Conversation

vipeller
Copy link
Contributor

(cherry picked from commit 6dd7275)

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.

@kodiakhq kodiakhq bot merged commit c7a81c1 into Azure:release/1.1 Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants