ryzom / ryzomcore

Ryzom Core is the open-source project related to the Ryzom game. This community repository is synchronized with the Ryzom Forge repository, based on the Core branch.
https://wiki.ryzom.dev
GNU Affero General Public License v3.0
337 stars 90 forks source link

Improve reliability of naming service #681

Open kaetemi opened 1 year ago

kaetemi commented 1 year ago

The naming service currently broadcasts changes as soon as services register and unregister to all other registered services. When connection to the naming service drops temporarily, broadcasts may be missed, and the list of connected services may go out of sync. Similarly, restarts of the NS cause failure.

Upon launch of NS, generate a time + random number pair as a unique identifier of the NS instance. Additionally add a counter starting from 0 to track registration changes.

When a service connects or reconnects, it registers, and sends along any previously known NS identifier and the local change counter in the case of a reconnection.

If the received identifier mismatches, NS sends all registered services plus the new identifier, otherwise, it sends all changes that are more recent than the registration counter.

If a service receives a new NS identifier, this means the NS restarted, and it's registration info will be incomplete. In this case, wait 10 seconds or so before dropping any missing entries as unregistered. Track per registration entry from which NS instance the registration came.

On disconnections and unregistrations, NS needs to track a tombstone entry to update any services that were disconnected during unregistration of another service.