Request for further explanation of the behaviour of RemoveAsync in relation to other requests

https://developer.roblox.com/en-us/api-reference/function/GlobalDataStore/UpdateAsync
https://developer.roblox.com/en-us/api-reference/function/GlobalDataStore/RemoveAsync

Forewarning: I might not be requesting the right thing here because I don’t know how the data service works. Either my request pertains to more information on RemoveAsync respecting other requests, how UpdateAsync respects other requests and if it stops retrying when the data it attempts to set is no longer up to date or how requests are processed by the data server. I linked both but my primary focus is on RemoveAsync’s use and processing.


Earlier while submitting a pull request on ProfileService to change UpdateAsync to RemoveAsync while handling profile wipes I realised that I don’t actually know anything about how RemoveAsync works when the request reaches the data server and that’s concerning if the PR gets accepted. ProfileService is a widely used module so I had a moment of internal breakdown wondering if I’d be responsible for many games having issues deleting profiles.

I’ve checked through the RemoveAsync announcement thread, the documentation and all DataStores articles. There’s not a single mention of how RemoveAsync behaves other than that it’s the canonical way to wipe an entry from a DataStore (cannot set a key to nil) and that it returns the data originally in the DataStore. This is not helpful in contrast to UpdateAsync.

The problem here is that if RemoveAsync behaves like SetAsync. UpdateAsync has a very nice explanation and all about how it validates data, respects other servers that may update the data (what does that even mean specifically?) and about how the transform function is called as many times as it needs to be until data is ensured saved. What about other methods like RemoveAsync then? Wouldn’t UpdateAsync’s retry behaviour overwrite a remove attempt or… something?

Just requesting documentation or something that affirms that RemoveAsync is safe to use without getting overwritten, even by UpdateAsync and its retries, unless explicitly done so by the developer.

2 Likes

No longer want or need this. I had this explained to me after better forming my question and after a few read throughs I realise the documentation is very clear about the way these requests perform.

RemoveAsync is treated in a similar fashion as SetAsync but its used to remove data since SetAsync cannot accept nil values. It is possible to encounter race conditions when using RemoveAsync inappropriately. This reinforces the idea that it is imperative that developers use UpdateAsync when needing to update data because UpdateAsync actually respects other requests.

Regarding my specific case that prompted this documentation request, I’m safe. ProfileService only uses UpdateAsync when interacting with DataStores however I submitted a pull request to use RemoveAsync instead for wiping profiles. This is safe to do and will not encounter race conditions when wiping profiles. If an UpdateAsync is in progress while RemoveAsync is called, UpdateAsync’s retry behaviour will be triggered. Safe to use.