sai-pullabhotla / catatumbo

JPA like Persistence Framework for Google Cloud Datastore and Cloud Firestore
http://catatumbo.io
Apache License 2.0
51 stars 20 forks source link

Retry the transaction again after configured time when too much contention occurs #203

Open akreddy21 opened 6 years ago

akreddy21 commented 6 years ago

Hi, I know that when two or more threads trying to update same entity with transaction leads to too much contention exception. Is there anyway to retry the transaction again instead of throwing exception back to client.

Thanks

sai-pullabhotla commented 6 years ago

@akreddy21 - you should be able to implement your own retry logic as explained below. I will see if this can be added to the framework in a future release.

https://cloud.google.com/datastore/docs/concepts/transactions#uses_for_transactions

akreddy21 commented 6 years ago

If I use the logic that google has provided in docs, I will end up in writing boiler plate code to put every method in while loop or I have to use AOP to manage this at one place. It will be helpful if framework can provide this feature with configurations in TransactionOptions like no-of-times, intialDelay..