datastore: Parallel Transaction on same kind with unique keys giving concurrent transaction error

https://github.com/googleapis/google-cloud-go/issues/10068

2024/04/30 05:06:42 Error during Upsert: datastore: concurrent transaction
UUID-NOT-COLLECTED API-NOT-COLLECTED class.Upsert tx.Commit: datastore: concurrent transaction
2024/04/30 05:06:43 Error during Upsert: datastore: concurrent transaction
UUID-NOT-COLLECTED API-NOT-COLLECTED class.Upsert tx.Commit: rpc error: code = InvalidArgument desc = Invalid transaction.
2024/04/30 05:06:43 Error during Upsert: rpc error: code = InvalidArgument desc = Invalid transaction.
UUID-NOT-COLLECTED API-NOT-COLLECTED class.Upsert tx.Commit: rpc error: code = InvalidArgument desc = Invalid transaction.
2024/04/30 05:06:43 Error during Upsert: rpc error: code = InvalidArgument desc = Invalid transaction.

Why parallel transaction is giving this error when keys are unique which are to be inserted/updated?

3 1 87
1 REPLY 1

Hello @mehulparmariitr,

Welcome to the Google Cloud Community!

The errors "datastore: concurrent transaction" and "InvalidArgument desc = Invalid transaction", might mean that your transactions are clashing with each other in Google Cloud Datastore. This issue can occur even if you are using unique keys but trying to change the same entity group.

For instance, even if your transactions involve different user IDs, they might still conflict if those IDs are part of the same "users" entity group.

To learn more about how transactions and entity groups work in Cloud Datastore, check out these links:
Transactions & Entities, Properties, and Keys.