top | item 36289073

(no title)

robert_dipaolo | 2 years ago

The problem with an annotation for that is it causes people to keep transactions open for too long. It's best practice in DB programming to keep tx's open for as short a time as possible. The longer it's open the more scope for deadlocks and contention. So we never use it in our prod code. We've put all the boiler plate code for creating the transaction, error handling, retires, etc in a helper function that takes a lambda as a param (that being the code to run in the tx). That way you can only wrap the code that needs to be in the tx, without copying and pasting all the boiler plate everywhere.

discuss

order

No comments yet.