Closed digitaldan closed 2 years ago
I ended removing a bunch of dead code that has never been used. Also i put a data cap on our notification log as that collection on mongo is uncapped and has grown to over 40gb on production for no good reason.
For the record, this potentially resolves a race condition which leads to cloud thinking that client is offline even though it is connected. See https://github.com/openhab/openhab-cloud/issues/134#issuecomment-1120132195 for more info
Quoting from our 1on1 discussion
Only failure scenario that comes to mind is race condition
- Client disconnects on node X, code continues to prepare to send “disconnected” notification and store new status to Mongo
- Node X hangs a moment
- Client reconnects on node Y code continues to prepare to send “connected” notification and store new status to Mongo
- Process on node Y commits to Mongo (online status)
- Process ok node X commits to Mongo (offline status)
I realized that any false online status will be always cleared by ping/pong. However, there are no mechanism in place to correct false offline status.
This PR utilizes unique IDs for sessions combined with Mongo atomic query/update commands to resolve the possible race conditions
@digitaldan how to get this merged?
Yeah, i have been procrastinating a little as I need to block off time to do a proper deployment to the general service once we merge. I also then need to remove a few unused (but very large) collections from mongo. I'll probably do that Sunday, probably will post something to the forums later today about the upcoming maintenance.
Signed-off-by: Dan Cunningham dan@digitaldan.com