Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
MOSS Concurrency Control Protocol (Distributed Locking in Database)
The MOSS (Multi-Object Synchronized Scheduling) Concurrency Control Protocol manages concurrency in distributed database systems by handling hierarchical transactions with parent-child relationships and lock inheritance.
Distributed Locking Types
- Optimistic locking No locks acquired upfront; conflicts detected at commit time.
- Pessimistic locking Locks acquired before accessing shared resources; conflicts prevented from the start.
MOSS Protocol
MOSS is a hierarchical locking protocol for nested transactions where subtransactions can inherit locks from ancestors ?
Core principles
- Lock acquisition Transactions acquire read or write locks on data items.
- Lock inheritance When a subtransaction commits, its parent inherits the lock.
- Retained locks Placeholders preventing external access while allowing descendant access.
Locking Rules
| Rule | Condition |
|---|---|
| Read lock | No descendant holds write lock; only ancestors hold write locks |
| Write lock | No other subtransaction holds any lock except ancestors |
| On commit | Parent inherits all locks in same mode |
| Top-level commit | All descendant locks released |
| On abort | All locks released; cascade abort to subtransactions |
Example: Banking Transfer
Consider a nested transaction transferring $100 from Account A to B ?
T1: Transfer $100 from A to B ??? T2: Debit $100 from A ? Write lock on A ??? T3: Credit $100 to B ? Write lock on B T2 commits ? T1 inherits write lock on A T3 commits ? T1 inherits write lock on B T1 commits ? All locks released
Advantages and Challenges
- High concurrency Nested transactions without excessive locking overhead.
- Deadlock prevention Hierarchical structure prevents circular waits.
- Challenges Network latency in distributed systems and complexity of managing retained locks across nodes.
Conclusion
The MOSS protocol manages hierarchical transactions in distributed databases through lock inheritance subtransactions acquire locks, parents inherit them on commit, and top-level commit releases everything. This makes it suitable for complex nested transaction workflows requiring both high concurrency and data consistency.
