Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
SYSTEM AND METHOD FOR TRANSACTION CONTINUITY ACROSS FAILURES IN A SCALE-OUT DATABASE
Document Type and Number:
WIPO Patent Application WO/2022/081397
Kind Code:
A1
Abstract:
A shared-nothing database system is provided in which the rows of each table are assigned to "slices", and multiple copies ("duplicas") of each slice are stored across the persistent storage of multiple nodes. Requests to read data from a particular row of the table may be handled by any node that stores a duplica of the slice to which the row is assigned. For each slice, a single duplica of the slice is designated as the "primary duplica". All DML operations are performed by the node that has the primary duplica of the slice to which the target row is assigned. The changes are then propagated other duplicas ("secondary duplicas") of the same slice.

Inventors:
MYLAVARAPU AJIT (US)
KRISHNASWAMY VASUDHA (US)
PENDSE SUKHADA (US)
KOLAHI SOLMAZ (US)
KUMAR ANKITA (US)
SWART GARRET F (US)
LAHIRI TIRTHANKAR (US)
LOAIZA JUAN R (US)
Application Number:
PCT/US2021/053824
Publication Date:
April 21, 2022
Filing Date:
October 06, 2021
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
ORACLE INT CORP (US)
International Classes:
G06F16/27; G06F16/23; G06F16/2455
Foreign References:
EP0567999A21993-11-03
Other References:
BEECHER VIRGINIA: "Oracle Database Using Oracle Sharding 18c", 27 July 2019 (2019-07-27), pages 1 - 230, XP055878050, Retrieved from the Internet [retrieved on 20220112]
BHATIYA RAJESH ET AL: "Oracle Database: Database Administrator's Guide", 1 May 2020 (2020-05-01), pages 1 - 2158, XP055901513, Retrieved from the Internet [retrieved on 20220315]
CHOUDHURY TANMAY: "Oracle Database SQLJ Developer's Guide Release 19c", 1 January 2019 (2019-01-01), pages 1 - 476, XP055901953, Retrieved from the Internet [retrieved on 20220316]
B E ANONYMOUS: "Oracle Active Data Guard Real-Time Data Protection and Availability", 1 October 2015 (2015-10-01), XP055435626, Retrieved from the Internet [retrieved on 20171215]
ANONYMOUS: "Database Administrator's Guide: Distributed Transactions Concepts", 19 September 2020 (2020-09-19), pages 1 - 18, XP055901510, Retrieved from the Internet [retrieved on 20220315]
ANONYMOUS: "Understanding Transaction Processing", 27 August 2016 (2016-08-27), pages 1 - 6, XP055901949, Retrieved from the Internet [retrieved on 20220316]
DIEGO ONGAROJOHN OUSTERHOUT: "In Search of an Understandable Consensus Algorithm", STANDFORD UNIVERSITY
Attorney, Agent or Firm:
HICKMAN, Brian D. et al. (US)
Download PDF:
Claims:
CLAIMS

What is claimed is:

1. A method comprising: assigning rows of a table to a plurality of slices; wherein each row of the table is assigned to a single slice of the plurality of slices; for each slice of the plurality of slices, storing a plurality of duplicas; wherein each duplica of each slice contains rows of the table that belong to the slice; wherein, for each slice of the plurality of slices, storing the plurality of duplicas includes: storing a primary duplica in one persistent storage of a plurality of persistent storages; and storing one or more secondary duplicas in one or more persistent storages of the plurality of persistent storages; wherein each persistent storage of the plurality of persistent storages is local to and directly accessible only by a single engine instance of a plurality of engine instances; wherein each engine instance of the plurality of engine instances includes logic for accessing rows stored in the table; wherein the plurality of persistent storages includes a first persistent storage and a second persistent storage; wherein the first persistent storage stores the primary duplica for a particular slice that includes data for a particular row of the table; wherein the second persistent storage stores a particular secondary duplica for the particular slice; receiving a request to perform a transaction that affects data in the particular row of the table; initiating execution of the transaction at a first engine instance that is local to the first persistent storage; in response to the first engine instance ceasing to function prior to committing the transaction: establishing the particular secondary duplica on the second persistent storage as a new primary duplica for the particular slice; and causing the transaction to be resumed and committed by a second engine instance that is local to the second persistent storage.

2. The method of Claim 1 wherein:

-78- the transaction is a multi-statement transaction; the request to perform the transaction includes a series of statement- level requests; and each statement- level request is a request to perform a corresponding statement of the multistatement transaction.

3. The method of Claim 1 wherein: the particular secondary duplica is one of a plurality of secondary duplicas of the particular slice; and establishing the particular secondary duplica as the new primary duplica is performed based on the particular secondary duplica having more transaction log records for the transaction than any other of the plurality of secondary duplicas of the particular slice.

4. The method of Claim 3 further comprising, prior to the second engine instance resuming the transaction, transmitting to each secondary duplica, of the other of the plurality of secondary duplicas, any transaction log records that are missing at the secondary duplica.

5. The method of Claim 1 further comprising: while the first engine instance is executing the transaction causing a particular change made to data in the primary duplica to be propagated to the particular secondary duplica; wherein causing the transaction to be resumed by the second engine instance is performed without the second engine instance repeating execution of the particular change.

6. The method of Claim 5 wherein: the request to perform the transaction is received from a client; the method further comprises: after initiating propagation of the particular change to the particular secondary duplica, the first engine instance communicates to the client that the particular change was successfully executed; the client stores transaction status data that indicates that the particular change was successfully executed; causing the transaction to be resumed by the second engine instance includes the client sending to the second engine instance requests to only perform portions of the transaction that the first engine instance did not report as successfully executed.

7. The method of Claim 5 wherein: the request to perform the transaction is received from a client;

-79- the method further comprises: after initiating propagation of the particular change to the secondary duplica, the first engine instance communicates to the client that the particular change was successfully executed; the client stores transaction status data that indicates that the particular change was successfully executed; after the first engine instance ceases to function, the client sends the transaction status data to the second engine instance; and based on the transaction status data, the second engine instance does not repeat the particular change.

8. The method of Claim 7 wherein the transaction status data sent from the client to the second engine instance identifies a highest statement number that was confirmed-executed by the first engine instance.

9. The method of Claim 8 wherein causing the particular change to be propagated to the particular secondary duplica includes sending the particular change to a Network Interface Card (NIC) that is local to the first engine instance and, in response to the NIC successfully putting a message containing the change on transmission media, communicating to the client that the particular change was propagated to the particular secondary duplica without waiting for acknowledgement that the particular change was successfully propagated to the particular secondary duplica.

10. The method of Claim 9 further comprising, prior to the second engine instance resuming the transaction: determining whether the particular secondary duplica has all log records of the transaction up to and including log records for the highest statement number that was confirmed-executed by the first engine instance; and if the particular secondary duplica does not have all log records of the transaction up to and including log records for the highest statement number that was confirmed-executed by the first engine instance, then prior to the second engine instance resuming the transaction, storing in the particular secondary duplica any missing log records of the transaction up to and including log records for the highest statement number that was confirmed-executed by the first engine instance.

-80-

11. The method of Claim 9 wherein the NIC is connected to a host that is executing the second engine instance by at least two distinct networks.

12. A method for resuming a transaction, comprising: using a first engine instance to coordinate execution of the transaction; wherein the transaction involves making updates at a plurality of participants; after all statements in the transaction have been executed, the first engine instance sending, directly or indirectly, prepare request messages to each participant of a plurality participants in the transaction; upon receiving prepare acknowledgement messages, directly or indirectly, from each participant of the plurality of participants, the first engine instance selecting a candidate commit time; initiating transmission of the candidate commit time to one or more backup coordinators; wherein the one or more backup coordinators include a second engine instance; in response to the first engine instance failing after selecting a candidate commit time and before the second engine instance has received the candidate commit time, establishing the second engine instance as a new transaction coordinator for the transaction; the second engine instance resuming the transaction by sending, directly or indirectly, prepare messages to each participant of the plurality of participants; upon receiving prepare acknowledgement messages, directly or indirectly from each participant of the plurality of participants, the second engine instance selecting a second candidate commit time; and the second engine instance changing status of the transaction to committed, and storing the second candidate commit time as commit time of the transaction.

13. The method of Claim 12 wherein: the prepare acknowledgement messages received by the second engine instance include prepare times; the prepare times includes a highest prepare time; the second candidate commit time is selected to be higher than the greater of: the highest prepare time; and a current time on a logical clock used by the second engine instance.

14. The method of Claim 13 further comprising:

-81- the first engine instance reporting to a client that the transaction is committed before receiving confirmation that the second engine instance received the candidate commit time; the second engine instance establishes a blockout range for the transaction between the highest prepare time and the second candidate commit time; and raising an error when a read operation that has a snapshot time within the blockout range attempts to read any data item touched by the transaction.

15. A method comprising: establishing a lane between a client and a host, wherein the lane is a pipe through which the client may submit database statements to the host to cause the host to perform operations that target one or more rows in a database; determining that the lane is set to auto-commit; in response the lane being set to auto-commit, the host treating each statement received through the lane as a single-statement transaction; and after the host receives confirmation that the operations in a statement received through the lane have been successfully completed, the host automatically initiating a commit protocol without receiving any explicit commit command.

16. The method of Claim 15 wherein: the host is a first host of a plurality of hosts; a second client submitted commands for a second transaction to the first host through a second lane; the second transaction fails over to a second host of the plurality of hosts; and in response to the second transaction failing over to the second host: causing the second lane to be established between the second client and the second host; and the second client using the second lane to submit commands to the second host to resume the second transaction at the second host.

17. One or more non- transitory computer-readable media storing instructions which, when executed by one or more computing devices, cause performance of the method recited in any one of Claims 1-16.

18. A system comprising: a plurality of computing devices, each of which has one or more processors;

-82- the plurality of computing devices having access to one or more non-transitory computer- readable media storing instructions which, when executed by the plurality of computing devices, cause performance of the method recited in any one of Claims 1-16.

-83-

Description:
UNITED STATES INTERNATIONAL APPLICATION

FOR

SYSTEM AND METHOD FOR TRANSACTION CONTINUITY ACROSS FAILURES IN A SCALE-OUT DATABASE

CROSS-REFERENCE TO RELATED APPLICATIONS, BENEFIT CLAIM

[0001] This application claims the benefit as a Continuation of Appln. Ser. No. 17/070,277, filed October 14, 2020 the entire contents of which is hereby incorporated by reference as if fully set forth herein, under 35 U.S.C. §120. The applicant hereby rescind any disclaimer of claim scope in the parent application or the prosecution history thereof and advise the USPTO that the claims in this application may be broader than any claim in the parent application.

FIELD OF THE INVENTION

[0002] The present invention relates to storage systems and, more specifically, to shared- nothing database systems.

BACKGROUND

[0003] Databases that run on multi-processing systems typically fall into two categories: shared-persistent-storage databases and shared-nothing databases. A shared-persistent-storage database expects all persistent storage devices in the computer system to be visible to all processing nodes. Consequently, a coordinator process in a shared-persistent-storage database system may assign any work granule to a process on any node, regardless of the location of the persistent storage that contains the data that will be accessed during execution of the work granule. Shared-persistent-storage databases may be run on both shared-nothing and shared- persistent-storage computer systems. To run a shared-persistent-storage database on a shared- nothing computer system, software support may be added to the operating system or additional hardware may be provided to allow processes to have direct access to remote persistent storage devices. [0004] A shared-nothing database assumes that a process can access data only if the data is contained on a persistent storage that belongs to the same node as the process. Consequently, a coordinator process in a shared-nothing database can only assign a work granule to a process if the data to be processed in the work granule resides on persistent storage in the same node as the process. Shared-nothing databases may be run on both shared-persistent-storage and shared- nothing multi-processing systems. To run a shared-nothing database on a shared-persistent- storage machine, a mechanism may be provided for logically partitioning the database, and assigning ownership of each partition to a particular node.

[0005] Based on the foregoing, it is clearly desirable to provide a shared-nothing database system that has less constraints with respect to which node of the shared-nothing database system is able to process work. For example, when the task is reading a particular version of a particular data item that is stored in the database system, it is desirable to provide a shared-nothing database system in which multiple nodes are capable of performing the task. The larger the number of nodes that are able to perform the same task, the easier it is for workloads to be balanced among the available nodes. In addition, it is desirable that a node that is performing a read operation be able to read the data as of a designated snapshot time. To further improve performance, it is desirable that the read operations be performed without obtaining locks, and without blocking even when reading data items that were touched by transactions that have not yet committed.

[0006] The approaches described in this section are approaches that could be pursued, but not necessarily approaches that have been previously conceived or pursued. Therefore, unless otherwise indicated, it should not be assumed that any of the approaches described in this section qualify as prior art merely by virtue of their inclusion in this section. Further, it should not be assumed that any of the approaches described in this section are well-understood, routine, or conventional merely by virtue of their inclusion in this section.

BRIEF DESCRIPTION OF THE DRAWINGS

[0007] In the drawings:

[0008] FIG. 1 is a block diagram of a distributed database system that illustrates the relationship between hosts, databases, and tablespaces, according to an embodiment; [0009] FIG. 2 is a block diagram of a distributed database system in which the rows of a table are mapped to slices, and multiple duplicas are stored for each slice, according to an embodiment;

[0010] FIG. 3 is a block diagram that illustrates contents of a duplica of a slice, according to an embodiment;

[0011] FIG. 4 is a block diagram that illustrates chronological entry chains of two rows R1 and R2, according to an embodiment;

[0012] FIG. 5. is a block diagram that illustrates the chronological entry chain of row R1 after an entry is added to the tail of the chronological entry chain, according to an embodiment; [0013] FIG. 6 is a block diagram that illustrates the chronological entry chain of row R1 after a delta log entry in the chain is applied to the row heap, according to an embodiment;

[0014] FIG. 7 is a block diagram that illustrates the circular buffer nature of a delta log, according to an embodiment;

[0015] FIG. 8 is a block diagram that illustrates the contents of a row heap entry, according to an embodiment;

[0016] FIG. 9 illustrates the inter-host messages sent during execution of a statement of a database command, according to an embodiment;

[0017] FIG. 10 illustrates the inter-host messages sent during commit of a transaction, according to an embodiment;

[0018] FIG. 11 is a block diagram of a computer system that may be used as a client or host in a distributed database system that employs the techniques described herein;

[0019] FIG. 12 is a block diagram illustrating a distributed database system with two engine clusters and one control cluster executing on six hosts, according to an embodiment;

[0020] FIG. 13 is a block diagram illustrating a host from FIG. 12 in greater detail;

[0021] FIG. 14 is a block diagram illustrating messages sent between a control cluster and hosts when a host fails, according to an embodiment;

[0022] FIG. 15 is a flowchart illustrating steps taken to reconfigure the host cluster when a host fails, according to an embodiment; and

[0023] FIG. 16 is a block diagram showing a distributed database system that includes a control cluster where all hosts are able to communicate with each other through two distinct networks, according to an embodiment. DETAILED DESCRIPTION

[0024] In the following description, for the purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, that the present invention may be practiced without these specific details. In other instances, well-known structures and devices are shown in block diagram form in order to avoid unnecessarily obscuring the present invention.

GENERAL OVERVIEW

[0025] A shared-nothing database system is provided in which parallelism and workload balancing are increased by assigning the rows of each table to “slices”, and storing multiple copies (“duplicas”) of each slice across the persistent storage of multiple nodes of the shared- nothing database system. When the data for a table is distributed among the nodes of a shared- nothing system in this manner, requests to read data from a particular row of the table may be handled by any node that stores a duplica of the slice to which the row is assigned.

[0026] According to an embodiment, for each slice, a single duplica of the slice is designated as the “primary duplica”. All DML operations (e.g. inserts, deletes, updates, etc.) that target a particular row of the table are performed by the node that has the primary duplica of the slice to which the particular row is assigned. The changes made by the DML operations are then propagated from the primary duplica to the other duplicas (“secondary duplicas”) of the same slice.

SLICES

[0027] As mentioned above, a “slice” is an entity to which rows of a table are assigned. The assignment of rows to slices may be made in a variety of ways, and the techniques described herein are not limited to any particular row-to-slice assignment technique. For example, the table may have a primary key, and each slice may be assigned the rows whose primary keys fall into a particular range. In such an embodiment, a table whose primary key is alphabetic may have its rows assigned to three slices, where the first slice includes rows whose primary key starts with letters in the range A-K, the second slice includes rows whose primary key starts with letters in the range L-T, and the third slice includes rows whose primary key starts with letters in the range U-Z. [0028] As another example, the row-to-slice assignment may be made using a hash function. For example, a hash function that produces hash values in the range 1-3 may be used to assign rows to three slices. The slice to which any given row is assigned is determined by the hash value produced when the hash function is applied to the row’s primary key.

[0029] For any given table, the number of slices to which its rows are assigned may vary based on a variety of factors. According to one embodiment, the number of slices is selected such that no single slice will store more than 1 gigabyte of data. Thus, as a general rule, the more data contained in a table, the greater the number of slices to which the rows of the table are assigned.

[0030] In situations where a table has no designated primary key column, the database system creates and populates a column with values that may serve as the primary key for the purpose of assigning the rows of the table to slices. The values for such a system- created primary key column may be, for example, an integer value that increases for each new row. This is merely an example of how system-generated primary key values can be created, and the techniques described herein are not limited to any particular method of generating primary key values.

DUPLICAS

[0031] A “duplica” is a stored copy of a slice. According to one embodiment, every slice has at least two duplicas. As mentioned above, each slice has one duplica that is designated as the primary duplica of the slice, and one or more secondary duplicas. Requests to read data from a slice may be performed by any node whose persistent storage has a duplica of the slice.

However, requests to perform DML operations (e.g. insert, delete, update) on a slice are only performed by the node whose persistent storage has the primary duplica of the slice.

HOSTS

[0032] As used herein, the term “host” refers to the hardware components that constitute a shared-nothing node. For example, a host may be a computer system having one or more processors, local volatile memory, and local persistent storage. The volatile memory and persistent storage of a host are “local” in that I/O commands issued by the host to the volatile memory and persistent storage do not travel over inter-host network connections. As shall be described in greater detail hereafter, one host may interact directly over inter-host network connections with the volatile memory or persistent storage of another host through the use of Remote Direct Memory Access (RDMA) operations.

PERSISTENT STORAGE

[0033] As mentioned above, each host has local persistent storage on which the duplicas that are hosted by the host are stored. The persistent storage may take a variety of forms, including but not limited to magnetic disk storage, NVRAM, NVDIMM, and FLASH/NVMe storage. In addition, the persistent storage may include a combination of storage technologies, such as NVRAM and magnetic disk storage, or NVRAM and FLASH/NVMe. For the purpose of explanation, it shall be assumed that the persistent storage used by the hosts is NVRAM. However, the techniques described herein are not limited to any persistent storage technology. ENGINE INSTANCES

[0034] As used herein, the term “engine instance” refers to the code, executing within a host, for storing, manipulating and retrieving data that is stored in duplicas on the persistent storage that is local to the host. A single host may execute any number of engine instances.

[0035] In one embodiment, each host executes a distinct engine instance for each database whose data the host is hosting. For example, if a host Hl is hosting duplicas for a table in database DI and duplicas for a table in database D2, host Hl would execute one engine instance for accessing the duplicas that belong to database DI, and a second engine instance for accessing the duplicas that belong to database D2.

