IP Library › Granted Patent US 12,360,981
Granted Patent B2
US 12,360,981 · App. 17/936,339 · Granted Jul 15, 2025

Record-level locks with constant space complexity

Inventor: Himanshu Jindal (Mountlake Terrace, WA)
Assignee: Amazon Technologies, Inc.
G06F16/2343G06F16/2255G06F16/2365G06F16/256
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 12,360,981
App. No.
17/936,339
Granted
Jul 15, 2025
Kind
B2
Abstract

Systems and methods for implementing record locking for transactions using a probabilistic data structure are described. This probabilistic structure enables adding of data records without growth of the data structure. The data structure includes a hash table for each of multiple hash functions, where entries in the respective hash tables store a transaction time and locking state. To lock a record, each hash function is applied to a record key to provide an index into a respective hash table and a minimum of the values stored in the hash tables is retrieved. If the retrieved value is less than a transaction time for a transaction attempting to lock the record, locking is permitted and the transaction time is recorded to each of the hash tables. To commit the transaction, the probabilistic data structure is atomically updated as part of the commit operation.

Claims (48)

1. A system, comprising:

at least one processor and a memory storing program instructions that, when executed by the at least one processor, cause the at least one processor to implement a transaction processor configured to:

allocate a lock of a record of a database for a transaction, wherein to allocate the lock the transaction processor is configured to:

identify a last commit time for the record in view of a commit time stored in an entry of a count-min sketch (CMS) of a lock structure for the record, wherein the CMS comprises a plurality of entries, including the entry, respectively storing lock state values and commit times; and

update the CMS to lock the record responsive to determining that the last commit time is earlier than a transaction time for the transaction, wherein to update the CMS the transaction processor is configured to update an entry of the plurality of entries of the CMS to indicate a locked state;

atomically commit the transaction and the CMS prior to releasing the lock of the record for the transaction; and

release the lock of the record for the transaction subsequent to atomically committing the transaction and the CMS, wherein to release the lock the transaction processor is configured to update the entry to indicate an unlocked state with a commit time determined by completion of the atomic committing.

2. The system of claim 1 , wherein the database comprises a plurality of records including the record, wherein a size of the lock structure for the database is independent of a number of the plurality of records of the database, and wherein the transaction processor is further configured to insert one or more records into the database without modifying the lock structure.

3. The system of claim 1 , wherein to access the lock structure the transaction processor is configured to:

apply individual ones of a plurality of hash functions of the CMS to a key of the record to access respective entries, of the plurality of entries, of respective hash tables for the respective hash functions; and

select a minimum commit time of respective commit times stored in the respective entries, the selected minimum commit time corresponding to the commit time of a selected entry.

4. The system of claim 1 , wherein to update the CMS the transaction processor is configured to write the entry with a maximum value of the commit time stored in the entry and the commit time determined by completion of the atomic committing.

5. A computer-implemented method, comprising:

allocating a lock of a record of a database for a transaction, comprising:

identifying a last commit time for the record in view of a commit time stored in an entry of a count-min sketch (CMS) of a lock structure for the record, wherein the CMS comprises a plurality of entries, including the entry, respectively storing lock state values;

updating the CMS to lock the record responsive to determining that a last commit time is earlier than a transaction time for the transaction, wherein updating the CMS comprises updating an entry of the plurality of entries of the CMS to indicate a locked state; and

atomically committing the transaction and the updated CMS.

6. The computer-implemented method of claim 5 , wherein the database comprises a plurality of records including the record, and wherein a size of the lock structure for the database is independent of a number of the plurality of records of the database.

7. The computer-implemented method of claim 5 , wherein accessing the lock structure comprises:

applying individual ones of a plurality of hash functions of the CMS to a key of the record to access respective entries, of the plurality of entries, of respective hash tables for the respective hash functions; and

selecting a minimum commit time of respective commit times stored in the respective entries to determine the last commit time, the selected minimum commit time corresponding to a respective commit time of a selected entry.

8. The computer-implemented method of claim 5 , wherein updating the CMS further comprises writing the entry with an identifier of the transaction.

9. The computer-implemented method of claim 5 , further comprising allocating another lock of another record of the database for another transaction, comprising:

accessing the lock structure to identify another last commit time for the other record; and

returning an allocation failure for the other transaction responsive to determining that the other last commit time is not earlier than another transaction time for the other transaction.

10. The computer-implemented method of claim 5 , further comprising releasing the lock of the record for the transaction, the releasing comprising:

updating the entry to indicate an unlocked state; and

writing the entry with a maximum value of the commit time stored in the entry and a commit time determined by completion of the atomic committing.

11. The computer-implemented method of claim 10 , further comprising atomically committing the transaction and the updated CMS prior to releasing the lock of the record for the transaction.

12. The computer-implemented method of claim 5 , further comprising inserting one or more records into the database without modifying the lock structure.

13. One or more non-transitory computer-accessible storage media storing program instructions that when executed on or across one or more computing devices cause the one or more computing devices to perform:

allocating a lock of a record of a data store for a transaction, comprising:

identifying a last commit time for the record in view of a commit time stored in an entry of a count-min sketch (CMS) of a lock structure for the record, wherein the CMS comprises a plurality of entries, including the entry, respectively storing lock state values;

updating the CMS to lock the record responsive to determining that the last commit time is earlier than a transaction time for the transaction, wherein updating the CMS comprises updating an entry of the plurality of entries of the CMS to indicate a locked state; and

atomically committing the transaction and the updated CMS.

14. The one or more non-transitory computer-accessible storage media of claim 13 , wherein the data store comprises a plurality of records including the record, and wherein a size of the lock structure for the data store is independent of a number of the plurality of records of the data store.

15. The one or more non-transitory computer-accessible storage media of claim 13 , wherein accessing the lock structure comprises:

applying individual ones of a plurality of hash functions of the CMS to a key of the record to access respective entries, of the plurality of entries, of respective hash tables for the respective hash functions; and

selecting a minimum transaction time of respective transaction times stored in the respective entries, the selected minimum transaction time corresponding to the last commit time.

16. The one or more non-transitory computer-accessible storage media of claim 13 , wherein updating the CMS further comprises writing the entry with an identifier of the transaction.

17. The one or more non-transitory computer-accessible storage media of claim 13 , comprising additional program instructions that when executed on or across the one or more computing devices cause the one or more computing devices to perform allocating another lock of another record of the data store for another transaction, comprising:

accessing the lock structure to identify another last commit time for the other record; and

aborting the other transaction responsive to determining that the last commit time is not earlier than a transaction time for the transaction.

18. The one or more non-transitory computer-accessible storage media of claim 13 , wherein the program instructions that when executed on or across the one or more computing devices cause the one or more computing devices to further perform releasing the lock of the record for the transaction, comprising:

updating the entry to indicate an unlocked state; and

writing the entry with a maximum value of the commit time stored in the entry and the commit time determined by completion of the atomic committing.

19. The one or more non-transitory computer-accessible storage media of claim 18 , comprising additional program instructions that when executed on or across the one or more computing devices cause the one or more computing devices to perform atomically committing the transaction and the updated CMS prior to releasing the lock of the record for the transaction.

20. The one or more non-transitory computer-accessible storage media of claim 13 , comprising additional program instructions that when executed on or across the one or more computing devices cause the one or more computing devices to perform inserting one or more records into the data store without modifying the lock structure.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 29, 2022
From: JINDAL, HIMANSHU
To: AMAZON TECHNOLOGIES, INC.
Reel/Frame 061252/0971 →
Continuity (1)
Related Publication 20240111751A1 · Apr 4, 2024
References Cited (18)
US 10409864B2 · Schreter · 2019 [cited by examiner]
US 10608992B2 · Jain et al. · 2020 [cited by applicant]
US 10761946B2 · Bensberg · 2020 [cited by examiner]
US 10769126B1 · Hagerup · 2020 [cited by examiner]
US 11106653B2 · Thomsen · 2021 [cited by examiner]
US 20090183159A1 · Michael · 2009 [cited by examiner]
US 20090300022A1 · Little · 2009 [cited by examiner]
US 20110302143A1 · Lomet · 2011 [cited by examiner]
US 20160147906A1 · Schreter · 2016 [cited by examiner]
US 20170017435A1 · Peeters · 2017 [cited by examiner]
US 20170250953A1 · Jain · 2017 [cited by examiner]
US 20190340275A1 · Thomsen · 2019 [cited by examiner]
US 20210334257A1 · Bensberg · 2021 [cited by examiner]
US 20220413952A1 · Shu · 2022 [cited by examiner]
International Search Report and Written Opinion mailed Jan. 17, 2024 in PCT/US2023/074365, Amazon Technologies, Inc., pp. 1-10. [cited by applicant]
Han, Hyuck, et al., “Scalable Serializable Snapshot Isolation for Multicore Systems”, 2014 IEEE 30th International Conference on Data Engineering, Mar. 31, 2014,, pp. 700-711, IEEE. [cited by applicant]
Cormode, Graham, et al., “An improved data stream summary: the count-min sketch and its applications”, Journal of Algorithms, Apr. 1, 2005, pp. 58-75. [cited by applicant]
Cormode, Graham, “Count-Min Sketch,” Retrieved from the Internet: URL:http://dimacs.rutgers.edu/-graham/pubs/papers/cmencyc.pdf [retrieved on Dec. 1, 2023], 5 pages. [cited by applicant]