IP Library Granted Patent US 12,111,822
Granted Patent B2
US 12,111,822 · App. 17/489,062 · Granted Oct 8, 2024

Database race condition prevention

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.
G06F16/2379G06F16/2343G06Q10/087
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,111,822
App. No.
17/489,062
Granted
Oct 8, 2024
Kind
B2
Abstract

A method comprises: setting an first entry and an second entry in a database; receiving a first online transaction; responsive to determining a lock of the database is in progress, suspending the first online transaction; updating the first entry; removing the lock; receiving a second online transaction; responsive to determining that the first field is greater than zero, decrementing the first field by an amount indicated in the second online transaction; and responsive to determining the second entry is greater than zero, decrementing the second entry.

Claims (52)

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

setting an orderable entry and an in-stock entry for a product in the database;

receiving an online transaction for the product;

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

updating a quantity of the orderable entry while the lock of the database is in progress;

removing the lock; and

responsive to determining that the lock is removed:

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

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

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

responsive to determining that the quantity of the orderable entry is greater than zero and that the quantity of the in-stock entry is greater than zero, decrementing the quantity of the in-stock entry by the amount indicated in the online transaction.

2. The method of claim 1 , further comprising decrementing the quantity of the in-stock entry in a same amount that the quantity of the orderable entry was decremented.

3. The method of claim 1 , wherein the quantity of the orderable entry is always equal to or greater than the quantity of the in-stock entry.

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

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

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

7. The method of claim 1 , further comprising before the removing the lock, updating the in-stock entry.

8. The method of claim 1 , further comprising generating a historical audit trail of inventory movement based on the decrementing the in-stock entry.

9. The method of claim 1 , further comprising in response to determining the quantity of the orderable entry comprises a value smaller than a quantity of a second online transaction, rejecting the second 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 an orderable entry for a product and an in-stock entry for the product in a database;

receiving an online order for the product;

responsive to determining a lock of the database is in progress, suspending the online order;

updating a quantity of the orderable entry while the lock of the database is in progress;

removing the lock; and

responsive to determining that the lock is removed:

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

decrementing the quantity of the orderable entry by an amount indicated in the online order, and

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

responsive to determining that the quantity of the orderable entry is greater than zero and that the quantity of the in-stock entry is greater than zero, decrementing the quantity of the in-stock entry by the amount indicated in the online order.

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 for a product and an in-stock entry for the product in a database;

receiving an online order for the product;

responsive to determining a lock of the database is in progress, suspending the online order;

updating a quantity of the orderable entry while the lock of the database is in progress;

removing the lock; and

responsive to determining that the lock is removed:

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

decrementing the quantity of the orderable entry by an amount indicated in the online order, and

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

responsive to determining that the quantity of the orderable entry is greater than zero and that the quantity of the in-stock entry is greater than zero, decrementing the quantity of the in-stock entry by the amount indicated in the online order.

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 orderable entry was decremented.

13. The database system of claim 11 , wherein the quantity of the orderable entry is greater than the quantity of 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 the 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 quantity of 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 comprises a value smaller than a quantity of a second online order, rejecting the second online order.

20. The database system of claim 11 , wherein the operations further comprise in response to removing the lock, processing the online order.

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 Jun 1, 2022
From: WANG, PETER; THIEMANN, ALEXANDER; EAGLE, ADAM; ZHOU, HONGSHAN; HUANG, JI
To: STRIPE, INC.
Reel/Frame 060065/0207 →