B+ Tree Locking Mechanism for Concurrent Write Operations
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Conventional datastores overuse exclusive locks on B+ trees, leading to reduced concurrency and performance issues in highly concurrent environments, especially during write operations and copy-on-write operations, due to unnecessary locking mechanisms.
Innovation Solution
Implementing a locking mechanism that uses shared locks on multiple nodes while traversing the B+ tree and acquires exclusive locks only on nodes that need to be modified, utilizing modification numbers and other parameters to ensure efficient locking and minimize lock conversions and retries.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If exclusive locks are used on every parent-child pair during write operations, then data consistency is ensured, but concurrency of I/O operations is reduced
Solution Approach 1:
The patent applies local quality by differentiating lock types based on the specific operation and node characteristics. Instead of uniformly applying exclusive locks to all parent-child pairs, the system uses shared locks for read operations and selective exclusive locks only for write operations on specific nodes, allowing other operations to proceed concurrently without unnecessary blocking.
Solution Approach 2:
The patent implements partial action by acquiring exclusive locks only on the specific parent-child pairs that are actually modified during write operations, rather than locking all parent-child pairs in the tree. This selective locking approach maintains data consistency for modified nodes while allowing concurrent access to unrelated nodes, thereby improving overall system concurrency.
2Reliability
If exclusive locks are used on every parent-child pair during copy on write operations, then cloning integrity is maintained, but system performance deteriorates
Solution Approach 1:
The patent applies local quality by using shared locks for most nodes during copy-on-write operations and reserving exclusive locks only for the specific parent-child pairs that require modification. This allows the majority of the tree to remain accessible for concurrent read operations while maintaining integrity for the cloned nodes being written.
Solution Approach 2:
The patent implements partial action by acquiring exclusive locks only on the minimal set of parent-child pairs that are actually modified during copy-on-write operations, rather than locking the entire tree. This selective approach maintains cloning integrity for the affected nodes while preserving system performance through concurrent access to unaffected nodes.
3Reliability
If lock coupling mechanism is used to lock parent-child pairs, then data consistency is maintained, but lock conversion overhead increases
Solution Approach 1:
The patent applies preliminary action by determining in advance which parent-child pairs require exclusive locks based on the write operation targets. By pre-identifying the specific nodes that need modification and acquiring locks only on those pairs, the system avoids unnecessary lock conversions and retries, reducing overhead while maintaining data consistency.
4Reliability
If retries are implemented when exclusive lock acquisition fails, then lock acquisition is eventually achieved, but operation latency increases
Solution Approach 1:
The patent implements partial action by acquiring exclusive locks only on the specific parent-child pairs that are actually modified, rather than attempting to lock all possible pairs. This reduces the probability of lock conflicts and the need for retries, thereby decreasing operation latency while still ensuring reliable lock acquisition for the necessary nodes.
Data Source
AI summary
A method for modifying key-value pairs of a B+ tree is provided. The method receives a request to modify a particular key-value pair. Each node of the tree has a modification number. The method traverses a path on the tree from the root node toward the particular node. The traversing includes upon reaching a parent node of the path, acquiring a shared lock on both the parent node and a child node one level below the parent node. Upon determining that the child node is the particular node, the method stores the modification number of the particular node, releases the shared lock on the particular node, compares a current modification number of the node with its stored number, and acquires an exclusive lock on the node if the numbers are the same. The method increments the current modification number of the node and modifies it while in the exclusive lock.


