Database system and data management method therefor
Persisting the write operation log through the client solves the problem of long transaction processing delays in the database system, reduces the load on the database nodes, and improves the throughput rate and recovery speed of the system.
Patent Information
- Application Number
- PCT/CN2024/084876
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-09
- Filing Date
- 2024-03-29
- Publication Date
- 2024-10-03
AI Technical Summary
During the transaction processing of the database system, the coordinator node and the participant node need to perform persistence operations, resulting in a long end-to-end delay for a single transaction and increasing the load on the database node.
The write operation log is persisted through the client, so that the database node can send a response to the client without persistence, reducing the client's transaction processing delay, and reducing the database system through batch persistence of the write operation log. The number of requests increases the ultimate throughput rate.
It effectively reduces the client's transaction processing delay, reduces the persistence load on the database node, and improves the ultimate throughput rate and transaction recovery speed of the database system.
Smart Images

Figure CN2024084876_03102024_PF_FP_ABST
Abstract
Description
Database system and data management method thereof
[0001] This application claims priority to Chinese patent application No. 202310339861.1 filed on March 31, 2023, with invention name “Database management method”, and priority to Chinese patent application No. 202310684553.2 filed on June 9, 2023, with invention name “Database system and data management method thereof”, all contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of database technology, and in particular to a database system and a data management method thereof. Background Art
[0003] Currently, transaction processing in database systems requires the collaborative participation of multiple database nodes. Furthermore, upon receiving a client's write request, both the coordinator and participant nodes must first perform the corresponding persistence operation before returning a corresponding write response to the client. Because persistence operations are at the critical path of transaction processing, they can result in excessive end-to-end latency for individual transactions.
[0004] Summary of the Invention
[0005] This application provides a database system and data management method thereof. This application reduces the latency of client-side transaction processing, can solve the problem of excessive latency in client-side transaction processing, and reduces the persistent load on database nodes. The technical solutions provided by this application are as follows:
[0006] In a first aspect, the present application provides a database system. The database system includes: a client, multiple database nodes, and storage resources, wherein the multiple database nodes include a first database node; the client is configured to send a first write request for a target transaction to the first database node, the first write request indicating first data to be written; the first database node is configured to send a first write response to the client based on the first write request, the first write response carrying a first write operation log of the first data; and the client is further configured to persist the first write operation log using the storage resources.
[0007] In this database system, the client persists the first write operation log, so that the first database node can send a write response to the client without persisting the first write operation log. This makes it easier for the client to send the next write request as soon as possible, reduces the delay in the client processing transactions, solves the problem of excessive delay in the client processing transactions, and reduces the persistence load of the database node.
[0008] Optionally, the multiple database nodes also include a second database node; the client is further configured to send a second write request for the target transaction to the second database node, the second write request being configured to indicate second data to be written; the second database node is configured to send a second write response to the client based on the second write request, the second write response carrying a second write operation log for the second data; and the client is specifically configured to utilize storage resources to batch persist the first write operation log and the second write operation log. This reduces the number of persistence requests sent by the client to the storage resource, thereby reducing the total number of requests required by the database system to process a single transaction, and thus achieving a higher maximum throughput for the database system.
[0009] In one implementation, both the client and the database node have exclusive storage resources. The exclusive resources of the client and the database node can be obtained by prior declaration. In this case, the client is specifically used to persist the write operation log in its exclusive storage resource. In addition, when the client persists the write operation log in the storage resource, it can write the write operation log to the storage resource by appending. In this way, when the client persists the write operation log in its exclusive storage resource, all the write operation logs are stored in the exclusive resource. When the target transaction has multiple write operation logs, the multiple write operation logs are stored continuously in the storage resource. When it is necessary to read all the write operation logs of the target transaction, the multiple write operation logs of the target transaction can be read sequentially in the exclusive storage, which can shorten the time spent on reading the write operation logs and ensure the reading speed of the write operation logs.
[0010] In this database system, multiple database nodes include a coordinator node and a participant node; the client is further configured to provide the coordinator node with all write operation logs of a target transaction; the coordinator node is configured to obtain a third write operation log for which the coordinator node is responsible based on all write operation logs, and to persist the third write operation log using storage resources; the coordinator node is further configured to obtain a fourth write operation log for which the participant node is responsible based on all write operation logs, and to send the fourth write operation log to the participant node; and the participant node is configured to persist the fourth write operation log using storage resources.
[0011] In this way, both the coordinator node and the participant node can persist the write operation logs for which they are responsible. When the write operation logs need to be used, for example, when transaction recovery is required based on the write operation logs, the coordinator node and the participant node can obtain their own persisted write operation logs from their respective storage resources and perform related processing based on the obtained write operation logs, without having to obtain the client's persisted write operation logs and without having to repeatedly read their own storage resources and the client's storage resources, which is conducive to improving the execution speed of operations performed based on the write operation logs.
[0012] To ensure that the coordinator node can obtain the write operation log of the target transaction, the client is also used to provide the storage address of all write operation logs to the coordinator node.
[0013] When the coordinator node has exclusive storage resources, the coordinator node is specifically used to persist the third write operation log in its exclusive storage resources. And / or, when the participant node has exclusive storage resources, the participant node is specifically used to persist the fourth write operation log in its exclusive storage resources. In addition, the coordinator node and / or the participant node can write the write operation log to the storage resource in an append-write manner. In this way, when the database node persists the write operation log in its exclusive storage resource, the data stored in the exclusive storage resource is the relevant information of the transaction (such as the status of the transaction) and the write operation log, and the relevant information of the transaction and the write operation log are stored continuously in the storage resource in a time sequence. When it is necessary to obtain the relevant information and write operation log of the target transaction, the relevant information and write operation log of the target transaction can be read sequentially in the exclusive storage to ensure the reading speed. For example, when it is necessary to recover the target transaction, it is usually necessary to first query the status of the target transaction, and then determine whether it is necessary to recover the transaction based on the persistent write operation log of the database node based on the status. When it is necessary to recover the transaction based on the persistent write operation log of the database node, the persistent write operation log of the database node can be read sequentially after the storage address of the status of the target transaction. This can shorten the time spent on reading the status and writing the operation log, and help ensure the speed of transaction recovery.
[0014] In one implementation, any data node among the multiple data nodes is further configured to obtain the current state of the target transaction when recovery of the target transaction is required, and execute a recovery process of the target transaction based on the current state.
[0015] Among them, the coordinator node is specifically used to: when the current status indicates that the target transaction is in the executing state, after receiving the client's write request, send a write response to the client to instruct the re-execution of the target transaction; when the current status indicates that the target transaction is in the committed state, obtain the client's persistent write operation log, and perform a replay operation based on the client's persistent write operation log; when the current status indicates that the target transaction is in the completed state, obtain a third write operation log, and perform a replay operation based on the third write operation log.
[0016] Optionally, the coordinator node is also used to obtain the fourth write operation log that the participant node is responsible for based on the write operation log persisted by the client when the current status indicates that the target transaction is in a committed state, and send the fourth write operation log to the participant node; the participant node is also used to persist the fourth write operation log using storage resources.
[0017] The participant node is specifically used for: when the current status indicates that the participant node has persisted the write operation log of the target transaction, performing a replay operation based on the fourth write operation log; when the current status indicates that the participant node has not persisted the write operation log of the target transaction, if the fourth write operation log for which the participant node is responsible is received within the specified time period, performing a replay operation based on the fourth write operation log; when the current status indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log for which the participant node is responsible is not received within the specified time period, after receiving the write request from the client, sending a write response to the client instructing the re-execution of the target transaction.
[0018] After the coordinator node and the participant node also persist the write operation logs for which they are responsible, the write operation log of the transaction is actually stored in two copies, the first copy is persisted by the client, and the second copy is persisted by the coordinator node and the participant node. Although this can facilitate the use of the write operation log, it also causes redundant storage. In order to reduce the overhead on storage space, the database system provided by the embodiment of the present application also has a storage space recovery mechanism. In one implementation method, the coordinator node is also used to send a storage space recovery request to the client when the target transaction is completed, and the recovery request carries indication information of the storage space; the client is also used to reclaim the storage space based on the recovery request.
[0019] Optionally, the indication information is the address of the storage space.
[0020] In a second aspect, the present application provides a data management method for a database system. The database system includes: a client, multiple database nodes, and storage resources, wherein the multiple database nodes include a first database node. The method includes: the client sending a first write request for a target transaction to the first database node, the first write request being used to indicate first data to be written; the first database node sending a first write response to the client based on the first write request, the first write response carrying a first write operation log of the first data; and the client using the storage resources to persist the first write operation log.
[0021] Optionally, the multiple database nodes also include a second database node, and the method also includes: the client sends a second write request for the target transaction to the second database node, the second write request is used to indicate the second data to be written; the second database node sends a second write response to the client based on the second write request, the second write response carries a second write operation log of the second data; the client uses storage resources to persist the first write operation log, including: the client uses storage resources to batch persist the first write operation log and the second write operation log.
[0022] Optionally, the client persists the first write operation log using storage resources, including: the client persists the write operation log in its exclusive storage resources.
[0023] Optionally, the multiple database nodes include a coordinator node and a participant node, and the method further includes: the client provides all write operation logs of the target transaction to the coordinator node; the coordinator node obtains a third write operation log for which the coordinator node is responsible based on all write operation logs, and persists the third write operation log using storage resources; the coordinator node obtains a fourth write operation log for which the participant node is responsible based on all write operation logs, and sends the fourth write operation log to the participant node; the participant node persists the fourth write operation log using storage resources.
[0024] Optionally, the method further includes: the client providing the coordinator node with storage addresses of all write operation logs.
[0025] Optionally, the coordinator node persists the third write operation log in its exclusive storage resources; and / or the participant node persists the fourth write operation log in its exclusive storage resources.
[0026] Optionally, data in the storage resource is written in an append-write manner.
[0027] Optionally, the method further includes: when any data node among the multiple data nodes needs to recover the target transaction, obtaining the current state of the target transaction, and executing a recovery process of the target transaction based on the current state.
[0028] Optionally, the coordinator node executes a recovery process of the target transaction based on the current state, including: when the current state indicates that the target transaction is in an executing state, after receiving a write request from the client, sending a write response to the client instructing the re-execution of the target transaction; when the current state indicates that the target transaction is in a committed state, obtaining the client's persistent write operation log, and performing a replay operation based on the client's persistent write operation log; when the current state indicates that the target transaction is in a completed state, obtaining a third write operation log, and performing a replay operation based on the third write operation log.
[0029] Optionally, the method also includes: when the current status indicates that the target transaction is in a committed state, the coordinator node obtains the fourth write operation log that the participant node is responsible for based on the write operation log persisted by the client, and sends the fourth write operation log to the participant node; the participant node uses storage resources to persist the fourth write operation log.
[0030] Optionally, the participant node executes a recovery process of the target transaction based on the current state, including: when the current state indicates that the participant node has persisted the write operation log of the target transaction, performing a replay operation based on the fourth write operation log; when the current state indicates that the participant node has not persisted the write operation log of the target transaction, if the fourth write operation log for which the participant node is responsible is received within a specified time period, performing a replay operation based on the fourth write operation log; when the current state indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log for which the participant node is responsible is not received within the specified time period, after receiving the client's write request, sending a write response to the client instructing the re-execution of the target transaction.
[0031] Optionally, after the participant node uses storage resources to persist the fourth write operation log, the method also includes: when the target transaction is completed, the coordinator node sends a storage space recovery request to the client, and the recovery request carries indication information of the storage space; the client reclaims the storage space based on the recovery request.
[0032] Optionally, the indication information is the address of the storage space.
[0033] In a third aspect, the present application provides a computing device comprising a memory and a processor, wherein the memory stores program instructions, and the processor executes the program instructions to implement the client, database node or storage resource in the system provided in the first aspect of the present application and any possible implementation thereof.
[0034] In a fourth aspect, the present application provides a computing device cluster, comprising multiple computing devices, wherein the multiple computing devices include multiple processors and multiple memories, wherein the multiple memories store program instructions, and the multiple processors execute the program instructions, so that the computing device cluster implements the system provided in the first aspect of the present application and any possible implementation thereof.
[0035] In a fifth aspect, the present application provides a computer-readable storage medium, which is a non-volatile computer-readable storage medium. The computer-readable storage medium includes program instructions. When the program instructions are executed on a computing device, the computing device executes the system provided in the first aspect of the present application and any possible implementation thereof.
[0036] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when run on a computer, enables the computer to execute the system provided in the first aspect of the present application and any possible implementation thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] FIG1 is a schematic structural diagram of an implementation scenario of a data management method for a database system provided in an embodiment of the present application;
[0038] FIG2 is a schematic diagram of a storage-computing integrated architecture provided in an embodiment of the present application;
[0039] FIG3 is a schematic diagram of a storage and computing separation architecture provided in an embodiment of the present application;
[0040] FIG4 is a flow chart of a data management method for a database system provided in an embodiment of the present application;
[0041] FIG5 is a schematic diagram of a process of executing a transaction in a data management method of a database system provided in an embodiment of the present application;
[0042] 6 is a schematic diagram of data persisted in a client, a first database node, and a second database node during a transaction execution process provided by an embodiment of the present application;
[0043] FIG7 is a schematic diagram of a coordinator node recovery transaction provided in an embodiment of the present application;
[0044] FIG8 is a schematic diagram of a participant node recovery transaction provided in an embodiment of the present application;
[0045] FIG9 is a schematic diagram of managing storage resource usage through a hash table according to an embodiment of the present application;
[0046] FIG10 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0047] FIG11 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0048] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.
[0049] This article provides a detailed introduction to the technical solution of this application from multiple perspectives, including implementation scenarios, system composition, method flow, and hardware devices.
[0050] The following first illustrates the application scenarios of the embodiments of the present application.
[0051] FIG1 is a structural diagram of an implementation scenario involved in a data management method for a database system provided in an embodiment of the present application. As shown in FIG1 , the implementation scenario includes: a database system. The database system includes: a client 101, multiple database nodes 102, and a storage resource 103. Communication connections can be established between any two of the client 101, the database node 102, and the storage resource 103. For example, a communication connection can be established between the client 101 and the database node 102 via a network, a communication connection can be established between the client 101 and the storage resource 103 via a network, and a communication connection can be established between the storage resource 103 and the database node 102 via a network. Optionally, the network can be a local area network, the Internet, or other networks, which are not limited by the embodiments of the present application.
[0052] Client 101 is used to send transaction statements to a database node. In this document, client 101 refers to a node that directly communicates with a database node. It can be either a system gateway node or a client node with a client installed. For example, the client can be a gateway server for the entire database system, or a client proxy cluster that supports dynamic scaling. Alternatively, the client node can be a computer, personal computer, laptop computer, mobile phone, smartphone, tablet computer, cloud host, portable mobile terminal, multimedia player, e-book reader, wearable device, smart home appliance, artificial intelligence device, smart wearable device, smart vehicle-mounted device, or Internet of Things device.
[0053] Database node 102 is used to process read and write requests in transactions. Database node 102 can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center. The cloud computing service center is equipped with a large number of basic resources owned by the cloud service provider. For example, the cloud computing service center is equipped with computing resources, storage resources, and network resources. The cloud computing service center can utilize these basic resources to implement the database system data management method provided in the embodiments of the present application.
[0054] When the database node 102 is implemented through a cloud computing service center, the user can access the cloud platform and use the database functions provided by the database system 10. At this time, the database functions provided by the database system 10 to the user can be abstracted into a database cloud service by the cloud service provider on the cloud platform. After the user purchases the database cloud service on the cloud platform, the cloud platform can use the resources of the cloud computing service center and use the data management method of the database system provided in the embodiment of the present application to provide database cloud services. In addition, the database cloud service can be provided as an independent cloud service or as an additional service to other cloud services. Optionally, the cloud platform can be a cloud platform of a central cloud, a cloud platform of an edge cloud, or a cloud platform including a central cloud and an edge cloud, and the embodiment of the present application does not make specific restrictions on it. It should be noted that in the implementation scenario shown in Figure 1, the database node 102 can also be implemented through other resource platforms other than the cloud platform, and the embodiment of the present application does not make specific restrictions on it.
[0055] Storage resource 103 is a storage medium used to store data in a database system, also known as persistent storage. A high-performance storage resource can be a persistent storage medium such as non-volatile memory (NVM), a solid state drive (SSD), or a hard disk drive (HDD), and is not specifically limited in this embodiment of the present application.
[0056] In terms of implementation, the storage resource 103 can be a storage pool implemented by multiple servers. Furthermore, the storage resource 103 can be the storage resource of the server used as the database node 102, that is, the storage resource 103 is equivalent to the medium for storing data copies within the database node 102. In this case, the database system 10 has a storage-computing integrated architecture. Alternatively, the storage resource 103 can be a storage resource independent of the server used as the database node 102. The storage resource 103 can be considered a remote storage pool of the database node 102, and all database nodes 102 can access the storage resource 103. In this case, the database system 10 has a storage-computing separation architecture.
[0057] The storage-computing integrated architecture refers to a computing node that is also a storage node. Figure 2 is a schematic diagram of a storage-computing integrated architecture provided by an embodiment of the present application to implement multiple copies of data. As shown in Figure 2, the database node is configured with computing resources and storage resources. The database node uses its computing resources to participate in the processing of transactions and uses its storage resources to participate in the storage of data. In the storage-computing integrated architecture, in order to improve the availability of data, the database system usually performs multiple backup copies of data between different database nodes. In order to ensure consistency between multiple copies, it usually adopts a corresponding consensus algorithm, such as Raft or Paxos protocol. Ap, Bp and Cp are the master copies of the corresponding data blocks respectively. When the client wants to write data A, it will only send a request to the node containing Ap, that is, the node configured with persistent memory (PM) 1 in Figure 2. When the database node receives a write request, it will send a request to the two nodes on the right, that is, the nodes configured with PM1 and PM2 in Figure 2, requesting them to update A. After waiting for a successful response, the node configured with PM1 will write the local Ap data and finally return a response to the client.
[0058] The storage and computing separation architecture refers to the independence of computing nodes from storage nodes. Figure 3 is a schematic diagram of a storage and computing separation architecture provided by an embodiment of the present application. As shown in Figure 3, the database node is responsible for the processing of transactions, the storage node is responsible for the storage of data, and the storage resources of the storage node can be used by the database node. In the storage and computing separation architecture, when the client wants to write A data, it only needs to send the request to the corresponding database node. After receiving the client's request, the database node will concurrently send a data write request to the storage node to complete the redundant storage of the data. By storing data in a redundant manner (such as multiple copies or using erasure code (EC), etc.), the reliability of the data can be improved. In addition, when the database system provided in an embodiment of the present application is a storage and computing separation architecture, the database system can also be deployed using cloud resources, such as using cloud resources to deploy the storage resources and database nodes of the database system, to achieve efficient and simple deployment of the database system.
[0059] In the process of a database system processing transactions, the database nodes involved in the transaction processing can be divided into transaction coordinator nodes (hereinafter referred to as coordinator nodes) and transaction participant nodes (hereinafter referred to as participant nodes). Coordinator nodes and participant nodes are both database nodes used to process read and write requests in transactions. The two are exactly the same in physical configuration, but there are some differences in the operations required to process transactions. Among them, both coordinator nodes and participant nodes respond to write requests. In addition, the coordinator node also assumes the role of committing transactions and maintains relevant metadata of the transaction, such as transaction status and other information. Generally, when a client needs to send multiple write requests to process a transaction, the database node that receives the first write request is the coordinator node, and the database node that receives the remaining write requests is the participant node.
[0060] In one implementation, the database system data management method provided in the embodiments of the present application can be implemented by running an executable program on the client 101 and the database node 102 in the database system. For example, the executable program of the database system data management method can be presented in the form of an application installation package. After the application installation package is installed on the client 101, the functions of the client 101 in the data management method can be implemented by running the executable program. After the application installation package is installed on the database node 102, the functions of the database node 102 in the data management method can be implemented by running the executable program.
[0061] It should be understood that the above content is an illustrative description of the implementation scenario of the data management method for the database system provided in the embodiment of the present application, and does not constitute a limitation on the implementation scenario of the data management method for the database system. A person of ordinary skill in the art will know that as business needs change, its implementation scenario can be adjusted according to application requirements, and the embodiments of the present application do not list them one by one.
[0062] The following describes the current transaction processing process of the database system. Assume that the client sends two write requests during the transaction, and the two write requests are mapped to different database nodes. The transaction processing process includes:
[0063] Step S1: The client sends the first write request to the database node.
[0064] Step S2, after the database node receives the write request, the database node becomes the coordinator node of the client's write transaction. The coordinator node first creates a transaction record internally and saves relevant information of the transaction, such as the transaction status, the key corresponding to the write request, etc. After the creation of the transaction record is completed, the coordinator node checks other transactions in the memory to determine whether there are read-write conflicts and write-write conflicts. If a conflict is detected, a write response with abort retry information is sent to the client; otherwise, the status of the transaction is persisted as being executed (inProgress), and the write operation log of the write request is persisted. After the persistence is completed, a write response indicating the completion of the persistence is sent to the client so that the client can send the next write request. Among them, inProgress means that the transaction is being executed. When the coordinator node receives the write operation of the transaction for the first time, it opens a new transaction on behalf of the client. The coordinator node will record that the transaction is in the inProgress state to indicate that the transaction is in progress. The write operation log stores the data of the write operation. The basic format of a write operation log is: txnId key1 value1, indicating that the transaction marked with transaction txnId wrote key1 to value1. If there are multiple write operations within a transaction, more key-value pair modification records can be added later. For example, txnId key1 value1[key2 value2…] indicates that key2 was also written to value2.
[0065] Step S3: After the client receives the write response from the coordinator node, if it finds that it is an abort retry message, it aborts the transaction and tries again after a period of time; otherwise, it continues to send the next request to the participant node.
[0066] Step S4: After receiving a write request from a client, the participant node also needs to perform a conflict determination in memory and respond to the client based on whether a conflict exists. If no conflict is found, the write operation log of the write request is persisted and a write response is sent to the client indicating that the persisted operation is complete, allowing the client to continue the operation.
[0067] Step S5: After the client receives the write response from the participant node, if it is a write response indicating to continue the operation, it sends a commit request to the coordinator node to request to commit the transaction.
[0068] Step S6: After receiving the commit request, the coordinator node persists the transaction status to committed and notifies the client to complete the transaction commit operation. Simultaneously, the coordinator node, in the background, determines the transaction's participant nodes based on the information in the client's commit request and sends a finalization request to all participant nodes. Committed indicates that the transaction has been committed. Upon receiving the client's commit request, the coordinator node needs to record the transaction as committed, indicating that the data operations within the transaction have been completed.
[0069] Step S7, after the participant node receives the finalization request sent by the coordinator node, it changes the status of the write data it is responsible for to commit, and then sends a finalization response to the coordinator node. Among them, commit is a special status. It is not the transaction status displayed to all nodes processing the transaction, but the write operation status of the transaction displayed to the participant node itself. Therefore, the write operation status can also be regarded as the transaction status, but it is not the transaction status displayed to all nodes processing the transaction. The commit recorded in each participant node is used to record the data modified by the participant node, that is, which data the client has modified through the participant node. The data recorded by commit is also called a commit log. For example, the commit log recorded by the participant node is txnId commit key1 value1, which indicates that the participant node has modified the data of transaction txnId with a key of key1 and a value of value1.
[0070] Step S8: After receiving the finalization responses from all participant nodes, the coordinator node persists the transaction status as finalized. Finalized means that the transaction has been successfully submitted and the lock release and other operations have been completed, which means that the entire transaction is completed.
[0071] It should be noted that, in contrast to the committed state, there is also the aborted state, which indicates that the transaction has been aborted. In other words, when a transaction is aborted due to a conflict, the transaction state is recorded as aborted.
[0072] The transaction processing process requires the joint participation and collaborative processing of multiple database nodes. It's not difficult to see that after receiving a client's write request, both the coordinator and participant nodes must first perform the corresponding persistence operation before returning the corresponding write response to the client. Because persistence operations are on the critical path of transaction processing, they can cause excessive end-to-end latency for individual transactions, a problem known as persistence delay.
[0073] To further understand the persistence latency issue, let's break down the processing time of a write request within a transaction. The write request processing time is primarily divided into three components: the round-trip network latency (T1) between the client and the database node; the internal processing latency (T2) after the database node receives the write request; and the persistence latency (T3) of the write operation log. T1 is primarily due to network communication latency, approximately one round-trip time (RTT). T2 is primarily due to memory operations within the database node, such as conflict detection and locking. This latency is very low and essentially negligible. T3 includes the latency of communication between the database node and the storage node, approximately one RTT. Furthermore, after receiving the persistence request, the storage node needs to write to a persistent device such as a HDD, SSD, or NVM, which also incurs some latency. The persistence latency issue essentially refers to the fact that each write operation processing latency is approximately T1 + T2 + T3, resulting in excessive write latency, which in turn leads to excessive latency in write-only transactions.
[0074] To this end, embodiments of the present application provide a database system and a data management method thereof. The following examples illustrate the system configuration of the database system provided in embodiments of the present application. It should be noted that this description primarily focuses on the architecture of the database system, and its operating principles are elaborated later in the description of the data management method.
[0075] Please refer to Figure 1 for a schematic diagram of the database system provided in an embodiment of the present application. As shown in Figure 1, the database system includes: a client, multiple database nodes, and storage resources. The database system can have an integrated storage and computing architecture. Alternatively, the database system can have a separate storage and computing architecture.
[0076] Multiple database nodes include a first database node. In the database system, the client is used to send a first write request of a target transaction to the first database node, and the first write request is used to indicate the first data to be written. The first database node is used to send a first write response to the client based on the first write request, and the first write response carries a first write operation log of the first data. For example, after receiving the first write request, the first database node first performs conflict detection and locking operations in the memory, and then immediately sends the first write response to the client. The client is also used to persist the first write operation log using storage resources. In one implementation, the first write request carries the first data and its key. The first data is the data that the first database node is responsible for. The first write operation log carries relevant information indicating the persistence method of the first data. For example, the first write operation log carries information such as the key indicating the use of the persistent first data.
[0077] In this database system, the client persists the first write operation log, so that the first database node can send a write response to the client without persisting the first write operation log. This makes it easier for the client to send the next write request as soon as possible, reduces the delay in the client processing transactions, solves the problem of excessive delay in the client processing transactions, and reduces the persistence load of the database node.
[0078] In this database system, the multiple database nodes also include a second database node. In this case, the client is also used to send a second write request for the target transaction to the second database node, and the second write request is used to indicate the second data to be written. The second database node is used to send a second write response to the client based on the second write request, and the second write response carries a second write operation log of the second data. For example, after receiving the second write request, the second database node first performs conflict detection and locking operations in the memory, and then immediately sends a second write response to the client. The client is also used to use storage resources to persist the second write operation log. In one implementation, the second write request carries the second data and its key. The second data is the data that the second database node is responsible for. The second write operation log carries relevant information indicating the persistence method of the second data. For example, the second write operation log carries information such as the key indicating the use of the persistent second data.
[0079] Optionally, the client's persistence process for the first write operation log and the second write operation log can be achieved through a single persistence request. That is, the client can achieve persistence of the first write operation log and the second write operation log by sending a persistence request to the storage resource. Among them, the persistence request is used to request persistence of the write operation log in the storage resource. At this time, the client is specifically used to use the storage resource to perform batch persistence on the first write operation log and the second write operation log. Similarly, the client can perform batch persistence on all write operation logs in a single transaction. In this way, the number of persistence requests sent by the client to the storage resource can be reduced, thereby reducing the total number of requests that the database system needs to send to process a single transaction, which can bring a higher extreme throughput rate to the database system.
[0080] In one implementation, both the client and the database node have exclusive storage resources. The exclusive resources of the client and the database node can be obtained by prior declaration. In this case, the client is specifically used to persist the write operation log in its exclusive storage resource. In addition, when the client persists the write operation log in the storage resource, it can write the write operation log to the storage resource by appending. In this way, when the client persists the write operation log in its exclusive storage resource, all the write operation logs are stored in the exclusive resource. When the target transaction has multiple write operation logs, the multiple write operation logs are stored continuously in the storage resource. When it is necessary to read all the write operation logs of the target transaction, the multiple write operation logs of the target transaction can be read sequentially in the exclusive storage, which can shorten the time spent on reading the write operation logs and ensure the reading speed of the write operation logs.
[0081] In the database system provided in the embodiments of the present application, the database nodes involved in processing transactions include coordinator nodes and participant nodes. For example, when a client needs to send multiple write requests to process a transaction, the database node that receives the first write request is the coordinator node, and the database nodes that receive the remaining write requests are participant nodes. In the database system provided in the embodiments of the present application, the coordinator node and participant nodes can also persist the write operation log to facilitate subsequent use.
[0082] In one implementation, the persistent write operation logs of the coordinator node and the participant nodes can be provided by the client. In this case, the client is also configured to provide the coordinator node with all write operation logs of the target transaction. The coordinator node is configured to obtain a third write operation log for which the coordinator node is responsible based on the write operation logs, and to persist the third write operation log using storage resources. Furthermore, based on the write operation logs, the coordinator node is configured to obtain a fourth write operation log for which each participant node is responsible, and to send the fourth write operation log for which each participant node is responsible to each participant node. The participant node is configured to persist the fourth write operation log for which it is responsible using storage resources. In this way, both the coordinator node and the participant node can persist the write operation logs for which they are responsible. When the write operation logs are needed, such as when transaction recovery based on the write operation logs is required, the coordinator node and the participant node can obtain their respective persistent write operation logs from their respective storage resources and perform relevant processing based on the obtained write operation logs, without having to obtain the client's persistent write operation logs or repeatedly read their own storage resources and the client's storage resources. This helps to improve the execution speed of operations performed based on the write operation logs.
[0083] Optionally, the timing at which the client provides the coordinator node with all write operation logs for the target transaction can be adjusted based on application requirements. For example, after the client persists all write operation logs for the target transaction, it can provide the coordinator node with all write operation logs for the target transaction. For another example, the client can provide the coordinator node with all write operation logs for the target transaction when sending a commit request to the coordinator node. The commit request is used to request the commit of the target transaction. In one implementation, all write operation logs for the target transaction can be carried in the commit request.
[0084] In order to ensure that the coordinator node can obtain the write operation log of the target transaction, the client is also used to provide the storage address of the write operation log to the coordinator node. The storage address is the address obtained by the client to persist the write operation log. In one implementation, the storage address may include the starting address and offset (offset) of the write operation log in the storage resource. For example, when a log unit (persistent log, plog) in a storage medium is used to store the write operation log, the storage address may include the identifier (plogId) and offset of the plog. In this way, when the write operation log sent by the client to the coordinator node cannot be obtained, such as the write operation log sent by the client to the coordinator node cannot be obtained due to the coordinator node crashing and restarting, the coordinator node can obtain the client's persistent write operation log through the storage address.
[0085] When the coordinator node has exclusive storage resources, the coordinator node is specifically used to persist the third write operation log in its exclusive storage resources. And / or, when the participant node has exclusive storage resources, the participant node is specifically used to persist the fourth write operation log in its exclusive storage resources. In addition, the coordinator node and / or the participant node can write the write operation log to the storage resource in an append-write manner. In this way, when the database node persists the write operation log in its exclusive storage resource, the data stored in the exclusive storage resource is the relevant information of the transaction (such as the status of the transaction) and the write operation log, and the relevant information of the transaction and the write operation log are stored continuously in the storage resource in a time sequence. When it is necessary to obtain the relevant information and write operation log of the target transaction, the relevant information and write operation log of the target transaction can be read sequentially in the exclusive storage to ensure the reading speed. For example, when it is necessary to recover the target transaction, it is usually necessary to first query the status of the target transaction, and then determine whether it is necessary to recover the transaction based on the persistent write operation log of the database node based on the status. When it is necessary to recover the transaction based on the persistent write operation log of the database node, the persistent write operation log of the database node can be read sequentially after the storage address of the status of the target transaction. This can shorten the time spent on reading the status and writing the operation log, and help ensure the speed of transaction recovery.
[0086] In the database system provided by the embodiment of the present application, when the state of the target transaction to be recovered is different, the operations that need to be performed to recover the target transaction are different. Then any data node among the multiple data nodes is also used to obtain the current state of the target transaction when the target transaction needs to be recovered, and execute the recovery process of the target transaction based on the current state. According to the previous description, the coordinator node needs to maintain the metadata of the transaction. For example, the coordinator node needs to record the transaction status, and the participant node does not need to maintain the transaction status displayed to all nodes processing the transaction, but needs to record the write operation status of the transaction. Therefore, when the coordinator node recovers the transaction, the transaction status that needs to be referenced is the transaction status recorded by the coordinator node. When the participant node recovers the transaction, the transaction status that needs to be referenced is the write operation status recorded by the participant node. There are some differences in the recovery mechanisms of the coordinator node and the participant node, which are explained below.
[0087] The data recovery process of the coordinator node includes the following recovery situations:
[0088] In the first recovery scenario, when the current status indicates that the target transaction is in the executing state, the coordinator node, after receiving the client's write request, sends a write response to the client instructing it to re-execute the target transaction, causing the client to perform an abort-retry operation on the transaction based on the write response. If the target transaction is in the executing state, it means that the client has not persisted the write operation log of the target transaction before starting recovery. Therefore, an abort-retry operation is required to recover the target transaction.
[0089] In the second recovery scenario, when the current status indicates that the target transaction is in the committed state, the coordinator node obtains the client's persistent write operation log and performs a replay operation based on the client's persistent write operation log. When the target transaction is in the committed state, it means that the target transaction has been successfully committed, but the coordinator node may not have persisted the write operation log for which it is responsible. In this case, the coordinator node can obtain the client's persistent write operation log and perform a replay operation based on the client's persistent write operation log. For example, the coordinator node can obtain the client's persistent write operation log from the storage address of the write operation log provided to it by the client.
[0090] Furthermore, in this second scenario, since the participant node may not have persisted the write operation log for which it is responsible, the coordinator node is further configured to obtain a fourth write operation log for which the participant node is responsible based on the write operation log persisted by the client, and send the fourth write operation log to the participant node. In this case, the participant node is further configured to persist the fourth write operation log using storage resources.
[0091] In the third recovery scenario, when the current status indicates that the target transaction is completed, the coordinator node retrieves the third write operation log and performs a replay operation based on the third write operation log. If the target transaction is in the completed state, it means that the target transaction was successfully committed and cleaned up, and the coordinator node has persisted the write operation log for which it is responsible. In this case, the coordinator node can retrieve its own persisted write operation log and perform a replay operation based on the third write operation log.
[0092] The implementation process of data recovery by participant nodes includes the following recovery situations:
[0093] In the first recovery scenario, when the current state indicates that the participant node has persisted the write operation log of the target transaction, the participant node can perform a replay operation based on the fourth write operation log. For example, if a participant node finds a commit log in its log, it indicates that the participant node has persisted the write operation log for which it is responsible. In this case, the participant node can replay the commit log to recover the transaction.
[0094] The second recovery scenario is when the current status indicates that the participant node has not persisted the write operation log of the target transaction. If the participant node receives the fourth write operation log for which the participant node is responsible within the specified time period, a replay operation is performed based on the fourth write operation log. For example, when the participant node does not find the commit log in its log, it means that the participant node has not persisted the write operation log for which it is responsible. At this time, the participant node can wait for a period of time. If it receives the finalization request sent by the coordinator node within the specified time period, or if the participant node receives the finalization request for the target transaction sent by the coordinator node after inquiring from the coordinator node, it means that the coordinator node is able to send the finalization request to the participant node normally, but the participant node has not received the finalization request sent by the coordinator node when recovery begins. After receiving the finalization request, the participant node can directly perform a replay operation based on the write operation log contained in the finalization request to achieve recovery of the transaction. The timestamp of the finalization request of the target transaction is less than the timestamp when the participant node starts to recover the transaction.
[0095] The third recovery scenario is when the current status indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log for which the participant node is responsible has not been received within the specified time period, the participant node, after receiving the client's write request, sends a write response to the client instructing the re-execution of the target transaction. For example, when the participant node does not find the commit log in its log, and after the participant node inquires with the coordinator node, if it is determined that there is no finalization request for the target transaction that the coordinator node has not sent, it means that the execution of the transaction failed before the coordinator node was ready to send the finalization request. Then, after receiving the client's write request, the participant node can send a write response to the client instructing the re-execution of the target transaction to achieve recovery of the transaction.
[0096] After the coordinator node and the participant node also persist the write operation logs for which they are responsible, the write operation log of the transaction is actually stored in two copies, the first copy is persisted by the client, and the second copy is persisted by the coordinator node and the participant node. Although this can facilitate the use of the write operation log, it also causes redundant storage. In order to reduce the overhead on storage space, the database system provided by the embodiment of the present application also has a storage space recovery mechanism. In one implementation, the coordinator node is also used to send a storage space recovery request to the client when the target transaction is completed, and the recovery request carries indication information of the storage space. The client is also used to reclaim the storage space based on the recovery request. Optionally, the indication information of the storage space can be the address of the storage space, for example, the indication information can be plogId and offset. Alternatively, the indication information can directly indicate the data to be recovered, and the client can obtain the storage space to be recovered based on the indication information and the storage address of its persisted data.
[0097] The following describes a data management method for a database system provided in an embodiment of the present application. The method is applied to a database system provided in an embodiment of the present application. As shown in FIG4 , the data management method for a database system includes the following steps:
[0098] Step 401: The client sends a first write request of a target transaction to a first database node. The first write request is used to indicate first data to be written.
[0099] When a client needs to perform a write operation, as shown by a1 in Figure 5, it can send a first write request to a database node in the database system. In one implementation, the first write request carries first data and its key. The first data is the data for which the first database node is responsible. For example, suppose the client needs to execute the target transaction txnId: write a=10, write b=20, where a and b are mapped to different database nodes respectively. The client needs to send a request a to one database node, where request a is used to indicate writing a=10, and send a request b to another database node, where request b is used to indicate writing b=20. In this case, the first write request can be request a.
[0100] Step 402: The first database node sends a first write response to the client based on the first write request. The first write response carries a first write operation log of the first data.
[0101] After receiving the first write request, the first database node can first perform conflict detection and locking operations in the memory to determine whether there are available resources for executing the target transaction. After determining that there are available resources for executing the target transaction, as shown in a3 in Figure 5, the first database node can immediately send a first write response to the client. In this way, there is no need for the first database node to send the first write response to the client after persisting the first data, which can facilitate the client to send the next write request as soon as possible, reducing the delay in the client processing transactions. Among them, the first write operation log carries relevant information indicating the persistence method of the first data. For example, the first write operation log carries information such as the key used to persist the first data.
[0102] When the first database node is the first to receive a write request belonging to a target transaction in the database system, the first database node becomes the coordinator node of the target transaction, and the data node that receives subsequent write requests belonging to the target transaction becomes the participant node of the target transaction. After the coordinator node receives the write request, as shown in a2 in Figure 5, after determining that there are available resources for executing the target transaction, it is also necessary to persist the state of the target transaction as being executed (inProgress), while the participant node does not need to persist the state of the target transaction. In addition, the write response can be sent after the coordinator node completes the persistence of the state of the target transaction. For example, continuing with the example of step 401, Figure 6 is a schematic diagram of the data persisted in the client, the first database node, and the second database node during the execution of the transaction. As shown in Figure 6, in the entire execution timeline of the target transaction, the first data to be persisted is the transaction state txnId inProgress persisted in the first database node.
[0103] Step 403: The client sends a second write request of the target transaction to the second database node, where the second write request is used to indicate second data to be written.
[0104] When a client's write operation requires multiple write requests, after receiving the first write response, the client can send a second write request for the target transaction to the second database node, as shown in step a4 in Figure 5. In one implementation, the second write request carries the second data and its key. This second data is the data for which the second database node is responsible. Continuing with the example in step 401, this second write request can be request b.
[0105] Step 404: The second database node sends a second write response to the client based on the second write request. The second write response carries a second write operation log of the second data.
[0106] After receiving the second write request, the second database node can first perform conflict detection and locking operations in the memory to determine whether there are available resources for executing the transaction. After determining that there are available resources for executing the transaction, as shown in a5 in Figure 5, the second database node immediately sends a second write response to the client. In this way, there is no need for the second database node to send the second write response to the client after persisting the second data, which can facilitate the client to send the next write request as soon as possible and reduce the delay in the client processing the transaction. Among them, the second write operation log carries relevant information indicating the persistence method of the second data. For example, the second write operation log carries information such as the key used to persist the second data.
[0107] Step 405: The client uses storage resources to batch persist the first write operation log and the second write operation log.
[0108] After receiving a write response from a database node, the client can persist the write operation logs carried in the write response. In one implementation, after receiving multiple write operation logs, the client can batch-persist the multiple write operation logs. For example, as shown in a6 in Figure 5 , after receiving all write responses for a target transaction, the client can batch-persist the write operation logs carried in all write responses. That is, the client can persist all write operation logs for a target transaction by sending a single persistence request to the storage resource. The persistence request is used to request persistence of the write operation logs in the storage resource. This reduces the number of persistence requests sent by the client to the storage resource, thereby reducing the total number of requests required by the database system to process a single transaction, thereby achieving a higher maximum throughput for the database system. For example, continuing with the example of step 401, as shown in Figure 6 , in the entire execution timeline of the target transaction, following the persistence of the transaction status txnId inProgress, the next data to be persisted is the write operation log txnId a=10b=20 of the target transaction persisted in the client.
[0109] It's important to note that when a client persists all write operation logs for a target transaction in batches, it can cache each write operation log locally before persisting all write operation logs in batches after receiving all the write operation logs for the target transaction. Furthermore, if a transaction needs to be rolled back, the client does not need to persist the write operation logs, which reduces persistence request overhead.
[0110] When the client has exclusive storage resources, the client is specifically used to persist the write operation log in its exclusive storage resources. Among them, the client's exclusive resources can be obtained through prior declaration. In addition, when the client persists the write operation log in the storage resource, it can write the write operation log to the storage resource by appending. In this way, when the client persists the write operation log in its exclusive storage resource, all the write operation logs are stored in the exclusive resource. When the target transaction has multiple write operation logs, the multiple write operation logs are stored continuously in the storage resource. When it is necessary to read all the write operation logs of the target transaction, the multiple write operation logs of the target transaction can be read sequentially in the exclusive storage, which can shorten the time spent on reading the write operation logs and ensure the reading speed of the write operation logs.
[0111] Step 406: The client sends a commit request to the coordinator node. The commit request carries all write operation logs of the target transaction.
[0112] After the client persists all the write operation logs of the target transaction, as shown in a7 in Figure 5, it can send a commit request to the coordinator node to request that the target transaction be committed. In the database system provided in the embodiment of the present application, in order to facilitate the subsequent use of the write operation log, the coordinator node and the participant node can also persist the write operation log. In one implementation, the write operation logs persisted by the coordinator node and the participant node can be provided by the client. The client can also provide the coordinator node with all the write operation logs of the target transaction. Optionally, the timing at which the client provides the coordinator node with all the write operation logs of the target transaction can be adjusted according to application requirements. For example, after the client persists all the write operation logs of the target transaction, it can provide the coordinator node with all the write operation logs of the target transaction. For another example, the client can provide the coordinator node with all the write operation logs of the target transaction when sending a commit request to the coordinator node. For example, all the write operation logs of the target transaction can be carried in the commit request.
[0113] In order to ensure that the coordinator node can obtain the write operation log of the target transaction, the client is also used to provide the storage address of the write operation log to the coordinator node. The storage address is the address obtained by the client to persist the write operation log. In one implementation, the storage address may include the starting address and offset of the write operation log in the storage resource. For example, when plog is used to store the write operation log, the storage address may include plogId and offset. In this way, when the write operation log sent by the client to the coordinator node cannot be obtained, such as the write operation log sent by the client to the coordinator node cannot be obtained due to the coordinator node crashing and restarting, the coordinator node can obtain the client's persistent write operation log through the storage address.
[0114] Step 407: The coordinator node commits the target transaction based on the commit request, obtains the third write operation log for which the coordinator node is responsible based on the write operation log, and persists the third write operation log using storage resources.
[0115] After receiving the commit request, as shown in a8 in Figure 5 , the coordinator node, after determining that there are available resources for executing the target transaction, can persist the target transaction's status as committed, thereby committing the target transaction. As shown in a9 in Figure 5 , the coordinator node then sends a commit response to the client, facilitating the client's request for the next transaction. For example, continuing with the example of step 401, as shown in Figure 6 , throughout the entire execution timeline of the target transaction, following the persistence of the target transaction's write operation log txnId a 10b 20, the next data persisted is the transaction status txnId committed persisted in the first database node.
[0116] Optionally, after the coordinator node receives all the write operation logs of the target transaction, as shown in a10 in Figure 5, it can obtain the third write operation log for which the coordinator node is responsible, and use storage resources to persist the third write operation log so that the third write operation log can be used later. In one implementation, the coordinator node can obtain the third write operation log for which the coordinator node is responsible from all the write operation logs of the target transaction based on the information carried in the write response sent by the coordinator node to the client, for example, based on the key carried in the write response sent by the coordinator node to the client. Optionally, persisting the third write operation log can be performed after sending the commit response. In this way, the client can immediately process the next transaction after receiving the commit response. In addition, when the client also provides the coordinator node with the storage address of all the write operation logs of the target transaction, the coordinator node also uses storage resources to persist the storage address. In one implementation, when a commit request carries a write operation log and its storage address, to ensure that the write operation log can be obtained, the coordinator node may first persist the storage address after receiving the commit request, and then persist the third write operation log after obtaining the third write operation log. In addition, the coordinator node may send a commit response to the client after persisting the transaction status txnId committed and the storage address. For example, continuing with the example of step 401, as shown in FIG6 , in the entire execution timeline of the target transaction, after persisting the write operation log txnId a 10b 20 of the target transaction, what is persisted next is the transaction status txnId committed and the plogId and offset in the storage address of all the write operation logs of the target transaction, followed by the third write operation log txnId commit a 10 persisted in the first database node. Alternatively, the storage address can be persisted in batches together with the third write operation log, which can reduce the number of persistence requests sent to the storage resource.
[0117] When the coordinator node has exclusive storage resources, the coordinator node is specifically used to persist the third write operation log in its exclusive storage resources. Among them, the exclusive resources of the coordinator node can be obtained by prior declaration. In addition, when the coordinator node persists the write operation log in the storage resource, it can write the write operation log to the storage resource by appending. In this way, when the coordinator node persists the write operation log in its exclusive storage resource, the data stored in the exclusive storage resource is the relevant information of the transaction (such as the status of the transaction) and the write operation log, and the relevant information of the transaction and the write operation log are stored continuously in the storage resource in time sequence. When the coordinator node needs to obtain the relevant information and write operation log of the target transaction, it can read the relevant information and write operation log of the target transaction sequentially in its exclusive storage to ensure the reading speed. For example, when the target transaction needs to be recovered, the coordinator node usually needs to query the status of the target transaction first, and then determine whether transaction recovery needs to be performed based on the third write operation log based on the status. When transaction recovery needs to be performed based on the third write operation log, the third write operation log can be read sequentially after the storage address of the target transaction status. This can shorten the time spent on reading the status and writing the operation log, and help ensure the speed of transaction recovery.
[0118] The coordinator node persists the write operation log for which it is responsible. When the coordinator node needs to use the write operation log, for example, when transaction recovery is required based on the write operation log, the coordinator node can obtain its own persisted write operation log from its own storage resources and perform related processing based on the obtained write operation log without obtaining the client's persisted write operation log and repeatedly reading its own storage resources and the client's storage resources, which is conducive to improving the execution speed of operations performed based on the write operation log.
[0119] Step 408: The coordinator node obtains the fourth write operation log for which the participant node is responsible based on the write operation log, and sends the fourth write operation log to the participant node.
[0120] The commit request also carries indication information of the participant node. The coordinator node can determine the participant node of the target transaction based on the indication information, obtain the fourth write operation log for which the participant node is responsible from all write operation logs of the target transaction, and then send the fourth write operation log to the participant node. In one implementation, the indication information can include the address of the participant node and the key range of the write operation log for which the participant node is responsible. The coordinator node can determine the participant node of the target transaction based on the address of the participant node, and obtain the fourth write operation log for which the participant node is responsible from all write operation logs of the target transaction based on the key range of the write operation log for which the participant node is responsible.
[0121] After the coordinator node commits the transaction, as shown in a11 in Figure 5 , it sends a finalization request to the participant node, instructing the participant node to change the status of the write data it is responsible for to committed. In one implementation, the finalization request sent by the coordinator node to the participant node may include a fourth write operation log sent to the participant node. Optionally, the coordinator node can send the finalization request to the participant node asynchronously with the coordinator node sending the commit response.
[0122] Step 409: The participant node uses storage resources to persist the fourth write operation log.
[0123] When a participant node has exclusive storage resources, as shown in a12 in Figure 5, the participant node is specifically configured to persist the fourth write operation log in its exclusive storage resources to facilitate subsequent use of the fourth write operation log. The exclusive resources of the participant node can all be obtained through prior declaration. Furthermore, when the participant node persists the write operation log in the storage resource, it can write the write operation log to the storage resource via an append write. Furthermore, as described above, the process of the coordinator node sending a finalization request to the participant node and the process of the coordinator node sending a commit response can be executed asynchronously. Accordingly, the process of the coordinator node persisting the third write operation log and the participant persisting the fourth write operation log can be executed asynchronously. For example, continuing with the example of step 401, as shown in Figure 6, in the entire execution timeline of the target transaction, following the persistence of the third write operation log txnId commit a 10, the next data to be persisted is the fourth write operation log txnId commit b 20 persisted in the second database node.
[0124] In this way, when the participant node persists the write operation log in its exclusive storage resource, the data stored in the exclusive storage resource is the commit log and the write operation log, and the commit log and the write operation log are stored in the storage resource in a time sequence. When the participant node needs to obtain the commit log and the write operation log, it can read the commit log and the write operation log sequentially in its exclusive storage to ensure the reading speed. For example, when it is necessary to recover the target transaction, the participant node usually needs to query the commit log of the target transaction first, and then determine whether it is necessary to perform transaction recovery based on the fourth write operation log according to the status indicated by the commit log. When it is necessary to perform transaction recovery based on the fourth write operation log, it can read the fourth write operation log sequentially after the storage address of the status of the target transaction. This can shorten the time spent on reading the status and write operation logs, and help ensure the speed of transaction recovery.
[0125] The participant node persists the write operation log for which it is responsible. When the participant node needs to use the write operation log, for example, when transaction recovery is required based on the write operation log, the participant node can obtain its own persisted write operation log from its own storage resources and perform related processing based on the obtained write operation log, without having to obtain the client's persisted write operation log and repeatedly reading its own storage resources and the client's storage resources, which is conducive to improving the execution speed of operations performed based on the write operation log.
[0126] After the participant node modifies the status of the write data it is responsible for to committed, as shown in a13 in Figure 5, it can send a finalized response to the coordinator node. After the coordinator node receives the finalized responses from all participant nodes, as shown in a14 in Figure 5, after determining that there are available resources for executing the target transaction, it can persist the status of the target transaction as completed, to indicate that the transaction has been submitted normally and the cleanup of the response has been completed. For example, continuing with the example of step 401, as shown in Figure 6, in the entire execution timeline of the target transaction, after persisting the fourth write operation log txnId commit b 20, the next data to be persisted is the transaction status txnId finalized persisted in the first database node.
[0127] Step 410: When any data node among the multiple data nodes needs to recover a target transaction, it obtains the current state of the target transaction and executes a recovery process of the target transaction based on the current state.
[0128] When the status of the target transaction to be recovered is different, the operations that need to be performed to recover the target transaction are different. Then any data node among the multiple data nodes is also used to obtain the current status of the target transaction when the target transaction needs to be recovered, and execute the recovery process of the target transaction based on the current status. According to the previous description, the coordinator node needs to maintain the metadata of the transaction. For example, the coordinator node needs to record the transaction status, and the participant node does not need to maintain the transaction status displayed to all nodes processing the transaction, but needs to record the write operation status of the transaction. Therefore, when the coordinator node recovers the transaction, the transaction status that needs to be referenced is the transaction status recorded by the coordinator node. When the participant node recovers the transaction, the transaction status that needs to be referenced is the write operation status recorded by the participant node. There are some differences in the recovery mechanisms of the coordinator node and the participant node, which are explained below.
[0129] The data recovery process of the coordinator node includes the following recovery situations:
[0130] In the first recovery scenario, when the current status indicates that the target transaction is in the executing state, the coordinator node, after receiving the client's write request, sends a write response to the client instructing it to re-execute the target transaction, causing the client to perform an abort-retry operation on the transaction based on the write response. When the target transaction is in the executing state, as shown in Figure 7, the execution progress of the target transaction may only reach Q11. Before recovery begins, the client has not yet persisted the target transaction's write operation log. Therefore, an abort-retry operation is required to recover the target transaction.
[0131] In the second recovery scenario, when the current status indicates that the target transaction is in the committed state, the coordinator node obtains the client's persistent write operation log and performs a replay operation based on the client's persistent write operation log. When the target transaction is in the committed state, as shown in Figure 7, the execution progress of the target transaction may only reach Q12. The target transaction has been successfully committed, but the coordinator node may not have persisted the write operation log for which it is responsible. In this case, the coordinator node can obtain the client's persistent write operation log and perform a replay operation based on the client's persistent write operation log. For example, the coordinator node can obtain the client's persistent write operation log from the storage address of the write operation log provided to it by the client.
[0132] Furthermore, in this second scenario, since the participant node may not have persisted the write operation log for which it is responsible, the coordinator node is further configured to obtain a fourth write operation log for which the participant node is responsible based on the write operation log persisted by the client, and send the fourth write operation log to the participant node. In this case, the participant node is further configured to persist the fourth write operation log using storage resources.
[0133] In the third recovery scenario, when the current state indicates that the target transaction is completed, the coordinator node retrieves the third write operation log and performs a replay operation based on the third write operation log. When the target transaction is in the completed state, as shown in Figure 7, the execution progress of the target transaction may only reach Q13. The target transaction was successfully committed and cleaned up, and the coordinator node has persisted the write operation log for which it is responsible. In this case, the coordinator node can retrieve its own persisted write operation log and perform a replay operation based on the third write operation log.
[0134] The implementation process of data recovery by participant nodes includes the following recovery situations:
[0135] In the first recovery scenario, when the current state indicates that the participant node has persisted the write operation log for the target transaction, the participant node can perform a replay operation based on the fourth write operation log. For example, when a participant node finds a commit log in its log, as shown in Figure 8, the execution progress of the target transaction may only reach Q21. The participant node has persisted the write operation log for which it is responsible, so it can replay the commit log to recover the transaction.
[0136] In the second recovery scenario, when the current status indicates that the participant node has not persisted the write operation log for the target transaction, if the participant node receives the fourth write operation log for which the participant node is responsible within a specified time period, a replay operation is performed based on the fourth write operation log. For example, when the participant node does not find a commit log in its log, as shown in Figure 8, the execution progress of the target transaction may only reach Q22, and the participant node has not yet persisted the write operation log for which it is responsible. In this case, the participant node can wait for a period of time. If it receives a finalization request from the coordinator node within the specified time period, or if the participant node receives a finalization request for the target transaction from the coordinator node after querying the coordinator node, this indicates that the coordinator node is able to send the finalization request to the participant node normally, but the participant node had not received the finalization request from the coordinator node when recovery began. After receiving the finalization request, the participant node can directly perform a replay operation based on the write operation log contained in the finalization request to achieve transaction recovery. The timestamp of the finalization request for the target transaction is less than the timestamp when the participant node started recovering the transaction.
[0137] The third recovery situation is when the current status indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log that the participant node is responsible for has not been received within the specified time period, the participant node sends a write response to the client instructing the re-execution of the target transaction after receiving the write request from the client. For example, when the participant node does not find the commit log in its log, as shown in Figure 8, the execution progress of the target transaction may only reach Q22. After the participant node inquires with the coordinator node, if it is determined that there is no finalization request for the target transaction that the coordinator node has not sent, it means that the execution of the transaction failed before the coordinator node was ready to send the finalization request. Then, after receiving the write request from the client, the participant node can send a write response to the client instructing the re-execution of the target transaction to achieve recovery of the transaction.
[0138] Step 411: When the target transaction is completed, the coordinator node sends a storage space reclaim request to the client, where the reclaim request carries indication information of the storage space.
[0139] After the coordinator node and the participant node also persist the write operation logs for which they are responsible, the write operation log of the transaction is actually stored in two copies, the first copy is persisted by the client, and the second copy is persisted by the coordinator node and the participant node. Although this can facilitate the use of the write operation log, it also causes redundant storage. In order to reduce the overhead on the storage space, the database system provided by the embodiment of the present application also has a storage space recovery mechanism. In one implementation, as shown in a15 in Figure 5, the coordinator node is also used to send a storage space recovery request to the client when the target transaction is completed, and the recovery request carries indication information of the storage space. Optionally, the indication information of the storage space can be the address of the storage space, for example, the indication information can be plogId and offset. Alternatively, the indication information can directly indicate the data to be recovered, so that the client can obtain the storage space to be recovered based on the indication information and the storage address of its persisted data.
[0140] Step 412: The client reclaims the storage space based on the reclaim request.
[0141] After the client receives the recycling request, it can reclaim the storage space based on the recycling request. It should be noted that the description here is based on the recycling of the storage resources corresponding to the client, but it does not exclude the recycling of the storage resources corresponding to the database node. Ordinary technicians in this field know that as business needs change, the objects that need to be recycled can be adjusted according to application needs, and no specific restrictions are made here. In addition, when recycling the storage resources corresponding to the database node, the implementation method of the recycling can refer to the implementation method of recycling the storage resources corresponding to the database node, which will not be repeated here.
[0142] In one implementation, when a plog is used to store the target transaction's data, the data is written to the storage resource in an append-only manner, and the reclaim request indicates a plogId and an offset, the client can maintain a local hash table and use this hash table to manage the storage resource's usage. As shown in Figure 9, the hash table includes multiple index chunks. Each chunk is used to store index information for data written through the same input / output interface (I / O interface) address. Each data write process generates a new index. Each plog can store data corresponding to multiple chunks. The plogId in the hash table indicates the plog storing the data, the offset indicates the chunk's offset within the current plog, and the isFinalized field indicates whether the data in the chunk can be reclaimed: false (e.g., f in Figure 9) indicates that it cannot be reclaimed, and true (e.g., t in Figure 9) indicates that it can be reclaimed. The hash table has a head and a tail, and the nodes between the head and the tail represent all unreclaimed chunks in the storage resource. After receiving the recycling request, the client can compare the plogId and offset in the recycling request with the hash table and execute the corresponding processing strategy based on the comparison results. It mainly includes the following three situations:
[0143] In the first case, when the plogId in the reclaim request is different from the plogId pointed to by the head in the hash list, and / or the offset in the reclaim request is different from the offset pointed to by the head in the hash list, the isFinalized of the chunk currently pointed to by the head is changed to true.
[0144] In the second case, when the plogId in the recycling request is the same as the plogId pointed to by the head in the hash list, and the offset in the recycling request is the same as the offset pointed to by the head in the hash list, the head is moved to the next chunk whose isFinalized is false in the order of the hash list.
[0145] In the third case, when the head finds that the plog to which the next chunk belongs is different from the plog to which the current chunk belongs during the movement, it means that all chunks corresponding to the plog to which the current chunk belongs have been used up, and the plog can be recycled.
[0146] As shown in Figure 9, when the plogId in the reclaim request is the same as the plogId pointed to by the head in the hash list, and the offset in the reclaim request is the same as the offset pointed to by the head in the hash list, the head is moved to the second chunk in Figure 9 according to the order of the hash list. Since isFinalized in the second chunk is true, the head needs to be moved back again, that is, to the third chunk in Figure 9. At this time, it is found that the plogId of the third chunk in Figure 9 is 2, which is different from the plogId of 1 in the case of the chunk pointed to by the head before the move. Therefore, at this time, the client can send a request to the storage resource to instruct it to reclaim the plog with plogId 1, so that the storage resource will reclaim the plog.
[0147] In summary, in the data management method for a database system provided in an embodiment of the present application, the client persists the first write operation log, allowing the database node to send a write response to the client without persisting the write operation log. This facilitates the client to send the next write request as quickly as possible, reducing the client's transaction processing latency, resolving the issue of excessive client transaction processing latency, and alleviating the persistence load on the database node. Furthermore, the client can batch persist all write operation logs in a single transaction, reducing the number of persistence requests sent by the client to the storage resource, thereby reducing the total number of requests the database system needs to send to process a single transaction, and thus achieving a higher extreme throughput for the database system, for example, a 160% improvement in extreme performance. In addition, during transaction processing, although the client caches the write operation log locally, it still sends a write request to the database node to notify the database node to perform conflict detection and locking operations. This allows the database system to discover conflicts between transactions more quickly, avoiding additional waste and achieving better throughput performance under the same degree of data contention load, such as achieving better performance under high-contention workload.
[0148] It should be noted that the order of the steps in the data management method for a database system provided in the embodiments of the present application can be adjusted appropriately, and the number of steps can be increased or decreased accordingly. Any method that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application, and therefore will not be described in detail.
[0149] The following is an example of the hardware structure involved in the embodiments of the present application.
[0150] An embodiment of the present application provides a computing device. The computing device is used to implement some or all of the functions of the data management method provided in the embodiment of the present application. For example, it implements the functions of a customer database node or storage resource. Figure 10 is a schematic diagram of the structure of a computing device provided in the embodiment of the present application. As shown in Figure 10, the computing device 1000 includes a processor 1001, a memory 1002, a communication interface 1003, and a bus 1004. The processor 1001, the memory 1002, and the communication interface 1003 are connected to each other via the bus 1004.
[0151] Processor 1001 may include a general-purpose processor and / or a dedicated hardware chip. A general-purpose processor may include: a central processing unit (CPU), a microprocessor or a graphics processing unit (GPU). The CPU is, for example, a single-core processor (single-CPU), or a multi-core processor (multi-CPU). A dedicated hardware chip is a hardware module for high-performance processing. The dedicated hardware chip includes at least one of a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or a network processor (NP). Processor 1001 may also be an integrated circuit chip with signal processing capabilities. During implementation, some or all of the functions of the data management method of the present application may be completed by the hardware integrated logic circuit in the processor 1001 or instructions in the form of software.
[0152] Memory 1002 is used to store computer programs, which include an operating system 1002a and executable code (i.e., program instructions) 1002b. Memory 1002 may be, for example, a read-only memory or other type of static storage device capable of storing static information and instructions, or a random access memory or other type of dynamic storage device capable of storing information and instructions, or an electrically erasable programmable read-only memory, a read-only optical disc or other optical disc storage, an optical disc storage (including a compact disc, laser disc, optical disc, digital versatile disc, Blu-ray disc, etc.), a magnetic disk storage medium, or other magnetic storage device, or any other medium capable of carrying or storing desired executable code in the form of instructions or data structures and accessible by a computer, but not limited to these. For example, memory 1002 is used to store an outbound port queue, etc. Memory 1002 may be independent and connected to processor 1001 via bus 1004. Alternatively, memory 1002 and processor 1001 may be integrated. Memory 1002 can store executable code. When the executable code stored in memory 1002 is executed by processor 1001, processor 1001 is used to perform some or all of the functions of the data management method provided in the embodiments of this application. For the implementation of the process executed by processor 1001, please refer to the relevant description of the aforementioned embodiments. Memory 1002 may also include software modules and data required for other running processes, such as an operating system.
[0153] The communication interface 1003 uses a transceiver module, such as, but not limited to, a transceiver, to communicate with other devices or communication networks. For example, the communication interface 1003 can be any one or a combination of the following devices: a network interface (such as an Ethernet interface), a wireless network card, or other device with network access capabilities.
[0154] Bus 1004 is any type of communication bus used to interconnect the internal components of a computing device (e.g., memory 1002, processor 1001, and communication interface 1003). For example, a system bus is provided. The embodiments of this application illustrate the interconnection of the aforementioned components within a computing device via bus 1004. Alternatively, the aforementioned components within computing device 1000 may be communicatively connected to each other using other connection methods besides bus 1004. For example, the aforementioned components within computing device 1000 may be interconnected via an internal logical interface.
[0155] It should be noted that the above-mentioned multiple devices can be respectively arranged on independent chips, or at least partially or completely arranged on the same chip. Whether each device is independently arranged on different chips or integrated on one or more chips often depends on the needs of product design. The embodiments of the present application do not limit the specific implementation form of the above-mentioned devices. The descriptions of the processes corresponding to the above-mentioned figures have different focuses. For parts that are not described in detail in a certain process, please refer to the relevant descriptions of other processes.
[0156] In the above embodiments, all or part of the embodiments may be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product providing a program development platform includes one or more computer instructions that, when loaded and executed on a computing device, fully or partially implement the functions of the data management method provided in the embodiments of the present application.
[0157] Furthermore, computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium stores computer program instructions that provide a program development platform.
[0158] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, some of the computing devices in the computing device cluster can also be terminal devices such as desktop computers, laptop computers, or smartphones.
[0159] Optionally, the structure of at least one computing device included in the computing device cluster may refer to the computing device 1000 shown in Figure 10. The memory 1002 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the data management method.
[0160] In some possible implementations, the memory 1002 of one or more computing devices 1000 in the computing device cluster may also store some instructions for executing the data management method. In other words, the combination of one or more computing devices 1000 can jointly execute the instructions for executing the data management method.
[0161] It should be noted that the memory 1002 in different computing devices 1000 in the computing device cluster can store different instructions, each for executing a portion of the database system's functions. In other words, the instructions stored in the memory 1002 in different computing devices 1000 can implement the functions of the client, database node, and storage resource.
[0162] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network (WAN) or a local area network (LAN), etc. FIG11 shows a possible implementation. As shown in FIG11 , two computing devices 1100A and 1100B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, computing devices 1100A and 1100B include a bus 1102, a processor 1104, a memory 1106, and a communication interface 1108. The memory 1106 in computing device 1100A stores instructions for executing the functions of the client. At the same time, the memory 1106 in computing device 1100B stores instructions for executing the functions of a database node.
[0163] It should be understood that the functions of computing device 1100A shown in FIG11 may also be performed by multiple computing devices 1100. Similarly, the functions of computing device 1100B may also be performed by multiple computing devices 1100. Furthermore, the deployment method of the modules used to implement the data management method in the computing devices may also be adjusted according to application requirements.
[0164] An embodiment of the present application also provides a computer-readable storage medium, which is a non-volatile computer-readable storage medium. The computer-readable storage medium includes program instructions. When the program instructions are executed on a computing device, the computing device implements the data management method provided in the embodiment of the present application.
[0165] The embodiment of the present application also provides a computer program product containing instructions. When the computer program product is run on a computer, the computer implements the data management method provided by the embodiment of the present application.
[0166] Those skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware, or by a program to instruct the relevant hardware, and the program may be stored in a computer-readable storage medium, which may be a read-only memory, a disk, or an optical disk, etc.
[0167] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, storage, display, etc.), and signals involved in this application are all authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the raw data and executable code involved in this application were obtained with full authorization.
[0168] In the embodiments of the present application, the terms "first," "second," and "third" are used for descriptive purposes only and should not be understood as indicating or implying relative importance. The term "at least one" refers to one or more, and the term "plurality" refers to two or more, unless otherwise expressly limited.
[0169] In this application, the term "and / or" simply describes an association between related objects, indicating that three possible relationships exist. For example, A and / or B can represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this document generally indicates that the related objects are in an "or" relationship.
[0170] The above description is merely an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the concepts and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A database system, characterized in that: The database system comprises: a client, a plurality of database nodes and storage resources, wherein the plurality of database nodes comprises a first database node; The client is used to send a first write request of a target transaction to a first database node, where the first write request is used to indicate first data to be written; The first database node is used to send a first write response to the client based on the first write request, where the first write response carries a first write operation log of the first data; The client is also used to use the storage resource to persist the first write operation log.
2. The database system according to claim 1, characterized in that: The plurality of database nodes further includes a second database node; The client is further used to send a second write request of the target transaction to the second database node, where the second write request is used to indicate second data to be written; The second database node is used to send a second write response to the client based on the second write request, where the second write response carries a second write operation log of the second data; The client is specifically used to use the storage resource to batch persist the first write operation log and the second write operation log.
3. The database system according to claim 1 or 2, characterized in that: The plurality of database nodes include a coordinator node and a participant node; The client is also used to provide all write operation logs of the target transaction to the coordinator node; The coordinator node is used to obtain a third write operation log for which the coordinator node is responsible based on all the write operation logs, and to persist the third write operation log using the storage resource; The coordinator node is further used to obtain, based on all the write operation logs, a fourth write operation log for which the participant node is responsible, and send the fourth write operation log to the participant node; The participant node is used to persist the fourth write operation log using the storage resource.
4. The database system according to claim 3, characterized in that: The client is also used to provide the coordinator node with the storage addresses of all the write operation logs.
5. The database system according to claim 3 or 4, characterized in that: Any data node among the multiple data nodes is further used to obtain the current state of the target transaction when it is necessary to recover the target transaction, and execute the recovery process of the target transaction based on the current state.
6. The database system according to claim 5, characterized in that: The coordinator node is specifically used for: When the current state indicates that the target transaction is in an executing state, after receiving the write request from the client, sending a write response to the client indicating re-execution of the target transaction; When the current state indicates that the target transaction is in a committed state, obtaining the persistent write operation log of the client, and performing a replay operation based on the persistent write operation log of the client; When the current state indicates that the target transaction is in a completed state, the third write operation log is obtained, and a replay operation is performed based on the third write operation log.
7. The database system according to claim 6, characterized in that: The coordinator node is further configured to, when the current state indicates that the target transaction is in a committed state, obtain a fourth write operation log for which the participant node is responsible based on the write operation log persisted by the client, and send the fourth write operation log to the participant node; The participant node is further used to utilize the storage resource to persist the fourth write operation log.
8. The database system according to claim 5, characterized in that: The participant node is specifically used for: When the current state indicates that the participant node has persisted the write operation log of the target transaction, performing a replay operation based on the fourth write operation log; When the current state indicates that the participant node has not persisted the write operation log of the target transaction, if a fourth write operation log for which the participant node is responsible is received within a specified time period, a replay operation is performed based on the fourth write operation log; When the current status indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log for which the participant node is responsible has not been received within the specified time period, after receiving the write request from the client, a write response is sent to the client instructing the re-execution of the target transaction.
9. The database system according to any one of claims 3 to 8, characterized in that: The coordinator node is further configured to send a storage space recovery request to the client when the target transaction is completed, wherein the recovery request carries indication information of the storage space; The client is further configured to reclaim the storage space based on the reclaim request.
10. The database system according to claim 9, characterized in that: The indication information is the address of the storage space.
11. A data management method for a database system, characterized in that: The database system comprises: a client, a plurality of database nodes and storage resources, the plurality of database nodes comprises a first database node, and the method comprises: The client sends a first write request of a target transaction to a first database node, where the first write request is used to indicate first data to be written; The first database node sends a first write response to the client based on the first write request, where the first write response carries a first write operation log of the first data; The client uses the storage resource to persist the first write operation log.
12. The method according to claim 11, characterized in that The plurality of database nodes further include a second database node, and the method further includes: The client sends a second write request of the target transaction to the second database node, where the second write request is used to indicate second data to be written; The second database node sends a second write response to the client based on the second write request, where the second write response carries a second write operation log of the second data; The client uses the storage resource to persist the first write operation log, including: The client uses the storage resource to batch persist the first write operation log and the second write operation log.
13. The method according to claim 11 or 12, characterized in that The plurality of database nodes include a coordinator node and a participant node, and the method further includes: The client provides all write operation logs of the target transaction to the coordinator node; The coordinator node obtains the third write operation log for which the coordinator node is responsible based on all the write operation logs, and uses the storage resource to persist the third write operation log; The coordinator node obtains the fourth write operation log that the participant node is responsible for based on all the write operation logs, and sends the fourth write operation log to the participant node; The participant node uses the storage resource to persist the fourth write operation log.
14. The method according to claim 13, characterized in that The method further comprises: The client provides the coordinator node with the storage addresses of all the write operation logs.
15. The method according to claim 13 or 14, characterized in that The method further comprises: When any data node among the multiple data nodes needs to recover the target transaction, it obtains the current state of the target transaction and executes the recovery process of the target transaction based on the current state.
16. The method according to claim 15, characterized in that The coordinator node performs a recovery process of the target transaction based on the current state, including: When the current state indicates that the target transaction is in an executing state, after receiving the write request from the client, sending a write response to the client indicating re-execution of the target transaction; When the current state indicates that the target transaction is in a committed state, obtaining the persistent write operation log of the client, and performing a replay operation based on the persistent write operation log of the client; When the current state indicates that the target transaction is in a completed state, the third write operation log is obtained, and a replay operation is performed based on the third write operation log.
17. The method according to claim 16, characterized in that The method further comprises: When the current state indicates that the target transaction is in a committed state, the coordinator node obtains the fourth write operation log for which the participant node is responsible based on the write operation log persisted by the client, and sends the fourth write operation log to the participant node; The participant node uses the storage resource to persist the fourth write operation log.
18. The method according to claim 15, characterized in that The participant node performs a recovery process of the target transaction based on the current state, including: When the current state indicates that the participant node has persisted the write operation log of the target transaction, performing a replay operation based on the fourth write operation log; When the current state indicates that the participant node has not persisted the write operation log of the target transaction, if a fourth write operation log for which the participant node is responsible is received within a specified time period, a replay operation is performed based on the fourth write operation log; When the current status indicates that the participant node has not persisted the write operation log of the target transaction, and the fourth write operation log for which the participant node is responsible has not been received within the specified time period, after receiving the write request from the client, a write response is sent to the client instructing the re-execution of the target transaction.
19. The method according to any one of claims 13 to 18, characterized in that: After the participant node persists the fourth write operation log using the storage resource, the method further includes: When the target transaction is completed, the coordinator node sends a storage space recovery request to the client, where the recovery request carries indication information of the storage space; The client reclaims the storage space based on the reclaim request.
20. The method of claim 19, wherein: The indication information is the address of the storage space.
21. A computing device cluster, characterized in that: The method comprises a plurality of computing devices, wherein the plurality of computing devices comprises a plurality of processors and a plurality of memories, wherein program instructions are stored in the plurality of memories, and the plurality of processors execute the program instructions, so that the computing device cluster executes any one of the methods described in claims 11 to 20.
22. A computer-readable storage medium, characterized in that: The method comprises program instructions, and when the program instructions are executed on a computing device, the computing device is caused to execute the method according to any one of claims 11 to 20.
Citation Information
Patent Citations
Database system and data management method thereof
CN118733552A
Distributed transaction processing method on cloud computing platform
CN102831156A
Data writing method and device, electronic equipment and storage medium
CN115408411A
Transaction submission system, method and device based on distributed database system
CN115658245A
Write Access Control in a Database
US20180150504A1
Cited By
Business processing method and electronic equipment
CN120196272A
