typeorm icon indicating copy to clipboard operation
typeorm copied to clipboard

Auto Retry options on error in transactions(e.g. Deadlock)

Open jayvaghani opened this issue 2 years ago • 3 comments

Feature Description

Whenever Deadlock happen in any transaction query, Retrying same query transaction is needed in most of the cases. Writing code for each query to retry on deadlock is too much headache and it does not keep code clean.

The Solution

We should be able to configure auto retry options like(shouldRetryOnError,attempts,delay etc). This configurations should be allowed at typeorm level that applies to all queries. User should also be able to be override configurations for each typeorm query.

Considered Alternatives

Workaround was to write additional lines of code to retry queries on such error, But that makes code messy and less readable.

Additional Context

No response

Relevant Database Driver(s)

  • [x] aurora-mysql
  • [x] aurora-postgres
  • [ ] better-sqlite3
  • [ ] cockroachdb
  • [ ] cordova
  • [ ] expo
  • [ ] mongodb
  • [X] mysql
  • [ ] nativescript
  • [ ] oracle
  • [x] postgres
  • [ ] react-native
  • [ ] sap
  • [ ] spanner
  • [ ] sqlite
  • [ ] sqlite-abstract
  • [ ] sqljs
  • [ ] sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

jayvaghani avatar Feb 24 '23 07:02 jayvaghani

I'd love to see such a feature for the exact same reasons OP stated

daitay4 avatar Jun 06 '23 15:06 daitay4

This would really be a helpful feature! We are currently facing some deadlock issues and we will need to use some techniques to prevent them instead of just simply adding a such "retry" configuration either to the call or to the typeorm module globally as is suggested by the OP.

scr4bble avatar Jun 19 '24 21:06 scr4bble