(no title)
ishjoh | 2 years ago
I'm building an app on top of django where I have to worry about this, if you're using django check out there support for select-for-update, and if you're database supports it nowait=True can be a great thing that will fail a read if a select for update is already run:
https://docs.djangoproject.com/en/4.2/ref/models/querysets/#...
Also worth mentioning optimistic locking if you're looking to solve the issue in a different way, there is more involved from the application side but it has some advantages as well. I tend to prefer select for update with nowait=True since it's simpler on the application side, but I have used optimistic locking in the past with great success and some systems support it OOTB. Here is a description from AWS for those curious:
https://docs.aws.amazon.com/amazondynamodb/latest/developerg...
No comments yet.