Has the whole "losing data randomly" thing been solved yet?

This seems to have been an issue forever on Roblox.
Players would randomly have their data reset and lose all their progress in every game I have, very rarely, but I have no way of knowing what went wrong or to prevent it.

This kind of stuff makes me hesitant to do things like add more complex inventories and progression for my games. I have systems in place to detect “reasonably low progress” data and double check to save progress/ prevent saving at all if it’s at absolute zero.

But nothing seems to work. Every other day or so I get the odd PM saying “please help, all my progress was lost, can i get it back”

Has this issue been “solved” by anyone yet? Have the sources for these data losses been determined?

2 Likes

It’s likely problems with your data saving logic. There’s lots of common mistakes that developers make with their data stores code:

  • Not handling errors correctly.
  • Using too many requests, that get throttled, and then throw errors.
  • Using SetAsync() in scenarios where it overwrites the previous data.
  • Not saving data when the player leaves and when the game closes (game:BindToClose()).

To avoid these, you should:

  • If you use GetAsync to fetch the player’s data, make sure that it actually succeeded, and that when you save the player’s data that they’re not operating on some “from scratch” copy.
  • Use UpdateAsync() and reconcile changes in your data instead of blindly overwriting it using SetAsync().
  • If GetAsync() fails, you should make sure that it fails in a safe state. Retry it until it succeeds, and make sure that your UpdateAsync() handles the case where the player made progress on a “new account” despite already having existing data.
  • Upon a successful UpdateAsync() call, you know what the new state in the data store is. You should update your game state with this information, in case an earlier GetAsync() call failed.
  • Retry with exponential backout if saving fails.
  • If the user is making progress, then automatically save that progress every few minutes, depending on your data store budget. This way, even if the server crashes, their progress for the past however many minutes will be saved.
  • If the user just bought something (with robux or otherwise), try to save that progress immediately.
  • When the user buys things, consider saving a record of their transactions instead of just bumping a number, so that you can restore their data from the log if something goes wrong (e.g. a bug in your game’s code causes some items to be deleted).
  • Use a centralized player data manager script that can keep track of data store limits better than doing it in one-off scripts. It’s common practice to have a queue of pending things to save, and then you can prioritize that queue and implement retries easily.

There are some modules that developers have released publicly that attempt to solve these problems in a way that can be reused by others. For example, the PlayerDataStore module by stravant. https://www.roblox.com/library/159129148/PlayerDataStore-Module

16 Likes

Doesn’t really help since I do all of these sans the “keeping a backlog” (how do you do this without setting up even more datastores and trusting those)

I literally have my scripts prevent saving “zero progress” and retry checking a save in this instance

And I don’t have a thing that keeps track of datastore limits, because I don’t think I’m nearing the limit. (accounted for limits in my scripts, and unless some anomoly happens where 10 players join and leave all at the same time while the server updates some global variables, it’s not really worth the effort of keeping track of the limits and complicating things further)

If you’re sure you’re doing everything right, then you should really log players’ data history. I have gotten reports before of data loss, and every one of them just turned out to be the player lying to receive some form of bonus.

You need to provide yourself with the information you need to solve data loss issues. You should never trust your players blindly.

1 Like

I don’t have any way to track the players’ data any way, or the tools to restore their data, so I kind of just let these anomolies be

As far as I know Roblox doesn’t let you create backups of their datastores

They don’t let you create backups of data stores, however that doesn’t mean you can’t make your own backup system. See @berezaa’s method here:

https://devforum.roblox.com/t/best-way-to-use-datastores-with-minimal-data-loss/32159/3

4 Likes

This is what I was looking for! I’d love to use this but I can’t conceptualize ordereddatastores

I have a hard time keeping track of how it works in my head; I remember that I wanted to use this for various things but one or two random properties of it were counter-intuitive/ made the whole thing obsolete, but I forget what these elements were

http://wiki.roblox.com/index.php?title=API:Class/OrderedDataStore

As per usual the wiki doesn’t make things clear; where’s the guarantee things will be ordered to a certain key/ value? How would using os.time() combined with this work?
It all feels too intangible, just like regular datastores, with random pitfalls throughout

Ok, so… i roughly understand how it’s supposed to work, but what i’m wondering is what does this imply? How does this affect throttling?
How do i go about setting the data? Do i still have to do ~ 3 min. intervals between saving, and if so, does it mean both of them, or just one?
My intuition says that i shouldn’t care about the regular data store causing trouble, if the keys are different, i’m not overwriting then, but i should have the ordered data store at intervals, is this true?