-
Notifications
You must be signed in to change notification settings - Fork 26
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
fixed bug where duplicated device would remove itself and the newly added device #439
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #439 +/- ##
==========================================
- Coverage 86.80% 86.76% -0.04%
==========================================
Files 187 187
Lines 8201 8207 +6
==========================================
+ Hits 7119 7121 +2
- Misses 881 885 +4
Partials 201 201 ☔ View full report in Codecov by Sentry. |
It looks like if there is a duplicate connected device is found, we leave the previous connection open until it naturally will close down due to inactivity (in the case where a device reconnects after a non-graceful socket shutdown). Or will allow multiple connected devices with the same identifier on each talaria. This means that at any given moment instead of having a max of 1 per datacenter instance of a duplicate CPE, we could have |
The problem detected is that in registry.go the newDevice replaces existing and calls existing.requestClose:
In pumpClose (manager.go) it will remove from the map the device by its id, which will remove newDevice from the map and close both connections:
|
It's not exactly leaving the previous connection open. It's not allowing the "new" same id device to connect again in the first try (the talaria closes both connections, the new and the old one). The next retries work correctly again, because the bug it's not triggered again since both previous connections were closed, therefore with no duplicates. @diogoViana95 described above that the bug it's related with the adding the "r.data[id] = newDevice" to the dictionary of devices before removing the supposed "oldDevice". Since the removal it's done afterwards by getting by id from the same dictionary, then the pumpClose will trigger the "newDevice" instead of the "oldDevice" (the "oldDevice" it's not in the dictionary of devices at this time). |
- fixed bug where duplicated device would remove itself - xmidt-org/webpa-common#439
- fixed bug where duplicated device would remove itself - #439 (cherry picked from `master`)
…xed-duplicated–device-removal patch: fixed duplicated device removing itself (#439 cherry picked)
- fixed bug where duplicated device would remove itself - xmidt-org/webpa-common#439
fixes #438
When there's a new connection request from a device with an id that already exists, the existing device is replaced by the new one.
The old device will call requestClose which removes the new device.