[0036] For the purpose of explanation, examples shall be given hereafter involving a single database, where each host is executing a single engine instance. However, the techniques described herein are not limited to such an embodiment.

DATABASES AND TABLESPACES

[0037] A database typically includes a set of tables and corresponding support structures, such as indexes. Databases include one of more tablespaces. According to an embodiment, each tablespace is assigned to one or more hosts. The host(s) to which a tablespace is assigned store the duplicas for the tables that reside in the tablespace.

[0038] For example, FIG. 1 is a block diagram that illustrates a database system 100 that includes six hosts Hl, H2, H3, H4, H5 and H6. In the illustrated example, the database system 100 manages two databases DI and D2. Database DI has two tablespaces D1T1 and D1T2, and database D2 has three tablespaces D2T1, D2T2 and D2T3. [0039] Tablespace D1T1 is assigned to hosts Hl, H2, H3 and H4. Thus, the “footprint” of tablespace D1T1 spans hosts H1-H4, and each of hosts Hl, H2, H3 and H4 host a “tablespace member” of tablespace D1T1. Similarly, tablespace D1T2 is assigned to hosts H4, H5 and H6. Consequently, hosts H4, H5 and H6 each host a tablespace member of D1T2.

[0040] Tablespace D2T1 is assigned to hosts Hl, H2 and H3. This illustrates that a single host may host tablespace members from multiple databases (e.g. Hl hosts a tablespace member of D1T1 from database DI, and a tablespace member of D2T1 from database D2). Tablespace D2T2 is assigned to hosts H3 and H4. Tablespace D2T3 is assigned to hosts H5 and H6.

[0041] Based on these assignments, the duplicas for a table that belongs to D2T2 would, for example, be stored in the persistent storages of hosts H3 and H4. Similarly, the duplicas for a table that belongs to tablespace D1T2 would be stored in the persistent storages of hosts H4, H5 and H6.

[0042] In some embodiments, databases may be hosted on a subset of the available hosts. For example, database DI may be hosted on hosts H1-H4. The hosts of the tablespaces of the database are limited to the hosts of the database. Thus, if database DI is limited to hosts H1-H4, then tablespaces D1T1 and D1T2 would only be hosted on hosts H1-H4. Under these circumstances, duplicas for tables that reside in tablespace D1T2 could not be hosted on H5 or H6, as illustrated in FIG. 1.

EXAMPLE DATABASE SYSTEM

[0043] Referring to FIG. 2, it is a block diagram of a database system 200 comprising a cluster of engine instances. The database system 200 illustrated in FIG. 2 includes five hosts (200A, 202A, 204 A, 206A, 208 A). Each host includes local volatile memory (200C, 202C, 204C, 206C, 208C) and local persistent storage (200D, 202D, 204D, 206D, 208D). Each host is executing an engine instance (200B, 202B, 204B, 206B, 208B).

[0044] Engine instances 200B, 202B, 204B, 206B, 208B manage access to duplicas that store data for a database that is managed by the database system 200. In the illustrated embodiment, the database includes a single table T whose rows have been mapped to five slices (SI, S2, S3, S4 and S5). The database stores two duplicas for slices SI, S2, S4 and S5, and three duplicas for slice S3. Specifically, the primary duplica for slice SI (S1D1) is hosted at host 200 A. The secondary duplica for slice SI (S1D2) is hosted at host 202A. The primary duplica for slice S2 (S2D1) is hosted at host 204 A. The secondary duplica for slice S2 (S2D2) is hosted at host 200A. The primary duplica for slice S3 (S3D1) is hosted at host 202A. The secondary duplicas for slice S3 (S3D2 and S3D3) are hosted at hosts 208A and 204A, respectively. The primary duplica for slice S4 (S4D1) is hosted at host 208 A. The secondary duplica for slice S4 (S4D2) is hosted at host 206A. The primary duplica for slice S5 (S5D1) is hosted at host 206A. The secondary duplica for slice S5 (S5D2) is hosted at host 204A.

[0045] Because each of hosts 200A-208A operates as a shared-nothing node, the engine instances on the hosts only have direct access to the duplicas that are in their local persistent storage. As mentioned above, operations to read data from a slice can be performed by any engine instance that is local to any duplica of the slice. Thus, a request to read data from slice S2 may be directed to engine instance 200B (which has access to a secondary duplica of S2) or to engine instance 204B (which has access to the primary duplica of S2). However, DML operations are performed only on the primary duplica of a slice. Thus, any DML operations that operate on data in slice S2 must be directed to engine instance 204B, because only engine instance 204B has access to the primary duplica of slice S2.

THE SLICE-TO-HOST MAP

[0046] According to an embodiment, to ensure that database requests are directed to the appropriate engine instances, each host maintains a slice-to-host map that indicates the duplicas that are being hosted by each host. For example, the slice-to-host map for the system 200 illustrated in FIG. 2 may contain the following information:

[0047] The slice-to-host map is used in conjunction with a row-to-slice map in order to identify the host to which any given request should be directed. For example, in response to a request to insert a new row into table T, the host receiving the request determines the primary key of the new row and uses the row-to-slice map to determine the slice of table T to which the new row belongs. For the purpose of explanation, it shall be assumed that the new row belongs to slice S2. The host then inspects the slice-to-host map to determine that the primary duplica of slice S2 is hosted at host 204A. If the host that received the request is host 204A, then host 204A causes engine instance 204B to perform the insert into primary duplica S2D1. If the host that received the request is not host 204A, then the host that received the request ships the request to host 204A. The process of selecting the appropriate host to coordinate execution of any given database request shall be described in greater detail hereafter.

[0048] In the example given above, the requested operation is a DML operation (insert). Consequently, only the host of the primary duplica of the slice in question can perform the operation. However, if the operation were simply to read data from slice S2, then the operation could be performed either by host 204A (which has the primary duplica of S2) or host 200A (which has a secondary duplica of S2).

THE CONTENT OF A DUPLICA

[0049] As mentioned above, a duplica stores those rows, of a table, that have been mapped to the slice represented by the duplica. For example, assume that slice SI is a slice of a table T1 whose primary key is social security number (SSN). Assume further that all rows of table T1 whose primary keys fall into the range 000-00-0000 to 399-99-9999 are mapped to slice SI. Under these circumstances, each duplica of SI would store all rows of table T1 whose primary keys fall into the range 000-00-0000 to 399-99-9999.

[0050] In the system illustrated in FIG. 2, the duplicas for slice SI reside on host 200A (which has primary duplica S1D1) and on host 202A (which has secondary duplica S1D2). Thus, both duplicas S1D1 and S1D1 would store all rows of table T1 whose primary keys fall into the range 000-00-0000 to 399-99-9999. However, according to one embodiment, to support snapshot-based retrieval of data, duplicas store more than the current version of the rows that are mapped to the slice represented by the duplica.

[0051] Referring to FIG. 3, it illustrates the various structures, within a duplica, for improving performance and supporting versioning, according to an embodiment. Specifically, duplica S1D1 includes a delta log 304 that contains delta log entries 310 and 312, and a row heap 302 that initially includes no entries. Duplica S1D1 also includes local indexes 306, which include indexes 320, 322 and 324. Each of the structures contained in duplica S1D1, and how those structures are used to efficiently accessed specific versions of rows stored in slice SI, shall be described in greater detail below. THE DELTA LOG: TEMPORARY STORAGE OR ROW DATA

[0052] The delta log 304 and row heap 302 are collectively used to store versions of rows that belong to slice SI. The delta log 304 serves as short-term storage for row data, while the row heap 302 serves as longer-term storage of the row data. Changes made to a row are first placed in entries within delta log 304, and then eventually “applied” to row heap 302 to create new entries in row heap 302. Thus, entries in delta log 304 represent changes to the rows of slice SI that are not yet reflected in the row heap 302. The changes represented in a delta log entry may by committed or uncommitted. Any given row may have its data spread between entries in the delta log 304 and entries in the row heap 302.

[0053] For example, assume that slice SI is initially empty. At that point, a transaction TX1 may insert two rows (R1 and R2) into table Tl, where those rows have primary keys that fall into the range associated with slice SI. When executing TX1, engine instance 200B (the engine instance local to the primary duplica S1D1 of slice SI) will cause two log records to be generated (one for each newly inserted rows). The two log records will be stored in delta log 304. For the purpose of illustration, it shall be assumed that delta log entry 310 is the log entry for the data that transaction TX1 inserted as row Rl, and that delta log entry 312 is the log entry for the data that transaction TX1 inserted as row R2.

[0054] According to one embodiment, the delta log 304 is implemented as a circular buffer for temporarily storing delta log entries. The circular nature of the delta log is illustrated in delta log 714 of FIG. 7. As DML operations are performed on a slice, new log entries are added to the delta log of the primary duplica of the slice. In addition, those log entries are propagated to the secondary duplicas of the slice, where the log entries are added to the delta logs at those secondary duplicas.

[0055] Older delta log entries in a delta log are “applied” to the row heap to make room for new entries to be added to the delta log. If the transaction that made the changes that are reflected in the new row heap entry has committed, the new row heap entry includes the commit time of the transaction. Otherwise, the new row heap entry includes the transaction ID of the transaction. In some cases, a new row heap entry will contain a “full-row version”. That is, the new row heap entry will include values for all columns of the row as they existed at the time that the changes reflected in the row heap entry were made to the row. [0056] In the case where an applied delta log contains values for all columns of a table, the row heap entry that is created when the delta log entry is applied can simply obtain its column values from the delta log entry. In the case where an applied delta log does not contain values for all columns of the table, and the new row heap entry is to contain a full-row version, then the full-row version must be constructed. To construct a full-row version of a row, the engine instance that manages the duplica in question “stitches together” (a) the column values in delta log entry and (b) values obtained from older row heap entries for the row.

[0057] Rather than create a full-row version, a delta log entry may be applied by creating a row heap entry that contains a sparse-row version of the row. A sparse-row version of a row contains less than all of the column values of the row.

[0058] As shall be explained in greater detail hereafter, in situations where the new row heap entry is sparse, the missing values for the row that are required by a read operation may obtained by following a pointer to the previous row heap entry for the same row. If that previous row heap entry is also sparse and does not contain all of the needed column values, the process of following pointers to previous row heap entries for the row is repeated until all values required to satisfy the read operation are obtained.

LOG RECORDS

[0059] Delta log entries are stored in log records within the delta log 304. According to one embodiment, a log record may store all delta log entries that are generated for a slice during execution of a transaction fragment. Thus, if the same transaction fragment inserted both row R1 and R2 in slice SI, then the corresponding delta log entries 310 and 312 would both be contained within the same log record 315. When a log record, such as log record 315, includes multiple delta log entries, the log record is not deallocated until all delta log entries contained therein have been applied to the row heap 302.

[0060] For the purpose of explanation, it shall be assumed that each log record has a single delta log entry in examples given hereafter. However, the techniques described herein are not limited with respect to the number of delta log entries that may be contained in a single log record. THE ROW HEAP: LONG-TERM STORAGE OF ROW DATA

[0061] As explained above, row heap entries are created when delta log entries are “applied” to the row heap. Once applied, the delta log entries may be deallocated so that the space in the delta log that was occupied by the applied delta log entries may be reused to store new delta log entries. For any given row, the delta log entries for the row and the row heap entries for the row are connected using pointers to form a linked list. Within the linked list, the entries are ordered chronologically to form a chronological entry chain for the row. Chronological entry chains shall be described in greater detail hereafter.

[0062] Referring to FIG. 8, it illustrates the content of a row heap entry 800, according to an embodiment. Row heap entry 800 includes transaction information 806, a reference to a previous version of the same row 808, an indicator of the columns for which the heap entry has values 810, and the values for those columns 812.

[0063] The transaction information 806 includes information about the transaction that made the changes contained in the row heap entry. For example, before the transaction commits, the transaction information 806 may include the transaction ID of the transaction. The transaction ID may be used to look up the status of the transaction in a transaction table. After the transaction commits and row heap entry 800 is cleaned out, the transaction information 806 may include the commit time of the transaction.

[0064] The previous-row-reference 808 contains a reference to another row heap entry. The row heap entry pointed to by the previous-row-reference is the row heap entry (a) for the same table row as row heap entry 800, (b) that includes values for that row that were committed immediately before the changes reflected in row heap entry 800 were made. If row heap entry 800 is the first row heap entry for the row in question, then previous-row-reference 808 will be null. As shall be described hereafter, the links created by the previous-row-references form part of the linked list referred to as the chronological entry chain of the row.

