-
Notifications
You must be signed in to change notification settings - Fork 81
Data being reverted to a previous save when shutting down servers #45
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
Comments
Can you try this and see what happens (best if it works on a slightly modified baseplate):
What data do you get? Old data or the data from when you shut down? My theory is it's still saving by the time people rejoin. |
I followed the steps and got the old data. |
@Intrance1 That's strange--and it says in the console it didn't save because of unchanged data, correct? DataStore2 runs code on BindToClose, so there could be something incorrect there. |
There's nothing in the log after the game is shutdown. I'm not sure if messages continue to be posted to the console after the server is shutdown. The message could be posted after I'm kicked from the server and that could be why I don't see anything in the console. |
Can you see what happens when you add this somewhere in your code:
I wonder if it's a BindToClose problem or a DataStore2 problem. |
That worked. I shutdown the server and "saved key" outputted in the console, then rejoined and had the correct data. |
Strange, that means it must be an issue with how DataStore2 specifically implements it. Not so coincidentally, there's also no unit tests for it. Here's the relevant lines: Lines 619 to 644 in 56a0d27
It's a bit weird, but the gist of it is:
This logic makes sense to me, so I'm not sure why it isn't working. While we could just call |
So I was doing some testing with the playerLeavingConnection and I think the problem is with the AncestryChanged event. I replaced it with a PlayerRemoving event and that worked. |
That must be it, the AncestryChanged patch is recent: 620688e Thanks for you research! I'll fix it when I can unless you want to make a stab at a PR (that also fixes the memory leak the previous version had). |
After doing some testing, I think what's happening is when a game server is shutdown, the player's data is reverted back to the data received from the initial :Get() when the player joined the server, ignoring any changes made to the player's data while in the server.
The text was updated successfully, but these errors were encountered: