IP Library Granted Patent US 11,663,186
Granted Patent B2
US 11,663,186 · App. 17/177,686 · Granted May 30, 2023

Enhanced locking mechanism for B+ tree data structures

Inventors: Hardik Singh Negi (Palo Alto, CA); Wenguang Wang (Santa Clara, CA); Eric Knauft (Palo Alto, CA)
Assignee: VMware, Inc.
G06F16/2246G06F16/2343G06F16/24552G06F16/288
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,663,186
App. No.
17/177,686
Granted
May 30, 2023
Kind
B2
Abstract

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.

Claims (49)

1. A method for modifying a particular node of a B+ tree comprising a plurality of nodes placed in a plurality of levels, wherein a root node is placed in a highest level of the B+ tree, comprising:

receiving a request to modify the particular node placed in a level that is at least one level below the root node, each node of the plurality of nodes being associated with a modification number that indicates a number of times the node is modified;

traversing a path on the B+ tree from the root node toward the particular node until determining that the particular node is reached, the traversing comprising upon reaching a parent node on the path, acquiring a shared lock on both the parent node and a child node placed one level below a level of the parent node on the path; and

upon determining that the particular node is reached by determining that a last child node is the particular node:

storing a modification number associated with the particular node;

releasing the shared lock on the particular node;

attempting to acquire an exclusive lock on the particular node;

when determining that the exclusive lock on the particular node is acquired, comparing a current modification number associated with the particular node with the stored modification number; and

when the current modification number associated with the particular node is equal to the stored modification number (i) incrementing the current modification number associated with the particular node, and (ii) modifying the particular node as requested.

2. The method of claim 1 , wherein each node in the plurality of nodes is also associated with a cache address that indicates an address of a page containing the node:

wherein storing the modification number further comprises storing a cache address associated with the particular node along with the modification number; and

wherein acquiring the exclusive lock on the particular node further comprises acquiring the exclusive lock on the particular node if the modification number associated with the particular node is equal to the stored modification number and a current cache address associated with the particular node is the same as the stored cache address.

3. The method of claim 1 , wherein the last child node is determined to be the particular node based on an indicator associated with the last child node, the method further comprising:

determining that the parent node has to be modified as well based on the indicator;

storing a second modification number associated with the parent node;

releasing the shared lock on the parent node;

attempting to acquire an exclusive lock on the parent node;

when determining that the exclusive lock on the parent node is acquired, comparing a current modification number associated with the parent node with the stored second modification number; and

when the current modification number associated with the parent node is equal to the stored second modification number, (i) incrementing the current modification number associated with the parent node, and (ii) modifying the parent node.

4. The method of claim 3 , wherein the indicator associated with the particular node indicates that the particular node is a node shared between the B+ tree and a second B+ tree, the method further comprising:

performing a copy on write on the particular node by creating a second node that is a duplicate of the particular node; and

modifying the parent node such that the parent node is linked to the second node instead of the particular node.

5. The method of claim 4 , wherein modifying the particular node comprises modifying the second node.

6. The method of claim 1 , wherein the last child node is determined to be the particular node based on an indicator associated with the parent node that indicates the parent node is placed in a first level of the B+ tree.

7. The method of claim 1 , further comprising, when the current modification number associated with the particular node is not equal to the stored modification number:

forgoing acquiring the exclusive lock on the particular node;

incrementing a traversal counter that indicates how many times the path on the B+ is traversed; and

when the incremented traversal counter is less than a threshold, re-traversing the path on the B+ tree from the root node for a second time.

8. The method of claim 7 , wherein when the incremented traversal counter is equal to or greater than the threshold, traversing the path on the B+ tree from the root node toward the particular node until reaching the particular node, the traversing comprising upon reaching each parent node of the path, acquiring an exclusive lock on both the parent node and the child node placed one level below the level of the parent node on the path.

9. A non-transitory computer readable medium comprising instructions that, when executed by one or more processors of a computing system, cause the computing system to perform a method for modifying a particular node of a B+ tree comprising a plurality of nodes placed in a plurality of levels, wherein a root node is placed in a highest level of the B+ tree, the method comprising:

receiving a request to modify the particular node placed in a level that is at least one level below the root node, each node of the plurality of nodes being associated with a modification number that indicates a number of times the node is modified;

traversing a path on the B+ tree from the root node toward the particular node until determining that the particular node is reached, the traversing comprising upon reaching a parent node on the path, acquiring a shared lock on both the parent node and a child node placed one level below a level of the parent node on the path; and

upon determining that the particular node is reached by determining that a last child node is the particular node:

storing a modification number associated with the particular node;

releasing the shared lock on the particular node;

attempting to acquire an exclusive lock on the particular node;

when determining that the exclusive lock on the particular node is acquired, comparing a current modification number associated with the particular node with the stored modification number; and

when the current modification number associated with the particular node is equal to the stored modification number (i) incrementing the current modification number associated with the particular node, and (ii) modifying the particular node as requested.

10. A computer system, comprising:

a memory; and

a processor coupled to the memory, the processor being configured to:

receive a request to modify a particular node of a B+ tree comprising a plurality of nodes placed in a plurality of levels, wherein a root node is placed in a highest level of the B+ tree, the particular node placed in a level that is at least one level below the root node, each node of the plurality of nodes being associated with a modification number that indicates a number of times the node is modified;

traverse a path on the B+ tree from the root node toward the particular node until determining that the particular node is reached, the traversing comprising upon reaching a parent node on the path, acquiring a shared lock on both the parent node and a child node placed one level below a level of the parent node on the path; and

upon determining that the particular node is reached by determining that a last child node is the particular node:

store a modification number associated with the particular node;

release the shared lock on the particular node;

attempt to acquire an exclusive lock on the particular node;

when determining that the exclusive lock on the particular node is acquired, compare a current modification number associated with the particular node with the stored modification number; and

when the current modification number associated with the particular node is equal to the stored modification number, (i) increment the current modification number associated with the particular node, and (ii) modify the particular node as requested.

Assignments (2)
CHANGE OF NAME Recorded Apr 15, 2024
From: VMWARE, INC.
To: VMWARE LLC
Reel/Frame 067102/0395 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded May 13, 2021
From: NEGI, HARDIK SINGH; WANG, WENGUANG; KNAUFT, ERIC
To: VMWARE, INC.
Reel/Frame 056236/0737 →
Continuity (1)
Related Publication 20220261386A1 · Aug 18, 2022