[0065] The number-of-columns information 810 indicates the number-of-columns for which data is stored in the heap row entry 800. If row heap entry 800 is a sparse-row entry (i.e. the entry contains column values for less than all of the columns of the table, then the columns for which row heap entry 800 has data may be indicated using a bitmap. For example, if table T has four columns, and row heap entry 800 is for a row of table T but only has values for the first and fourth columns, then the number-of-columns field 810 may include the bitmap “1001”, with the first and fourth bits set to indicate that values for the first and fourth columns are contained in the row heap entry 800.

[0066] The data columns field 812 contains the actual values for the columns. If row heap entry 800 is the row heap entry that corresponds to the initial insertion of the row, then data columns field 812 will contain values for all columns. If row heap entry 800 corresponds to a later DML operation performed on an already-inserted row, then the data columns field 812 may contain values for all columns (if row heap entry 800 is a full-row version) or values for a subset of the columns (if row heap entry 800 is a sparse-row version).

[0067] The other metadata field 814 includes other metadata associated with the row heap entry 800. For example, the other metadata field 814 may include various flags, as well as a checksum to verify that the row heap entry has not become corrupted.

CHRONOLOGICAL ENTRY CHAIN OF A ROW

[0068] As explained above, the most recent change to a row may be contained in a delta log entry, where the delta log entry points to a row heap entry that contains an older version of the row. However, a given row is not limited to a single delta log entry and/or a single row heap entry. Rather, the same row (e.g. Rl) may have any number of delta log entries and any number of row heap entries.

[0069] According to one embodiment, the entries (both delta log entries and row heap entries) for a row are linked chronologically to form a “chronological entry chain” for the row. The “tail” of a row’s chronological entry chain contains the most recent change to the row, while the “head” of a row’s chronological entry chain contains the oldest available version of the row. [0070] The chronological entry chain for a row may include zero or more delta log entries followed by zero or more row heap entries. For example, as illustrated in FIG. 4, the entries in row Rl’s entry chain include:

• delta log entry 332 that contains a change to Rl committed at time T100

• delta log entry 334 that contains a change to Rl committed at time T90

• row heap entry 342 that contains changes made to Rl at commit time T50 and

• row heap entry 346 that contains all values for Rl that were originally inserted at commit time T10.

[0071] In this example, row Rl has a chronological entry chain that includes two delta log entries and two row heap entries. The pointers between the entries in the chronological entry chain of row R1 are illustrated in FIG. 4, where delta log entry 332 (which has the most recent change to Rl) is at the tail of the chronological entry chain of R1 and row heap entry 346 (which has the oldest available data for Rl) is at the head of the chronological entry chain of Rl.

[0072] In contrast, the chronological entry chain for row R2 in FIG. 4 contains only a single entry (row heap entry 344). Thus, the hash table entry associated with the primary key of row R2 points directly to row heap entry 344.

[0073] As shall be explained hereafter, the chronological entry chain for a row includes the data to reconstruct all available versions for a row. Consequently, the system is able to provide the data from a row as of any specified snapshot time, as long as that snapshot time is not older than the oldest version of the row stored in the chronological entry chain for the row.

HASH TABLE ACCESS

[0074] According to one embodiment, each engine instance maintains a per-duplica hash table for accessing the rows in each duplica to which it has access. For example, engine instance 200B maintains hash table 350 (FIGS. 3 and 4) for accessing the rows in duplica SIDE According to one embodiment, the hash table entry for a row points to the tail of the chronological entry chain of the row.

[0075] To access a row’s chronological entry chain using the hash table, an engine instance applies a hash function to the primary key of the row to produce a hash value that corresponds to a hash bucket within hash table 350. Within that hash bucket is stored an entry for the row that has that primary key (if a version of the row has been stored in the slice). The hash table entry for a row includes a pointer to the tail of the chronological entry chain for the row.

[0076] If the row in question has no delta log entries, then the hash table entry for the row will point to the newest row heap entry for the row. Thus, if row R2 is stored only in row heap entry 344, and row R2 has no delta log entries, then the hash table entry for row R2 will point directly to row heap entry 344, as illustrated in FIG. 4.

[0077] On the other hand, if the row has one or more delta log entries, then the hash table entry for the row will point to the most recent delta log entry for the row. Thus, in the example illustrated in FIG. 4, the hash table entry for row Rl points to delta log entry 332 (the tail of the chronological entry chain for Rl).

[0078] The hash table 350 may be implemented in any one of a variety of ways, and the techniques described herein are not limited to any particular hash table implementation. According to one embodiment, a hash function is applied to a primary key to generate a hash value. A first subset of the bits of the hash value are used to identify a hash bucket into which the primary key falls, and a second subset of the bits of the hash value are used as an offset into that hash bucket. The hash entry for the primary key is then stored at the location, within the specified hash bucket, that begins at the specified offset. If the primary keys of two rows “collide” (produce the same bucket and offset), then any one of a number of collision resolving techniques may be used. The techniques described herein are not limited to any particular collision resolving technique.

[0079] According to an alternative embodiment, the first set of bits (e.g. bits 0-7) are used to identify a bucket, and the second set of bits (e.g. bits 8-15) are compared with each tag in a “hash tag array” that is stored within the bucket. The hash tag array may be, for example, bits 8-15 of the hash value produced by the primary key associated with each of the hash bucket entries. A SIMD operation may be used to compare, in a single operation, bits 8-15 of the primary key in question with each 8 bit entry in the hash tag array. The result of the SIMD operation will indicate which hash table entries, within the bucket have the same bits 8-15 as the primary key in question. Since this comparison is based on fewer bits than the entire primary keys, the result of the comparison may produce false positives. For example, the comparison may indicate that three hash entries have hash values whose bits 8-15 “match” the hash value of the primary key in question. At least two of those matching hash entries must be false positives, since a table may have a maximum of one row for any given primary key.

[0080] To ensure that a “matching” hash table entry is actually for the primary key in question, the pointer in the hash table entry may be followed to the entry at the tail of the chronological entry chain for the row associated with the hash table entry. That chronological entry chain tail, whether it be a delta log entry or a heap row entry, will include the entire primary key for the row. The primary key for the row may then be compared to the primary key in question to determine whether the primary key of the row actually matches the primary key in question, or whether the match was a false positive.

INSERTING A NEW ROW INTO A DUPLICA

[0081] When the engine instance that hosts the primary duplica of a slice receives a request to insert a new row into the slice, the engine instance generates a delta entry for the change and stores the delta entry in a log record within the delta log of the primary duplica of the slice. The engine instance then stores, in the appropriate bucket of hash table 350, a hash table entry for the row. The hash table entry points to the new delta log entry.

[0082] In addition to storing the hash table entry and delta log entry for the new row, the engine instance propagates the log entry to the hosts that have secondary duplicas of the slice into which the row was inserted. Within each of those hosts, the log entry for the new row is stored in the delta logs of the respective secondary duplicas, and hash table entries are created to point to those newly stored delta log entries. Thus, on every duplica of the slice, the newly inserted row starts with a single-entry chronological entry chain.

READING DATA FROM AN EXISTING ROW

[0083] As mentioned above, read operations may be performed by any engine instance that has access to any duplica of the slice that contains the desired data. Further, read operations may be performed as of any specified snapshot time, as long as the snapshot time is not older than the oldest version of the row in the chronological entry chain of the row. Read operations are performed by:

• determining the slice from which data is to be read

• using the slice-to-host mapping, selecting a host that has access to a duplica of the slice (may be a primary or secondary duplica)

• at the selected host, causing the appropriate engine instance to perform a hash operation on the primary key of the row from which data is to be read,

• using the resulting hash value to locate the appropriate hash bucket within the hash table,

• locating the hash table entry for the row in question within that bucket,

• using the pointer from the hash table entry to locate the tail of the chronological entry chain for the row, and

• reading the desired data from the entries that belong to the entry chain of the row [0084] In some situations, the entry pointed to by the hash table entry of a row will not contain all of the data needed for a requested operation on a row. For example, the operation may require values from columns cl and c2 of Rl, and delta log entry 332 may only have a value for column cl . As another example, the operation may require the value of cl from Rl as of a particular snapshot time (e.g. T50). However, the value of cl contained in delta log entry 322 may be associated with commit time T100. Consequently, the read operation requires an older version of cl than the version contained in delta log 322. [0085] The commit time stored in each entry indicates the snapshot to which the data in the entry belongs. If cleanout has not yet been performed on an entry, the entry will contain a transaction ID rather than a commit time. Under these circumstances, the engine instance performing the read can use the transaction ID to look up the status of the transaction in a transaction table. If the transaction is committed, the commit time of the transaction that is specified in the transaction table is the commit time of the entry that includes the transaction ID. If the transaction is still active, then the entry is skipped because uncommitted changes cannot be provided to any read operation. If the transaction is not committed and is in a state other than active, additional work may be required to determine whether the read operation should see the changes in the entry, as shall be described in greater detail hereafter.

[0086] When the entry pointed to by the hash table entry of a row does not have all of the data of the row that is required by the specified read operation, the engine instance traverses the links between the entries of the row’s chronological entry chain until all of the required data is obtained. In the case of Rl, that may require going from delta log entry 332, to delta log entry 334, to row heap entry 342, to row heap entry 346.

[0087] The engine instance need not always follow a row’s chronological entry chain all the way to the head of the chronological entry chain to obtain the data needed for a read operation. For example, the data required by a read operation may be obtained after reading only a subset of the entries in the chronological entry chain. Thus, if a request is to read the latest version of cl for Rl, then that may be available directly from the delta log entry 332, without traversing any additional links in Rl’s chronological entry chain.

[0088] According to one embodiment, all read operations are performed without obtaining any locks. Thus, reads do not block write operations or other read operations, and write operations do not block read operations. As long as the entry chain for a row in a duplica (either primary or secondary) has data committed as of the snapshot time of a read operation, the engine instance performing the read operation may obtain the data it needs from the entries in the entry chain for the row in the duplica without obtaining a lock and without blocking any concurrent writes or reads to the same row. LOCAL INDEXES FOR PRIMARY KEY COLUMNS

[0089] As illustrated in FIG. 3, a duplica may store any number of local indexes 306. In the embodiment illustrated in FIG. 3, duplica S1D1 includes local indexes 320, 322 and 324. Local indexes 306 may be implemented in a variety of ways. For the purpose of explanation, it shall be assumed that local indexes 306 are implemented using B-tree structures. However, the techniques described herein are not limited to the use of any particular index structure for implementing local indexes 306.

[0090] A local index may be built on the primary key of a table. Such an index would generally be unnecessary for point look ups (e.g. finding a single row based on the row’s primary key), since that is the purpose of the hash table. However, a local index built on the primary key may be useful, for example, to facilitate range scans. For example, if a request is for the names of people who have social security numbers within the range 555-55-5555 and 555-55-9999, then a B-tree index may be traversed to find the index entry associated with the first primary key that is equal to or greater than “555-55-5555”. The first matching primary key may be obtained from that entry. From that index entry, a leaf-node-to-leaf-node linked list may be followed, obtaining the primary keys from each index entry thus visited, until an index entry is encountered that has a primary key greater than 555-55-9999. The primary keys thus obtained may then be used to index into the hash table to obtain the data from the chronological entry chains of the rows whose primary keys fall into the specified range.

[0091] According to one embodiment, when a local index is built on the primary key in order to facilitate range scans, rather than include entire primary keys, the leaf node index entries may simply include a pointer to the hash table entry associated with the row. In such an embodiment, the engine instance locates the hash table entry directly from the pointer in the index entry, rather than having to apply the hash function to the primary key to obtain a hash value, and then looking up the hash table entry in the hash bucket that is associated with the hash value.

[0092] According to an alternative embodiment, the entries in the leaf nodes of an index built on the primary key include the hash value produced by the primary key of the row that corresponds to the index entry. Based on the hash value obtained from the index entry, a rangebased scan operation may locate the appropriate bucket in the hash table. The hash table entries in that bucket may then be examined to identify any hash table entries that have primary keys that fall into the range specified for the scan. The pointers in those entries, if any such entries exist, point to the tails of the chronological entry chains of the rows whose primary keys (a) hash to that hash table bucket, and (b) fall into the range specified for the scan.

DEFERRED INDEX MAINTENANCE ON DELETES

[0093] As mentioned above, a local index may be built on the primary key to facilitate range scans based on the primary key. Under normal circumstances, such a local index would have to be updated in response to DML operations that affect rows in the slice associated index. For example, if a new row with a primary key of PK7 is inserted, an entry for that primary key PK7 would have to be (a) added to the hash table, and (b) inserted in the appropriate position within the index. Similarly, if a row with primary key PK9 is deleted, then (a) the hash table entry associated with the primary key PK9 is deleted, and (b) the index entry associated with primary key PK9 is deleted.

[0094] According to one embodiment, to improve performance of DML operations that delete rows, the deletion of the corresponding index entries is deferred. Thus, deletion of the row associated with PK9 would result in deletion of the hash table entry for PK9, but not in deletion of the index entry for PK9.

[0095] Because the hash table entry is deleted, the system will not respond to read requests with already-deleted data even though the entries for deleted rows remain in the index. For example, assume that after the row associated with PK9 is deleted, the system receives a request to read data from the rows whose primary keys fall in the range PK1-PK10. In response to the request, the system may use the local index built on the primary key to determine that the slice to which the range PK1-PK10 maps has rows associated with the primary keys PK4, PK9 and PK10.

[0096] Based on this information, the scan operation will use the hash table to find the chronological entry chains for the rows with primary keys PK4, PK9 and PK10. When the scan operation attempts to find the hash table entry for PK9, it will not find it because the hash table entry for PK9 has been deleted. Based on the absence of a hash table entry for PK9, the scan operation will skip PK9 and only return data from the rows associated with PK4 and PK10. LOCAL INDEXES FOR NON-PRIMARY KEY COLUMNS

[0097] Local indexes may be used to locate rows based on values from columns other than the primary key column. For example, for table T, the primary key column may be social- security-number, but a query may ask for the ages of all people with the first name “Amy”. To find rows that satisfy a predicate involving the “firstname” column, index 320 may be built based on values from the firstname column. Index 320 may then be traversed based on the name “Amy” to find a leaf node with an entry for “Amy”.

[0098] According to one embodiment, rather than contain pointer(s) to the row(s) with the firstname “Amy”, the index entry for “Amy” within index 320 includes the primary key of each row with the firstname “Amy”. After obtaining the primary keys of the rows with firstname “Amy”, the engine instance hashes the primary keys to find the corresponding entries in hash table 350, and follows the pointers in those entries to obtain the data from the corresponding entry chains for those rows.

[0099] Referring to FIG. 7, it is a block diagram that illustrates how a secondary index 706 that is built on a non-primary-key column may be traversed based on a value to find the primary key of a row that has that value in the non-primary-key column. For the purpose of illustration, it shall be assumed that secondary index 706 is built on the firstname column, that the request is for rows with the firstname of “Amy” and that row R1 is the one row that includes the firstname “Amy”

[0100] Under these circumstances, the secondary index 706 is traversed based on the key value “Amy” to locate the index entry 708 associated with the key value “Amy”. The index entry includes the primary key of row R1. The primary key of row R1 is then be used find the hash table entry for that primary key. The hash table entry points to the tail of the chronological entry chain for row R1. In the example shown in FIG. 7, the chronological entry chain for row R1 includes only one entry, which is a row heap entry in row heap 702.

[0101] In contrast to the chronological entry chain for row R1 , the chronological entry chain for row R2 in FIG. 7 includes one delta log entry in delta log 714 and one row heap entry in row heap 702. Consequently, the hash table entry for row R2 points to the delta log entry for row R2, which in turn points to the row heap entry for row R2.

GLOBAL SECONDARY INDEXES

[0102] When local indexes are maintained for a non-primary column, such a firstname, then such a local index must be maintained for every slice, and the local index for the slice must be on every duplica of the slice. This is because it is not possible to know which slice or slices have rows where the firstname is “Amy”, for example. Thus, for each slice, its respective local firstname index must be searched to determine if that slice has any rows where the firstname is “Amy”.

[0103] As an alternative to maintaining per-slice local indexes for non-primary columns, a single “global” index may be maintained for such columns. Such a global index would be similar to a local index, but the global index would contain entries for all rows of the table, regardless of the slices to which they belong. Thus, the index entry associated with “Amy” in such an index would include the primary keys of all rows of the table whose firstname value is “Amy”. Those primary keys may then be used, in conjunction with the range-to-slice mapping, to identify the slices to which each row retrieval request should be directed. The read requests may then be sent to the hosts that manage duplicas of those slices.

PERFORMING DML ON AN EXISTING ROW

[0104] Transactions that perform DML operations on an existing row (a row that already has a chronological entry chain in a duplica) are executed by:

• creating a new log entry that includes the change to the row,

• storing the new log entry in the delta log of the primary duplica of the slice that contains the row,

• propagating the new log entry to hosts that have secondary duplicas of the slice,

• causing the new log entry to point to the previous tail of the chronological entry chain for the row, and

• causing the hash table entry for the row to point to the newly added entry (which is the new tail of the chronological entry chain for the row)

[0105] For example, assume that the chronological entry chain for row R1 includes four entries, as illustrated in FIG. 4. In response to a DML operation that performs a change to row Rl, the change made by the DML operation is stored in a new delta log entry 500 (shown in FIG. 5). The new delta log entry 500 points to delta log entry 332, which was the previous tail of row Rl’s chronological entry chain. The hash table entry for row Rl is then updated to point to the new delta log entry 500, as illustrated in FIG. 5.

APPLYING DELTA LOGS TO THE ROW HEAP

[0106] As mentioned above, when a row is initially added to a duplica, the row is typically added as a delta log entry. However, delta log 304 serves as temporary storage for row data that ultimately should be applied to the row heap 302. In one embodiment, a background process periodically applies delta log entries to the row heap 302.

[0107] For example, assume that the delta log 304 has a delta log entry for a newly inserted row R3. At this point, the chronological entry chain for R3 consists of only that one delta log entry (to which the hash table entry for R3 points). To apply the delta log entry for R3 to row heap 302, a row heap entry that contains the content of the delta log entry of R3 is stored in row heap 302. The hash table entry for R3 is updated to point to the new row heap entry, and the delta log entry can be garbage collected/reused.

[0108] When a row’s chronological entry chain includes one or more row heap entries, the oldest delta log entry (or entries) for the row must be applied before any newer delta log entries for the row. For example, referring to FIG. 5, delta log entry 334 must be applied before applying delta log entries 332 and 500. Under these circumstances, applying a delta log entry to the row heap involves:

• making a new row heap entry with the contents of the delta log entry being applied, and

• patching the pointers in the chronological entry chain of the row so that: o the applied delta log entry is removed from the chronological entry chain, and o the new row heap entry is inserted into the chronological entry chain of the row in the same position that was previously occupied by the applied delta log entry [0109] For example, referring to FIG. 5, in the chronological entry chain for row Rl, delta log entry 334 is after delta log entry 332 and before row heap entry 342. To apply delta log entry 334 to the row heap 302, a new row heap entry (e.g. row heap entry 348) is created. Row heap entry 348 is populated with at least the contents of delta log 334. Doing so may create a sparse row heap entry (a row heap entry that includes less than all values of the row as of the commit time associated with the row heap entry). To create a fully-populated row heap entry, row heap entry 348 may be further populated by coalescing all values for row Rl as they existed when delta log entry 334 was created. This may be accomplished by obtaining the missing values from row heap entries that reside further in row Rl’s chronological entry chain (e.g. row heap entries 342 and 346).

[0110] After creating and populating the new row heap entry 348, the pointers of Rl ’s chronological entry chain are updated so that the new row heap entry 348 replaces the applied delta log entry 304 within Rl’s chronological entry chain. In the present example, updating the pointers includes causing delta log entry 332 to point to the new row heap entry 348, and causing row heap entry 348 to point to row heap entry 342. These changes are illustrated in FIG. 6.

After these pointer changes have been made, delta log entry 334 is no longer part of the chronological entry chain for row Rl, and the space occupied by delta log entry 334 may be deallocated/reused.

PROPAGATING CHANGES MADE BY DML OPERATIONS

[0111] As mentioned previously, all DML operations that affect data in a slice are made to the primary duplica of the slice. However, for the secondary duplicas to be available for read operations, those changes made at the primary duplica must be propagated to the secondary duplicas. According to one embodiment, changes made to the primary duplica of a slice are propagated to the secondary duplicas by sending a log record that contains information about the changes to the hosts that are hosting the secondary duplicas.

[0112] For example, returning to FIG. 2, a DML operation that targets data in slice SI would be performed by engine instance 200B (which hosts S1D1, the primary duplica of SI). In the primary duplica (S1D1), the change may be made by (a) generating a log record for the change, and (b) storing the log record for the change as a delta log entry in the delta log of the primary duplica (S1D1). The log record is then propagated from host 200A to host 202A (which hosts S1D2, the secondary duplica of SI).

[0113] Changes made to a slice are propagated to all secondary duplicas of the slice. Thus, changes made to slice S3 would be made at primary duplica S3D1 on host 202A and propagated to both host 204A (with has secondary duplica S3D3) and to host 208A (which has secondary duplica S3D2).

THE CONTENT OF LOG RECORDS

[0114] According to one embodiment, the content of the log records that are propagated to secondary replicas of a slice is similar to the content of the delta log record for the change that is stored in the primary duplica of the slice. Specifically, according to one embodiment, the content of the log records that are stored as delta log records at the primary duplica of a slice and propagated to the secondary duplicas of the slice include:

• the transaction ID of the transaction that performed the change reflected in the log record

• the primary key of the row affected by the DML operation

• the change made by the DML operation (e.g. the updated column value(s)) • an indication of which statement, within a transaction, specified the DML operation

• an indication of the type of DML operation (e.g. insert, update, delete, etc.)

• an indication (last-log-of-statement flag) of whether the log record is the last log record for the statement

[0115] The indication of which statement, within the transaction, is specified by the DML operation may be made by (a) assigning a number to each statement, and (b) including the number of the statement in every log record generated while executing the statement. For example, if a transaction TX1 has three statements STI, ST2, and ST3, then the three statements may be assigned the respective numbers of 1, 2 and 3. All log records generated for changes made by statement STI would then include the statement number 1, while all log records generated for changes made by statement ST2 would include the statement number 2. In the case where a statement, such as statement ST2 causes multiple log records to be generated, the last of the log records will contain a last-log-of-statement flag to indicate that it is the last log record for statement ST2. As shall be described in greater detail hereafter, the statement numbers and last-log-of-statement flags are used to ensure that a secondary duplica has received all of a transaction’s log records when the transaction commits or fails over to the host of the secondary duplica.

[0116] The transaction ID in a log record may be used to determine the status of the transaction that made the change that is reflected in the log record. For example, referring to FIG. 7, assume that the delta log entry for row R2 includes the transaction ID TX2. That transaction ID may be used to look up a transaction table entry 712 for transaction TX2 in a transaction table 710. Transaction table entry 712 contains information about the status of transaction TX2. For example, the transaction may indicate whether transaction TX2 is executing, preparing, committing or committed. If committed, the transaction table entry 712 will indicate the commit time of transaction TX2.

CLEANOUT OF ENTRIES

[0117] When a transaction commits, the delta log entries and/or row heap entries that correspond to changes made by the transaction may be updated to include the commit time of the transaction. By placing the commit time in the entries themselves, the need to look up the transaction in the transaction table is avoided. The process of updating the entries associated with a committed transaction to reflect the commit time of the transaction is referred to as “cleanout”. Cleanout may be performed, for example, by replacing the transaction ID in the entry with the commit time of the transaction.

[0118] For entries that have not yet been cleaned out, but which correspond to committed transactions, the version of the data contained in the entry is determined by looking up the transaction in transaction table 710 to determine the commit time of the transaction.

[0119] Once a cleanout operation has been performed on an entry, that commit time that is stored in the entry serves to indicate the “version” of the row to which the associated entry belongs. The version of cleaned out entries may thus be determined without having to use the transaction table 710 to look up the status of the transaction that made the change that is reflected in the entry.

[0120] Cleanout of the logs generated by a transaction need not be performed at the time the transaction commits. Rather, cleanout can be performed, for example, periodically by a background process.

SEMI-SYNCHRONOUS PROPAGATION OF LOG RECORDS

[0121] As mentioned above, when a DML operation makes a change to data in a slice, the change is made by generating a log record that reflects the change, storing the log record in the delta log of the primary duplica of the slice, and propagating the log record to the secondary duplicas of the slice. However, according to one embodiment, performance of DML operations is improved by performing the propagation of log records to the secondary duplicas “semi- synchronously”.

[0122] The propagation of log records to secondary duplicas is semi-synchronous in that the engine instance that propagates the log records for a change reports to the client that requested the change that the change was successful without waiting to receive acknowledgements that the log records for the change were successfully propagated to the secondary duplicas. For example, assume that a client requests insertion of a row, where the primary key of the row falls into a range that is mapped to slice S3. Under these circumstances, the insert request is executed by engine instance 202B on host 202A, which hosts the primary duplica of slice S3 (S3D1). During execution of the request, engine instance 202B inserts a delta log entry into the delta log of S3D1, and initiates propagation of the log entry to engine instance 208B (which hosts secondary duplica S3D2 of slice S3) and to engine instance 204B (which hosts secondary duplica S3D3 of slice S3). After initiating propagation of the log entry, but before receiving acknowledgement that the secondary duplicas received the log entry, engine instance 202B reports to the client that the statement that made the change was successfully executed. Because completion of the statement is reported as successful prior to receiving acknowledgement that the log record was received at the secondary duplicas, the changes at the primary and secondary duplicas are not fully synchronous.

[0123] According to one embodiment, a driver at the client keeps track of which statements of a transaction have been reported to be successfully executed. As shall be described in greater detail hereafter, the “last successfully executed statement” information maintained by the client is used to resume the transaction (without having to completely restart it) if the transaction fails over to a different host. The fact that the engine instance 202B does not wait for acknowledgements from the secondary duplicas before informing the client that a statement was executed can result in significant performance improvements, since execution of DML operations does not incur acknowledgement-related delays.

[0124] According to one embodiment, the engine instance that is making a change that is specified in a statement reports to the client that the statement was successfully executed when:

• the log record for the change is stored in the delta log of the primary duplica, and

• the log record(s) has been placed “on the wire” for transmission to the secondary duplica(s)

[0125] In this context, “on the wire” refers to a situation where the log records have been communicated to a failure domain other than the failure domain of the engine instance making the change. Because the engine instance waits until the log record is on the wire, the changes made at the primary duplica and secondary duplicas is also not fully asynchronous. Hence, the term “semi-synchronous” is used to refer to the propagation of log records from primary duplicas to secondary duplicas.

[0126] In the present example, assume that host 202A has a Network Interface Card (NIC) that connects host 202A to a network to which hosts 204A and 208A are connected. Under these conditions, engine instance 202B may report that a statement has been successfully executed against slice S3 when the NIC acknowledges receipt of the log record associated with the statement. The NIC may send this acknowledgment prior to actually sending the packet that contains the log record, as long as the log record is stored in memory associated with the NIC (as opposed to the memory in which the engine instance is running). Alternatively, the NIC sends the acknowledgement after successfully putting the record on a transmission media, but prior to determining that the record was received successfully. Thus, at the time of the NIC’s acknowledgement, the packet containing the log record may not yet have been received by the hosts of the secondary duplicas. In this example, the NIC constitutes a separate failure domain because, after the NIC has acknowledged receipt, the propagation of the log record from the NIC to hosts 204A and 208A should succeed even if engine instance 202B subsequently fails or hangs.

REDUNDANTLY-CONNECTED HOSTS

[0127] As explained above, NICs and engine instances fall into different failure domains. Thus, log records will be propagated by NICs to the secondary duplicas successfully even though the engine instances that generate the log records fail or hang. However, it is still possible that a double-failure (failure of the engine instance of the primary duplica, and failure of the NIC/network) will result in a situation where a change is not propagated to a secondary duplica even though the client has been told that the corresponding statement succeeded.

[0128] Therefore, to decrease the likelihood that secondary duplicas will not receive changes, each host in the system may be connected to each other host through multiple redundant networks. For example, as illustrated in FIG. 2, host 202A may be connected to host 204A through two distinct networks (networkl, network2), each with its respective NIC (NIC1, NIC2) in host 202A. Under these circumstances, engine instance 202B may concurrently send the log record for a change to slice S3 to the host 204A through both NICs/networks. Thus, the log record will only fail to arrive at host 204A if both NICs/networks fail, which is a highly unlikely event.

[0129] While not shown in FIG. 2, each of the two networks (networkl, network2) may connect each host with each other host. Under these circumstances, any communication between hosts will only fail if both networks fail. Further, the number of networks between each of the host may be increased as necessary to ensure the success of communications. For example, in one embodiment, each host is connected to each other host through at least three distinct networks. GARBAGE COLLECTION ON ROW HEAP ENTRIES

[0130] As explained above, the chronological entry chain for a row grows as DML operations are performed on the row, where each DML operation adds a new entry to the tail of the chronological entry chain for the row. As also explained above, the oldest delta log entry for a row may be applied to the row heap by making a new row heap entry for the row, thereby allowing the space occupied by the delta log entry to be reclaimed. However, if the chronological entry chain for each row is allowed to grow indefinitely, a host will eventually run out of persistent storage space.

[0131] Therefore, according to one embodiment, the system periodically reclaims the space occupied by the row heap entry that resides at the head of a row’s chronological entry chain. The row heap entry that resides at the head of a row’s chronological entry chain is referred to herein as the “head entry”. The head entry contains the oldest available version of the row. The space occupied by head entries may be reclaimed, for example, when the timestamp associated with the head entry is older than a designated threshold age. For example, assume that a system has a designated retention time of three days. Under these circumstances, the system is able to handle read requests associated with snapshot times that are up to three days old. If a particular row has a head entry with a commit timestamp that is more than three days old, then the system may deallocate the head entry and reuse the storage space thereof.

[0132] When deallocating the head entry of a row, it may be necessary to rewrite the row heap entry that precedes the head entry. The row heap entry the precedes a row’s head entry is referred to as the row’s “penultimate entry”. The penultimate entry may need to be rewritten, for example, when the penultimate entry is a sparse entry.

[0133] For example, assume that a row R1 has five columns cl, c2, c3, c4 and c5. Further assume that the head entry for row R1 is a full-row version that has values for all five columns as of time T10. Finally, assume that the penultimate entry for row R1 is a sparse row heap entry with only the values of cl and c2 as of time T50.

[0134] Under these circumstances, deallocating the head entry for Rl, without any additional changes, will result in problems. Specifically, after such deallocation, if the system receives a request to read row Rl as of time T50, the values for c3, c4 and c5 as of time T50 will no longer be available. [0135] According to one embodiment, when deallocating the head entry of a row that has a sparse penultimate entry, the system creates a new full-row version of the row that reflects the snapshot time of the penultimate entry. For example, in the case where the penultimate entry for row R1 is a sparse entry with a timestamp of T50, the system creates a full-row version for R1 as of time T50. This full-row version of R1 replaces the sparse penultimate version of Rl. Consequently, the pointers of Rl’s chronological entry chain are revised to:

• remove both the head entry and the penultimate entry from the chronological entry chain of the row, and

• add the new full-row version to the head of the chronological entry chain of the row [0136] After the new full-row entry has been added to the head of the chronological entry chain of the row, the space occupied by the old head entry and the old penultimate entry may be deallocated and reused.

COORDINATOR SELECTION

[0137] Referring again to FIG. 2, when a client requests execution of a transaction, the system 200 selects an engine instance to coordinate the transaction. According to one embodiment, the system selects the coordinating transaction based on the slices that are targeted by the transaction. In the simple case that a transaction only operates on data from a single slice, that slice is designated as the “controlling slice” for the transaction, and the engine instance that manages the primary duplica of the slice is selected as the coordinating engine instance for the transaction. Thus, in the system illustrated in FIG. 2, a transaction that only operated on data from slice S3 would be coordinated by engine instance 202B, which manages the primary duplica S3D1 of slice S3.

[0138] In situations where a transaction operates on data from more than one slice, the system selects a controlling slice from among those operated on by the transaction. For example, assume that a transaction operates on data from slice SI and data from slice S2. In this case, the system would choose either slice SI or S2 as the controlling slice. If slice SI is chosen, then engine instance 200B, which manages the primary duplica S1D1 of slice SI is designated the coordinator of the transaction. If slice S2 is chosen, then engine instance 204B, which manages the primary duplica S2D1 of slice S2 is designated the coordinator of the transaction.

[0139] Various techniques may be used to select a controlling slice when a transaction operates on data from multiple slices. For example, if the transaction operates on slices SI and S2, but does more work on slice SI than on slice S2, then slice SI may be chosen as the controlling slice. In cases where it is not possible to determine, from the transaction itself, the slice(s) that will be changed, the engine instance that received the request from the client may simply select, as the controlling slice, any slice for which it manages the primary duplica, and then assume the role as the coordinating engine instance for the transaction. Thus, it is possible to have situations where the controlling slice of a transaction is not one of the slices that are touched by the transaction.

[0140] Alternatively, when a transaction operates on multiple slices, the controlling slice may be selected based on the current workload of the respective hosts. For example, if host 200A is being heavily used while host 204A is relatively idle, then slice S2 may be selected as the coordinating slice, so that the transaction may be coordinated by engine instance 204B on the less-busy host 204A. Yet other embodiments may take into account a variety of factors when selecting the controlling slice of transaction, including but not limited to which host received the request from the client, the current host workload, and the amount of work the transaction must perform on each slice.

[0141] In some embodiments, the client contains the logic for selecting the host to whom to send a transaction. The host selection may be made by the client based on the factors described above (e.g. the primary key(s) operated on by the transaction and which hosts manage the primary duplicas of the slices to which those primary keys map). In such an embodiment, the client may maintain a topology cache that indicates the mapping between primary keys and hosts that manage the primary duplicas of the slices to which the primary keys map. In an embodiment where the client selects the host, after selecting the host:

• the client connects to the host,

• a slice whose primary duplica resides at the host is selected as the controlling slice (based on the primary key(s) involved in the transaction), and

• the engine instance that manages that primary duplica serves as the coordinator for that transaction.

[0142] In an alternative embodiments, the logic for selecting a controlling slice is on each host. In such an embodiment, the host to which the client sends a transaction may select a controlling slice whose primary duplica resides on a different host. In such a situation, the transaction, and the responsibility for coordinating it, may be forwarded to that other host. Alternatively, the host that initially received the transaction from the client may send a message back to client that tells the client to send the transaction to a different host (i.e. the host that manages the primary duplica of the slice that is selected by request-receiving host as the controlling slice).

CLIENT-ASSISTED FAILOVER

[0143] When an engine instance that is coordinating a transaction fails or ceases to work for any reason, the transaction becomes a “failover transaction” and a new coordinator is selected to resume the failover transaction. According to one embodiment, the new coordinator is selected from among the engine instances that manage secondary duplicas of the controlling slice.

[0144] In addition to selecting a new coordinator, all remaining hosts set their logical clocks to max(current clock value, highest timestamp generated by failed host). Techniques for determining the highest timestamp generated by the failed host shall be described hereafter.

[0145] With respecting to selecting a new coordinator for a failover transaction, if slice S3 is the controlling slice of a transaction, then engine instance 202B would be initially designated as the coordinator for the transaction (because engine instance 202B manages the primary duplica (S3D1) of slice S3). If engine instance 202B ceases to function, then the system selects a new coordinator for the transaction. In this case, the candidates for coordinating the transaction are engine instance 204B (which manages access to one secondary duplica S3D3 of the controlling slice S3) and engine instance 208B (which manages access to another secondary duplica S3D2 of the controlling slice S3). When there are multiple secondary duplicas of a controlling slice, the new coordinator may be selected based on a variety of factors, such as the busyness of the respective hosts and which host has the most log records for the transaction.

[0146] According to one embodiment, if the candidates for becoming the new coordinator for the transaction do not have the same number of transaction log records for the transaction, then the candidate with the highest number of transaction log records is selected. For example, assume that engine instance 208B has more log records for the failover transaction than engine instance 204B. Under these circumstances, engine instance 208B would be selected as the new coordinator for the failover transaction.

[0147] Before resuming execution of the transaction at the new coordinator, any transaction log records that are missing at the other candidates are sent from the new coordinator to the other candidates. In the present example, engine instance 208B would send to engine instance 204B any transaction records, from the failover transaction, that were missing in the secondary duplica managed by engine instance 204B. Transaction log records, and how they are used during failover, shall be described in greater detail hereafter.

[0148] Once a new coordinating engine instance is selected, the secondary duplica of the controlling slice that is managed by the new coordinating engine becomes the new primary replica of the controlling slice. For example, if engine instance 208B is selected as the new coordinating process for a transaction whose controlling slice is S3, then secondary duplica S3D2 is designated as the new primary replica of slice S3. In addition, the client sends information to engine instance 208B to allow engine instance 208B to resume the transaction that was begun by now-failed engine instance 202B.

[0149] To enable engine instance 208B to resume the transaction, the client sends host 208A information about the transaction as well as an indication of the last change that was confirmed by the previous coordinator. For example, before failing, engine instance 202B would have sent the client a series of messages relating to the status of the transaction. Each message may acknowledge that a statement was successfully executed. Thus, the client will have stored the highest statement number whose execution was acknowledged by engine instance 202A prior to failure.

[0150] When engine instance 202B fails, the client sends to the new coordinator (engine instance 208B) a request to resume the transaction, along with the highest statement number that was confirmed-executed by the previous coordinator (engine instance 202B). The new coordinator (engine instance 208B) then resumes executing the transaction at that statement that follows the statement associated with the statement number that was received from the client.

[0151] For example, assume that a transaction TX1 has ten statements (STI to ST10), and slice S3 is selected to be the controlling slice for the transaction. Under these circumstances, engine instance 202B (which manages the primary duplica of slice S3) is selected as the coordinator of the transaction. While performing the transaction, engine instance 202B successfully executes statements STI to ST4, sending an acknowledgement message to the client each time a statement is successfully executed. After failover, secondary duplica S3D2 is designated the primary duplica and engine instance 208B becomes the new coordinator for the transaction. The client informs engine instance 208B that ST4 was the last statement to be successfully executed, so the new coordinator (engine instance 208B) resumes execution of the transaction at statement ST5.

FAILOVERUSING SEMI-SYNCHRONOUS PROPAGATION OF LOG RECORDS

[0152] As mentioned above, changes may be propagated to secondary replicas semi- synchronously. That is, the coordinator may indicate to a client that a statement has been successfully executed on a primary replica of a slice before the hosts of the secondary replicas have acknowledged receipt of the changes made by the statement.

[0153] In embodiments where semi-synchronous propagation of log records is used, the coordinator may send the confirmations to the client after pushing the changes to a different failure domain, such as getting confirmation for the local NIC that the log was received by the NIC. However, even though it is highly unlikely that the secondary duplicas will not receive the log records under these circumstances, it is still possible. Thus, in the example given above, it is possible that the changes made by statement ST4 of the transaction were not propagated to secondary duplicas S3D2 and S3D3.

[0154] Therefore, according to one embodiment, after a failover, before the new coordinator to resumes a transaction, the new coordinator confirms that its duplica has the log records for all statements up to and including the last-confirmed statement. In the present example, engine instance 208B does not resume execution of the transaction at statement ST5 until verifying that duplica S3D2 includes all log records of the transaction up to and including the log records for statement ST4 (including the log record containing the end-of-statement-flag for ST4). In the case where any log records are missing, the new coordinator aborts the transaction, which may then be re-executed from the start. In the case where all log records are present, the new coordinator resumes the transaction at the next statement (ST5).

ADJUSTING CLOCKS ON HOST FAILURE

[0155] As mentioned above, when a host fails, all remaining hosts set their logical clocks to max(current clock value, highest timestamp generated by failed host). However, it is not easy to determine the highest timestamp generated by a failed host. Therefore, a leasing technique is used so that non-failed nodes can always know a timestamp that is at least as high as the highest timestamp generated by a failed host.

[0156] According to the leasing technique, a “maximum clock value” is communicated to all hosts in the system. The lease grants the hosts permission to generate timestamps up to the maximum clock value. Whenever the logical clock of any host in the system reaches the maximum clock value, the host must request an additional “lease”. Upon receiving a new lease request, a new maximum clock value is selected, and the new lease is granted by communicating the new maximum clock value.

[0157] In a system that uses this leasing technique, it is guaranteed that no host in the system will have seen a timestamp value that is greater than the current maximum clock value granted by the leasing mechanism. Thus, when a host dies, all of the hosts in the system may set their clocks to the current maximum clock value to guarantee that their clocks are at least as high as any timestamp generated by the failed host node. When the clocks are adjusted in this manner after a host failure, a new maximum clock value is selected and the remaining hosts are granted leases to generate timestamps up to the new maximum clock value.

DETERMINISTIC RESPONSE TIME

[0158] According to one embodiment, the system responds to all commands within a specified maximum time. When execution of a transaction would otherwise exceed the specified maximum time, the engine instance that is coordinating the transaction returns to the client the results from the statements of the transaction that have already been executed, along with a resume token. The resume token contains information, such as the number of the last statement executed, that is required for an engine instance to resume the transaction.

[0159] Upon receiving the intermediate results and the resume token, the client may resubmit the transaction along with the resume token. The coordinating engine instance assigned to the resubmitted transaction resumes execution of the transaction at the appropriate statement based on the content of the resume token. Use of a resume token in this manner not only allows a guaranteed response time, but it allows the hosts to largely forget the state of the transaction (and therefore free up resources) between the time where the resume token is sent to the client and when the client resends the transaction.

[0160] It is possible that, to avoid exceeding the time threshold, the engine instance must stop processing a command mid- statement. For example, the command may request the scan of an entire table. Under these circumstances, it is possible that the table is only partially scanned when the time threshold is reached. If the partially-performed scan is being performed in an order based on the primary key, the resume token may include the primary key of the last scanned row. Thus, when the operation is resumed, the scan may resume with the following row. Similarly, if the scan is ordered by another column for which a secondary index exists, the resume token may indicate the last-scanned value from the indexed column. When the operation is resumed, the secondary index on that column may be used to resume the scan at row containing the next value from the indexed column.

MULTI-SLICE STATEMENTS

[0161] A single statement may involve multiple slices. For example, a statement may request the scan of a table T that has been divided into the five slices S1-S5 whose duplicas are stored in the system illustrated in FIG. 2. As mentioned above, when a transaction operates on multiple slices, the system selects a controlling slice, and the engine instance that manages the primary duplica of the controlling slice coordinates the transaction.

[0162] In the case of a table scan operation, the scan of a given slice may be performed by any engine instance that manages any duplica of the slice. According to one embodiment, the engine instance that is coordinating the transaction allocates the work among the other hosts in a way that maximizes parallelization and workload balancing among the hosts. For example, if engine instance 202B is selected to coordinate a full scan of table Tl, engine instance 202B may scan S1D2, and assign engine instance 200B to scan S2D2, assign engine instance 204B to scan S3D3, assign engine instance 208B to scan S4D1, and assign engine instance 206B to scan S5D1. These scan operations may be performed in parallel, with the results being returned to the coordinating engine instance 202B. The coordinating engine instance 202B then sends to results back to the client that requested the table scan.

[0163] The logic within an engine instance that coordinates the work of a statement that accesses multiple slices is referred to herein as the statement coordinator. According to one embodiment, the statement coordinator breaks the work required by a statement into statement fragments, where each statement fragment specifies the work to be done by a distinct engine instance. These statement fragments are then sent to their respective engine instances to cause those engine instances to perform the work that is specified therein. Thus, in the present example, the statement coordinator of engine instance 202B creates five statement fragments for the statement that requires a full scan of table T, and sends those statement fragments to the appropriate engine instances to cause the table scan to be performed in parallel. TRANSACTIONS

[0164] As mentioned above, database operations performed by system 200 are often performed as part of transactions. A transaction is a unit of work that must be performed atomically. Thus, if system 200 has performed some of the work specified in a transaction, but is unable to complete the remainder of the work, then system 200 must abort the transaction and “roll back” the work that has been performed.

[0165] Each transaction may have multiple statements. Within each transaction, the statements are executed serially. However, the work of one transaction may be performed concurrently with the work of other transactions. In addition, the work specified within any given statement may be divided up and performed in parallel. As mentioned above, the log record that is generated while executing a statement of a transaction includes both the number of the statement and the transaction ID.

[0166] When a transaction commits, the transaction is assigned a commit time from the logical clock of the host in which the coordinating engine instance for the transaction is running. As mentioned above, the engine instance that is selected to coordinate a transaction is selected by determining the controlling slice of a transaction, and then selecting the engine instance that manages the primary duplica of the controlling slice as the coordinator for the transaction.

[0167] As also mentioned above, the statements within a transaction may require performance of DML operations on multiple slices. Under these circumstances, the primary duplicas of some of those slices may be managed by engine instances residing on host other than the host to which the coordinating engine instance belongs. For example, assume that a transaction updates data that resides in both slices SI and S3. Under these circumstances, slice SI may be selected as the controlling slice. As a consequence of SI being the controlling slice, engine instance 200B, which manages S1D1 (the primary duplica of slice DI) is selected as the coordinating engine instance.

[0168] To perform the DML operation on slice S3, the coordinating engine instance 200B sends a statement fragment to the engine instance that manages S3D1, the primary duplica of slice S3. In the embodiment illustrated in FIG. 2, the engine instance that manages S3D1 is engine instance 202B on host 202A. The statement fragment specifies the work that must be done on slice S3. Engine instance 202B performs the requested work and communicates completion of the work back to coordinating engine instance 200B. PREREQUISITES FOR COMMITTING A TRANSACTION

[0169] The coordinating engine instance of a transaction cannot commit the transaction until it has confirmed that all work required by the transaction has been successfully performed. In a system where each slice may have one or more secondary duplicas and each transaction may perform DML on multiple slices, the work of a transaction includes (a) performing DML on the primary duplicas of the slices, and (b) propagating of log records to the secondary duplicas.

[0170] Further, performing the DML on the primary duplicas of the slices may involve (al) the coordinating engine instance performing work on the primary duplica of the controlling slice, (a2) the coordinating engine instance performing work on the primary duplicas of one or more non-controlling slices, and (a3) one or more non-coordinating engine instances performing work on the primary duplicas of one or more other non-controlling slices.

[0171] Consequently, a commit protocol is needed to ensure that a transaction is not committed until all of the follow has occurred:

• the coordinating engine instance has performed all work requested on the primary duplica of the controlling slice

• the coordinating engine instance has performed all requested work on any noncontrolling slices for which the coordinating engine instance manages the primary duplicas

• the non-coordinating engine instances have performed all requested work on the primary duplicas of any other slices that are changed by the transaction, and

• the log records for all changes made by the transaction to primary duplicas have been successfully propagated to the corresponding secondary duplicas

[0172] As mentioned previously, a coordinating engine instance may report to a client that a DML operation requested by the client has been successfully performed without waiting for acknowledgement that the log record that corresponds to the DML operation was actually received by the host(s) containing the secondary duplica(s) of the slice that was changed in the DML operation. However, prior to commit, it is necessary for the coordinating engine instance to obtain such acknowledgements. For example, assume that statement STI in transaction TX1 requires a change to a row that maps to slice SI . Under these circumstances, engine instance 200B may acknowledge to the client that statement STI has been performed after updating primary duplica S1D1 and sending the correspond log record to a NIC of host 200A. However, before committing transaction TX1, engine instance 200B must receive confirmation that the log record was successfully received by host 202A (which hosts the secondary duplica S1D2 of slice SI).

[0173] In addition, before committing the transaction TX1, the coordinator engine instance must receive confirmation that all other engine instances that work performed as part of the transaction TX1 are ready to commit. For example, if statement ST2 of TX1 specifies a DML operation on data in slice S3, then coordinating engine instance 200B would have sent a request to engine instance 202B (which manages the primary duplica S3D1 of slice S3) to perform the DML on slice S3.

[0174] A non-coordinating engine instance that performs a DML on the primary duplica of a non-controlling slice cannot report to the coordinating engine instance that it is prepared to commit until it receives confirmation that the log records for the changes it made to the noncontrolling slice have been successfully propagated to the engine instances that manage the secondary duplicas of the non-controlling slice. In the present example, engine instance 200B sends a statement fragment to engine instance 202B to cause engine instance 202B to perform the requested DML operation for slice S3 on data in S3D1. Under these circumstances, engine instance 202B cannot report that it is prepared to commit until engine instance 202B receives confirmation that the log record that corresponds to its changes to S3D1 have been successfully propagated to S3D2 and S3D3, which are managed by engine instances 208B and 204B, respectively.

COMMUNICATIONS DURING EXECUTION OF STATEMENTS

[0175] Prior to explaining the operations involved in committing a transaction, an explanation shall be given of the various communications that occur during execution of statements within the transaction. Referring to FIG. 9, it is a block diagram of a system 900 that shall be used to explain the transaction commit protocol that may be used by distributed slicebased database systems, according to an embodiment. System 900 includes six hosts 950, 952, 954, 956, 958 and 960. Hosts 950, 952, 954, 956, 958 and 960 are executing engine instances 902, 904, 906, 908, 910 and 912, respectively. Engine instance 902 manages the primary duplica 930 of slice SI, and Engine instance 912 manages the primary duplica 932 of slice S2. [0176] Slice SI has two secondary duplicas 934 and 936, managed by engine instances 904 and 906, respectively. Slice S2 has two secondary duplicas 938 and 940, managed by engine instances 908 and 910, respectively.

[0177] For the purpose of explaining the commit protocol, it shall be assumed that a client 990 submits a transaction TX1 that includes two statement STI and ST2, where statement STI performs DML on slice SI and statement ST2 performs DML on slice S2. It shall further be assumed that slice SI is selected to be the controlling slice of the transaction TX1. Because engine instance 902 manages the primary duplica of the controlling slice SI, engine instance 902 is designated to be the coordinator for the transaction TX1.

EXECUTION OF A STATEMENT BY THE COORDINATOR

[0178] In the present example, execution of statement STI by engine instance 902 proceeds by:

• making changes to the primary duplica 930 of slice SI

• semi-synchronously sending the log records for those changes to secondary duplicas 934 and 936 of slice SI

• semi-synchronously sending an end-of-statement savepoint message for statement SI to secondary duplicas 934 and 936 of slice SI

• sending a statement-complete acknowledgement message for statement SI to client 990. EXECUTION OF A STATEMENT BY A NON-COORDINATOR

[0179] Because statement S2 involves performing a DML operation on a slice whose primary replica is managed at a host other than the host of the controlling engine instance, additional communications are required. The communications required to execute statement ST2 are illustrated in FIG. 9.

[0180] Referring to FIG. 9, the submission of statement S2 from client 990 to host 950 is illustrated as “(1) STATEMENT” to indicate that the client’s submission of the statement ST2 is the first of the actions illustrated in FIG. 9. According to one embodiment, engine instance 902 includes statement coordinating logic and transaction coordinating logic. If necessary, the statement coordinating logic splits the statement ST2 received from client 990 into statement fragments, where each fragment operates on slices whose primary duplicas are managed by a different host. The statement fragments are then sent to the engine instances that manage the primary duplicas of those slices. [0181] In the present example, statement S2 has only one fragment Fl, which indicates the DML to be performed on slice S2. Engine instance 902 sends fragment Fl to engine instance 912 (which manages the primary duplica 932 of S2) for execution. The transmission of fragment Fl to host 958 is illustrated as “(2) DML FRAGMENT” in FIG. 9 to indicate that the transmission of fragment Fl is the second of the actions illustrated in FIG. 9.

[0182] The transaction coordinating logic on host 950 keeps track of the state of transaction TX1 and stores transaction log records that indicate the transaction state of transaction TX1 in the primary duplica of the controlling slice. In the present example, the transaction coordinating logic of engine instance 902 stores transaction log records for transaction TX1 in primary duplica 930. As shall be described in greater detail hereafter, these transaction log records (which are distinct from the data log records that contain delta log entries) are propagated to the secondary duplicas 934 and 936 of slice SI before TX1 is committed.

[0183] Because the transaction log records are propagated to the secondary duplicas of the controlling duplica of a transaction, any one of the engine instance(s) that manage those secondary duplica(s) is able to serve as the backup coordinator for the transaction. Thus, as described earlier, if the coordinating engine instance of a transaction fails, one of the backup coordinators is selected to resume the transaction.

[0184] After engine instance 912 receives the statement fragment Fl, engine instance 912 executes the statement fragment to perform the specified DML operation on data in primary duplica 932 of slice S2. The log record that contains the delta log entry that reflects those changes is then propagated to the secondary duplicas 938 and 940 of slice S2. The propagation of that data log record to hosts 956 and 960 is illustrated as “(3) DATA LOG RECORD” to indicate that the propagation of the data log records is, chronologically, the third action illustrated in FIG. 9. As mentioned above, the propagation of log records is performed in a semi- synchronous manner, where engine instance 912 waits for a local NIC to confirm receipt of the log record for transmission, but does not wait for acknowledgement of receipt of the log record from hosts 956 and 960.

[0185] After semi-synchronous transmission of log records to the secondary duplicas 938 and 940 of slice S2, engine instance 912 reports to the coordinating engine instance 902 that fragment execution is complete. In the “fragment complete” message, the engine instance 912 includes information that identifies the last log record that was generated for the changes made by engine instance 912 during execution of the fragment. For example, if the fragment was associated with statement ST2 of the transaction, and execution of the fragment produced three log records, then the fragment complete message may include (a) the statement number ST2, and (b) the log record sequence number (i.e. 3) of the last log record for the statement. The transmission of the “fragment complete” message is illustrated as “(4) FRAGMENT COMPLETE + Last LOGREC ID” to indicate that the transmission of the “fragment complete” message is, chronologically, the fourth action illustrated in FIG. 9.

[0186] Upon receiving confirmation from all engine instances involved in the execution of a statement that their portion of the statement has been fully executed, the coordinator stores an “end-of-statement savepoint transaction log” to its transaction log and semi-synchronously sends the end-of-statement savepoint transaction log to the backup coordinators (the hosts of the secondary duplicas of the controlling slice). According to one embodiment, the end-of-statement savepoint transaction log includes:

• the transaction ID of the transaction to which the statement belongs

• the statement number

• a retry number (how many attempts have been made to execute the statement)

• for each slice touched by the statement, a slice-specific record that includes the slice ID and a LogRecID that indicates the sequence number of the last log record with changes this statement made to the specified slice

[0187] In the present example, upon receiving the fragment-complete message from engine instance 912, engine instance 902 stores an end-of-statement savepoint transaction log and transmits the end-of-statement savepoint transaction log to engine instances 904 and 904, which respectively manage the secondary duplicas 934 and 936 of the controlling slice SI. The semi- synchronous transmission of the end-of-statement savepoint transaction log is illustrated as “(5) END-OF-STATEMENT SAVEPOINT TXN-LOG” in FIG. 9 to indicate that this transmission is, chronologically, the fifth action depicted in FIG. 9.

[0188] As mentioned earlier, coordinating engine instances communicate back to the client that a statement has been successfully completed without waiting for acknowledgements that semi-synchronous transmissions relating to the statement actually arrived at their destinations. Thus, upon providing the end-of-statement savepoint transaction log to a NIC for transmission to engine instances 904 and 906, engine instance 902 reports to client 990 that statement SI was successfully completed.

THE COORDINATING ENGINE INSTANCE

[0189] At the start of a transaction, the coordinating engine instance (engine instance 902 in the example given above) stores a transaction record for the transaction in a transaction table in the primary duplica of the controlling slice. The transaction record includes the transaction ID of the transaction and status information about the transaction (e.g. whether the transaction is ACTIVE, COMMITTED, ABORTED, etc.). In addition, the transaction entry may also include:

• Retry information for statements that have been executed, and

• A list of “participating slices” along with their respective “last LogRecIDs”

[0190] The list of participating slices is a list of the non-controlling slices that are the target of DML operations in the transaction. In the example given above, slice SI was the controlling slice, and slice S2 was a participating slice because S2 was updated during the transaction for which slice SI was the controlling slice. The last LogRecID associated with a participating slice indicates the last LogRecID received by the coordinating engine instance from the engine instance that performed the DML on the participating slice. In the example illustrated in FIG. 9, the LogRecID associated with participating slice S2 is the LogRecID sent by engine instance 912 to host 950 after engine instance 912 completes execution of statement ST2 (i.e. action (4)).

[0191] As shall be explained hereafter, the coordinating engine instance uses state information to track statement completion and coordinate the commit protocol. In one embodiment, the state information is maintained within the transaction record of a transaction, which may be in the primary duplica of the controlling slice for the transaction. However, in alternative embodiments, the state information may be stored elsewhere, so long as it is accessible to the coordinator engine instance. How the transaction state information is used by the coordinator engine instance shall be described hereafter with reference to FIG. 10.

BRANCH COORDINATORS

[0192] When the coordinating engine instance of a transaction sends a statement fragment to cause another engine instance to perform a DML operation, that other engine instance is responsible for coordinating a “branch” of the transaction. In the example illustrated in FIG. 9, engine instance 912 is a “branch coordinator” responsible for coordinating a branch of the transaction TX1 that is being coordinated by engine instance 902. [0193] According to one embodiment, each branch coordinator stores, in a local transaction table, an entry that indicates:

• a local-transaction-ID-to-global-transaction-ID mapping

• the state of the local branch of the transaction (ACTIVE, COMMITTED, ABORTED, etc.)

• timestamp information

[0194] These “branch transaction entries” are propagated, using semi-synchronous propagation, to the secondary duplicas of the primary duplica that was updated during execution of the branch. For example, during execution of the branch by engine instance 912, engine instance 912 performed a DML operation on the primary duplica 932 of slice S2. Consequently, the branch transaction entry for the branch is propagated, using semi-synchronous propagation, to the secondary duplicas 938 and 940 of slice S2.

[0195] Transactions can see their own uncommitted changes. However, transactions can only see the committed changes of other transactions. Further, transactions can only see those changes by other transactions if the commit time of the changes is on or before their snapshot time. The transaction state information, in combination with the timestamp information, allows reads to be performed at the secondary duplicas. For example, assume that a client sends host 956 a request to read data from slice S2 as of a snapshot time T10. Engine instance 908 inspects the transaction state information to determine whether the change made to slice S2 during the transaction branch has been committed. If the change made to slice S2 has been committed, then engine instance 908 inspects the timestamp information to determine whether the changes made in the transaction branch fall within the T10 snapshot. If the changes are either uncommitted or too recent (i.e. the commit time of the branch is greater than T10), then engine instance 908 skips the entries, in the chronological entry chains, that are associated with the changes made during the transaction branch, to locate older entries that contain data that does fall within the T10 snapshot.

UPDATING LOGICAL CLOCKS

[0196] It is critical that the commit times of two transactions that updated the same data item reflect the order in which the changes were made to that data item. Thus, if TX1 updates a data item and commits, and TX2 then updates the same data item and commits, then TX2 must be assigned a later timestamp than TX1, even if TX2 being coordinated by a different host than the host that coordinated TX1.

[0197] In order to ensure no transaction is given a commit timestamp that is earlier than later transactions that touch the same data items, the hosts piggyback the current values of their logical clocks on messages that are sent to other hosts. For example, according to one embodiment, the prepare acknowledge messages sent by all participants in a transaction back to the coordinating engine instance include the current values of the logical clocks of their respective hosts.

[0198] All nodes that were involved in a transaction must report back their logical clock values to the coordinator engine instance to ensure that the transaction is assigned a commit time that is later than logical clocks of the participating nodes at the time they were involved in the transaction. Specifically, the nodes that have to report their clock values back to the coordinator engine instance include the nodes of (a) all primary duplicas touched by the transaction, and (b) all secondary duplicas of the primary duplicas that were touched by the transaction. As shall be described in greater detail hereafter, the prepare acknowledge message sent from backup coordinator engine instance 904 would include the current value of the logical clock of host 952. The prepare acknowledge message sent from backup coordinator engine instance 906 would include the current value of the logical clock of host 954. The prepare acknowledge message sent from branch coordinator engine instance 912 would include the current value of the logical clock of host 958.

[0199] If any of the prepare acknowledge messages includes a logical timestamp that is greater than the current value of the logical clock on the host of the coordinating engine instance (e.g. host 950), then the logical clock of the host of the coordinating engine instance is updated to reflect a time that is greater than the highest logical clock value it received. For example, assume that the current value of the logical clock on host 950 is T500. In this case, if the prepare acknowledge messages from engine instances 904, 906 and 912 contained the timestamps T300, T400, and T600, respectively, then the logical clock on host 950 would be updated to at least T601. This clock adjustment is performed before the coordinating engine instance uses the logical clock on host 950 to obtain a candidate commit time from transaction TX1. COMMITTING A TRANSACTION

[0200] Referring to FIG. 10, it illustrates a protocol for committing transaction TX1 after the actions illustrated in FIG. 9 have been performed. Initially, while the statements of the transaction are being executed, the state of the transaction is active. The “active” status of the transaction is reflected in the transaction log records maintained by the coordinating engine instance (e.g. engine instance 902), the backup coordinators (e.g. engine instances 904 and 906) and the branch coordinators (e.g. engine instance 912).

[0201] After all statements in the transaction have been performed, the client submits a commit command. At the time the commit command is received, the coordinating engine instance 902 has received confirmation that all of the statements (STI and ST2) of TX1 have been performed, the coordinating engine instance 902 has updated the transaction record for TX1 accordingly, and has semi-synchronously sent the transaction record to the secondary duplicas 934 and 936 of the controlling slice SI . Engine instance 902 has also reported to client that statements SI and S2 have been fully executed (along with the last LogRecID for each statement).

[0202] In response to the commit command, the coordinating engine instance transitions to a “preparing” state by:

• updating the state information in its transaction record for TX1, and

• sending prepare request messages to all engine instances that participated in the transaction, including the backup coordinators, the branch coordinators (which host primary duplicas that were touched by the transaction) and the hosts of all secondary duplicas of all slices that were touched by the transaction.

[0203] To send prepare request messages to the participants in the transaction, the coordinating engine instance reads the list of participants from the transaction record of the transaction. According to an embodiment, the coordinating engine instance also obtains a “prepare timestamp” for the transaction. The prepare timestamp for the transaction may be the current value of the logical clock of the host on which the coordinating engine instance resides. [0204] According to an embodiment, the prepare request messages include:

• the global transaction ID of the transaction being prepared

• the prepare timestamp the slice ID for each slice touched by the transaction • for each slice touched by the transaction, the last LogRecID of the log records associated with changes made by the transaction to that slice.

[0205] In response to receiving the prepare request messages, the participants in the transaction:

• update their local logical clock to the global prepare timestamp if the global prepare timestamp is greater than the current value of the local logical clock

• use the last LogRecIDs in the prepare request message to confirm that they possess all of the log records that the coordinating engine instance thinks they should have

• obtain a local prepare timestamp from their local logical clock

[0206] With respect to checking whether all needed log records exist, assume that a participating engine instance has a duplica of slice SI. Assume further that the changes made by the transaction to slice SI were reflected in three data log records DL1, DL2 and DL3. In this example, the prepare request message sent to engine instance 912 includes, for slice SI, the last LogRecID of DL3. In response to receiving the prepare request message from the coordinating engine instance 902, the participating engine instance verifies that it has the log records for slice SI up to and including log record DL3. How errors are handled (e.g. the participating engine instance is missing a log record) shall be described in greater detail hereafter.

[0207] Upon confirming that they have the required log records, the transaction participants obtain a local prepare timestamp and update the status information in their respective transaction records to indicate the local prepare timestamp and that the transaction TX1 is in the “prepared” state. After updating their respective transaction records, the transaction participants send prepare acknowledgement messages to the coordinating engine instance. According to one embodiment, each prepare acknowledgement message includes the local prepare timestamp. This timestamp value represents the local “prepare time” of the transaction. As shall be described in greater detail hereafter, the coordinating engine instance uses these local prepare times to ensure that that commit time of the transaction TX1 is greater than all of the local prepare times.

[0208] Upon receiving prepare acknowledgement messages from all transaction participants, the coordinating engine instance: • updates its local logical clock to a value that is greater than the highest local prepare time (if any local prepare time is greater than the current time of the coordinating engine instance’s logical clock)

• obtains a candidate commit time based on the current value of its local logical clock

• updates its transaction record with the candidate commit time and with an indication that the transaction is in a “prepared/committing” state, and

• sends a message containing a candidate commit time to each of the backup coordinators. [0209] According to one embodiment, the “candidate commit time” sent by the coordinating engine instance to the backup coordinators is obtained by incrementing the value of the coordinating engine instance’s logical clock, and then using the new value of coordinator’s logical clock as the candidate commit time. Stated another way, the candidate commit time is set to max(local prepared times, current local clock) +1.

[0210] In the present example, the logical clock on host 950 is incremented and then its value is sent to engine instances 904 and 906 as the candidate commit time of TX1. Because this occurs after that logical clock has been updated based on the local prepare times at all hosts involved in the transaction, the candidate commit time is guaranteed to be higher than the prepare times of all participates in the transaction.

[0211] In response to the message containing the candidate commit time, the backup coordinators update their transaction log with the candidate commit time and an indication that the transaction is in the “prepared/committing” state. The backup coordinators then send “acknowledge commit time” messages back to the coordinating engine instance.

[0212] Upon receiving acknowledge commit time messages from all backup coordinators, the coordinating engine instance:

• changes the state of the transaction to “committed”,

• tells the client the that transaction has committed (and provides the commit time),

• sends the committed transaction record to the backup coordinators

[0213] In response to receiving the committed log record of the transaction, the backup coordinators update their transaction log record for the transaction to reflect that the transaction is committed.

[0214] After the transaction is committed, commit confirm messages are sent (asynchronously) to all participants in the transaction. In response to the commit confirm messages, cleanout is performed on all entries (delta log records and/or row heap entries) that correspond to the transaction. After cleanout, the participants of the transaction send commit acknowledgement messages back to the coordinating engine instance.

REPORTING THAT A TRANSACTION COMMITTED

[0215] In the commit protocol described above, the coordinating engine instance does not tell the client that the transaction is committed until the coordinating engine instance receives acknowledge commit time messages from the backup coordinators. The reason that the coordinating engine instance waits to report the commit of the transaction until the receiving the acknowledge commit time messages from the backup coordinators is because, under certain circumstances, the commit time of the transaction will change from the candidate commit time that is initially set by the coordinating engine instance.

[0216] For example, assume that the transaction is initially assigned a candidate commit time of T121. Assume further that the coordinating engine instance (e.g. engine instance 902) marks the transaction as “committed” as of time T121 before receiving the commit time acknowledgements from the backup coordinators (e.g. engine instances 904 and 906). At this point, a read operation with a snapshot time of T125 will see the changes made by the transaction.

[0217] However, the coordinating engine instance may crash at time T130, before the coordinating engine instance has received commit time acknowledgements from the backup coordinators. Under these circumstances, a backup coordinator (e.g. engine instance 904) may be assigned to be the new coordinating engine instance for the transaction.

[0218] The new coordinating engine instance, which may have no knowledge of the candidate commit time of T121 :

• re-prepares the transaction for commit (confirming that all participants are prepared to commit the transaction),

• selects a new candidate commit time (e.g. T135)

• sends the candidate commit time to the backup coordinators

• when acknowledgements are received, communicates the new commit time to the client. [0219] Because the transaction now has a commit time T135 that is greater than T125, the read operation that was performed before the crash of the coordinating engine instance (which used snapshot time 125) is not repeatable. Specifically, executing the same read operation with the same snapshot time will produce results that do not include the changes made by the transaction (because the new commit time is after the snapshot time of the read operation). BLACKOUT RANGES FOR RESUMED TRANSACTIONS

[0220] According to one embodiment, the commit protocol is modified such that the coordinating transaction reports to the client that the transaction committed when the candidate commit time message are “on-the-wire” without waiting to receive acknowledgements of the commit time messages from the backup coordinators. To avoid the non-repeatable-read- operation problem caused when such transactions are resumed by backup coordinators that did not receive the original candidate commit time, such transaction-resuming backup coordinators assign a “blackout range” for the transaction.

[0221] According to one embodiment, the blackout range for a transaction that is resumed by a backup coordinator is the time period between (a) the highest prepare time for the transaction and (b) the commit time assigned to the transaction by the resuming backup coordinator. In the example given above, assume that the highest prepare time received by the original coordinating engine instance 902 is T124. Consequently, coordinating engine instance 902 selects a commit time of T125. Coordinating engine instance 902 reports that transaction TX1 has committed (before receiving acknowledgements of the commit time from the backup coordinators 904 and 906), and then crashes.

[0222] Backup coordinator engine instance 904 may then be selected to resume transaction TX1. Engine instance 904, which is the new coordinator, re-prepares the transaction. The highest prepare time received by engine instance 904 will once again be T124. However, the internal logical clock at engine instance 904 may be T134. Thus, engine instance 904 may assign transaction TX1 a commit time of T135. In this example, the “blackout range” for the resumed transaction TX1 is the time range between but excluding T124 (the highest prepare time) and T135 (the commit time of the resumed transaction).

[0223] After a blackout range has been assigned to a resumed transaction that has been committed, the system reports an error if a read operation with a snapshot time within the blackout range attempts to read data items that were touched by the resumed transaction. For example, after transaction TX1 is committed with a commit time of T135 and a blackout range of T125-134, errors will be generated if any read operation with a snapshot time in the range T125-T134 attempts to read a row that was touched by transaction TX1. In response to receiving such an error, a client may resubmit the read operation with a snapshot time that falls outside the blackout range (e.g. a read snapshot time of T157).

ATOMICALLY CHANGING STATE AND TIMESTAMP INFORMATION

[0224] It is often necessary to make multiple changes atomically (so that processes either see all of the changes, or none of the changes). For example, after obtaining a candidate commit time, the coordinating engine instance must change, within the transaction record, the state of the transaction to “committing” and the timestamp to the candidate commit time. It is important that no process sees one of these changes without seeing the other.

[0225] According to an embodiment, if the hardware does not support making these two changes atomically, the atomicity may be achieved by (a) storing an invalid timestamp in the transaction record, (b) changing the state information in the transaction record, and (c) storing the candidate commit time over the invalid timestamp in the transaction record. Using this technique, a process that is reading the transaction record will either see:

• state = prepared, timestamp = prepared timestamp

• state = prepared, timestamp = invalid timestamp

• state = committing, timestamp = invalid timestamp

• state = committing, timestamp = candidate commit timestamp

[0226] In the cases where the reading process sees an invalid timestamp (e.g. a timestamp of 0), the reading process knows that the transaction record is being updated, so the reading process does not use the information. Instead, the reading process waits until it sees a timestamp that is valid, at which time the process will see the “candidate commit timestamp” and that the state is “committing”.

LANES AND AUTO-COMMIT TRANSACTIONS

[0227] In the example given above, the commit protocol is initiated when a commit command is received from the client. However, in the case of an auto-commit transaction, the commit command may be implicit. According to one embodiment, a configuration parameter for a “lane” between a client and a host is set to “auto-commit”. A “lane” is a logical entity that connects a client to a host that ensures ordering of the statements submitted through the lane. Thus, a lane may be considered a “pipe” through which a client sends commands to a host.

[0228] If a configuration parameter of a lane is set to auto-commit, then every statement received through that lane is treated as a single-statement transaction. Thus, after receiving confirmation that the operations specified in a statement from that lane have been made, the coordinating engine instance automatically initiates the commit protocol, even though no explicit commit command was received.

[0229] While a lane is a pipe that is initially established between a client and a host, lanes may be considered client-side entities in that a client associated with a lane does not change, but the host associated with a lane can change. For example, when a transaction fails over from one host to another, the lane through which the client submitted commands for the transaction is connected to the new host, and the client continues to use that same lane to submit commands to the new host for the resumed transaction.

EAGER PREPARE

[0230] According to one embodiment, for auto-commit transactions, it is possible to piggyback the messages normally sent during the prepare phase of the transaction on messages sent during the active phase of the transaction. For example, transmission of the data log record containing the changes made by a transaction can be combined with transmission of prepare request messages. Under these circumstances, the “prepare request message” may simply be a flag in the data log record. When the flag is set, the recipient knows to prepare the changes made by the transaction and piggyback a prepare timestamp on its acknowledgement message for the received data log record.

[0231] Referring again to FIG. 9, assume that an auto-commit transaction specifies a change to data in slice SI. SI is selected as the controlling slice, and engine instance 902 is therefore selected as the coordinating engine instance. After making the change to the primary duplica 930 of SI, engine instance 902 sends a data log record containing those changes to hosts 952 and 954 which respectively store secondary duplicas 934 and 936 of slice SI. With eager prepare, the message that includes that data log record additionally serves as the prepare request message. Thus, hosts 952 and 954 would respond to the message by determining a prepare time for the transaction, and sending back to engine instance 902 an acknowledgement that not only indicates that the data log record was received, but also includes their respective prepare times for the transaction. Based on the prepare times, engine instance 902 selects a candidate commit time and proceeds with the steps for committing the transaction (illustrated in FIG. 10). Thus, the need for a separate “preparing” phase is avoided. If the auto-commit transaction changes data in two slices (e.g. SI and S2), then the engine instances responsible for the primary duplicas of those slices would make their respective changes and send their respective log records to the appropriate secondary duplicas. All secondary duplicas would tread the data log record as a prepare request message, and respond with prepare times for the transaction.

[0232] For transactions that are not auto-commit, it may be inefficient to eagerly prepare the transaction. For example, if a transaction includes 20 statements, it would be inefficient to request participants to “prepare” after each of the 20 statements. If a participant indicates that the transaction is prepared after the first of the 20 statements, then from that point on, read operations that target the data touched by the transaction will have to treat the transaction as being in the prepared state, rather than being in an active state. As explained in greater detail below, read operations for data that is in a prepared state may require additional steps (when the snapshot time of the read is greater than the prepared timestamp) to increase the likelihood that the transaction will ultimately be assigned a commit time that is greater than the snapshot time of the read operation.

[0233] In the case where the number of statements in a non-auto-commit transaction is known or can be accurately estimated, it may still be worthwhile to eagerly prepare the transaction. In such cases, combining the data log record message with the prepare request message would only be performed for what is known or estimated to be the last log record of the final statement in the transaction. For example, in a transaction with 20 statements, the prepare request message may be combined with the data log record message of the last log record for changes made by the 20 th statement.

[0234] In the case where the work for the last statement is to be performed by a noncoordinating engine instance, the coordinating engine instance combines the prepare request message with the DML fragment sent to the non-coordinating engine instance. For example, referring again to FIG. 9, assume that engine instance 902 is coordinating a transaction where the last statement operates on slice S2. Under these circumstances, the DML fragment sent from engine instance 902 is combined with a prepare request message. After executing the DML fragment, engine instance 912 includes prepare request messages in the data log records sent to the secondary duplicas 938 and 940 of slice S2. In this example, engine instances 908 and 910 not only acknowledge receipt of the log records, but (a) confirm that they are prepared to commit the transaction and (b) include their local prepare timestamp in the acknowledgement. Upon receipt of those acknowledgement messages, engine instance 912 updates its local logical clock, obtains its own prepare time for the transaction, and acknowledges to the coordinating engine instance 902 that it is prepared to commit. In this context, “updating a local logical clock” involves setting its logical clock to the greater of (a) its current value, and (b) the local prepare timestamp. In its acknowledgement message to engine instance 902, engine instance 912 includes its prepare timestamp.

[0235] According to one embodiment, when a message that would normally be sent asynchronously is combined with a prepare request, the message is instead sent synchronously. For example, engine instance 912 does not report to engine instance 902 that it successfully executed its DML fragment until it receives acknowledgments and prepare timestamps from the secondary duplicas 938 and 940.

[0236] Any transaction participants that did not receive an “eager prepare” message must be sent a prepare message, as explained above, during the preparing phase of the transaction. On the other hand, if eager prepare messages (prepare request messages piggybacked on other messages, such as log records) were sent to all participants, then there is no separate prepare phase. Under these circumstances, when the commit instruction is received, the coordinating engine instance will already have the prepare times of all the participants. At that point, the coordinating engine instance selects a candidate commit time and proceeds to the committing phase, as described above.

EAGER PREPARE OF AUTO-COMMIT TOUCHING TWO SLICES

[0237] Eager prepare may be used even for auto-commit transactions that touch data in more than one slice. For example, assume that an auto-commit transaction touches slices SI and S2 in the system illustrated in FIG. 9. Assume further that slice SI is selected as the controlling slice. Because slice SI is selected as the controlling slice, engine instance 902 is designated the coordinating engine instance. Engine instance 902 executes the portion of the transaction that touches slice SI, and sends a DML fragment to engine instance 912 to cause engine instance 912 to perform the portion of the transaction that touches slice S2. Engine instance 902 piggybacks a prepare request message on the DML fragment sent to engine instance 912.

[0238] Engine instance 902 sends one or more log records to secondary duplicas 934 and 936 so the secondary duplicas will reflect the changes made by engine instance 902 to the primary duplica 930 of SI. The last of those log records to each of the secondary duplicas is sent synchronously and includes a prepare request. [0239] Similarly, engine instance 912 sends one or more log records to secondary duplicas 938 and 940 so the secondary duplicas will reflect the changes made by engine instance 912 to the primary duplica 932 of S2. The last of those log records to each of the secondary duplicas is sent synchronously and includes a prepare request.

[0240] Engine instances 904 and 906 respond to the data log records/pr epare requests from engine instance 902 by obtaining prepare timestamps and sending the prepare timestamps to engine instance 902. Similarly, engine instances 908 and 910 respond to the data log records/prepare requests from engine instance 912 by obtaining prepare timestamps and sending the prepare timestamps to engine instance 912. Engine instance 912 then increases its clock, as needed, and obtains a prepare timestamp. Engine instance 912 piggybacks its prepare timestamp on the message that acknowledges execution of the DML fragment.

[0241] At this point, the coordinating engine instance 902 has received, directly or indirectly, prepare timestamps from all participants in the transaction. Coordinating engine instance 902 increases is current clock as necessary based on those prepare timestamps, and determines a candidate commit time. Coordinating engine instance 902 may then proceed directly to the commit phase of the transaction.

DOWNGRADE FROM PREPARED STATE

[0242] When eager prepare is used, the transaction is treated as “prepared” by each engine instance that has received a piggybacked prepare request message. Because with eager prepare, the prepare request messages are combined with messages that are sent before the transaction as a whole is ready to be committed, the read operations that are received in the meantime may be handled in an inefficient manner. That is, they cannot safely ignore the uncommitted changes as they could safely do if the transaction were not yet in the prepared state. According to one embodiment, the system tracks how many read operations attempt to read data touched by a transaction that has been eagerly prepared. If the number of read operations exceeds a threshold, then the transaction automatically transitions from eager-prepare to no-eager-prepare. In response to the transition, the participants in the transaction that have eagerly prepared change the transaction state back to “active”. In addition, the coordinating engine instance discards the prepare times that have been provided by the participants.

[0243] As a result of the transaction state returning to “active”, new read operations can access older versions of the data items touched by the transaction based on the assumption that the transaction will be assigned a commit time that is greater than their snapshot time. Thus, special handling is avoided for situations where their snapshot time is greater than the prepare time. Any transaction that transitions from eager-prepare to no-eager-prepare must undergo a full prepare phase after the last statement of the transaction has been executed, as illustrated in FIG. 10.

READING DATA ITEMS UPDATED BY TRANSACTIONS THAT HAVE NOT YET COMMITTED

[0244] The fact that a data item has been updated by a transaction that has not yet committed does not necessarily halt the progress of a read operation that targets that data item. For example, assume that the chronological entry chain for a row R1 in slice SI has ten entries, where the first five entries are associated with a transaction that has not committed. Assume further that a client submits a request to read row R1 as of time T20. As explained above, any duplica of slice SI may be used to service the read operation. How the read operation proceeds depends on the status of the not-yet-committed transaction.

[0245] If the not-yet-committed transaction is still “active”, then the first five entries may be skipped, and the row version of R1 that corresponds to time T20 may be obtained from one or more of the older five entries for the row. In this case, it is safe to assume that the read operation need not see any changes made by the not-yet-committed transaction because that transaction is guaranteed to be assigned a commit time greater than the read operation’s snapshot time of T20.

[0246] If the not-yet-committed transaction is in the “prepared” stage and the prepared timestamp is greater than T20, then the first five entries may be skipped and the row version that corresponds to time T20 may be obtained from one or more of the older five entries for the row. In this case, it is safe to assume that the read operation need not see any changes made by the not-yet-committed transaction because that transaction is guaranteed to be assigned a commit time greater than the prepare time, which is known to be greater than the snapshot time T20.

[0247] On the other hand, if the not-yet-committed transaction is in the prepared phase and the prepared timestamp is less than T20, it is possible that the not-yet-committed transaction will be assigned a commit time less than T20. For example, assume that the read operation is to read a row of slice S2 from the secondary duplica 938 of S2. If the transaction is in the prepared state and the prepared time is T15, then engine instance 908 would have already sent a prepare acknowledge message with the prepare time of T15 to the coordinating engine instance 902. Thus, the commit time of the transaction is guaranteed to be greater than T15, but not guaranteed to be greater than T20. Under these circumstances, the read operation may be halted until a commit time is assigned to the transaction. In some situations, the read operation may be halted until cleanout of the entries generated by the transaction, because the coordinator of the read operation will not know the commit time of the transaction until cleanout, on the host executing the read operation, of the entries generated for the transaction.

[0248] If the commit time is greater than T20, the read operation may proceed by skipping the five entries generated by the transaction. On the other hand, if the commit time is less than T20, then changes made by the transaction must be seen by the read operation, so values in those first five entries are used as needed to obtain the data needed by the read operation.

[0249] A transaction in a “prepared/committing” state is handled similar to a “prepared” transaction. Specifically, if a read operation has a snapshot time that is lower than the committing timestamp, then the read operation may be performed by skipping the entries of the chronological entry chain of a row that are associated with the committing transaction, because the committing transaction is guaranteed to have a snapshot time at least as high as the committing timestamp. On the other hand, if the committing timestamp is less than the snapshot time of the read operation, then the read operation must wait until the transaction has been assigned a commit time.

OPTIMIZATION FOR PREP ARE-TIME READ OPERATIONS

[0250] As mentioned above, read operations that have snapshot times greater than the prepared time of a transaction that has updated an item they must read normally have to wait until that transaction commits and is assigned a commit time. Once the transaction has committed and the commit time is assigned, if the commit time is greater than the snapshot time of the read operation, changes made by the transaction are skipped. On the other hand, if the commit time is less than the snapshot time of the read operation, then the read operation sees the changes made by the transaction.

[0251] According to one embodiment, a technique is employed to avoid making a read operation that needs to see a particular version of a particular data item wait during the prepared phase of a transaction that performed DML on the particular data item. Specifically, when (read snapshot time > TXN prepared time), the engine instance that is executing the read operation sends an increase-clock message to the host that is executing the coordinating engine instance. The increase-clock message may be sent immediately, or after a short wait.

[0252] The increase-clock message includes the snapshot time of the read operation. If the logical clock at the coordinating host is not already higher than the snapshot time in the increaseclock message, then the host that receives the increase-clock message responds to the increaseclock message by increasing the value of its logical clock to a value higher than the snapshot time contained in the message. Upon receipt of an acknowledgement that the host of the transaction has increased its logical clock, the read operation may proceed under the assumption that the changes made by the transaction do not belong to the read operation’s snapshot, and therefore can be safely skipped by the read operation. At this point, the prepare time at the duplica can also be increased to the snapshot time of the read operation (since, now that the coordinating engine instance’s clock has been maxed with the snapshot time of the read operation, the transaction is guaranteed to be assigned a commit time higher than the snapshot time).

[0253] For example, assume that TX1 updated a particular row in slice S2, the status of TX1 at secondary duplica 938 is “preparing”, and the prepare time for TX1 at secondary duplica 938 is T10. Assume further that engine instance 908 receives a request to read that particular row as of time T20. Under these circumstances, rather than wait for TX1 to commit, engine instance 908 may send an increase-clock message with timestamp T20 (or higher) to host 950. In response, host 950 increases the value of its local logical clock to a time later than the timestamp included in the increase-clock message. Increasing the clock of host 950 in this manner ensures that host 950 will assign a commit time to TX1 that is higher than the read operation’s snapshot time of T20. Host 950 sends an acknowledge increase-clock message back to host 956. After receiving the acknowledgement of the increase-clock message, the prepare time may be increased to T20, and the read operation may proceed, skipping the entries associated with TX1 because the changes made by TX1 are guaranteed to not be in the snapshot associated with time T20.

[0254] According to one embodiment, the increase-clock operation is accomplished using a series of Remote Direct Memory Access (RDMA) calls. An RDMA call may be made to read the relevant transaction table entry at the host on which the coordinating engine instance is running. From the transaction table entry, the coordinator of the read operation may obtain the global prepare time for the transaction. If read operation snapshot is less, then the change can safely be ignored because the commit time will only go up. If the read operation snapshot is greater than the global prepare time, then an RDMA write operation may be used to change the global prepare time to the read operation’s snapshot time. Changing the global prepare time in this manner ensures that the coordinating engine instance of the transaction will ultimately assign the transaction a commit time that is higher than the read operation’s snapshot time.

HANDLING COMMITTING-TIME READ OPERATIONS

[0255] As explained above, read operations that arrive during a transaction’s preparing phase may proceed to read older versions of data items that were touched by the transaction after ensuring that the transaction will be assigned a commit time that is greater than the snapshot time of the read operations. Unfortunately, a similar optimization cannot be performed for read operations when the transaction at issue is in the prepared/committing state.

[0256] When the transaction is in the prepared/committing state, the coordinator of the transaction has already sent a candidate commit time to the backup coordinators. Thus, increasing the logical clock of the host of the coordinating engine instance at that time, based on the snapshot time of the read operation, may not have any effect on the commit time assigned to the transaction. Similarly, changing the prepare time of the transaction in the global transaction table entry will change the candidate commit time that the coordinating engine instance has already sent out to the backup coordinators.

[0257] According to one embodiment, the coordinator of a read operation may still send an increase-clock message to the coordinating engine instance when the transaction is in the “prepared/committing” state. However, rather than adjust its clock or change the global prepare time, the coordinating engine instance waits until it has received the acknowledge commit time messages from the backup coordinators. At that point, the coordinating engine instance not only changes the transaction state to “committed”, but also responds to the held-up read operations by providing the commit time assigned to the transaction.

[0258] Because the commit time is sent directly to the coordinator of the read operation, the read operation is only held up until transaction commit, rather than the cleanout time of the data log entries at issue. By comparing the commit time of the transaction to the snapshot time of the read operation, the coordinator of the read operation determines whether to obtain data from or skip the chronological entry chain entries that were generated for the transaction. [0259] According to one embodiment, when the transaction is in the prepared/committing phase and a read operation is held up, the coordinating engine instance may send the candidate commit time of the transaction to the coordinator of the held-up reading operation. This candidate commit time may be sent without the coordinating engine instance waiting for all backup coordinators to acknowledge the commit time. Under these circumstances, if the candidate commit time is less than the snapshot time of the read operation, then the read operation must continue to wait (because it is not yet guaranteed that the transaction will commit). On the other hand, if the candidate commit time is greater than the snapshot time of the read operation, the read operation may proceed under the assumption that it cannot see the changes made by the transaction. This is possible because if the transaction does commit, it will have a commit time at least as high as the candidate commit time.

OPTIMISTIC PREPARE TIMES

[0260] As explained above and illustrated in FIG. 10, upon receiving prepare acknowledgement messages from all participants in a transaction, the coordinating engine instance selects a candidate commit time that is higher than (a) its current logical clock, and (b) the highest prepare times received from the transaction participants. In the embodiment described above, the prepare time sent by each transaction participants is the value of the logical clock at the participant’s host when the participant prepared the changes associated with the transaction.

[0261] For example, if transaction TX1 performed DML on slices SI and S2 in the system 900 illustrated in FIG. 9, then all hosts in system 900 would be participants in TX1 because each of the hosts has a duplica of either slice SI or slice S2. Since the logical clocks at these hosts are independent of each other, the prepare times established at each of the hosts for transaction TX1 may differ.

[0262] As mentioned above, read operations that target data items touched by TX1 during the preparing phase of TX1 must perform additional work before reading the data items (e.g. send clock-increase messages to the controlling engine instance) if their snapshot times are greater than the prepare time of TX1. However, if their snapshot times are less than the prepare time of TX1, that additional work is not necessary.

[0263] According to one embodiment, to increase the likelihood that the snapshot times of later-received read operations will be less than the prepare time of a transaction being prepared, the transaction’s participants may assign the transaction a prepare time that is higher than its current clock. For example, assume that engine instance 910 has received a prepare request for TX1. In response, engine instance 910 verifies that secondary duplica 940 of S2 has the log records for all changes TX1 made to slice S2. Engine instance 910 then changes its locally- stored status of TX1 to “prepared”, stores the local prepared time for TX1, and returns the local prepared time in a prepare acknowledge message. To assign an optimistic prepare time, engine instance 910 selects a prepare time that is significantly higher than the current value of the logical clock of host 960.

[0264] For example, if the current value of the logical clock of host 960 is T1000, engine instance 910 may select a prepare time of T10,000. By selecting an optimistic prepare time in this manner, engine instance 910 increases the likelihood that any read operation that targets data items touched by TX1 that are received during the preparing state of TX1 will have snapshot times that are less than the local prepare time of TX1. Because those read operations will have snapshot times lower than the local prepare time of TX1, the read operations may proceed (seeing the pre-TXl version of the data items) without having to perform any additional work to ensure that TX1 will be assigned a commit time that is greater than the read operation’s snapshot time.

LOGICAL ROLLBACK OF LOG RECORDS

[0265] Under various circumstances, it is necessary to “roll back” or “undo” changes that have been made to a slice. According to an embodiment, rather than creating a new version of data in which the changes have been removed, the system simply stores data indicating which log records are to be treated as “undone”.

[0266] For example, assume that a statement ST3 makes changes to multiple slices whose primary replicas are spread across multiple hosts. During execution of the statement, log records for the statement ST3 are generated by each of those hosts. Each of those log records is tagged with an identifier for statement ST3. If the coordinating engine instance fails before execution of the statement ST3 has completed, the transaction fails over to another engine instance that becomes the new coordinating engine instance for the transaction. To undo the changes that were made for statement ST3, the new coordinating engine instance generates a “rollback log record”. The rollback log record indicates that all log records tagged with the statement number ST3 of the transaction are to be treated as “undone”. [0267] After storing the rollback log record, the new coordinating engine instance resubmits the statement for execution. However, rather that reusing the same statement number, the new coordinating engine assigns a new statement number (e.g. ST4) to the statement. Because a new statement number is used for the re-executed statement, the log records for the aborted execution of the statement may be readily distinguished from the log records generated when the statement is re-executed.

[0268] When delta log entries are applied to the row heap, delta log entries in an “undone” log record are skipped. Thus, applying such log records involves removing the delta log entries from their respective chronological entry chains without creating any new heap row entries. After the undone delta log entries have been removed from their chronological entry chains, the space allocated to the undone log record in the delta log can be deallocated/reused.

RECOVERING FROM A LOST DATA LOG RECORD

[0269] During the execution of a transaction, numerous different types of failures can occur. One such error is the failure of a secondary duplica to receive a data log record that reflects a change made to the primary duplica. When that error is discovered depends on a variety of factors, such as whether the host containing the primary duplica fails.

[0270] Referring again to FIG. 9, assume engine instance 912 generates three data log records (DL1, DL2 and DL3) during execution of the DML fragment associated with statement ST2 of transaction TX1. Assume further that hosts 960 and 956 of the secondary duplicas 940 and 938 of S2 do not receive the data log record DL2.

[0271] If hosts 960 and 956 receive a subsequent data log record (e.g. DL3) without receiving DL2, then hosts 960 and 956 are able to tell that they are missing a data log record. Under these conditions, hosts 960 and 956 may request the missing log record (DL2) from host 958.

[0272] In some cases, a failure may not be discovered until later in transaction execution.

For example, assume that hosts 956 and 960 receive log records DL1 and DL2, but fail to receive the log record DL3, which was sent semi-synchronously from host 958. Assume further that host 958 acknowledged completion of the statement fragment to host 950, and then crashed. The fragment completion acknowledgement message sent from host 958 to host 950 includes the last- LogRecID for the changes made by engine instance 912 to the primary duplica 932 of slice S2. Thus, after the crash, the coordinating engine instance 902 will have the LogRecID for log record DL3 that was generated by engine instance 912 before the crash.

[0273] Unfortunately, with the crash of host 958, the actual log record DL3 will have been lost. After the crash, secondary duplica 938 may be designated to be the new primary duplica of S2. Under these circumstances, the change associated with the log record DL3 will not be reflected in the new primary duplica 938 of S2. During the prepare stage of the commit protocol for transaction TX1, the controlling engine instance 902 will send out prepare messages to all participants in transaction TX1. In the present example, the controlling engine instance 902 will ask host 956 whether it has prepared all changes to slice S2 up to the change reflected in data log record DL3. Because engine instance 908 only has data log records up to DL2, engine instance 908 will report an error during the prepare phase of TX1. Under these circumstances, the entire transaction TX1 may need to be rolled back and re-executed.

THE ENGINE CLUSTER

[0274] The term “engine cluster” is used herein to collectively refer to the set of entities that work together that service database commands from clients. For example, in system 200 illustrated in FIG. 2, the engine cluster includes engine instances 200B-208B. Membership of a engine cluster can change dynamically. For example, if engine instance 202B fails, engine instance 202B ceases to be a member of the engine cluster. Conversely, to increase capacity of a engine cluster, new hosts and engine instances may be added to the engine cluster.

[0275] When a change in membership of the engine cluster occurs, duplica hosting responsibilities need to be reassigned. For example, because the duplicas managed by a failed host are no longer accessible, for each primary duplica at the failed host, a secondary duplica at a different host is promoted to primary status. This promotion of secondary duplicas may be performed as part of a transaction failover operation, as described above. Similarly, when new hosts are added to the engine cluster, engine instances at those new hosts need to be assigned to host duplicas in order to distribute some of the system’s workload to the new hosts.

THE CONTROL CLUSTER

[0276] According to an embodiment, in addition to the engine cluster, the distributed database system includes a control cluster. A control cluster includes a set of control instances. Referring to FIG. 12, it illustrates a distributed database system that includes six hosts 1200, 1210, 1220, 1230, 1240 and 1250. Two engine clusters and one control cluster are executing on those hosts. Specifically, the control cluster includes control instances 1202, 1222, 1232 and 1242 executing on hosts 1200, 1220, 1230 and 1240, respectively. Engine instances 1204, 1214, 1224, 1234 and 1254, respectively executing on hosts 1200, 1210, 1220, 1230 and 1250 form one engine instance cluster (ECI). Engine instances 1206, 1216, 1236, 1246 and 1256, respectively executing on hosts 1200, 1210, 1230, 1240 and 1250 for another engine instance cluster (EC2).

[0277] It is the responsibility of the control cluster to keep track of the current state and membership of each of the engine clusters. Specifically, the control cluster keeps track of which hosts are currently operating as part of the distributed database system, and the neighbormonitoring relationships between the hosts. Neighbor-monitoring shall be described in greater detail below.

[0278] According to one embodiment, the control instances operate as a High- Availability Metadata Infrastructure (HAMI) ensemble. In one embodiment, HAMI provides a hierarchical key-value store over enough machines to be highly available, using only local storage. An ensemble that supports writes typically has 3-9 voting members. There may also be non-voting observers (that can handle client write requests) for additional read scaling. In one embodiment, HAMI improves scalability by directing read-operations to replicas and non-voting observers. A HAMI ensemble is a collection of individual instances of the HAMI engine that are called members. An ensemble is configured with a definite number of members, and in the simple case, a quorum of those configured members must be up and running to provide service. In some embodiments, there may also be a configured number of shared (non-local) storage locations. When there is shared storage, an ensemble can come up with either a quorum of configured members, or when less than a quorum of members that can reach a quorum of the shared storage locations. This allows one configured member to provide service when it can reach enough shared storage, even if the majority of configured members are unavailable. Configured members have fixed network locations and ports. The configuration is kept in the replicated object store visible to all members, and needs nothing beyond name resolution.

[0279] In tracking the state and membership of the engine clusters, the control cluster must be able to make very fast decisions about engine cluster membership in response to changes that affect membership. Further, the control cluster itself should be fault tolerant, so that a failure that necessitates a change in an engine cluster’s membership does not also cause the control cluster to fail.

[0280] The control cluster’s view of the host cluster is deemed to be the “truth” for the investigating failures. As shall be described in detail hereafter, investigations are necessary because it is not safe to assume that a host has failed simply because another host has reported that the host has failed. For example, if host 1200 reports that host 1210 has failed, it may be true that host 1210 has failed. However, it may alternatively be true that host 1200 is experiencing network problems (and therefore cannot read the health counters of host 1210), while host 1210 is operating normally. The use of health counters to detect failures shall be described in greater detail hereafter.

HEALTH COUNTERS

[0281] Referring to FIG. 13, it illustrates host 1200 of FIG. 12 in greater detail. According to one embodiment, each host maintains a set of health counters 1330. Health counters 1130 are values, in the volatile memory of host 1200, that are periodically updated by components within host 1200. When a counter ceases to be updated for more than a threshold period of time, it is likely that the component that is responsible for incrementing the counter has failed. Thus, according to one embodiment, health inspectors monitor the health of their respective components by periodically checking the counters associated with the components to ensure that the counters are incrementing as expected.

HEALTH INSPECTORS AND MONITORING TREES

[0282] According to one embodiment, a variety of “health inspectors” are used to monitor the health of the various components of a distributed database system. A health inspector is an entity whose role is to detect when a component has failed. According to one embodiment, the health inspectors are arranged in a hierarchy, where higher-level health inspectors monitor the health of one or more lower-level health inspectors. The hierarchy of health inspectors within a host form a “monitoring tree”, where the “root” of the monitoring tree is a health inspector responsible for monitoring the health of the host itself.

[0283] In the embodiment illustrated in FIG. 13, engine instances 1204 and 1206 include instance inspectors 1312 and 1314, respectively. In one embodiment, the instance inspectors are the lowest-level health inspectors in the monitoring tree. Instance inspectors monitor scheduler- group-specific health counters that are incremented by scheduler groups executing within their respective engine instances. When the scheduler-group-specific heath counters indicate that the corresponding scheduler groups are executing properly, the instance inspectors increment their own engine-specific health counters.

[0284] In addition to instance inspectors 1312 and 1314, host 1200 includes host inspector 1310 and neighbor inspector 1340. Host inspector 1310 monitors the health of the host 1200 based on the engine- specific health counters set by the instance inspectors 1312 and 1314. In addition to monitoring the engine- specific health counters, host inspector 1312 may obtain information from a host manager 1350. Host manager may perform a variety of checks related to the health of host 1200, including but not limited to:

• checking the health of the operating system running on host 1200 (e.g. to check for kernel memory fragmentation)

• checking registers to detect any problems with the host controller adapter (e.g. one or more NICs connected to host 1200)

• checking the health of any SSDs and NVRAM local to host 1200

• checking the health of host services components

When the host manager 1350 and the engine-specific heath counters indicate that the engine instances are operating properly, the host inspector 1310 may increment a host-specific health counter.

[0285] Neighbor inspector 1340 monitors the health of a neighboring host by periodically reading the value of the host-specific health counter of the neighboring host, as shall be described in greater detail hereafter. In addition to monitoring the host-specific health counter of a neighboring host, neighbor inspector 1340 may periodically read a health counter for the neighbor inspector that is executing on the neighboring host. Thus, neighbor inspector 1340 is able to detect both when its neighboring host is not functioning properly, and when its neighboring host is not properly monitoring its respective neighboring host.

[0286] According to one embodiment, neighbor inspector 1340 determines whether a neighboring host is operating properly by reading the health counters from the memory of the neighboring host using RDMA operations. For example, neighbor inspector 1340 may use RDMA operations to read the health counters in the volatile memory of host 1210 (see FIG. 12) to determine whether host 1210 is operating properly. [0287] Finally, within control instance 1202 is logic for detecting the health of other control instances using a HAMI heartbeat. How the health of the control cluster is monitored is described in greater detail hereafter.

HOST MONITORING RING

[0288] As mentioned above, a neighbor inspector within each host uses RDMA to read the host-specific heath counters of a neighboring host to determine whether the neighboring host is operating normally. According to one embodiment, the control cluster makes neighbormonitoring assignments to ensure that the health of every host is being monitored by another host. Such neighboring-monitoring assignments may be made such that the neighbor-monitoring relationships form a ring that includes all hosts.

[0289] Referring again to FIG. 12, it illustrates neighbor-monitoring relationships 1270 that form a ring that includes all hosts 1200-1230. In the illustrated embodiment, host 1200 monitors the health of host 1210. Host 1210 monitors the health of host 1220. Host 1220 monitors the health of host 1250. Host 1250 monitors the health of host 1240. Host 1240 monitors the health of host 1230. Host 1230 monitors the health of host 1200.

NETWORK TOPOLOGY

[0290] Referring to FIG. 16, it illustrates a network topology to support communications between the entities illustrated in FIG. 12. In FIG. 16, each of eight hosts is executing a host monitor. The host monitors are part of a host monitoring ring, where each host monitors the health of a neighboring host. In addition, some of the hosts are executing control instances.

[0291] The topology of the network that connects the hosts is such that each host can connect to each other host through two distinct networks. For example, the host on the far left may communicate with the host on the far right through one network that includes switches 1 , 2 and 3, or through a second network that includes switches 4, 5 and 6.

RESPONDING TO ENGINE INSTANCE FAILURES

[0292] When an engine instance fails, the failure will be detected by the host inspector that is running on the same host as the failed engine instance. For example, if engine instance 1204 fails, then instance inspector 1312 will detect the failure and cease to increment the health counter for engine instance 1204. Host inspector 1310 will see that the health counter for engine instance 1204 is not changing, and know that engine instance 1204 has failed. [0293] After the host inspector detects that an engine instance on its host has died, the host inspector sends a message to the surviving engine instances in the engine cluster informing them that a sibling engine instance has died. For example, if there are 100 hosts and there were 10 engine instances in the engine cluster and one engine instance dies, the host inspector would send 9 messages. The engine eviction message tells the other hosts to evict the failed engine instance from the engine instance cluster. According to one embodiment, the engine eviction messages are set using RDMA (the fast path), and the host inspector sending the engine eviction messages does not wait for the messages to be acknowledged. These peer-to-peer evict messages are therefore "unreliable".

[0294] In addition to sending the engine evict messages to the surviving engine instances, the host inspector that is running on the host of the failed engine instance also sends a message to the control cluster. However, unlike the engine eviction messages sent to the surviving engine instances, after sending the engine eviction message to the control cluster, the host inspector waits for an acknowledgement from the control cluster that the message was received.

[0295] Upon receipt of the engine instance eviction message, the control cluster records the engine instance eviction in a control catalog and broadcasts an eviction notification to all surviving members of the engine instance cluster. In contrast to the peer-to-peer evict messages, the evict messages from the control cluster (the slow path) are reliable. Thus, if all inter-host connections are functioning properly, each surviving engine instance will be informed of an engine instance eviction twice: once through RDMA from the host of the failed engine instance, and once through an eviction broadcast from the control cluster.

[0296] Upon being informed that an engine instance is to be evicted, the surviving engine instances update their engine instance cluster configuration information to evict the specified engine instance, adjust the slice hosting assignments to account for the removal of the failed engine instance, etc.

RESPONDING TO HOST FAILURES

[0297] When a host fails, the host assigned to neighbor-monitor that failed host will detect the failure by noticing that the health counters on the failed host are not advancing. For example, assume that the host monitoring ring is established as illustrated in FIG. 12. If host 1210 fails, the failure would be detected by the neighbor inspector on host 1200, which is currently assigned to neighbor- monitor host 1210. [0298] Upon detecting the failure of a host, the host that detected the failure sends a message to the control cluster to report the host failure. After reporting the host failure to the control cluster, the host that detected the failure will begin neighbor-monitoring the host that the failed host was neighbor-monitoring. Thus, upon reporting that host 1210 has failed, host 1200 will commence neighbor-monitoring host 1220 (the host previously monitored by the failed host 1210).

[0299] Upon receiving notification of a failed host, the control cluster initiates an investigation. According to one embodiment, the investigation proceeds in a hierarchical fashion. For example, if the failure was caused by a failed engine instance, then the host that is executing the failed engine instance may evict the engine instance locally. If local eviction of an engine instance solves the problem, then the host running the instance need not be evicted.

[0300] Referring to FIG. 14, illustrates a distributed database system that includes four hosts 1401, 1402, 1403 and 1404. For the purpose of illustration, it shall be assumed that the neighbor inspector on host 1403 detects a problem with host 1404. The problem may be that the host health counter of host 1404 has ceased to increment, or that host 1403 is unable to communicate with host 1404. Host 1403’s attempt to read the health counter of host 1404 is illustrated as (1), indicating that it is chronologically the first action illustrated in FIG. 14.

[0301] Upon detecting a problem with host 1404, the neighbor inspector on host 1403 determines who is the current leader in the control cluster 1450. In one embodiment, this may be accomplished using a RDMA of any of the control instances. In the illustrated example, the RDMA of a follower control instance (CI-F) is illustrated as (2).

[0302] Once the leader of the control cluster is identified, the neighbor inspector of host 1403 sends a host eviction alert to the control instance leader (CI-L). The transmission of the host eviction alert is illustrated as (3).

[0303] In response to receiving a host eviction alert, the control instance leader:

• determines an eviction list (4)

• sends a suspect notification to each of the surviving hosts (5)

• records the eviction list in a control catalog

• updates the state information that corresponds to the hosts that were evicted

• sends an eviction notification to each surviving host (6) [0304] In response to receiving the suspect notification, the engine instances. In response to receiving the eviction notification, the surviving engine instances.

DETERMINING AN EVICTION LIST

[0305] As explained above with reference to FIG. 14, when one or more hosts have failed, the leader of the control cluster determines which hosts are to be evicted from the host cluster. As a general rule, the leader attempts to keep in the host cluster the largest set of hosts that can communicate with each other. That set is referred to herein as the “largest-fully-connected-set of hosts”. The largest-fully-connected-set of hosts is determined based on the connectivity between the hosts, as shall now be described with reference to FIG. 15.

[0306] Referring to FIG. 15, it is a flowchart for determining the largest-fully-connected-set of hosts, according to one embodiment. At step 1502 it is determined whether the “local investigation” succeeded. The local investigation refers to the troubleshooting steps taken to recover a host. The local investigation may involve attempting to restart one or more components, for example. If the local investigation succeeds, then control passes to step 1550 where the problem is considered resolved and normal operation may proceed. If the local investigation fails, then control passes to step 1504.

[0307] At step 1504, a “focused investigation” is started. The focused investigation is to determine which engine instances need to be evicted from the host cluster. According to one embodiment, engine instances that do not belong to the largest-fully-connected-set of engine instances are evicted.

[0308] For the purpose of illustration, it shall be assumed that the focused investigation was triggered by a situation in which a host A is unable to communicate with a host B. In that scenario, at step 1508, host A determines whether it can reach the current leader of the control cluster. If host A cannot reach the current leader of the control cluster, then host A knows that it will be evicted. Thus, at step 1552, host A self-evicts. After self-eviction, host A ceases to process client requests for data until recovery is performed to add host A back into the host cluster.

[0309] If host A can reach the current leader of the control cluster, host A informs the current leader that it is unable to reach host B. At step 1510, the leader of the control cluster attempts to contact host B. If the leader cannot communicate with host B, then at step 1554 host B is added to the eviction list. [0310] If the leader can reach host B, then at step 1512 the leader determines whether hosts

A and B have access to the same network. If A and B do not have access to the same network, then control passes to step 1518 and a tie-breaking heuristic is used to determine which of A and B will be evicted. At step 1556, the loser is added to the eviction list.

[0311] If hosts A and B have access to the same network, then control passes to step 1514 where one or more other members of the control cluster are used to probe connections to hosts A and B. As a result of the probing performed by the one or more other members of the control cluster, the control cluster determines connectivity scores for hosts A and B. According to one embodiment, the connectivity score for host A reflects how members of the control cluster can communicate with host A, while the connectivity score for host B reflects how many members of the control cluster can communicate with host B.

[0312] At step 1516, it is determined whether the connectivity scores of hosts A and B are equal. If the connectivity scores are not equal, then the host with the lower connectivity score is considered the “loser”, and is added to the eviction list at step 1556. If the connectivity scores are equal, then a tie-breaking heuristic is used at step 1518 to determine the loser that is put on the eviction list at step 1556.

[0313] Steps 1552, 1554 and 1556 are followed by step 1558, where the eviction list is ready. Once ready, the eviction list is committed to the control catalog in step 1560, and at 1562 the eviction protocol is initiated.

RESPONDING TO OTHER TYPES OF FAILURES

[0314] Host and engine instance failures are not the only type of failure that can occur within the distributed database system. For example, software components, such as a host service (e.g. host inspector 1310) and instance service (e.g. engine instance 1204 or control instance 1202) may fail. When a software component fails, the system automatically attempts to restart the failed component.

[0315] If an engine instance dies (fails and cannot be restarted), the instance inspector for the engine instance, which is executing on the same host as the engine instance, detects the failure and reports the failure to the control cluster. For example, if engine instance 1204 dies, instance inspector 1312 reports to the control cluster that engine instance 1204 is dead. Reporting a dead engine instance in this manner is referred to as “unilateral reporting” since it does not involve a component on any host other than the host on which the failed engine instance was executing. In response to being informed that an engine instance has failed, the control cluster reconfigures the engine cluster in a manner that evicts the failed engine instance.

ENGINE INSTANCE EVICTION

[0316] An engine instance may need to be evicted from the engine cluster for a variety of reasons. For example, as explained above, the engine instance may need to be evicted because an instance inspector had detected that the engine instance has ceased doing useful work. An engine instance will also need to be evicted if the host on which the engine instance is executing fails (which may be detected through neighbor monitoring). Finally, an engine instance will need to be evicted if the host on which the engine instance is executing loses connection to the other hosts in the host cluster (e.g. because of a link or switch failure).

[0317] Evicting an engine instance involves reconfiguring the engine cluster in a manner that excludes the engine instance. Reconfiguring the engine cluster may involve:

• determining the primary duplicas that were managed by the evicted engine instance

• designating secondary duplicas of those primary duplicas as new primary duplicas

• creating new secondary duplicas to take the place of those secondary duplicas that were turned into primary duplicas

• updating the slice-to-host mapping to reflect the changes

CONTROL INSTANCE HEALTH MONITORING

[0318] By monitoring neighboring hosts in a host monitoring ring, as described above, it is possible to detect when a host fails. In one embodiment, a separate health monitoring mechanism is used to detect failure of control instances. Specifically, according to an embodiment, the control cluster uses a RAFT protocol to detect failures among its members. RAFT protocols are described in detail in “In Search of an Understandable Consensus Algorithm”, by Diego Ongaro and John Ousterhout, Standford University, which can be found at www.usenix.org/conference/atcl4/technical-sessions/presentat ion/ongaro, the content of which is incorporated herein by reference.

[0319] According to the RAFT protocol, at any given time there is a control instance that is designated the “leader instance”. However, the leader instance designation is temporary, and changes over time. In one embodiment, the leadership periods are of fixed duration. Once the leadership duration has elapsed with one leader, the leadership designation automatically passes to another leader. According to an embodiment, the sequence of leadership designation forms a ring that includes all control instances in the control cluster. Thus, each control instance has an equal “turn” at being the designated leader instance.

[0320] In one embodiment, to detect control instance failure, the leader instance sends heartbeat messages to all other control instances, and all other control instances send heartbeat messages back to the leader instance. Failure to receive a heartbeat message within a threshold period of time indicates that the control instance from which the heartbeat was not received is not operating correctly. Thus, the leader instance is able to detect when any other control instance (the “follower instances”) fails, and all follower instances are able to detect when the leader instance fails.

[0321] In an alternative embodiment, the control cluster may use health counters and RDMA to detect failures in a manner similar to the host cluster. Specifically, rather than the leader instance sending heartbeat messages to all follower instances, the leader instance may increment a health counter and the follower instances may check the leader instance’s health counter using RDMA. Similarly, rather than the follower instances sending heartbeat messages to the leader instance, the follower instances may update local health counters and the leader instance may use RDMA to check that the respective health counters of the follower instances are advancing. HANDLING CONTROL INSTANCE FAILURE

[0322] If a control instance misses a heartbeat from the leader instance, then a HAMI election is initiated to determine a new leader. In contrast, when a HAMI follower stops responding to the HAMI leader’s requests, the HAMI follower continues to be treated as part of the HAMI ensemble.

[0323] When an update request is received by the HAMI leader, the following events occur:

• the leader attempts to persist the request on a quorum of the members (including itself)

• once the quorum is achieved, the update request commits, even if a follower is not responding

• the leader will continue to ship log records, asynchronously, to any non-responding follower

[0324] Asynchronous requests sent to non-responding followers will not have any impact on the latency of update requests as long as a quorum can be achieved.

[0325] Whenever a follower that has been removed from the ensemble is able to join the ensemble again (after a restart or network partition repair, etc.), the follower will start receiving the log records (or a snapshot of the log records) to catch up. In addition, control instances can be added to or removed from the control cluster through an administrative action.

HARDWARE OVERVIEW

[0326] According to one embodiment, the techniques described herein are implemented by one or more special-purpose computing devices. The special-purpose computing devices may be hard-wired to perform the techniques, or may include digital electronic devices such as one or more application-specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs) that are persistently programmed to perform the techniques, or may include one or more general purpose hardware processors programmed to perform the techniques pursuant to program instructions in firmware, memory, other storage, or a combination. Such special-purpose computing devices may also combine custom hard-wired logic, ASICs, or FPGAs with custom programming to accomplish the techniques. The special-purpose computing devices may be desktop computer systems, portable computer systems, handheld devices, networking devices or any other device that incorporates hard-wired and/or program logic to implement the techniques. [0327] For example, FIG. 11 is a block diagram that illustrates a computer system 1100 upon which an embodiment of the invention may be implemented. Computer system 1100 includes a bus 1102 or other communication mechanism for communicating information, and a hardware processor 1104 coupled with bus 1102 for processing information. Hardware processor 1104 may be, for example, a general purpose microprocessor.

[0328] Computer system 1100 also includes a main memory 1106, such as a random access memory (RAM) or other dynamic storage device, coupled to bus 1102 for storing information and instructions to be executed by processor 1104. Main memory 1106 also may be used for storing temporary variables or other intermediate information during execution of instructions to be executed by processor 1104. Such instructions, when stored in non-transitory storage media accessible to processor 1104, render computer system 1100 into a special-purpose machine that is customized to perform the operations specified in the instructions.

[0329] Computer system 1100 further includes a read only memory (ROM) 1108 or other static storage device coupled to bus 1102 for storing static information and instructions for processor 1104. A storage device 1110, such as a magnetic disk, optical disk, or solid-state drive is provided and coupled to bus 1102 for storing information and instructions. [0330] Computer system 1100 may be coupled via bus 1102 to a display 1112, such as a cathode ray tube (CRT), for displaying information to a computer user. An input device 1114, including alphanumeric and other keys, is coupled to bus 1102 for communicating information and command selections to processor 1104. Another type of user input device is cursor control 1116, such as a mouse, a trackball, or cursor direction keys for communicating direction information and command selections to processor 1104 and for controlling cursor movement on display 1112. This input device typically has two degrees of freedom in two axes, a first axis (e.g., x) and a second axis (e.g., y), that allows the device to specify positions in a plane.

