The synchronization of state between clients and server is leading to some unindented duplication and orphaning of data.
I've found a way around 1, but have a clarifying issue as to how to properly delete from crdt dominictarr/crdt#21
Number 2 I don't have a solution for yet, and wonder in general with the way crdt is being employed here if it should be emphasized that the servers version of the state is authoritative. In the paste, before seaport was changed to use crdt, it worked very cleanly: the server would restart and all of the clients would reassert themselves.
I'm happy to continue to work through this, fix and pull request, but I need to better understand the intent and an agreed approach. What should happen to the state of things when the server restarts?
When a node restarts it's given (randomly generated) a different node id and then any data associated with the previous node id that's been syncronized to any other node maybe orphaned, especially if the node is a seaport service or the node goes down at the same time as a seaport server and the server can't unregister the nodes data in time and emit the change to the other nodes.
This results in both ghost nodes and data as well as memory leaks.
I think I have a reasonable solution for this, but I'll wait to submit the pull request until my crdt pull request is accepted since there is a dependency there.
Here's the approach:
If a client looses contact with the Seaport server and then reconnects, delete all of the crdt rows not owned by that client node.
This eliminates the client from polluting the server and other nodes with potentially stale and/or orphaned data. It also in essence gives that authority back to the Seaport server.
Fixes for crdt data consistency issues #29
Depends on new version of crdt pending acceptance of dominictarr/crdt#21
Once the crdt patches go through I'm ready to merge this.
The new crdt version has been published and I squashed my commits. I removed my original reinitialize logic and replaced with a heartbeat. Relevant discussion here: dominictarr/crdt#21
Fixes for crdt data consistency issues #29 Depends on new version of …
…crdt pending acceptance of dominictarr/crdt#21
This was merged. The squashing must've confused github about auto-closing.
Sorry about the confusion, didn't want to unnecessarily confuse the history. Thanks!