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

Data Inconsistency When Players Switch Servers with MySQL Sync #514

Closed
xiaozhangup opened this issue Dec 26, 2024 · 12 comments
Closed

Data Inconsistency When Players Switch Servers with MySQL Sync #514

xiaozhangup opened this issue Dec 26, 2024 · 12 comments
Assignees
Labels
Enhancement New feature or request

Comments

@xiaozhangup
Copy link
Contributor

Description
I encountered an issue when using MySQL to sync player data: there is a chance that data fails to synchronize properly when players switch between servers quickly, resulting in data loss. This is particularly noticeable in scenarios with frequent server switching and negatively impacts the player experience.

Steps to Reproduce

  1. Configure MySQL as the database for player data synchronization.
  2. Have a player switch between two servers rapidly.
  3. Observe the data in the database and on the new server; occasionally, the data may be missing or out of sync.

Expected Behavior
I would like a mechanism (e.g., a locking mechanism) to ensure data consistency during server switches, so that no data is lost in the process.

Proposed Solution
Consider implementing a locking mechanism during the synchronization process to prevent related operations or reads until the player's data is fully synchronized. This would help ensure that data remains consistent when players switch servers.

Environment Details

  • Plugin version: 1.15.2 for 1.19.2-1.21.1
  • Server software and version: Paper-1.21.1

Please let me know if more information or debugging assistance is needed!

@illyrius666
Copy link
Contributor

does anything show up in the logs? or is it only visible in the database?

@xiaozhangup
Copy link
Contributor Author

does anything show up in the logs? or is it only visible in the database?

Neither the database nor the server logs show anything; the data is simply lost.

@illyrius666
Copy link
Contributor

does anything show up in the logs? or is it only visible in the database?

Neither the database nor the server logs show anything; the data is simply lost.

if you dont mind and join the discord server, please create a ticket in the support forum, so the devs can help you more directly:
https://discord.gg/volmit

@AvianAeternum
Copy link

AvianAeternum commented Dec 26, 2024

What's providing the MySQL db. is it hosted on the server, or is it remote or?

@xiaozhangup
Copy link
Contributor Author

What's providing the MySQL db. is it hosted on the server, or is it remote or?

on server,not remote

@CrazyDev05
Copy link
Contributor

this is kinda expected as cross server sync is difficult by default and adapt wasn't even remotely designed for that

@xiaozhangup
Copy link
Contributor Author

this is kinda expected as cross server sync is difficult by default and adapt wasn't even remotely designed for that

I used to write plugins that required cross-server communication through a database, and I encountered the same issue where data couldn't synchronize correctly. My solution was to add a timestamp to the database to determine whether the current data was being used by any server. If it was occupied, I would wait until the occupation was released before loading the data.

@xiaozhangup
Copy link
Contributor Author

this is kinda expected as cross server sync is difficult by default and adapt wasn't even remotely designed for that

I just took a look at the implementation of Adapt, and it seems that using locking in this way would result in extensive code modifications. This is because it appears that the possibility of player data not being loaded yet during skill handling was not considered.🤔

@CrazyDev05
Copy link
Contributor

I just took a look at the implementation of Adapt, and it seems that using locking in this way would result in extensive code modifications. This is because it appears that the possibility of player data not being loaded yet during skill handling was not considered.🤔

yep exactly what I meant with adapt wasn't even remotely designed for that
if you wanna add it go ahead try but for now this will be a low prio due to it's complexity and relatively rare use case

@CrazyDev05 CrazyDev05 added Enhancement New feature or request Backburner This is something that I want to do but, not at the moment labels Dec 27, 2024
@CrazyDev05
Copy link
Contributor

CrazyDev05 commented Dec 27, 2024

if you servers are on the same machine, it's probably the easiest to just use the file storage with symbolic links
yes i know thats very janky

but even that may have sync problems, which are at least relatively easy to fix

@xiaozhangup
Copy link
Contributor Author

xiaozhangup commented Dec 27, 2024

if you servers are on the same machine, it's probably the easiest to just use the file storage with symbolic links yes i know thats very janky

but even that may have sync problems, which are at least relatively easy to fix

Actually, this would already cause the same issue as using the database, because the problem lies in the fact that the data isn't being saved in a timely manner. Could you tell me under what circumstances Adapt typically starts saving data?

Got it, I'll try adding a locking mechanism myself.

@CrazyDev05
Copy link
Contributor

Actually, this would already cause the same issue as using the database, because the problem lies in the fact that the data isn't being saved in a timely manner. Could you tell me under what circumstances Adapt typically starts saving data?

the current code yes but if you use a file lock only one server will be able to own the data, making desync impossible
the are two moments adapt saves the playerdata:

  1. once a minute
  2. on player quit event

@CrazyDev05 CrazyDev05 added In Development This is on our radar as something we want to add, and is probably already a class we are working on and removed Backburner This is something that I want to do but, not at the moment labels Dec 29, 2024
@CrazyDev05 CrazyDev05 self-assigned this Dec 29, 2024
@CrazyDev05 CrazyDev05 removed the In Development This is on our radar as something we want to add, and is probably already a class we are working on label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants