Locking mechanisms for preventing data integrity issues in concurrent data access scenarios #307
Open
8 tasks done
Labels
feature
New feature or request
First Check
Commit to Help
Example Code
Description
So far SQLModel does not provide mechanisms for preventing data integrity issues in concurrent data access scenarios out of the box.
Wanted Solution
It would be great to have something similar like
LockModeTypes
provided by the Java Persistence API (API).Optimistic locking (
@Lock(LockModeType.OPTIMISTIC_FORCE_INCREMENT)
):Pessimistic locking (
@Lock(LockModeType.<...>)
):When using OPTIMISTIC_FORCE_INCREMENT based optimistic locking and pessimistic locking table rows are locked at the database level. So this should be in the scope of SQLModel.
Another option would be to provide optimistic locking on the class instance level instead of the database level similar to the options available in Java. Hibernate provides e.g. optimistic locking via
@OptimisticLocking(type = OptimisticLockType.<...>
:In SQLModel one could implement this functionality using Pydantic classes instead of the SQLAlchemy classes.
Wanted Code
Alternatives
Reinvent the wheel over and over again :smil
Operating System
Other
Operating System Details
n.a.
SQLModel Version
n.a.
Python Version
n.a.
Additional Context
The article Optimistic and Pessimistic Locking in JPA is a nice resource about what types of locking is provided by and used in JPA.
The text was updated successfully, but these errors were encountered: