IP Library Granted Patent US 11,520,753
Granted Patent B1
US 11,520,753 · App. 16/992,602 · Granted Dec 6, 2022

Time reservations for ensuring consistent reads in a distributed database without logging

Inventors: Wilson Cheng-Yi Hsieh (Syosset, NY); Eric Hugh Veach (Bellevue, WA); Michael James Boyer Epstein (Brooklyn, NY); Alexander Lloyd (New York, NY)
Assignee: Google LLC
G06F16/20G06F16/2322G06F16/2343G06F16/27G06F16/273G06F16/951H04L69/04
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 11,520,753
App. No.
16/992,602
Granted
Dec 6, 2022
Kind
B1
Abstract

The subject matter described herein provides techniques to ensure that queries of a distributed database observe a consistent read of the database without locking or logging. In this regard, next-write timestamps uniquely identify a set of write transactions whose updates can be observed by reads. By publishing the next-write timestamps from within an extendable time lease and tracking a “safe timestamp,” the database queries can be executed without logging read operations or blocking future write transactions, and clients issuing the queries at the “safe timestamp” observe a consistent view of the database as it exists on or before that timestamp. Aspects of this disclosure also provide for extensions, done cheaply and without the need for logging, to the range of timestamps at which read transactions can be executed.

Claims (64)

1. A method, comprising:

determining a lead replica from amongst a plurality of replicas in a database;

reserving a time lease in which the lead replica serves as leader;

receiving a number of transactions, the transactions including read transactions and write transactions;

maintaining a first timestamp indicating a next time data is allowed to be committed to the database, the first timestamp being selected from within the time lease;

and

if a given transaction is a write transaction:

selecting a second timestamp from within the time lease that is greater than the first timestamp;

associating the second timestamp with the given write transaction;

increasing the first timestamp to be greater than the second timestamp;

executing the given write transaction.

2. The method of claim 1 , wherein each received write transaction is assigned a sequence number.

3. The method of claim 2 , further comprising applying the write transactions to the database in order of the assigned sequence numbers.

4. The method of claim 3 , further comprising associating the first timestamp with the sequence number assigned to the given write transaction.

5. The method of claim 4 , further comprising:

tracking a safe timestamp less than the first timestamp; and

advancing the safe timestamp to a value greater than the second timestamp associated with the given write transaction and less than any first timestamp associated with the sequence number assigned to the given write transaction.

6. The method of claim 1 , further comprising tracking a safe timestamp less than the first timestamp, wherein if a given read transaction includes a read timestamp before the first timestamp:

waiting a period of time for the safe timestamp to meet or exceed the read timestamp; and

executing the given read transaction after the period of time, the given read transaction returning data derived from the write transactions whose timestamps are less than or equal to the read timestamp.

7. The method of claim 1 , further comprising tracking a safe timestamp less than the first timestamp, wherein if a given read transaction includes a read timestamp after the first timestamp:

selecting a first timestamp from within the time lease;

publishing the first timestamp;

waiting a period of time for the safe timestamp to meet or exceed the read timestamp; and

executing the given read transaction after the period of time, the given read transaction returning data derived from the write transactions whose timestamps are less than or equal to the read timestamp.

8. The method of claim 1 , wherein the first timestamp is a next-write timestamp.

9. The method of claim 1 , wherein the second timestamp is a commit timestamp.

10. A method, comprising:

reserving, at a leader replica, a time lease in which the leader replica serves as leader with respect to a plurality of non-leader replicas in a database;

maintaining a first timestamp indicating a next time data is allowed to be committed to the database, the first timestamp being selected from within the time lease;

publishing the first timestamp to the plurality of non-leader replicas;

maintaining, at one or more of the plurality of replicas, a second timestamp less than the first timestamp;

using the published first timestamp to increase the second timestamp.

11. The method of claim 10 , wherein the first timestamp is a next-write timestamp.

12. The method of claim 10 , wherein the second timestamp is a safe timestamp.

13. A system, comprising:

a plurality of replicas in a database, including a lead replica and one or more non-leader replicas;

one or more processors in communication with the plurality of replicas, the one or more processors being configured to:

reserve a time lease in which the lead replica serves as leader;

receive a number of transactions, the transactions including read transactions and write transactions;

maintain a first timestamp indicating a next time data is allowed to be committed to the database, the first timestamp being selected from within the time lease; and

if a given transaction is a write transaction, the one or more processors are configured to:

select a second timestamp from within the time lease that is greater than the first timestamp;

associate the second timestamp with the given write transaction;

increase the first timestamp to be greater than the second timestamp;

execute the given write transaction.

14. The system of claim 13 , wherein: each received write transaction is assigned a sequence number; and

the one or more processors are further configured to:

apply the write transactions to the database in order of the assigned sequence numbers; and

associate the first timestamp with a sequence number assigned to the given write transaction.

15. The system of claim 14 , wherein the one or more processors are further configured to track a safe timestamp less than or equal to the first timestamp, and advance the safe timestamp a value greater than the second timestamp associated with the given write transaction and less than any next-write timestamp associated with the given write transaction's sequence number.

16. The system of claim 13 , wherein if a given read transaction includes a read timestamp before the first timestamp wherein, the one or more processors are further configured to:

track a safe timestamp less than or equal to the first timestamp;

wait a period of time for the safe timestamp to meet or exceed the read timestamp; and

execute the given read transaction after the period of time, the given read transaction returning data derived from the write transactions whose timestamps are less than or equal to the read timestamp.

17. The system of claim 13 , wherein if a given read transaction includes a read timestamp after the first timestamp, the processor is further configured to:

track a safe timestamp less than or equal to the first timestamp;

select a first timestamp from within the time lease;

publish the first timestamp;

wait a period of time for the safe timestamp to meet or exceed the read timestamp; and

execute the given read transaction after the period of time, the given read transaction returning data derived from the write transactions whose timestamps are less than or equal to the read timestamp.

18. The system of claim 13 , wherein the first timestamp is a next-write timestamp.

19. The system of claim 13 , wherein the second timestamp is a commit timestamp.

20. The system of claim 13 , wherein the one or more processors are further configured to extend the time lease in which the lead replica serves as leader.

Assignments (2)
CHANGE OF NAME Recorded Aug 18, 2020
From: GOOGLE INC.
To: GOOGLE LLC
Reel/Frame 053530/0975 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 17, 2020
From: HSIEH, WILSON CHENG-YI; VEACH, ERIC HUGH; EPSTEIN, MICHAEL JAMES BOYER; LLOYD, ALEXANDER
To: GOOGLE INC.
Reel/Frame 053512/0465 →
Continuity (3)
Continuation 15631646 · Jun 23, 2017
Division 13661913 · Oct 26, 2012
Provisional Application 61675556 · Jul 25, 2012
Cited By (1)
US 12,380,129