MOSS Concurrency Control Protocol (Distributed Locking in Database)
This is a protocol which is used to control the concurrency in the Distributed database environment, Here we’ll read about the rules and regulations that are required to keep in mind while applying MOSS Concurrency Control Protocol.
MOSS Concurrency Control Protocol:-
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
a) It is mainly used for handling the nested(hierarchal) transactions which are based on inheritance.
b) Consider a Transaction(T) acquire a lock on a data-item(X) in some mode(M).
c) The Transaction(T) holds the lock in mode(M) until it terminates.
d) When anyone subtransaction(T1) of T commits, then its parent Transaction occupies or inherits that lock and retains until all subtransaction can’t finish.
e) If a transaction holds a lock on a data-item(X) so, It has the right to access the locked data-item(X) in the corresponding mode. However, it is not valid in case if a transaction retained a lock from any other some subtransaction(descendant).
f) A retained lock is only a just a kind of placeholder and indicates that the subtransactions that are out of corresponding hierarchy can’t acquire the lock, but descendant can acquire the lock.
g) As soon as a transaction becomes a retainer of the descendant subtransaction S’s lock, it remains a retainer until the transaction finishes.
General Locking rules regarding this Protocol:-
a) Subtransaction(T1) may acquire a read lock over a data-item(X) if:
a.1) no other subtransaction(descendant) holds the write lock on X, and
a.2) All the subtransactions that have retained a write lock on X are ancestors of subtransaction(S).
b) Subtransaction(T1) may acquire a write-lock on a data-item(X) if:
b.1) no other subtransaction holds a read/write lock on X, and
b.2) all subtransactions that have retained a read/write lock on X are ancestors of T1.
c) When a subtransaction(T1) completes its execution, the parent of T1 inherits(retains) the lock held by T1 in the same mode as was held by T1.
d) When a top-level of subtransactions(T3) commits all of its descendent’s release the held locks along with retained locks.
e) When a subtransaction(T3) aborts, it releases all of its held locks along with retained locks. All subtransactions originated from an aborting transaction are also aborted and must start from the very beginning if they have started their execution.