[0331] Computer system 1100 may implement the techniques described herein using customized hard-wired logic, one or more ASICs or FPGAs, firmware and/or program logic which in combination with the computer system causes or programs computer system 1100 to be a special-purpose machine. According to one embodiment, the techniques herein are performed by computer system 1100 in response to processor 1104 executing one or more sequences of one or more instructions contained in main memory 1106. Such instructions may be read into main memory 1106 from another storage medium, such as storage device 1110. Execution of the sequences of instructions contained in main memory 1106 causes processor 1104 to perform the process steps described herein. In alternative embodiments, hard-wired circuitry may be used in place of or in combination with software instructions.

[0332] The term “storage media” as used herein refers to any non-transitory media that store data and/or instructions that cause a machine to operate in a specific fashion. Such storage media may comprise non-volatile media and/or volatile media. Non-volatile media includes, for example, optical disks, magnetic disks, or solid-state drives, such as storage device 1110. Volatile media includes dynamic memory, such as main memory 1106. Common forms of storage media include, for example, a floppy disk, a flexible disk, hard disk, solid-state drive, magnetic tape, or any other magnetic data storage medium, a CD-ROM, any other optical data storage medium, any physical medium with patterns of holes, a RAM, a PROM, and EPROM, a FLASH-EPROM, NVRAM, any other memory chip or cartridge.

[0333] Storage media is distinct from but may be used in conjunction with transmission media. Transmission media participates in transferring information between storage media. For example, transmission media includes coaxial cables, copper wire and fiber optics, including the wires that comprise bus 1102. Transmission media can also take the form of acoustic or light waves, such as those generated during radio- wave and infra-red data communications.

[0334] Various forms of media may be involved in carrying one or more sequences of one or more instructions to processor 1104 for execution. For example, the instructions may initially be carried on a magnetic disk or solid-state drive of a remote computer. The remote computer can load the instructions into its dynamic memory and send the instructions over a telephone line using a modem. A modem local to computer system 1100 can receive the data on the telephone line and use an infra-red transmitter to convert the data to an infra-red signal. An infra-red detector can receive the data carried in the infra-red signal and appropriate circuitry can place the data on bus 1102. Bus 1102 carries the data to main memory 1106, from which processor 1104 retrieves and executes the instructions. The instructions received by main memory 1106 may optionally be stored on storage device 1110 either before or after execution by processor 1104. [0335] Computer system 1100 also includes a communication interface 1118 coupled to bus 1102. Communication interface 1118 provides a two-way data communication coupling to a network link 1120 that is connected to a local network 1122. For example, communication interface 1118 may be an integrated services digital network (ISDN) card, cable modem, satellite modem, or a modem to provide a data communication connection to a corresponding type of telephone line. As another example, communication interface 1118 may be a local area network (LAN) card to provide a data communication connection to a compatible LAN. Wireless links may also be implemented. In any such implementation, communication interface 1118 sends and receives electrical, electromagnetic or optical signals that carry digital data streams representing various types of information.

[0336] Network link 1120 typically provides data communication through one or more networks to other data devices. For example, network link 1120 may provide a connection through local network 1122 to a host computer 1124 or to data equipment operated by an Internet Service Provider (ISP) 1126. ISP 1126 in turn provides data communication services through the world wide packet data communication network now commonly referred to as the “Internet” 1128. Local network 1122 and Internet 1128 both use electrical, electromagnetic or optical signals that carry digital data streams. The signals through the various networks and the signals on network link 1120 and through communication interface 1118, which carry the digital data to and from computer system 1100, are example forms of transmission media. [0337] Computer system 1100 can send messages and receive data, including program code, through the network(s), network link 1120 and communication interface 1118. In the Internet example, a server 1130 might transmit a requested code for an application program through Internet 1128, ISP 1126, local network 1122 and communication interface 1118.

[0338] The received code may be executed by processor 1104 as it is received, and/or stored in storage device 1110, or other non-volatile storage for later execution.

CLOUD COMPUTING

[0339] The term "cloud computing" is generally used herein to describe a computing model which enables on-demand access to a shared pool of computing resources, such as computer networks, servers, software applications, and services, and which allows for rapid provisioning and release of resources with minimal management effort or service provider interaction.

[0340] A cloud computing environment (sometimes referred to as a cloud environment, or a cloud) can be implemented in a variety of different ways to best suit different requirements. For example, in a public cloud environment, the underlying computing infrastructure is owned by an organization that makes its cloud services available to other organizations or to the general public. In contrast, a private cloud environment is generally intended solely for use by, or within, a single organization. A community cloud is intended to be shared by several organizations within a community; while a hybrid cloud comprises two or more types of cloud (e.g., private, community, or public) that are bound together by data and application portability.

[0341] Generally, a cloud computing model enables some of those responsibilities which previously may have been provided by an organization's own information technology department, to instead be delivered as service layers within a cloud environment, for use by consumers (either within or external to the organization, according to the cloud's public/private nature). Depending on the particular implementation, the precise definition of components or features provided by or within each cloud service layer can vary, but common examples include: Software as a Service (SaaS), in which consumers use software applications that are running upon a cloud infrastructure, while a SaaS provider manages or controls the underlying cloud infrastructure and applications. Platform as a Service (PaaS), in which consumers can use software programming languages and development tools supported by a PaaS provider to develop, deploy, and otherwise control their own applications, while the PaaS provider manages or controls other aspects of the cloud environment (i.e., everything below the run-time execution environment). Infrastructure as a Service (laaS), in which consumers can deploy and run arbitrary software applications, and/or provision processing, storage, networks, and other fundamental computing resources, while an laaS provider manages or controls the underlying physical cloud infrastructure (i.e., everything below the operating system layer). Database as a Service (DBaaS) in which consumers use a database server or Database Management System that is running upon a cloud infrastructure, while a DbaaS provider manages or controls the underlying cloud infrastructure, applications, and servers, including one or more database servers.

[0342] In the foregoing specification, embodiments of the invention have been described with reference to numerous specific details that may vary from implementation to implementation. The specification and drawings are, accordingly, to be regarded in an illustrative rather than a restrictive sense. The sole and exclusive indicator of the scope of the invention, and what is intended by the applicants to be the scope of the invention, is the literal and equivalent scope of the set of claims that issue from this application, in the specific form in which such claims issue, including any subsequent correction.