-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify semantics of locks wrt SELECT/READ #1614
base: main
Are you sure you want to change the base?
Conversation
There is a common misunderstanding that pessimistic locking, prevents select queries without locks. See also HANA docs https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/20fcf24075191014a89e9dc7b8408b26.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should have a table
state | select without lock | select with shared lock | select with exclusive lock / update |
---|---|---|---|
not locked | passes -> not locked | passes -> shared lock | passes -> exclusive lock |
shared lock | passes -> not locked | passes -> shared lock | passes -> exclusive lock |
exclusive lock | passes -> not locked | passes -> exclusive lock | waits -> exclusive lock |
Co-authored-by: Adrian Görler <[email protected]>
Maybe, but I don't think your table is correct, is it?
|
Yes, you are right. A shared lock can be promoted to an exclusive lock. But I think only in the transaction where the lock was originally created, I think. Others will wait.
Yes, you are right. |
Should we also link the db documentation? |
The db docs are also rather cryptic sometimes and not so clear in my opinion. Therefore not sure if that provides a lot of additional value. Do you think they would be helpful after taking a look at them? |
There is a common misunderstanding that pessimistic locking, prevents plain select queries without locks.
See also HANA docs https://help.sap.com/docs/SAP_HANA_PLATFORM/4fe29514fd584807ac9f2a04f6754767/20fcf24075191014a89e9dc7b8408b26.html
See also PostgreSQL docs
https://www.postgresql.org/docs/current/explicit-locking.html#LOCKING-ROWS
See also H2 docs
https://www.h2database.com/html/commands.html#select