question

dominiquecanzeri avatar image
dominiquecanzeri asked

conditional updateuser*data with dataversion

would it be possible to add a member inside UpdateUser*DataRequest

uint? DataVersion; 

to make sure the api sets the data if and only if the DataVersion matches?

returning an error if versions are different.

something similar to http etags.

this is to react to concurrency between multiple entities modifying the same data.

10 |1200

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

Seth Du avatar image
Seth Du answered

If you are using Entity Objects to maintain data, there is a property named ExpectedProfileVersion in the request of SetObject API that can handle concurrency writes from different players. if the expected version is not correct, error will be reported and I believe it is a relatively better and fail safe solution.

10 |1200

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

Seth Du avatar image
Seth Du answered

PlayFab doesn’t support update specific version of Player data and we can only get different versions of player data via specifying IfChangedFromDataVersion in the request of GetUserData API.

I think the work around solution is to store a stringified JSON for the value of a player data (adding a version as a kvp inside) and create the verification process in the Cloud Script.

Besides, multiple entities modifying the same data concurrently is not recommended because each update call will not effect immediately and in terms of Player Data, there will be few minutes to make data in all shards of PlayFab server up-to-date. If it is only updating, it will be fine because only the last update will be counted as the final result, however, if you need to do some verifications and getting data before the update, there can be issues because the data you get may not be the latest result.

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.

dominiquecanzeri avatar image dominiquecanzeri commented ·

hello,

the solution you provide is not fail safe. it is not atomic. if 2 entities try to update the UserData at the same time, even if we check the version inside a cloud script, only the last entity will get to write the data. Both will get a success, resulting in loss of data.

How do you propose we could achieve atomicity using playfab then?

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.