# US 2022/0276991 A1 · Database lock management with cache-optimized hash table

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0276991 A1
- Document ID: US20220276991A1
- Status: Published application
- Kind: A1
- Application number: 17/746,326
- Filed: 2022-05-17
- Published: 2022-09-01
- Earliest claimed: 2018-04-03
- Assignees: Sap SE
- Applicants: Sap SE
- Inventors: Chang Gyoo Park
- Web page: https://patentgrep.com/patent/US20220276991A1

## CPC

- G06F 16/2343: {Locking methods, e.g. distributed locking or locking implementation details}
- G06F 16/2255: {Hash tables}
- G06F 16/2272: {Management thereof}
- G06F 16/24552: {Database cache management}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Lock table management is provided for a lock manager of a database system, in which lock management is provided in a manner that is fast and efficient, and that conserves processing, memory, and other computational resources. For example, the lock table management can use a hashmap in which keys and values are stored in separate arrays, which can be loaded into separate CPU cache lines.

## Claims

### Claim 1

A computer program product, the computer program product being tangibly embodied on a non-transitory computer-readable storage medium and comprising instructions that, when executed, are configured to cause at least one computing device to:
receive a lock request for a database element used in a database transaction, specified with respect to a lock table configured to selectively restrict database;
determine a lock table entry of the lock table for the lock request, the lock table entry stored in a memory and having an array index value, and including a lock key stored in a key array, and further including at least one lock data value stored in a data array;
load a portion of the key array from the memory to a first cache line of a cache memory, including the lock key associated with the array index value, and one or more additional lock keys that are contiguous with the lock key associated with the array index value; and
execute the lock request by calling the first cache line of the cache memory, identifying an array location in the key array associated with the lock key, and using the array location.

### Claim 2 (depends on 1)

The computer program product of claim 1, wherein the instructions, when executed, are further configured to cause the at least one computing device to:
determine a first lock table entry having a first array index value, including hashing the lock key using a hashing function to determine the first array index value;
determine from reading the first cache line that the lock key is not stored at the first array index value; and
determine that the lock key is stored at the array index value within the first cache line and within the portion of the key array.

### Claim 3 (depends on 2)

The computer program product of claim 2, wherein determining that the lock key is stored at the array index value comprises using first key metadata stored with the lock key that identifies the array index value.

### Claim 4 (depends on 1)

The computer program product of claim 1, wherein the lock key is stored within the memory, and loaded to the first cache line, with key metadata that includes a hash value of the lock key.

### Claim 5 (depends on 1)

The computer program product of claim 1, wherein the lock key is stored within the memory, and loaded to the first cache line, with key metadata that includes a lock flag indicating whether the database element is locked.

### Claim 6 (depends on 1)

The computer program product of claim 1, wherein the portion of the key array includes the lock key and at least a second lock key of a second lock table entry having a second array index value.

### Claim 7 (depends on 1)

The computer program product of claim 1, wherein the key array is stored in a first column of the lock table, and the data array is stored as a second column of the lock table.

### Claim 8 (depends on 1)

The computer program product of claim 1, wherein the instructions, when executed, are further configured to cause the at least one computing device to:
determine that a size of the lock table has exceeded a load factor characterizing a proportion of the lock table that is filled; and
resize the lock table.

### Claim 9 (depends on 8)

The computer program product of claim 8, wherein the instructions, when executed, are further configured to cause the at least one computing device to resize the lock table including causing the at least one computing device to:
allocate a new key array and a new data array having a new array size;
read or erase existing lock table entries from the key array and data array when requested;
write new lock table entries to the new key array and the new data array; and
delete the key array and data array when empty.

### Claim 10 (depends on 1)

The computer program product of claim 1, wherein the lock request includes at least one of: a request to change a lock status of the database element, a request to erase the lock data value, a request to erase the lock table entry, a request to insert a new lock table entry, and a request to insert a new lock data value.

### Claim 11

A computer-implemented method, comprising:
receiving a lock request for a database element used in a database transaction, specified with respect to a lock table configured to selectively restrict database;
determining a lock table entry of the lock table for the lock request, the lock table entry stored in a memory and having an array index value, and including a lock key stored in a key array, and further including at least one lock data value stored in a data array;
loading a portion of the key array from the memory to a first cache line of a cache memory, including the lock key associated with the array index value, and one or more additional lock keys that are contiguous with the lock key associated with the array index value; and
executing the lock request by calling the first cache line of the cache memory, identifying an array location in the key array associated with the lock key, and using the array location.

### Claim 12 (depends on 11)

The method of claim 11, wherein the lock key is stored within the memory, and loaded to the first cache line, with key metadata that includes a hash value of the lock key.

### Claim 13 (depends on 11)

The method of claim 11, wherein the portion of the key array includes the lock key and at least a second lock key of a second lock table entry having a second array index value.

### Claim 14 (depends on 11)

The method of claim 11, wherein the key array is stored in a first column of the lock table, and the data array is stored as a second column of the lock table.

### Claim 15 (depends on 11)

The method of claim 11, further comprising:
determining that a size of the lock table has exceeded a load factor characterizing a proportion of the lock table that is filled; and
resizing the lock table.

### Claim 16 (depends on 15)

The method of claim 15, wherein resizing the lock table comprises:
allocating a new key array and a new data array having a new array size;
reading or erasing existing lock table entries from the key array and data array when requested;
writing new lock table entries to the new key array and the new data array; and
deleting the key array and data array when empty.

### Claim 17

A computer program product, the computer program product being tangibly embodied on a non-transitory computer-readable storage medium and comprising instructions that, when executed, are configured to cause at least one computing device to:
receive a lock key for a database element to be stored within a lock table configured to selectively restrict database access to maintain database consistency;
receive at least one lock data value corresponding to the lock key;
determine a lock table entry of the lock table, the lock table entry stored in a memory and having an array index value, a key array stored in a first column of the lock table, and a data array stored in a second column of the lock table;
store the lock key within the key array at the array index value;
store the at least one lock data value within the data array at the array index value receive a request for the lock key;
load a portion of the key array from a memory in which the lock table is stored to a cache line of a cache memory, the portion of the key array including the lock key and one or more additional lock keys that are contiguous with the lock key in the key array; and
read the lock key from the cache line.

### Claim 18 (depends on 17)

The computer program product of claim 17, wherein the lock key is stored within the memory, and loaded to the cache line, with key metadata that includes a hash value of the lock key.

### Claim 19 (depends on 17)

The computer program product of claim 17, wherein the lock key is stored within the memory, and loaded to the cache line, with key metadata that includes a lock flag indicating whether the database element is locked.

### Claim 20 (depends on 17)

The computer program product of claim 17, wherein the key array is stored in a first column of the lock table, and the data array is stored as a second column of the lock table.
