IP Library Granted Patent US 12,204,953
Granted Patent B2
US 12,204,953 · App. 17/590,206 · Granted Jan 21, 2025

Database locking mechanism

Inventors: Peter Wang (Seattle, WA); Alexander Thiemann (San Francisco, CA); Adam Eagle (San Francisco, CA); Hongshan Zhou (San Francisco, CA); Ji Huang (Bothell, WA)
Assignee: STRIPE, INC.
G06F9/524G06F16/2343G06F16/2365
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,204,953
App. No.
17/590,206
Granted
Jan 21, 2025
Kind
B2
Abstract

A method for preventing race conditions in a database comprises: setting a first numerical entry and a second numerical entry in a database; receiving a first online transaction; responsive to determining a lock of the database is in progress due to a second received online transaction, suspending the first online transaction; removing the lock after the second received online transaction is completed; responsive to determining that the first entry is greater than zero, decrementing the first entry by an amount indicated in the first online transaction; responsive to determining the second entry is greater than zero, decrementing the second entry; processing the first transaction; and generating an online transaction record for the first transaction and storing the generated record in an online transaction database.

Claims (55)

1. A method for preventing race conditions in a database by at least one hardware processor, comprising:

setting a first numerical entry and a second numerical entry in a database;

receiving a first online transaction;

responsive to determining a lock of the database is in progress due to a second received online transaction, suspending the first online transaction;

removing the lock after the second received online transaction is completed;

responsive to determining that the first numerical entry is greater than zero:

decrementing the first numerical entry by an amount indicated in the first online transaction;

determining whether the second numerical entry is greater than zero;

responsive to determining that the second numerical entry is greater than zero, decrementing the second numerical entry;

processing the first online transaction;

generating an online transaction record for the first online transaction comprising (i) a first delta between the first numerical entry prior to completion of the first online transaction and the first numerical entry after the completion of the first online transaction, (ii) a second delta between the second numerical entry prior to the completion of the first online transaction and the second numerical entry after the completion of the first online transaction, and (iii) a reference to a third transaction corresponding to the first numerical entry and the second numerical entry, wherein the third transaction was completed prior to the first transaction; and

storing the generated online transaction record in an online transaction database.

2. The method of claim 1 , further comprising decrementing the second numerical entry in a same amount that the first numerical entry was decremented.

3. The method of claim 1 , wherein the first numerical entry is always equal to or greater than the second entry.

4. The method of claim 1 , wherein the first numerical entry represents a back-order quantity.

5. The method of claim 1 , wherein the first numerical entry represents a preorder quantity.

6. The method of claim 1 , wherein the first numerical entry is set to unlimited.

7. The method of claim 1 , further comprising before the removing the lock, updating the second numerical entry.

8. The method of claim 1 , wherein the online transaction record comprises numerical values including the first delta, the second delta, a transaction number for the first online transaction, and the reference.

9. The method of claim 1 , further comprising in response to determining the first numerical entry would turn negative if the first online transaction was accepted, rejecting the first online transaction.

10. A non-transitory computer-readable storage medium, the computer-readable storage medium including instructions that when executed by a computer, cause the computer to perform operations comprising:

setting a first numerical entry and a second numerical entry in a database;

receiving a first online transaction;

responsive to determining a lock of the database is in progress due to a second received online transaction, suspending the first online transaction;

removing the lock after the second received online transaction is completed;

responsive to determining that the first numerical entry is greater than zero:

decrementing the first numerical entry by an amount indicated in the first online transaction; and

determining whether the second numerical entry is greater than zero;

responsive to determining that the second numerical entry is greater than zero, decrementing the second numerical entry;

processing the first online transaction;

generating an online transaction record for the first online transaction comprising (i) a first delta between the first numerical entry prior to completion of the first online transaction and the first numerical entry after the completion of the first online transaction, (ii) a second delta between the second numerical entry prior to the completion of the first online transaction and the second numerical entry after the completion of the first online transaction, and (iii) a reference to a third transaction corresponding to the first numerical entry and the second numerical entry, wherein the third transaction was completed prior to the first transaction; and

storing the generated online transaction record in an online transaction database.

11. A database system, comprising:

one or more hardware processors; and

a memory storing instructions that, when executed by at least one processor among the processors, cause the system to perform operations comprising, at least:

setting an orderable entry and an in-stock entry in a database;

receiving a first online transaction;

responsive to determining a lock of the database is in progress due to a second received online transaction, suspending the first online transaction;

removing the lock after the second received online transaction is completed;

responsive to determining that a quantity of the orderable entry is greater than zero:

decrementing the quantity of the orderable entry by an amount indicated in the first online transaction; and

determining whether a quantity of the in-stock entry is greater than zero;

responsive to determining that the quantity of the in-stock entry is greater than zero, decrementing the quantity of the in-stock entry;

processing the first online transaction;

generating an online transaction record for the first online transaction comprising (i) a first delta between the orderable entry prior to completion of the first online transaction and the orderable entry after the completion of the first online transaction, (ii) a second delta between the in-stock entry prior to the completion of the first online transaction and the in-stock entry after the completion of the first online transaction, and (iii) a reference to a third transaction corresponding to the orderable entry and the in-stock entry, wherein the third transaction was completed prior to the first transaction; and

storing the generated online transaction record in an online transaction database.

12. The database system of claim 11 , wherein the operations further comprise decrementing the quantity of the in-stock entry in a same amount that the quantity of the order entry was decremented.

13. The database system of claim 11 , wherein the orderable entry is greater than the in-stock entry.

14. The database system of claim 11 , wherein the orderable entry represents a back order quantity.

15. The database system of claim 11 , wherein the orderable entry represents a preorder quantity.

16. The database system of claim 11 , wherein the orderable entry is set to unlimited.

17. The database system of claim 11 , wherein the operations further comprise generating a historical audit trail of inventory movement based on the decrementing quantity of the in-stock entry.

18. The database system of claim 11 , wherein the operations further comprise before the removing the lock, updating the in-stock entry.

19. The database system of claim 11 , wherein the operations further comprise in response to determining the quantity of the orderable entry would turn negative if the second online order was accepted, rejecting the second online order and removing the lock.

20. The database system of claim 11 , wherein the online transaction record comprises numerical values including the first delta, the second delta, a transaction number for the first online transaction, and the reference.

Assignments (2)
CHANGE OF NAME Recorded Jan 7, 2026
From: STRIPE, INC.
To: STRIPE, LLC
Reel/Frame 074264/0807 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 1, 2022
From: WANG, PETER; THIEMANN, ALEXANDER; EAGLE, ADAM; ZHOU, HONGSHAN; HUANG, JI
To: STRIPE, INC.
Reel/Frame 058846/0064 →
Continuity (2)
Continuation In Part 17489062 · Sep 29, 2021
Related Publication 20230098748A1 · Mar 30, 2023
References Cited (19)
US 9336549B2 · Argue et al. · 2016 [cited by applicant]
US 9805334B2 · Overhultz et al. · 2017 [cited by applicant]
US 10163140B2 · Robinson et al. · 2018 [cited by applicant]
US 10339542B2 · Cicchitto et al. · 2019 [cited by applicant]
US 11205213B2 · Turner et al. · 2021 [cited by applicant]
US 11222380B2 · Koch et al. · 2022 [cited by applicant]
US 20020069082A1 · Choe et al. · 2002 [cited by applicant]
US 20020128918A1 · Chao et al. · 2002 [cited by applicant]
US 20070124217A1 · Terry · 2007 [cited by examiner]
US 20110125592A1 · Mesaros · 2011 [cited by applicant]
US 20130013368A1 · Grant · 2013 [cited by applicant]
US 20150363880A1 · Droste et al. · 2015 [cited by applicant]
US 20220083943A1 · He et al. · 2022 [cited by applicant]
US 20220245119A1 · Timpe · 2022 [cited by examiner]
US 20220358570A1 · Agrawal et al. · 2022 [cited by applicant]
WO WO02086650A2 · 2002 [cited by applicant]
Frap et al: “Record locking”, Wikipedia, Nov. 3, 2020 (Nov. 3, 2020), pp. 1-3, XP055982905, Retrieved from the Internet: URL:https://en.wikipedia.org/w/index.php?title=Record_locking&oldid=986904480 [retrieved on Nov. 1… [cited by applicant]
International Preliminary Report on Patentability for PCT App. PCT/US2022/041569 dated Apr. 2, 2024 (8 pages). [cited by applicant]
International Search Report and Written Opinion on PCT App. PCT/US2022/041569 dated Nov. 28, 2022 (8 pages). [cited by applicant]