# US 12,111,822 B2 · Database race condition prevention

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

- Number: US 12,111,822 B2
- Document ID: US12111822B2
- Status: Granted
- Kind: B2
- Application number: 17/489,062
- Filed: 2021-09-29
- Published: 2023-04-13
- Granted: 2024-10-08
- Earliest claimed: 2021-09-29
- Assignees: Stripe, Inc.
- Applicants: Stripe, Inc.
- Inventors: Peter Wang; Alexander Thiemann; Adam Eagle; Hongshan Zhou; Ji Huang
- Web page: https://patentgrep.com/patent/US12111822B2

## CPC

- G06F 16/2379: {Updates performed during online database operations; commit processing}
- G06F 9/466: {Transaction processing}
- G06F 16/2343: {Locking methods, e.g. distributed locking or locking implementation details}
- G06Q 10/087: Inventory or stock management, e.g. order filling, procurement or balancing against orders
- G06Q 10/08772: {Inventory counting methods}
- G06Q 20/023: {the neutral party being a clearing house}
- G06Q 20/12: specially adapted for electronic shopping systems
- G06Q 20/14: specially adapted for billing systems
- G06Q 20/389: {Keeping log of transactions for guaranteeing non-repudiation of a transaction}
- G06Q 20/405: {Establishing or using transaction specific rules}
- G06Q 30/0601: Electronic shopping [e-shopping]
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06Q: INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR

## 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

### Claim 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.

### Claim 2 (depends on 1)

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.

### Claim 3 (depends on 1)

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.

### Claim 4 (depends on 1)

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

### Claim 5 (depends on 1)

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

### Claim 6 (depends on 1)

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

### Claim 7 (depends on 1)

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

### Claim 8 (depends on 1)

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

### Claim 9 (depends on 1)

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.

### Claim 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.

### Claim 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.

### Claim 12 (depends on 11)

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.

### Claim 13 (depends on 11)

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

### Claim 14 (depends on 11)

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

### Claim 15 (depends on 11)

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

### Claim 16 (depends on 11)

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

### Claim 17 (depends on 11)

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.

### Claim 18 (depends on 11)

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

### Claim 19 (depends on 11)

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.

### Claim 20 (depends on 11)

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