Urgent data loss issue

People are reporting to me that their data gets wiped sometimes. I’m not sure if these people are lying, since usually they’re asking for a lot of wins in return. This hasn’t happened to me in my game before, but I do remember a couple times my wins didn’t load in studio. But I do have a backup data store, that saves every 240 seconds, since rounds are like 6 minutes long and if they lost a win, it’d be fine.

I suggest that instead of using :SetAsync you use :UpdateAsync as this may be the causing issue

1 Like

how would I use UpdateAsync? Like just do a simple datastore:UpateAsynce() statement

I have the same problem.

And I don’t know how to do this either. Do you mind explaining some of the details of API, I’m not sure what transformFunction does.

From what i see on GlobalDataStore:UpdateAsync, it seems like has to be used with a function. The example code explains it better.

here you go

1 Like

I’d recommend looking at this tutorial:

Without having any code to work off of, it’s hard to give further suggestions.

Hey, while you still haven’t managed to fix the data loss issues, you can instead, use :ListVersionsAsync (I believe that’s how you write that) to check for older versions of data for a datastore key. So you can just get that data and reverse it. It’s just a little complicated to do that though.

UpdateAsync wouldn’t have much to do with data loss …

*Edit: This IS wrong …

This is just flat out wrong. Take a look at this:

UpdateAsync isn’t used to recover data, it’s to prevent it from getting overwritten in the first place.

From what I understand I counts as both read and write

GlobalDataStore:SetAsync is best for a quick update of a specific key, and it only counts against the write limit. However, it may cause data inconsistency if two servers attempt to set the same key at the same time.

GlobalDataStore:UpdateAsync is safer for handling multi-server attempts because it reads the current key value (from whatever server last updated it) before making any changes. However, it’s somewhat slower because it reads before it writes, and it also counts against both the read and write limit.

You’re seemly right. I was thinking data loss due to the 6 seconds you got to save everything on a shut down … then again this would surly go over that …

This makes it so you’ll pretty much have to wright that multi save script that saves at the same time for everything as this would take even longer on a shut down I guess.

So if I had my whole data table, I can just return that data table in the update async function? This is so exciting but this is so exciting it’s midnight for me rn, and I can’t go on studio, but i’ll probably solution this tomorrow or if I don’t I’ll give you a reply in what went wrong