question

jan.hovorka avatar image
jan.hovorka asked

Concurrent user data write from client and from Leaderboards reset

Hello!

We have this scenario:

When our leaderboard reset (daily), our prize table is designed to call cloud script function which will write to user data (UpdateUserData call) to write prize. What will happen, when there will be another write call to user data from cloud script, which client application can call regularly to update user progress ? If client call fails due to concurrent write it doesn't matter, because client can send it later - but if call from leaderboards fail ? And if it can fails, what is better approach ? Shared data ?

Thanks for your, as always, best support!

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

First, what exactly is the script writing to player data? If it's a prize, why not make it an item in the game's catalog and grant it from the script?

Yes, since two simultaneous calls to write to the same user data key can collide, causing the second one that arrives to fail, it is entirely possible that the Cloud Script could fail to write to the data, in the scenario you describe (though given that they would have to arrive very close in time, it would be relatively uncommon). A more reliable design would be to use the catalog and grant the prize.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jan.hovorka avatar image jan.hovorka commented ·

Thanks for reply, our game doesn't use items in catalog, but only player data (because we are performing some special merging operations to data because we need to support both offline mode and multiple devices simulteanously). This scenario doesn't even really grant the item, but send message to the client (this means it writes into player data under ceratin key) and cleint will actually grant it (update player data). There is script function which is called both from client and also from leaderboard reset which then call UpdateUserData from server API to update this certain key with reward message for client to read and redeem.

I was also thinking to use items in catalogue just for this tournament scenario to avoid concurrency problem although as you said it will be probably very rare situation, I'm still not sure how really rare it will be, thanks for the tip!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.