googleforgames / open-saves

Open Saves is a cloud native data store for game development.
Apache License 2.0
222 stars 23 forks source link

Atomic incr/decr operations do not support multiple concurrent requests #413

Open ghost opened 2 years ago

ghost commented 2 years ago

What happened: Open Saves supports the update of record properties with the use of "atomic" messages to increment, decrement, add, subtract, and swap the property value.

What you expected to happen: When multiple clients are incrementing a record property field simultaneously, I would expect the property value to be incremented by the number of clients that made the request.

How to reproduce it (as minimally and precisely as possible): Using the Open Saves AtomicInc gRPC message, use 10 clients to increment a property field in the record at the same time. Some clients are going to be able to perform the operations, some others are going to fail with errors: concurrent transaction, signature mismatch, contention on entities.

Anything else we need to know?: Since best practices suggest limiting the update on Datastore entities to 1 rps to avoid database contention, we might need to look into alternatives to implement this feature (Datastore won't cut it).

The Golang library Redsync provides a distributed lock that we could use to help implement a solution to ensure that:

Environment: