Selective forwarding for multi-statement database transactions

Transaction statements may be forwarded for a database transaction. A transaction begun at a read-only node may include a write statement. The read-only node may forward the write statement to the read-only node to perform as a transaction. The read-only node may update a read view for the transaction to include the write statement before performing a read statement submitted after the write statement at the read-only node.

BACKGROUND

Database systems support various kinds of systems, services, and applications. Efficient utilization of a database can include fully leveraging the capabilities of each database system component in order to provide fast and efficient database system operations. In turn, fast and efficient database system operations can improve the performance of the systems, services, or applications that rely upon the database.

While embodiments are described herein by way of example for several embodiments and illustrative drawings, those skilled in the art will recognize that the embodiments are not limited to the embodiments or drawings described. It should be understood, that the drawings and detailed description thereto are not intended to limit embodiments to the particular form disclosed, but on the contrary, the intention is to cover all modifications, equivalents and alternatives falling within the spirit and scope as defined by the appended claims. The headings used herein are for organizational purposes only and are not meant to be used to limit the scope of the description or the claims. As used throughout this application, the word “may” is used in a permissive sense (i.e., meaning having the potential to), rather than the mandatory sense (i.e., meaning must). The words “include,” “including,” and “includes” indicate open-ended relationships and therefore mean including, but not limited to. Similarly, the words “have,” “having,” and “has” also indicate open-ended relationships, and thus mean having, but not limited to. The terms “first,” “second,” “third,” and so forth as used herein are used as labels for nouns that they precede, and do not imply any type of ordering (e.g., spatial, temporal, logical, etc.) unless such an ordering is otherwise explicitly indicated.

DETAILED DESCRIPTION OF EMBODIMENTS

Techniques for selective forwarding for multi-statement database transactions are described herein. In various embodiments, database systems may divide the workload for performing different requests between different database system components. For example, a database system may implement multiple nodes to serve requests for the database, such as requests that perform reads to a database and writes to the database, and nodes that perform reads alone. In this way, a database system can maintain consistency for the database by implementing a single writer to the database, while allowing for other portions of the workload to be distributed to read-only nodes. However, in order to take advantage of this division, client services, systems, or applications of the database may have to divide up their workload to ensure that requests are sent to the component (e.g., the read-only node or read-write node) that can support the desired request (e.g., writes may be to the read-write node, but reads can go to either).

In various embodiments, selective forwarding for multi-statement database transactions may be implemented to remove the burden of dividing up workloads between different node types. For example, selective forwarding for multi-statement database transactions may allow read-only nodes to support both read and write requests through transactions, similar to a read-only node. Instead of sacrificing consistency, a read view for the transaction may be updated to ensure that read after write consistency within a transaction is maintained. In this way, selective forwarding for multi-statement database transactions can improve the performance of client systems, services, and applications because workloads do not have to be divided by type. Instead, workloads can be directed to database system nodes as needed (e.g., read-only nodes can be added to a database system to expand the read and write processing capacity for a client service, system, or application. Moreover, greater utilization of read-only nodes can be realized by a database system, leading to increased performance of a database system overall.

FIG.1is a logical block diagram illustrating selective forwarding for multi-statement database transactions, according to some embodiments. Database system110may be a database system implemented using multiple different nodes, such as read-only nodes130and read-write node120, to access data stored in a database on behalf of client systems, services, or applications, such as database data140. Database system110can be various types of database system that implement read-only and read-write nodes, including various types of relational, non-relational, or other types of database (e.g., graph, time-series, etc.) that offer different consistency levels that can be automatically managed for read requests when forwarding write requests.

Read-write node120may accept both read requests126(e.g., queries, gets, scans, or other requests that cause a read of database140) and write requests124(e.g., insert, update, delete, put, store, modify, or other requests that cause a write to database data140). The requests may be submitted via a read/write session that supports both types of requests and is established with a client service, system, or application of database system110.

Database system110may also implement read-only nodes, such as read-only node130. Read-only node130may be able to perform read requests by accessing a local copy, cache or replica of database data140. In some embodiments, as discussed below with regard toFIGS.2and3, database data140may be stored in shared storage that may be accessible for reads by read-only nodes130directly (if not for writes). To increase utilization of read-only nodes130and remove the burden of dividing client system, service, or applications between the different types of nodes, read-only nodes130may support transactions, such as transaction160, to allow for both read statements and write statements of a transaction to be submitted to read-only node130. For those statements that cannot be performed by the read-only node directly (e.g., write statements), read-only node130may forward the write statements. In some embodiments, however, read-only node130may forward statements (e.g., read statements) that read-only node can perform.

For example, as illustrated in scene102, client150of database system110may submit a transaction160to read-only node130. Transaction160may include a read statement (e.g., a stated read request to perform)162. Read-only node130can perform the read statement162using a read view132defined for database data140.

As illustrated in scene104, client150may then submit a write statement166as part of transaction160. Write statement166may sent, as indicated at122to read-write node120to be performed124with respect to database data140. Read-write node120may acknowledge the write126. Read-only node130may update its read view132to include the change made by the write statement166, in some embodiments.

As illustrated in scene106, client150may submit another read statement168as part of transaction160. Read only node130can use read view132updated to include write statement166in order to provide read response169. In this way, read response169will have correct read after write consistency within transaction160.

Please note,FIG.1is provided as a logical illustration of database systems, storage, database data, read-only nodes, and read-write nodes, and is not intended to be limiting as to the physical arrangement, size, or number of components, modules, or devices to implement such features.

The specification first describes an example network-based database service that performs selective forwarding for multi-statement database transactions. Included in the description of the example network-based database service are various aspects of the example network-based database service, such as a primary node, read replica node, and a separate storage service. The specification then describes flowcharts of various embodiments of methods for implementing selective forwarding for multi-statement database transactions. Next, the specification describes an example system that may implement the disclosed techniques. Various examples are provided throughout the specification.

FIG.2is a block diagram illustrating a provider network that may implement a database service that implements selective forwarding for multi-statement database transactions, according to some embodiments. A provider network, such as provider network200, may be a private or closed system or may be set up by an entity such as a company or a public sector organization to provide one or more services (such as various types of cloud-based storage) accessible via the Internet and/or other networks to clients250, in some embodiments. The provider network200may be implemented in a single location or may include numerous provider network regions that may include one or more data centers hosting various resource pools, such as collections of physical and/or virtualized computer servers, storage devices, networking equipment and the like (e.g., computing system1000described below with regard toFIG.9), needed to implement and distribute the infrastructure and storage services offered by the provider network within the provider network regions.

In the illustrated embodiment, a number of clients (shown as clients250may interact with a provider network200via a network260. Provider network200may implement respective instantiations of the same (or different) services, a database services210, a storage service220and/or one or more other virtual computing service230across multiple provider network regions, in some embodiments. It is noted that where one or more instances of a given component may exist, reference to that component herein may be made in either the singular or the plural. However, usage of either form is not intended to preclude the other.

In various embodiments, the components illustrated inFIG.2may be implemented directly within computer hardware, as instructions directly or indirectly executable by computer hardware (e.g., a microprocessor or computer system), or using a combination of these techniques. For example, the components ofFIG.2may be implemented by a system that includes a number of computing nodes (or simply, nodes), each of which may be similar to the computer system embodiment illustrated inFIG.9and described below. In various embodiments, the functionality of a given service system component (e.g., a component of the database service or a component of the storage service) may be implemented by a particular node or may be distributed across several nodes. In some embodiments, a given node may implement the functionality of more than one service system component (e.g., more than one database service system component).

Generally speaking, clients250may encompass any type of client configurable to submit network-based services requests to provider network region200via network260, including requests for database services. For example, a given client250may include a suitable version of a web browser, or may include a plug-in module or other type of code module may execute as an extension to or within an execution environment provided by a web browser. Alternatively, a client250(e.g., a database service client) may encompass an application such as a database application (or user interface thereof), a media application, an office application or any other application that may make use of persistent storage resources to store and/or access one or more database tables. In some embodiments, such an application may include sufficient protocol support (e.g., for a suitable version of Hypertext Transfer Protocol (HTTP)) for generating and processing network-based services requests without necessarily implementing full browser support for all types of network-based data. That is, client250may be an application may interact directly with provider network200. In some embodiments, client250may generate network-based services requests according to a Representational State Transfer (REST)-style web services architecture, a document- or message-based network-based services architecture, or another suitable network-based services architecture. Although not illustrated, some clients of provider network200services may be implemented within provider network200(e.g., a client application of database service210implemented on one of other virtual computing service(s)230), in some embodiments. Therefore, various examples of the interactions discussed with regard to clients250may be implemented for internal clients as well, in some embodiments.

In some embodiments, a client250(e.g., a database service client) may be may provide access to network-based storage of database tables to other applications in a manner that is transparent to those applications. For example, client250may be may integrate with an operating system or file system to provide storage in accordance with a suitable variant of the storage models described herein. However, the operating system or file system may present a different storage interface to applications, such as a conventional file system hierarchy of files, directories and/or folders. In such an embodiment, applications may not need to be modified to make use of the storage system service model, as described above. Instead, the details of interfacing to provider network200may be coordinated by client250and the operating system or file system on behalf of applications executing within the operating system environment.

Clients250may convey network-based services requests to and receive responses from provider network200via network260. In various embodiments, network260may encompass any suitable combination of networking hardware and protocols necessary to establish network-based communications between clients250and provider network200. For example, network260may generally encompass the various telecommunications networks and service providers that collectively implement the Internet. Network260may also include private networks such as local area networks (LANs) or wide area networks (WANs) as well as public or private wireless networks. For example, both a given client250and provider network200may be respectively provisioned within enterprises having their own internal networks. In such an embodiment, network260may include the hardware (e.g., modems, routers, switches, load balancers, proxy servers, etc.) and software (e.g., protocol stacks, accounting software, firewall/security software, etc.) necessary to establish a networking link between given client250and the Internet as well as between the Internet and provider network200. It is noted that in some embodiments, clients250may communicate with provider network200using a private network rather than the public Internet. For example, clients250may be provisioned within the same enterprise as a database service system (e.g., a system that implements database service210and/or storage service220). In such a case, clients250may communicate with provider network200entirely through a private network260(e.g., a LAN or WAN that may use Internet-based communication protocols but which is not publicly accessible).

Generally speaking, provider network200may implement one or more service endpoints may receive and process network-based services requests, such as requests to perform queries. For example, provider network200may include hardware and/or software may implement a particular endpoint, such that an HTTP-based network-based services request directed to that endpoint is properly received and processed. In one embodiment, provider network200may be implemented as a server system may receive network-based services requests from clients250and to forward them to components of a system that implements database service210, storage service220and/or another virtual computing service230for processing. In other embodiments, provider network200may be configured as a number of distinct systems (e.g., in a cluster topology) implementing load balancing and other request management features may dynamically manage large-scale network-based services request processing loads. In various embodiments, provider network200may be may support REST-style or document-based (e.g., SOAP-based) types of network-based services requests.

In addition to functioning as an addressable endpoint for clients' network-based services requests, in some embodiments, provider network200may implement various client management features. For example, provider network200may coordinate the metering and accounting of client usage of network-based services, including storage resources, such as by tracking the identities of requesting clients250, the number and/or frequency of client requests, the size of data tables (or records thereof) stored or retrieved on behalf of clients250, overall storage bandwidth used by clients250, class of storage requested by clients250, or any other measurable client usage parameter. Provider network200may also implement financial accounting and billing systems, or may maintain a database of usage data that may be queried and processed by external systems for reporting and billing of client usage activity. In certain embodiments, provider network200may collect, monitor and/or aggregate a variety of storage service system operational metrics, such as metrics reflecting the rates and types of requests received from clients250, bandwidth utilized by such requests, system processing latency for such requests, system component utilization (e.g., network bandwidth and/or storage utilization within the storage service system), rates and types of errors resulting from requests, characteristics of stored and requested data pages or records thereof (e.g., size, data type, etc.), or any other suitable metrics. In some embodiments such metrics may be used by system administrators to tune and maintain system components, while in other embodiments such metrics (or relevant portions of such metrics) may be exposed to clients250to enable such clients to monitor their usage of database service210, storage service220and/or another virtual computing service230(or the underlying systems that implement those services).

In some embodiments, provider network200may also implement user authentication and access control procedures. For example, for a given network-based services request to access a particular database table, provider network200ascertain whether the client250associated with the request is authorized to access the particular database table. Provider network200may determine such authorization by, for example, evaluating an identity, password or other credential against credentials associated with the particular database table, or evaluating the requested access to the particular database table against an access control list for the particular database table. For example, if a client250does not have sufficient credentials to access the particular database table, provider network200may reject the corresponding network-based services request, for example by returning a response to the requesting client250indicating an error condition. Various access control policies may be stored as records or lists of access control information by database service210, storage service220and/or other virtual computing services230.

Note that in many of the examples described herein, services, like database service210or storage service220may be internal to a computing system or an enterprise system that provides database services to clients250, and may not be exposed to external clients (e.g., users or client applications). In such embodiments, the internal “client” (e.g., database service210) may access storage service220over a local or private network (e.g., through an API directly between the systems that implement these services). In such embodiments, the use of storage service220in storing database tables on behalf of clients250may be transparent to those clients. In other embodiments, storage service220may be exposed to clients250through provider network region200to provide storage of database tables or other information for applications other than those that rely on database service210for database management. In such embodiments, clients of the storage service220may access storage service220via network260(e.g., over the Internet). In some embodiments, a virtual computing service230may receive or use data from storage service220(e.g., through an API directly between the virtual computing service230and storage service220) to store objects used in performing computing services230on behalf of a client250. In some cases, the accounting and/or credentialing services of provider network region200may be unnecessary for internal clients such as administrative clients or between service components within the same enterprise.

Note that in various embodiments, different storage policies may be implemented by database service210and/or storage service220. Examples of such storage policies may include a durability policy (e.g., a policy indicating the number of instances of a database table (or data page thereof, such as a quorum-based policy) that will be stored and the number of different nodes on which they will be stored) and/or a load balancing policy (which may distribute database tables, or data pages thereof, across different nodes, volumes and/or disks in an attempt to equalize request traffic). In addition, different storage policies may be applied to different types of stored items by various one of the services. For example, in some embodiments, storage service220may implement a higher durability for redo log records than for data pages.

FIG.3is a block diagram illustrating various components of a database service and storage service that implement selective forwarding for multi-statement database transactions, according to some embodiments. Database service210may implement control plane340which may manage the creation, provisioning, deletion, or other features of managing a database hosted in database service210.

Database service210may implement one or more different types of database systems with respective types of query engines for accessing database data as part of the database. In the example database system implemented as part of database service210, a primary node310may be implemented for each of several databases and a log-structured storage service350(which may or may not be visible to the clients of the database system). Clients of a database may access a primary node310(which may be implemented in or representative of a database instance) via network utilizing various database access protocols (e.g., Java Database Connectivity (JDBC) or Open Database Connectivity (ODBC)). However, log-structured storage service350, which may be employed by the database system to store data pages of one or more databases (and redo log records and/or other metadata associated therewith) on behalf of clients, and to perform other functions of the database system as described herein, may or may not be network-addressable and accessible to database clients directly, in different embodiments. For example, in some embodiments, log-structured storage service350may perform various storage, access, change logging, recovery, log record manipulation, and/or space management operations in a manner that is invisible to clients of a primary node310.

As previously noted, a database instance may include a primary node310that implements a query engine320that receives requests, like request312, which may include queries or other requests such as updates, deletions, etc., from various client programs (e.g., applications) and/or subscribers (users), then parses them, optimizes them, and develops a plan to carry out the associated database operation(s). Query engine320may return a response314to the request (e.g., results to a query) to a database client, which may include write acknowledgements, requested data pages (or portions thereof), error messages, and or other responses, as appropriate. As illustrated in this example, primary node310may also include a storage service engine330(or client-side driver), which may route read requests and/or redo log records to various storage nodes within log-structured storage service350, receive write acknowledgements from log-structured storage service350, receive requested data pages from log-structured storage service350, and/or return data pages, error messages, or other responses to query engine320(which may, in turn, return them to a database client).

In this example, query engine320or another database system management component implemented at primary node310(not illustrated) may manage a data page cache, in which data pages that were recently accessed may be temporarily held. Query engine320may be responsible for providing transactionality and consistency in the database instance of which primary node310is a component. For example, this component may be responsible for ensuring the Atomicity, Consistency, and Isolation properties of the database instance and the transactions that are directed that the database instance, such as determining a consistent view of the database applicable for a query, applying undo log records to generate prior versions of tuples of a database. Query engine320may manage an undo log to track the status of various transactions and roll back any locally cached results of transactions that do not commit.

For example, a request312that includes a request to write to a page may be parsed and optimized to generate one or more write record requests321, which may be sent to storage service engine330for subsequent routing to log-structured storage service350. In this example, storage service engine330may generate one or more redo log records335corresponding to each write record request321, and may send them to specific ones of the storage nodes360of log-structured storage service350. Log-structured storage service350may return a corresponding write acknowledgement337for each redo log record335(or batch of redo log records) to primary node310(specifically to storage service engine330). Storage service engine330may pass these write acknowledgements to query engine320(as write responses323), which may then send corresponding responses (e.g., write acknowledgements) to one or more clients as a response314.

In another example, a request that is a query may cause data pages to be read and returned to query engine320for evaluation and processing or a request to perform query processing at log-structured storage service350may be performed. For example, a query could cause one or more read record requests325, which may be sent to storage service engine330for subsequent routing to log-structured storage service350. In this example, storage service engine330may send these requests to specific ones of the storage nodes360of log-structured storage service350, and log-structured storage service350may return the requested data pages339to primary node310(specifically to storage service engine330). Storage service engine330may send the returned data pages to query engine320as return data records327, and query engine may then evaluate the content of the data pages in order to determine or generate a result of a query sent as a response314.

In some embodiments, various error and/or data loss messages341may be sent from log-structured storage service350to primary node310(specifically to storage service engine330). These messages may be passed from storage service engine330to query engine320as error and/or loss reporting messages329, and then to one or more clients as a response314.

In some embodiments, the APIs335-3339of log-structured storage service350and the APIs321-329of storage service engine330may expose the functionality of the log-structured storage service350to primary node310as if primary node310were a client of log-structured storage service350. For example, primary node310(through storage service engine330) may write redo log records or request data pages through these APIs to perform (or facilitate the performance of) various operations of the database system implemented by the combination of primary node310and log-structured storage service350(e.g., storage, access, change logging, recovery, and/or space management operations).

Note that in various embodiments, the API calls and responses between primary node310and log-structured storage service350(e.g., APIs321-329) and/or the API calls and responses between storage service engine330and query engine320(e.g., APIs335-339) inFIG.3may be performed over a secure proxy connection (e.g., one managed by a gateway control plane), or may be performed over the public network or, alternatively, over a private channel such as a virtual private network (VPN) connection. These and other APIs to and/or between components of the database systems described herein may be implemented according to different technologies, including, but not limited to, Simple Object Access Protocol (SOAP) technology and Representational state transfer (REST) technology. For example, these APIs may be, but are not necessarily, implemented as SOAP APIs or RESTful APIs. SOAP is a protocol for exchanging information in the context of Web-based services. REST is an architectural style for distributed hypermedia systems. A RESTful API (which may also be referred to as a RESTful web service) is a web service API implemented using HTTP and REST technology. The APIs described herein may in some embodiments be wrapped with client libraries in various languages, including, but not limited to, C, C++, Java, C# and Perl to support integration with primary node310and/or log-structured storage service350.

Database service210may also implement read replica nodes370for a database hosted by database service210. Read replica nodes370may implement similar components to those of primary nodes310, such as a query engine and storage service engine, which may be used to handle respective requests316and responses318received at a read replica. As discussed above with regard toFIG.1and below with regard toFIGS.4-8, these read replicas, which may be a read-only node, may support both read and write requests to a database. Transaction handling372may be performed utilizing a primary node310, as discussed in detail below. Read handling374may be performed by accessing local database caches or replicated data, which may be updated from updates received from primary node(s)310and/or by reading data from log-structured storage service, in some embodiments.

In some embodiments, database data for a database of database service210may be organized in various logical volumes, segments, and pages for storage on one or more storage nodes360of log-structured storage service350. For example, in some embodiments, each database may be represented by a logical volume, and each logical volume may be segmented over a collection of storage nodes360. Each segment, which may live on a particular one of the storage nodes, may contain a set of contiguous block addresses, in some embodiments. In some embodiments, each segment may store a collection of one or more data pages and a change log (also referred to as a redo log) (e.g., a log of redo log records) for each data page that it stores. Storage nodes360may receive redo log records and to coalesce them to create new versions of the corresponding data pages and/or additional or replacement log records (e.g., lazily and/or in response to a request for a data page or a database crash). In some embodiments, data pages and/or change logs may be mirrored across multiple storage nodes, according to a variable configuration (which may be specified by the client on whose behalf the databases is being maintained in the database system). For example, in different embodiments, one, two, or three copies of the data or change logs may be stored in each of one, two, or three different availability zones or regions, according to a default configuration, an application-specific durability preference, or a client-specified durability preference.

In some embodiments, a volume may be a logical concept representing a highly durable unit of storage that a user/client/application of the storage system understands. A volume may be a distributed store that appears to the user/client/application as a single consistent ordered log of write operations to various user pages of a database, in some embodiments. Each write operation may be encoded in a log record (e.g., a redo log record), which may represent a logical, ordered mutation to the contents of a single user page within the volume, in some embodiments. Each log record may include a unique identifier (e.g., a Logical Sequence Number (LSN)), in some embodiments. Each log record may be persisted to one or more synchronous segments in the distributed store that form a Protection Group (PG), to provide high durability and availability for the log record, in some embodiments. A volume may provide an LSN-type read/write interface for a variable-size contiguous range of bytes, in some embodiments.

In some embodiments, a volume may consist of multiple extents, each made durable through a protection group. In such embodiments, a volume may represent a unit of storage composed of a mutable contiguous sequence of volume extents. Reads and writes that are directed to a volume may be mapped into corresponding reads and writes to the constituent volume extents. In some embodiments, the size of a volume may be changed by adding or removing volume extents from the end of the volume.

In some embodiments, a segment may be a limited-durability unit of storage assigned to a single storage node. A segment may provide a limited best-effort durability (e.g., a persistent, but non-redundant single point of failure that is a storage node) for a specific fixed-size byte range of data, in some embodiments. This data may in some cases be a mirror of user-addressable data, or it may be other data, such as volume metadata or erasure coded bits, in various embodiments. A given segment may live on exactly one storage node, in some embodiments. Within a storage node, multiple segments may live on each storage device (e.g., an SSD), and each segment may be restricted to one SSD (e.g., a segment may not span across multiple SSDs), in some embodiments. In some embodiments, a segment may not be required to occupy a contiguous region on an SSD; rather there may be an allocation map in each SSD describing the areas that are owned by each of the segments. As noted above, a protection group may consist of multiple segments spread across multiple storage nodes, in some embodiments. In some embodiments, a segment may provide an LSN-type read/write interface for a fixed-size contiguous range of bytes (where the size is defined at creation). In some embodiments, each segment may be identified by a segment UUID (e.g., a universally unique identifier of the segment).

In some embodiments, a page may be a block of storage, generally of fixed size. In some embodiments, each page may be a block of storage (e.g., of virtual memory, disk, or other physical memory) of a size defined by the operating system, and may also be referred to herein by the term “data block”. A page may be a set of contiguous sectors, in some embodiments. A page may serve as the unit of allocation in storage devices, as well as the unit in log pages for which there is a header and metadata, in some embodiments. In some embodiments, the term “page” or “storage page” may be a similar block of a size defined by the database configuration, which may typically a multiple of 2, such as 4096, 8192, 16384, or 32768 bytes.

As discussed above, log-structured storage service350may perform some database system responsibilities, such as the updating of data pages for a database, and in some instances perform some query processing on data. As illustrated inFIG.3, storage node(s)360may implement data page request processing361, and data management365to implement various ones of these features with regard to the data pages367and page log369of redo log records among other database data in a database volume stored in log-structured storage service. For example, data management365may perform at least a portion of any or all of the following operations: replication (locally, e.g., within the storage node), coalescing of redo logs to generate data pages, snapshots (e.g., creating, restoration, deletion, etc.), clone volume creation, as discussed in detail with regard toFIGS.4and5, log management (e.g., manipulating log records), crash recovery, and/or space management (e.g., for a segment). Each storage node may also have multiple attached storage devices (e.g., SSDs) on which data blocks may be stored on behalf of clients (e.g., users, client applications, and/or database service subscribers), in some embodiments. Data page request processing361may handle requests to return data pages of records from a database volume, and may perform operations to coalesce redo log records or otherwise generate a data pages to be returned responsive to a request.

In at least some embodiments, storage nodes360may provide multi-tenant storage so that data stored in part or all of one storage device may be stored for a different database, database user, account, or entity than data stored on the same storage device (or other storage devices) attached to the same storage node. Various access controls and security mechanisms may be implemented, in some embodiments, to ensure that data is not accessed at a storage node except for authorized requests (e.g., for users authorized to access the database, owners of the database, etc.).

In various embodiments, transaction forwarding for read-only nodes may be enabled or disabled for a database by a request (e.g., via an API, console, command line interface). In some embodiments, an active database may be changed to allow for transaction forwarding, while in other embodiments transaction forwarding may be enabled (or not selected, at the time of database creation. If transaction forwarding is not enabled, then a transaction request may be met with an error response or other indication that the transaction is not supported when received at a read replica, in some embodiments.

FIG.4is a block diagram illustrating interactions to perform a multi-statement transaction forwarding, according to some embodiments. For example, read replica node410may receive a request to begin a transaction, as indicated at432. Read replica node410may open a transaction forwarding session434with primary node420. Read replica node410may then receive a read statement436(e.g., a “select” statement). Read statement436may cause read replica node to create a read view for the database at read replica node410(in other scenarios a write statement (e.g., an “insert” statement) may be received first and thus may cause a read view to be generated). A response to the read, as indicated at438, may be returned using the read view, in some embodiments.

As indicated at440, a write statement may be received at read replica node410. Write statement440may be sent by read replica node410, as indicated at442, to primary node420, in some embodiments. The write statement may be sent as a transaction to primary node420, which may perform the transaction. Primary node420may send a response to acknowledge the write statement, transaction identifier, and statement logical sequence number (LSN), in some embodiments.

As indicated at446, another read statement may be received. In order to ensure that the read view includes the prior write (440), read replica node410may wait to return a read response until an update to database data at the read replica includes the write statement, as indicated at448. The LSN values in the updates sent from primary node420to read replica410may indicate whether the prior write is included by comparing the LSN value of the prior write (received with the acknowledgement444) with the LSN in the updates. As indicated at450, a read response may be sent after the read view can be updated to include prior write440.

As indicated at452, a request to commit a transaction may be received. Read replica410may send a request to commit the transaction454to primary node420. Primary node420may acknowledge the commit (or fail the transaction), as indicated at456. Read replica node410may then commit the transaction, as indicated at457(e.g., update a transaction table or other information to indicate commitment) and acknowledge the transaction as committed, as indicated at458.

FIG.5Aare logical block diagrams illustrating rollback events for transaction forwarding, according to some embodiments. InFIG.5A, rollback events may be detected at primary node520. For example, a user may send a request to disable a session, as indicated at526. In some embodiments, a session time out522may trigger a rollback event, such as when session504remains idle with no submitted statements more than X time. Rollback events may also be detected when transactions fail, as indicated at524. For example, a transaction may fail because a conflict write obtained a lock on a data page before the write statement of the transaction.

Primary node520may notify read replica510of the aborted transaction, as indicated at512, in some embodiments. Read replica510may decide whether to send via open transaction502an abort notification514or create a new session516, in some embodiments. For example, a new session516may be created when the operations performed by primary node520can be performed by read replica node510and/or when no write statements were actually submitted, in some embodiments. Abort notifications514may be sent when the aborted transaction at the primary node cannot be recovered from by read replica node510, in some embodiments.

FIG.5Billustrates rollback events detected at read replica nodes. Read replica node510may detect a roll back event when, for example, a request to abort the transaction, as indicated at532is received via transaction502. In some embodiments, a request to disable transaction forwarding, as indicated at538, may also cause an existing transaction to be aborted. Read replica node510may send a transaction abort notification534via session504to primary node520to perform, if necessary, appropriate roll-back actions (e.g., apply undo log records to undo the effects of previous writes).

The database service and storage service discussed inFIGS.2through5Bprovide examples of a database system that may implement selective forwarding for multi-statement database transactions. However, various other types of database systems may implement selective forwarding for multi-statement database transactions.FIG.6is a high-level flowchart illustrating various methods and techniques to implement selective forwarding for multi-statement database transactions, according to some embodiments. Various different systems and devices may implement the various methods and techniques described below, either singly or working together. For example, a database service and storage service as discussed above may implement the various methods. Alternatively, a combination of different systems and devices may implement the various techniques. Therefore, the above examples and or any other systems or devices referenced as performing the illustrated method, are not intended to be limiting as to other different components, modules, systems, or configurations of systems and devices.

As indicated at610, a transaction may begin at a read-only node of a database, in some embodiments. A transaction, in various embodiments, may be a group of one or more operations performed as part of the transaction that may succeed or fail together, in some embodiments. A transaction may be specified via an interactive interface (e.g., a graphical interface or command interface), which may allow a user to enter one or multiple statements, submit them for performance, receive results of the statements performance (e.g., query results or insert acknowledgement). Transactions may remain open, in some embodiments, until a request to commit the transaction is received so that the changes made by a transaction do not become visible to other clients of a database until the database system has committed them (which may be successful if the transaction does not conflict with another operation that takes precedence, such as an earlier submitted write or transaction). In some embodiments, a transaction may be submitted via a single request, to be started, operations performed, and committed without further actions from a user. Transaction statements may specify operations, such as read requests (e.g., requests to query, obtain, access, scan, view, or otherwise read data from a database), write requests (e.g., to insert, delete, modify, add, put, store, etc.), or other operations including start, begin, commit, abort, or end transactions. A transaction session or other transaction protocol may be initiated by a client application with the read-only node, in some embodiments. A key word, such as “Start” or “Begin” may be used in a statement, in some embodiments. As indicated at620, a statement may be received as part of the transaction (if not then the technique may wait, commit, or abort (not illustrated), in some embodiments. As indicated at630, a type for the statement of the transaction may be determined, in some embodiments.

For a read statement, a read view may be determined for the read statement, as indicated at642, in some embodiments. For example, if no read view exists, then the read view may be created. If a read view already exists, then it may be identified. Existing read views may have been previously updated by write statements, as indicated at664.

As indicated at652, the read statement may be performed using the read view. For a write statement, the write statement may be sent to a read-write node of the database to be performed as a read-write node transaction, as indicated at644. As indicated at654, the write statement may be performed at the read-write node as part of the read-write node transaction, in some embodiments. As indicated at664, the read view may be updated to include the write statement after the write statement is successfully performed by the read-write node (e.g., after receiving an acknowledgement).

The transaction may continue with new statements (e.g., read statements and/or new write statements until a commit is received, as indicated by the positive exit form670. When a commit is received, then the read-write node may be requested to commit the transaction, as indicated at680. For example, a “commit” command may be stated in a transaction. The transaction may also be committed at the read-only node, as indicated at690.

FIG.7is a high-level flowchart illustrating various methods and techniques to implement roll-back events for forwarded transactions at a read-only node, according to some embodiments. As indicated at710, a roll-back event may be detected for a transaction at a read-only node for a transaction started at the read-only node. A roll-back event may be triggered by a user requested transaction abort or a user requested modification to write forwarding for the read-only node (e.g., by disabling write forwarding), in some embodiments.

As indicated at720, an instruction to a read-write node may be sent to abort a read-write node transaction started to perform write statements for the transaction, in some embodiments. As indicated at730, write(s) for write statement(s) sent to the read-write node from the read-only node as part of the transaction may be rolled back, in some embodiments. As indicated at740, the transaction may be aborted at the read-only node, in some embodiments.

FIG.8is a high-level flowchart illustrating various methods and techniques to implement roll-back events for forwarded transactions at a read-write node, according to some embodiments. As indicated at810, a roll-back event may be detected for a read-write transaction at a read-write node for a transaction started at a read-only node. A roll-back event may be triggered by a failure to successfully complete a write (e.g., due to conflict), session timeout, or a user manually closing the session, in some embodiments.

As indicated at820, the read-write transaction at the read-write node may be rolled back, in some embodiments. As indicated at830, notification of the aborted read-write transaction may be sent to the read-only node, in some embodiments. As indicated at840, in some embodiments, the transaction may be aborted at the read-only node. In some embodiments, a new session can be created instead of aborting the transaction at the read-only node (e.g., when the read only node had not yet submitted a write statement to the read-write node).

FIG.9is a block diagram illustrating an example computer system that may implement the techniques for selective forwarding for multi-statement database transactions, according to various embodiments described herein. For example, computer system1000may implement a primary node and/or one of a plurality of storage nodes of a separate storage system that stores database tables and associated metadata on behalf of clients of the database tier, in various embodiments. Computer system1000may be any of various types of devices, including, but not limited to, a personal computer system, desktop computer, laptop or notebook computer, mainframe computer system, handheld computer, workstation, network computer, a consumer device, application server, storage device, telephone, mobile telephone, or in general any type of computing device.

Computer system1000includes one or more processors1010(any of which may include multiple cores, which may be single or multi-threaded) coupled to a system memory1020via an input/output (I/O) interface1030. Computer system1000further includes a network interface1040coupled to I/O interface1030. In various embodiments, computer system1000may be a uniprocessor system including one processor1010, or a multiprocessor system including several processors1010(e.g., two, four, eight, or another suitable number). Processors1010may be any suitable processors capable of executing instructions. For example, in various embodiments, processors1010may be general-purpose or embedded processors implementing any of a variety of instruction set architectures (ISAs), such as the x86, PowerPC, SPARC, or MIPS ISAs, or any other suitable ISA. In multiprocessor systems, each of processors1010may commonly, but not necessarily, implement the same ISA. The computer system1000also includes one or more network communication devices (e.g., network interface1040) for communicating with other systems and/or components over a communications network (e.g. Internet, LAN, etc.). For example, a client application executing on system1000may use network interface1040to communicate with a server application executing on a single server or on a cluster of servers that implement one or more of the components of the database systems described herein. In another example, an instance of a server application executing on computer system1000may use network interface1040to communicate with other instances of the server application (or another server application) that may be implemented on other computer systems (e.g., computer systems1090).

In the illustrated embodiment, computer system1000also includes one or more persistent storage devices1060and/or one or more I/O devices1080. In various embodiments, persistent storage devices1060may correspond to disk drives, tape drives, solid state memory, other mass storage devices, or any other persistent storage device. Computer system1000(or a distributed application or operating system operating thereon) may store instructions and/or data in persistent storage devices1060, as desired, and may retrieve the stored instruction and/or data as needed. For example, in some embodiments, computer system1000may host a storage system server node, and persistent storage1060may include the SSDs attached to that server node.

Computer system1000includes one or more system memories1020that may store instructions and data accessible by processor(s)1010. In various embodiments, system memories1020may be implemented using any suitable memory technology, (e.g., one or more of cache, static random access memory (SRAM), DRAM, RDRAM, EDO RAM, DDR 10 RAM, synchronous dynamic RAM (SDRAM), Rambus RAM, EEPROM, non-volatile/Flash-type memory, or any other type of memory). System memory1020may contain program instructions1025that are executable by processor(s)1010to implement the methods and techniques described herein. In various embodiments, program instructions1025may be encoded in native binary, any interpreted language such as Java™ byte-code, or in any other language such as C/C++, Java™, etc., or in any combination thereof. In some embodiments, program instructions1025may implement multiple separate clients, server nodes, and/or other components.

In some embodiments, system memory1020may include data store1045, which may be configured as described herein. For example, the information described herein as being stored by the database tier (e.g., on a primary node), such as a transaction log, an undo log, cached page data, or other information used in performing the functions of the database tiers described herein may be stored in data store1045or in another portion of system memory1020on one or more nodes, in persistent storage1060, and/or on one or more remote storage devices1070, at different times and in various embodiments. Along those lines, the information described herein as being stored by a read replica, such as various data records stored in a cache of the read replica, in-memory data structures, manifest data structures, and/or other information used in performing the functions of the read-only nodes described herein may be stored in data store1045or in another portion of system memory1020on one or more nodes, in persistent storage1060, and/or on one or more remote storage devices1070, at different times and in various embodiments. Similarly, the information described herein as being stored by the storage tier (e.g., redo log records, data pages, data records, and/or other information used in performing the functions of the distributed storage systems described herein) may be stored in data store1045or in another portion of system memory1020on one or more nodes, in persistent storage1060, and/or on one or more remote storage devices1070, at different times and in various embodiments. In general, system memory1020(e.g., data store1045within system memory1020), persistent storage1060, and/or remote storage1070may store data blocks, replicas of data blocks, metadata associated with data blocks and/or their state, database configuration information, and/or any other information usable in implementing the methods and techniques described herein.

Network interface1040may allow data to be exchanged between computer system1000and other devices attached to a network, such as other computer systems1090(which may implement one or more storage system server nodes, primary nodes, read-only node nodes, and/or clients of the database systems described herein), for example. In addition, network interface1040may allow communication between computer system1000and various I/O devices1050and/or remote storage1070. Input/output devices1050may, in some embodiments, include one or more display terminals, keyboards, keypads, touchpads, scanning devices, voice or optical recognition devices, or any other devices suitable for entering or retrieving data by one or more computer systems1000. Multiple input/output devices1050may be present in computer system1000or may be distributed on various nodes of a distributed system that includes computer system1000. In some embodiments, similar input/output devices may be separate from computer system1000and may interact with one or more nodes of a distributed system that includes computer system1000through a wired or wireless connection, such as over network interface1040. Network interface1040may commonly support one or more wireless networking protocols (e.g., Wi-Fi/IEEE 802.11, or another wireless networking standard). However, in various embodiments, network interface1040may support communication via any suitable wired or wireless general data networks, such as other types of Ethernet networks, for example. Additionally, network interface1040may support communication via telecommunications/telephony networks such as analog voice networks or digital fiber communications networks, via storage area networks such as Fibre Channel SANs, or via any other suitable type of network and/or protocol. In various embodiments, computer system1000may include more, fewer, or different components than those illustrated inFIG.9(e.g., displays, video cards, audio cards, peripheral devices, other network interfaces such as an ATM interface, an Ethernet interface, a Frame Relay interface, etc.)