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

Introduce new lockstep syncing system, modularize sync modes #178

Merged
merged 11 commits into from
Oct 5, 2023

Conversation

WiIIiam278
Copy link
Owner

Closes #69

This PR refactors the synchronization system and introduces a new LOCKSTEP sync mode, and modularizes the sync modes. It's my intent to make LOCKSTEP the default in the medium-term, though for now the old DELAY mode will remain as is (it works for most people, after-all). A new sync_mode config option has also been added, and a new server.yml file to track the server name of each server (this can also be added to the data snapshots to provide a handy bit of metadata)

The LOCKSTEP sync mode works as described below:

  • When a user connects to a server, the server will continuously asynchronously check if a DATA_CHECKOUT key is present.
    • If, or when, the key is not present, the plugin will set a new DATA_CHECKOUT key.
  • After this, the plugin will check Redis for the presence of a DATA_UPDATE key.
    • If a DATA_UPDATE key is present, the user's data will be set from the snapshot deserialized from Redis contained within that key.
    • Otherwise, their data will be pulled from the database.
  • When a user disconnects from a server, their data is serialized and set to Redis with a DATA_UPDATE key. After this key has been set, the user's current DATA_CHECKOUT key will be removed from Redis.

Additionally, note that DATA_CHECKOUT keys are set with the server ID of the server which "checked out" the data (taken from the server.yml config file). On both shutdown and startup, the plugin will clear all DATA_CHECKOUT keys for the current server ID (to prevent stale keys in the event of a server crash for instance)

@WiIIiam278 WiIIiam278 self-assigned this Oct 5, 2023
@WiIIiam278 WiIIiam278 merged commit cae17f6 into master Oct 5, 2023
@WiIIiam278 WiIIiam278 deleted the lockstep-syncing branch October 5, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve synchronization system stability on environments with fluctuating tick rates
1 participant