Skip to content
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

chore(docs): update documentation for lock_manager.h #601

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions src/include/concurrency/lock_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ class LockManager {
* Both LockTable() and LockRow() are blocking methods; they should wait till the lock is granted and then return.
* If the transaction was aborted in the meantime, do not grant the lock and return false.
*
*
* MULTIPLE TRANSACTIONS:
* LockManager should maintain a queue for each resource; locks should be granted to transactions in a FIFO manner.
* If there are multiple compatible lock requests, all should be granted at the same time
Expand All @@ -114,7 +113,6 @@ class LockManager {
* Row locking should not support Intention locks. Attempting this should set the TransactionState as
* ABORTED and throw a TransactionAbortException (ATTEMPTED_INTENTION_LOCK_ON_ROW)
*
*
* ISOLATION LEVEL:
* Depending on the ISOLATION LEVEL, a transaction should attempt to take locks:
* - Only if required, AND
Expand All @@ -134,21 +132,19 @@ class LockManager {
* READ_COMMITTED:
* The transaction is required to take all locks.
* All locks are allowed in the GROWING state
* Only IS, S locks are allowed in the SHRINKING state
* Only [IS, S] locks are allowed in the SHRINKING state
*
* READ_UNCOMMITTED:
* The transaction is required to take only IX, X locks.
* X, IX locks are allowed in the GROWING state.
* S, IS, SIX locks are never allowed
*
* The transaction is required to take only [IX, X] locks.
* [X, IX] locks are allowed in the GROWING state.
* [S, IS, SIX] locks are never allowed
*
* MULTILEVEL LOCKING:
* While locking rows, Lock() should ensure that the transaction has an appropriate lock on the table which the row
* belongs to. For instance, if an exclusive lock is attempted on a row, the transaction must hold either
* X, IX, or SIX on the table. If such a lock does not exist on the table, Lock() should set the TransactionState
* as ABORTED and throw a TransactionAbortException (TABLE_LOCK_NOT_PRESENT)
*
*
* LOCK UPGRADE:
* Calling Lock() on a resource that is already locked should have the following behaviour:
* - If requested lock mode is the same as that of the lock presently held,
Expand All @@ -162,21 +158,24 @@ class LockManager {
* A lock request being upgraded should be prioritized over other waiting lock requests on the same resource.
*
* While upgrading, only the following transitions should be allowed:
* IS -> [S, X, IX, SIX]
* S -> [X, SIX]
* IX -> [X, SIX]
* IS -> [S, X, IX, SIX]
* S -> [X, SIX]
* IX -> [X, SIX]
* SIX -> [X]
* Any other upgrade is considered incompatible, and such an attempt should set the TransactionState as ABORTED
* and throw a TransactionAbortException (INCOMPATIBLE_UPGRADE)
*
* Please note that we will not test the cases such as trying to acquire IS lock while holding IX lock.
* i.e., An insertion followed by a sequential scan on the same table within the same transaction under RR.
* Thus you will want to directly follow the instructions listed above for certain cases like this.
*
* Furthermore, only one transaction should be allowed to upgrade its lock on a given resource.
* Multiple concurrent lock upgrades on the same resource should set the TransactionState as
* ABORTED and throw a TransactionAbortException (UPGRADE_CONFLICT).
*
*
* BOOK KEEPING:
* If a lock is granted to a transaction, lock manager should update its
* lock sets appropriately (check transaction.h)
* lock sets appropriately (check `transaction.h`)
*
* You probably want to consider which type of lock to directly apply on table
* when implementing executor later
Expand All @@ -197,7 +196,7 @@ class LockManager {
*
* Finally, unlocking a resource should also grant any new lock requests for the resource (if possible).
*
* TRANSACTION STATE UPDATE
* TRANSACTION STATE UPDATE:
* Unlock should update the transaction state appropriately (depending upon the ISOLATION LEVEL)
* Only unlocking S or X locks changes transaction state.
*
Expand All @@ -211,8 +210,7 @@ class LockManager {
* READ_UNCOMMITTED:
* Unlocking X locks should set the transaction state to SHRINKING.
* S locks are not permitted under READ_UNCOMMITTED.
* The behaviour upon unlocking an S lock under this isolation level is undefined.
*
* The behaviour upon unlocking an S lock under this isolation level is undefined.
*
* BOOK KEEPING:
* After a resource is unlocked, lock manager should update the transaction's lock sets
Expand Down
Loading