Range Lock Acquisition Using Segmented Trees for Faster Conflict Checks
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
The efficiency of obtaining range locks in distributed systems is low due to the need to traverse a red-black tree structure as the number of obtained range locks increases, leading to increased traversal time and CPU load, especially in scenarios with a large quantity of concurrent read-write operations.
Innovation Solution
A method that involves a first device obtaining a packet requesting a range lock, determining intersection of intervals with existing range locks without traversing all locks, and sending a packet to a second device to obtain the lock when no intersection is found, using a multi-level search structure to quickly identify neighboring points for efficient endpoint determination.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If a red-black tree structure is used to manage range locks, then the system can handle concurrent read-write operations, but the traversal time increases as the number of range locks increases
Solution Approach 1:
The patent segments the single red-black tree structure into multiple red-black trees based on lock types (shared locks and exclusive locks). This segmentation allows the system to traverse only the relevant tree structure when acquiring a specific type of lock, reducing the traversal scope and time while maintaining the ability to handle concurrent read-write operations.
2Reliability
If all obtained range locks are traversed to check for conflicts, then lock consistency is ensured, but CPU load increases
Solution Approach 1:
The patent applies local quality by making different parts of the lock management system have different properties. Specifically, shared locks and exclusive locks are managed in separate red-black trees with different traversal rules. When acquiring a lock, the system only traverses the appropriate tree structure and checks only relevant locks, reducing CPU load while ensuring consistency through targeted conflict detection.
3Reliability
If the red-black tree structure is traversed for each new range lock acquisition, then conflict detection is thorough, but the efficiency of obtaining range locks decreases
Solution Approach 1:
The patent performs preliminary action by organizing locks into separate red-black trees based on their types before conflict detection is needed. This pre-organization allows the system to quickly identify and traverse only the relevant tree structure when a lock acquisition request arrives, maintaining thorough conflict detection while significantly improving acquisition efficiency through reduced traversal scope.
Data Source
Figure 1~3
Figure 4~6
Figure 7~8
AI summary
This application discloses a method, an apparatus, and a system for obtaining a range lock, and a computer-readable storage medium, and relates to the field of computer technologies. The method includes: A first device obtains a first packet sent by a second device, where the first packet is for requesting to obtain a first range lock, the first packet includes a type and an interval that are of the first range lock, and the first range lock is used to lock data stored in a distributed manner; then, obtains a second range lock corresponding to the type of the first range lock, to determine whether the interval of the first range lock intersects an interval of the second range lock; and sends a second packet to the second device based on a case in which the interval of the first range lock does not intersect the interval of the second range lock, where the second packet indicates the second device to obtain the first range lock. In the method, after the packet for requesting the range lock is obtained, the range lock corresponding to the type is directly obtained, to determine whether the intervals intersect, and there is no need to traverse a fixed range lock in all obtained range locks, so that efficiency of obtaining the range lock is high.