Sign In Register

How can we help you today?

Start a new topic

Locking a NoSQL collection

Hi,


I'm just getting started with GameSparks and trying to create my first few Cloud Code methods. I'm trying to implement a 'forgot password' functionality by following the example found here: https://docs.gamesparks.com/tutorials/social-authentication-and-player-profile/automating-user-password-change.html


I noticed in this example that there is the potential for a race condition which would allow 2 users to create accounts with duplicate email addresses. Basically, if 2 users both submitted the same email address at the exact same moment, the code in this sample may fail. This is because the script will first check if the email exists in the "playerEmailCollection" Runtime Collection, then do some stuff, then later insert into that collection if everything goes well.


I'm concerned about this because not only in this case, but in many other cases it will be important to make sure we can lock a collection while for reads while someone else is writing to it. Another example where this would be critical is consuming purchasable resources in the game (like drinking a potion that I paid a dollar for). Does GameSparks support this kind of thing? 

Login to post a comment