Database system and data management method thereof
Persisting the write operation log through the client solves the problem of excessive transaction processing delay in the database system, reduces the load on the database node, and improves the system throughput rate and transaction recovery speed.
Patent Information
- Application Number
- CN202310684553.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-03-31
- Filing Date
- 2023-06-09
- Publication Date
- 2024-10-01
Smart Images

Figure CN118733552A_ABST
Abstract
Description
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, in the transaction processing process of the database system, the joint participation and collaborative processing of multiple database nodes are required. In addition, in the transaction processing process, after receiving the write request from the client, the coordinator node and the participant node need to perform the corresponding persistence operation before returning the corresponding write response to the client. Since the persistence operation is on the critical path of the transaction processing process, it will cause the end-to-end delay of a single transaction to be too long. Summary of the invention
[0004] The present application provides a database system and a data management method thereof. The present application reduces the latency of client-side transaction processing, can solve the problem of excessive latency of client-side transaction processing, and reduces the persistent load of database nodes. The technical solutions provided by the present application are as follows:
[0005] In a first aspect, the present application provides a database system. The database system includes: a client, multiple database nodes and storage resources, the multiple database nodes include a first database node; the client is used to send a first write request of a target transaction to the first database node, 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, 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.
[0006] In this database system, the first write operation log is persisted by the client, 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.
[0007] Optionally, the multiple database nodes also include a second database node; the client is also used to send a second write request of 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 is used to send 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 is specifically used to use the storage resources to batch persist the first write operation log and the second write operation log. In this way, the number of persistence requests sent by the client to the storage resources 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 limit throughput rate to the database system.
[0008] 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. At this time, 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, the write operation log can be written 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 continuously stored 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.
[0009] In the database system, multiple 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 write operation logs, and to persist the third write operation log using storage resources; the coordinator node is also used 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; the participant node is used to persist the fourth write operation log using storage resources.
[0010] In this way, both the coordinator node and the participant node can persist the write operation logs they are responsible for. When the write operation logs are needed, for example, when transaction recovery is needed 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 repeatedly reading their own storage resources and the client's storage resources, which is beneficial to improving the execution speed of operations performed based on the write operation logs.
[0011] 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 all write operation logs to the coordinator node.
[0012] When the coordinator node has an exclusive storage resource, the coordinator node is specifically used to persist the third write operation log in its exclusive storage resource. And / or, when the participant node has an exclusive storage resource, the participant node is specifically used to persist the fourth write operation log in its exclusive storage resource. In addition, the coordinator node and / or the participant node can write the write operation log to the storage resource by appending. 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 in the storage resource in a continuous 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 query the status of the target transaction first, 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.
[0013] In one implementation, 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.
[0014] Among them, the coordinator node is specifically used for: when the current status indicates that the target transaction is in the executing state, after receiving the write request from the client, sending 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, 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 status indicates that the target transaction is in the completed state, obtaining a third write operation log, and performing a replay operation based on the third write operation log.
[0015] Optionally, the coordinator node is also used to obtain the 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 when the current status indicates that the target transaction is in a committed state; the participant node is also used to persist the fourth write operation log using storage resources.
[0016] 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.
[0017] When 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 in 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 the indication information of the storage space; the client is also used to recycle the storage space based on the recovery request.
[0018] Optionally, the indication information is the address of the storage space.
[0019] 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, the multiple database nodes include a first database node, and the method includes: the client sends a first write request of a target transaction to the first database node, the first write request is used to indicate the first data to be written; 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; the client uses the storage resources to persist the first write operation log.
[0020] 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, and 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.
[0021] Optionally, the client uses storage resources to persist the first write operation log, including: the client persists the write operation log in its exclusive storage resources.
[0022] 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.
[0023] Optionally, the method further includes: the client providing the coordinator node with storage addresses of all write operation logs.
[0024] 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.
[0025] Optionally, data in the storage resource is written by appending.
[0026] 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 the recovery process of the target transaction based on the current state.
[0027] 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 to re-execute 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.
[0028] 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 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 persists the fourth write operation log using storage resources.
[0029] 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 a 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 write request from the client, sending a write response to the client instructing the re-execution of the target transaction.
[0030] 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, the recovery request carries indication information of the storage space; the client reclaims the storage space based on the recovery request.
[0031] Optionally, the indication information is the address of the storage space.
[0032] In a third aspect, the present application provides a computing device comprising a memory and a processor, the memory storing program instructions, and the processor executing the program instructions to implement a client, a database node or a storage resource in the system provided in the first aspect of the present application and any possible implementation thereof.
[0033] In a fourth aspect, the present application provides a computing device cluster, including multiple computing devices, the multiple computing devices including multiple processors and multiple memories, the multiple memories storing program instructions, and the multiple processors executing 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 method thereof.
[0034] In a fifth aspect, the present application provides a computer-readable storage medium, which is a non-volatile computer-readable storage medium, and 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.
[0035] In a sixth aspect, the present application provides a computer program product comprising instructions, which, when executed 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
[0036] Figure 1It 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;
[0037] Figure 2 It is a schematic diagram of a storage-computing integrated architecture provided in an embodiment of the present application;
[0038] Figure 3 It is a schematic diagram of a storage-computing separation architecture provided in an embodiment of the present application;
[0039] Figure 4 is a flow chart of a data management method for a database system provided in an embodiment of the present application;
[0040] Figure 5 It is a schematic diagram of the process of executing a transaction in a data management method of a database system provided in an embodiment of the present application;
[0041] Figure 6 It 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;
[0042] Figure 7 It is a schematic diagram of a coordinator node recovery transaction provided in an embodiment of the present application;
[0043] Figure 8 It is a schematic diagram of a participant node recovery transaction provided by an embodiment of the present application;
[0044] Fig. 9 It is a schematic diagram of managing the usage of storage resources through a hash linked table provided in an embodiment of the present application;
[0045] Fig.10 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0046] Fig.11 It is a structural diagram of a computing device cluster provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0048] This article provides a detailed introduction to the technical solution of the present application from multiple perspectives, including implementation scenarios, system composition, method flow, and hardware devices.
[0049] The following first describes the application scenarios of the embodiments of the present application with examples.
[0050] Figure 11 is a schematic diagram of a structure of an implementation scenario of a data management method for a database system provided in an embodiment of the present application. Figure 1 As shown, the implementation scenario includes: a database system. The database system includes: a client 101, multiple database nodes 102 and a storage resource 103. A communication connection can be established between each 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 through a network, a communication connection can be established between the client 101 and the storage resource 103 through a network, and a communication connection can be established between the storage resource 103 and the database node 102 through a network. Optionally, the network can be a local area network, the Internet, or other networks, which is not limited in the embodiments of the present application.
[0051] The client 101 is used to send transaction statements to the database node. The client 101 in this article refers to a node that directly communicates with the database node, which can be a gateway node of the system or a client node with a client installed. For example, the client may be a gateway server of the entire database system, or it may be a client proxy cluster that supports dynamic expansion and contraction. Optionally, the client node can be a computer, a personal computer, a laptop computer, a mobile phone, a smart phone, a tablet computer, a cloud host, a portable mobile terminal, a multimedia player, an e-book reader, a wearable device, a smart home appliance, an artificial intelligence device, a smart wearable device, a smart vehicle-mounted device or an Internet of Things device, etc.
[0052] The database node 102 is used to process read and write requests in transactions. The database node 102 can be a server, or a server cluster consisting of several servers, or a cloud computing service center. Among them, a large number of basic resources owned by the cloud service provider are deployed in the cloud computing service center. For example, computing resources, storage resources, and network resources are deployed in the cloud computing service center. The cloud computing service center can use this large number of basic resources to implement the data management method of the database system provided in the embodiment of the present application.
[0053] 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, which is not specifically limited in the embodiment of the present application. It should be noted that in Figure 1 In the implementation scenario shown, the database node 102 may also be implemented through other resource platforms besides the cloud platform, and the embodiments of the present application do not specifically limit it.
[0054] Storage resource 103 is a storage medium for storing data in a database system, also known as persistent storage. A high storage resource may be a persistent storage medium such as a non-volatile memory (NVM), a solid state drive (SSD), or a hard disk drive (HDD), and the present application embodiment does not specifically limit it.
[0055] In terms of implementation, the storage resource 103 may be a storage pool implemented by multiple servers. Furthermore, the storage resource 103 may be a storage resource of a server used as a database node 102, that is, the storage resource 103 is equivalent to a medium for storing data copies in the database node 102. In this case, the database system 10 is a storage-computing integrated architecture. Alternatively, the storage resource 103 may be a storage resource independent of a server used as a database node 102, and the storage resource 103 may be regarded as a storage pool at the remote end of the database node 102, and all database nodes 102 may access the storage resource 103. In this case, the database system 10 is a storage-computing separation architecture.
[0056] The storage-computing integrated architecture means that the computing nodes are also storage nodes. Figure 2 Schematic diagram of a storage-computing integrated architecture for implementing multiple copies of data provided by an embodiment of the present application. Figure 2As shown in the figure, the database nodes are configured with computing resources and storage resources. The database nodes use their computing resources to participate in the processing of transactions and use their 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 makes multiple backup copies of data between different database nodes. In order to ensure the consistency between multiple copies, it usually adopts the corresponding consensus algorithm, such as Raft or Paxos protocol. Ap, Bp and Cp are the primary copies of the corresponding data blocks respectively. When the client wants to write A data, it will only send a request to the node containing Ap, that is, Figure 2 The node with persistent memory (PM) 1 is configured in the database. When the database node receives a write request, it sends the request to the two nodes on the right, namely Figure 2 The nodes configured with PM1 and PM2 request them to update A. After waiting for a successful response, the node configured with PM1 writes the local Ap data and finally returns a response to the client.
[0057] The storage-computing separation architecture means that the computing nodes are independent of the storage nodes. Figure 3 Schematic diagram of a storage and computing separation architecture provided in an embodiment of the present application. Figure 3 As shown, 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 calculation 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 request from the client, the database node will concurrently send a data write request to the storage node to complete the redundant storage of the data. By storing the data in a redundant manner (such as multiple copies or using erasure code (EC), etc.), the reliability of the data can be improved. Moreover, when the database system provided in the embodiment of the present application is a storage and calculation 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.
[0058] In the process of 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 that need to be performed 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 transactions, such as transaction status and other information. Usually, when the 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.
[0059] In one implementation, the data management method of the database system provided in the embodiment 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 data management method of the database system can be presented in the form of an application installation package. After the application installation package is installed in the client 101, the function of the client 101 in the data management method can be implemented by running the executable program. After the application installation package is installed in the database node 102, the function of the database node 102 in the data management method can be implemented by running the executable program.
[0060] 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 can know that as business needs change, the implementation scenario can be adjusted according to application requirements, and the embodiments of the present application do not list them one by one.
[0061] The following is an explanation of the transaction processing process of the current 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:
[0062] Step S1: The client sends the first write request to the database node.
[0063] 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 transaction record is created, 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 carrying abort retry information is sent to the client; otherwise, the state 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 the write operation log is: txnIdkey1 value1, which means that the transaction marked with transaction txnId writes key1, and the written value is value1. If there are multiple write operations in the transaction, more key-value pair modification records can be added later, such as txnId key1 value1[key2 value2…], which means that key2 is also written, and the written value is value2.
[0064] 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 waiting for a while; otherwise, it continues to send the next request to the participant node.
[0065] Step S4: After receiving the write request from the client, the participant node also needs to perform conflict judgment in memory and make different responses to the client according to whether there is a conflict. If no conflict is found, after persisting the write operation log of the write request, a write response indicating the completion of persistence is sent to the client so that the client can continue the operation.
[0066] 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.
[0067] Step S6: After receiving the commit request, the coordinator node persists the state of the transaction as committed, and then notifies the client to complete the transaction commit operation. At the same time, the coordinator node determines the participant nodes of the transaction in the background according to the information in the client commit request, and sends a finalization request to all participant nodes. Among them, committed means that the transaction has been committed. When the coordinator node receives the commit request from the client, it needs to record that the transaction is in the committed state, which is used to indicate that the operation of the data in the transaction has been completed.
[0068] Step S7, after the participant node receives the finalization request sent by the coordinator node, it changes the state 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 state, which is not the transaction state displayed to all nodes processing the transaction, but the write operation state of the transaction displayed to the participant node itself. Therefore, the write operation state can also be regarded as the transaction state, but it is not the transaction state 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 the key key1 and the value value1.
[0069] Step S8: After receiving the finalization responses from all the 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, that is, the entire transaction has been completed.
[0070] It should be noted that, in contrast to the committed state, there is also an aborted state for a transaction, which means that the transaction is aborted. In other words, when a transaction is aborted due to a conflict, the transaction state will be recorded as aborted.
[0071] In the transaction processing process, multiple database nodes need to participate and collaborate together. It is not difficult to find that in the transaction processing process, after receiving the client's write request, the coordinator node and the participant node need to perform the corresponding persistence operation before returning the corresponding write response to the client. Since the persistence operation is on the critical path of the transaction processing process, it will cause the end-to-end delay of a single transaction to be too long, that is, the persistence delay problem occurs.
[0072] In order to understand the persistence delay problem in more detail, the following decomposition of the processing time of the write operation request in the transaction is carried out. The processing time of the write operation request is mainly divided into three parts, namely the network round-trip delay T1 from the client to the database node, the internal processing delay T2 after the database node receives the write operation request, and the persistence delay T3 of the write operation log. T1 is mainly the delay caused by network communication, which is about one round-trip time (RTT). T2 is mainly the memory operation in the database node, such as conflict detection, locking and other operations. This part of the delay is very low and basically negligible. T3 includes the delay of the database node to communicate with the storage node, which is about one RTT. At the same time, after receiving the persistence request, the storage node also needs to write to the persistent device such as HDD, SSD or NVM. There is also a part of delay in this process. The persistence delay problem actually refers to the problem that the delay of each write operation is about T1+T2+T3, which causes the delay of the write operation to be too large, and then causes the delay of the write-only transaction to be too large.
[0073] To this end, the embodiment of the present application provides a database system and a data management method thereof. The system structure of the database system provided by the embodiment of the present application is illustrated below. It should be noted that the architecture of the database system is mainly described here, and its working principle is described in the description of its data management method later.
[0074] Please refer to the schematic diagram of the database system provided in the embodiment of this application. Figure 1 .like Figure 1 As shown, the database system includes: a client, multiple database nodes and storage resources. The database system can be a storage-computing integrated architecture. Alternatively, the database system is a storage-computing separated architecture.
[0075] The plurality of 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 a key indicating the use of the persistent first data.
[0076] In this database system, the first write operation log is persisted by the client, 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.
[0077] In the database system, the multiple database nodes also include a second database node. At this time, the client is also used to send a second write request of 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 the second write response to the client. The client is also used to persist the second write operation log using storage resources. 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 used to indicate the persistence of the second data.
[0078] Optionally, the persistence process of the first write operation log and the second write operation log by the client can be implemented through a persistence request. That is, the client can implement the 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 the 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 limit throughput rate to the database system.
[0079] 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. At this time, 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, the write operation log can be written 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 continuously stored 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.
[0080] In the database system provided in the embodiment 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 node that receives the remaining write requests is the participant node. 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.
[0081] In one implementation, the coordinator node and the participant node's persistent write operation logs can be provided by the client. At this time, the client is also used to provide the coordinator node with all the write operation logs of the target transaction. The coordinator node is used to obtain the third write operation log that the coordinator node is responsible for based on the write operation log, and use the storage resources to persist the third write operation log, and, based on the write operation log, obtain the fourth write operation log that each participant node is responsible for, and send the fourth write operation log that it is responsible for to each participant node. The participant node is used to persist the fourth write operation log that it is responsible for using the storage resources. In this way, the coordinator node and the participant node can persist the write operation log that they are responsible for. When the write operation log needs to be used, for example, when a transaction needs to be recovered based on the write operation log, the coordinator node and the participant node can obtain their own persistent write operation logs from their respective storage resources, and perform related processing based on the obtained write operation logs, without obtaining the client's persistent write operation logs, and without repeatedly reading 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.
[0082] Optionally, the timing at which the client provides the coordinator node with all write operation logs of the target transaction can be adjusted according to application requirements. For example, after the client persists all write operation logs of the target transaction, it can provide the coordinator node with all write operation logs of the target transaction. For another example, the client can provide the coordinator node with all write operation logs of 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 of the target transaction can be carried in the commit request.
[0083] 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 the log unit (persistent log, plog) in the 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.
[0084] When the coordinator node has an exclusive storage resource, the coordinator node is specifically used to persist the third write operation log in its exclusive storage resource. And / or, when the participant node has an exclusive storage resource, the participant node is specifically used to persist the fourth write operation log in its exclusive storage resource. In addition, the coordinator node and / or the participant node can write the write operation log to the storage resource by appending. 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 in the storage resource in a continuous 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 query the status of the target transaction first, 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.
[0085] In the database system provided by the embodiment of the present application, when the state of the target transaction to be restored is different, the operations to be performed to restore 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 restored, 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 meta-information 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 performs transaction recovery, the transaction status that needs to be referenced is the transaction status recorded by the coordinator node. When the participant node performs transaction recovery, 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.
[0086] The data recovery process of the coordinator node includes the following recovery situations:
[0087] In the first recovery case, when the current status indicates that the target transaction is in the executing state, the coordinator node sends a write response to the client indicating the re-execution of the target transaction after receiving the client's write request, so that the client performs an abort and retry operation on the transaction based on the write response. When 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 the recovery, so it is necessary to perform an abort and retry operation on the target transaction to recover the target transaction.
[0088] In the second recovery case, 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 it is responsible for. At this time, 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.
[0089] Furthermore, in the second case, since the participant node may not have persisted the write operation log for which it is responsible, the coordinator node is further used to obtain the 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. At this time, the participant node is also used to persist the fourth write operation log using storage resources.
[0090] In the third recovery case, when the current status indicates that the target transaction is in a completed state, the coordinator node obtains the third write operation log and performs a replay operation based on the third write operation log. When the target transaction is in a completed state, it means that the target transaction has been successfully committed and cleaned up, and the coordinator node has persisted the write operation log it is responsible for, then the coordinator node can obtain its own persisted write operation log and perform a replay operation based on the third write operation log.
[0091] The implementation process of data recovery by participant nodes includes the following recovery situations:
[0092] In the first recovery case, 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, when a participant node finds a commit log in its log, it means that the participant node has persisted the write operation log it is responsible for, and the commit log can be replayed to achieve recovery of the transaction.
[0093] The second recovery situation is that when the current state 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, the 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 the finalization request sent by the coordinator node is received within the specified time period, or after the participant node inquires the coordinator node, the finalization request of the target transaction sent by the coordinator node is received, it means that the coordinator node can 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 the recovery starts. After the participant node receives the finalization request, it can directly perform the replay operation based on the write operation log contained in the finalization request to realize the recovery of the transaction. Among them, the timestamp of the finalization request of the target transaction is less than the timestamp of the participant node starting to recover the transaction.
[0094] The third recovery situation is that 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, the participant node sends a write response to the client indicating 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, 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 write request from the client, the participant node can send a write response to the client indicating the re-execution of the target transaction to achieve the recovery of the transaction.
[0095] When 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, 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 the indication information of the storage space. The client is also used to recycle 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 the data it persists.
[0096] The following is an explanation of the data management method of the database system provided in the embodiment of the present application. The method is applied to the database system provided in the embodiment of the present application. Figure 4 As shown, the data management method of the database system includes the following steps:
[0097] Step 401: 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.
[0098] When the client needs to perform a write operation, such as Figure 5As shown in a1 in , a first write request can be sent to a database node in the database system. 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. For example, assuming that 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, and the a request is used to indicate writing a=10, and send a request b to another database node, and the b request is used to indicate writing b=20, then the first write request can be a request.
[0099] Step 402: 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.
[0100] After receiving the first write request, the first database node may first perform conflict detection and locking operations in the memory to determine whether there are available resources for executing the target transaction. Figure 5 As shown in a3 in the figure, the first database node can immediately send the first write response to the client. In this way, the first database node does not need 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.
[0101] 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 nodes that receive subsequent write requests belonging to the target transaction become the participant nodes of the target transaction. Figure 5 As shown in a2 in, after determining that there are available resources for executing the target transaction, the state of the target transaction needs to be persisted as being executed (inProgress), while the participant nodes do not need to persist the state of the target transaction. In addition, the write response can be sent after the coordinator node has completed the persistence of the state of the target transaction. For example, continue with the example of step 401, Figure 6 FIG. 1 is a schematic diagram of the data persisted in the client, the first database node, and the second database node during the transaction execution process. Figure 6 As shown, in the entire execution timeline of the target transaction, the first data persisted is the transaction state txnId inProgress persisted in the first database node.
[0102] 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.
[0103] When the client's write operation needs to be implemented through multiple write requests, after the client receives the first write response, such as Figure 5 As shown in a4 in the figure, the second write request of the target transaction can be sent to the second database node. 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. Continuing with the example in step 401, the second write request can be a request b.
[0104] Step 404: 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.
[0105] 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. Figure 5 As shown in a5 in the figure, the second database node immediately sends a second write response to the client. In this way, the second database node does not need 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, reducing the delay in the client processing transactions. 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.
[0106] Step 405: The client uses storage resources to batch persist the first write operation log and the second write operation log.
[0107] After receiving the write response sent by the database node, the client can persist the write operation log carried in the write response. In one implementation, after receiving multiple write operation logs, the client can persist the multiple write operation logs in batches. For example, Figure 5 As shown in a6 in , after receiving all the write responses of the target transaction, the client can batch persist the write operation logs carried by all the write responses. That is, the client can persist all the write operation logs of the target transaction by sending a persistence request to the storage resource. Among them, the persistence request is used to request the persistence of the write operation log in the storage resource. 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 limit throughput to the database system. For example, continuing with the example of step 401, as shown in Figure 6As shown, in the entire execution timeline of the target transaction, after the persistent transaction state 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.
[0108] It should be noted that when the client performs batch persistence on all write operation logs of the target transaction, the client can cache the write operation log locally each time it receives a write operation log, and then perform batch persistence on all write operation logs after receiving all write operation logs of the target transaction. In addition, if the transaction needs to be rolled back, the client does not need to persist the write operation log, which can reduce the persistence request overhead.
[0109] When the client has an exclusive storage resource, the client is specifically used to persist the write operation log in its exclusive storage resource. Among them, the exclusive resources of the client can be obtained by prior declaration. In addition, when the client persists the write operation log in the storage resource, the write operation log can be written 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 continuously stored 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 log and ensure the reading speed of the write operation log.
[0110] Step 406: The client sends a commit request to the coordinator node, and the commit request carries all write operation logs of the target transaction.
[0111] After the client persists all write operation logs of the target transaction, Figure 5As shown in a7 in, a commit request can be sent 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 log persisted by the coordinator node and the participant node can be provided by the client. The client can also provide all the write operation logs of the target transaction to the coordinator node. Optionally, the timing when the client provides all the write operation logs of the target transaction to the coordinator node 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 all the write operation logs of the target transaction to the coordinator node. For another example, the client can provide all the write operation logs of the target transaction to the coordinator node 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.
[0112] 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.
[0113] 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.
[0114] After the coordinator node receives the submission request, Figure 5 As shown in a8 in , after determining that there are available resources for executing the target transaction, the state of the target transaction can be persisted as committed to implement the commit of the target transaction, and Figure 5 As shown in a9 in FIG. 1 , a submission response is sent to the client so that the client can send a request for the next transaction. For example, continuing with the example of step 401, as shown in FIG. Figure 6 As shown, in the entire execution timeline of the target transaction, after persisting the write operation log txnId a 10b 20 of the target transaction, the next persisted data is the transaction status txnId committed persisted in the first database node.
[0115] Optionally, after the coordinator node receives all write operation logs of the target transaction, such as Figure 5 As shown in a10 in , the third write operation log for which the coordinator node is responsible can be obtained, and the third write operation log can be persisted using storage resources to facilitate the subsequent use of the third write operation log. In one implementation, the coordinator node can obtain the third write operation log for which the coordinator node is responsible from all 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 storage address of all write operation logs of the target transaction to the coordinator node, the coordinator node also uses storage resources to persist the storage address. In one implementation, when the commit request carries the write operation log and its storage address, in order to ensure that the write operation log can be obtained, the coordinator node can first persist the storage address after receiving the commit request, and then persist the third write operation log after obtaining the third write operation date. In addition, the coordinator node can send a commit response to the client after persisting the transaction status txnIdcommitted and the storage address. For example, continue with the example of step 401. Figure 6 As shown, in the entire execution timeline of the target transaction, after persisting the write operation log txnId a 10b20 of the target transaction, the transaction status txnId committed and the plogId and offset in the storage address of all write operation logs of the target transaction are persisted, and then the third write operation log txnIdcommit a 10 is persisted in the first database node. Alternatively, the storage address can be persisted in batches with the third write operation log, which can reduce the number of persistence requests sent to the storage resource.
[0116] 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 in the storage resource in a continuous 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 it is necessary to recover the target transaction, the coordinator node usually needs to query the status of the target transaction first, and then determine whether it is necessary to perform transaction recovery based on the third write operation log based on the status. When it is necessary to perform transaction recovery based on the third write operation log, the third write operation log 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.
[0117] 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 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 beneficial to improving the execution speed of operations performed based on the write operation log.
[0118] 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.
[0119] The submission request also carries the indication information of the participant node. The coordinator node can determine the participant node of the target transaction based on the indication information, and obtain the fourth write operation log that the participant node is responsible for 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 that the participant node is responsible for. The coordinator node can determine the participant node of the target transaction based on the address of the participant node, and can obtain the fourth write operation log that the participant node is responsible for from all write operation logs of the target transaction based on the key range of the write operation log that the participant node is responsible for.
[0120] After the coordinator node commits the transaction, Figure 5 As shown in a11 in , a finalization request will be sent to the participant node to instruct the participant node to change the status of the write data it is responsible for to submission. In one implementation, the finalization request sent by the coordinator node to the participant node may carry a fourth write operation log sent to the participant node. Optionally, the process of the coordinator node sending the finalization request to the participant node and the process of the coordinator node sending the submission response can be performed asynchronously.
[0121] Step 409: The participant node uses storage resources to persist the fourth write operation log.
[0122] When a participant node has exclusive storage resources, such as Figure 5 As shown in a12 in , the participant node is specifically used to persist the fourth write operation log in its exclusive storage resources to facilitate the subsequent use of the fourth write operation log. Among them, the exclusive resources of the participant nodes can be obtained through prior declaration. Moreover, when the participant node persists the write operation log in the storage resource, it can write the write operation log to the storage resource by appending. In addition, according to the previous description, the process of the coordinator node sending a finalization request to the participant node and the process of the coordinator node sending a submission 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 Figure 6 As shown, in the entire execution timeline of the target transaction, after the third write operation log txnId commit a 10 is persisted, the next persisted data is the fourth write operation log txnId commit b 20 persisted in the second database node.
[0123] 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, the fourth write operation log 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 write operation logs, which helps to ensure the speed of transaction recovery.
[0124] By persisting the write operation log for which the participant node is responsible, when the participant node needs to use the write operation log, for example, when transaction recovery is needed 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 without having to repeatedly read its own storage resources and the client's storage resources, which is beneficial to improving the execution speed of operations performed based on the write operation log.
[0125] After the participant node changes the status of the write data it is responsible for to submitted, Figure 5 As shown in a13 in , a finalized response can be sent to the coordinator node. After the coordinator node receives the finalized responses from all participant nodes, Figure 5 As shown in a14 in FIG. 1 , after determining that there are available resources for executing the target transaction, the state of the target transaction can be persisted as completed, indicating that the transaction has been submitted normally and the response cleanup work has been completed. For example, continuing with the example of step 401, as shown in FIG. Figure 6 As shown, in the entire execution timeline of the target transaction, after persisting the fourth write operation log txnIdcommit b20, the next persisted data is the transaction state txnIdfinalized persisted in the first database node.
[0126] Step 410: 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.
[0127] 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 it 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.
[0128] The data recovery process of the coordinator node includes the following recovery situations:
[0129] In the first recovery case, when the current status indicates that the target transaction is in the executing state, the coordinator node sends a write response to the client instructing to re-execute the target transaction after receiving the client's write request, so that the client aborts and retry the transaction based on the write response. Figure 7 As shown, the execution progress of the target transaction may only reach Q11. Before starting recovery, the client has not persisted the write operation log of the target transaction. Therefore, it is necessary to perform an abort and retry operation on the target transaction to recover the target transaction.
[0130] In the second recovery case, 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 the replay operation based on the client's persistent write operation log. Figure 7 As shown, the execution progress of the target transaction may only reach Q12, and the target transaction has been successfully submitted, but the coordinator node may not have persisted the write operation log for which it is responsible. At this time, 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.
[0131] Furthermore, in the second case, since the participant node may not have persisted the write operation log for which it is responsible, the coordinator node is further used to obtain the 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. At this time, the participant node is also used to persist the fourth write operation log using storage resources.
[0132] In the third recovery case, when the current status indicates that the target transaction is in a completed state, the coordinator node obtains the third write operation log and performs a replay operation based on the third write operation log. Figure 7 As shown, the execution progress of the target transaction may only reach Q13. The target transaction is successfully committed and cleaned up, and the coordinator node has persisted the write operation log for which it is responsible. The coordinator node can obtain its own persisted write operation log and perform a replay operation based on the third write operation log.
[0133] The implementation process of data recovery by participant nodes includes the following recovery situations:
[0134] In the first recovery case, 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, when the participant node finds a commit log in its log, such as Figure 8 As shown, 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 the commit log can be replayed to recover the transaction.
[0135] In the second recovery case, 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, the 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, such as Figure 8 As shown, 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. 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, or, after the participant node inquires the coordinator node, it receives the finalization request of the target transaction sent by the coordinator node, it means that the coordinator node can 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 the recovery starts. 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 realize the recovery of the transaction. Among them, the timestamp of the finalization request of the target transaction is less than the timestamp when the participant node starts to recover the transaction.
[0136] In the third recovery case, 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, the participant node, after receiving the client's write request, sends a write response to the client indicating that the target transaction should be re-executed. For example, when the participant node does not find the commit log in its log, such as Figure 8 As shown, the execution progress of the target transaction may only reach Q22. After the participant node inquires 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 to instruct the re-execution of the target transaction to achieve the recovery of the transaction.
[0137] Step 411: 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.
[0138] When the coordinator node and the participant node also persist the write operation logs they are responsible for, 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 in the embodiment of the present application also has a storage space recovery mechanism. In one implementation, Figure 5 As shown in a15 in , 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 the 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 according to the indication information and the storage address of its persistent data.
[0139] Step 412: The client reclaims the storage space based on the reclaim request.
[0140] After the client receives the recycling request, it can recycle the storage space based on the recycling request. It should be noted that the description here is based on the recycling of storage resources corresponding to the client, but it does not exclude the recycling of 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 requirements, and no specific limitation is made here. In addition, when the storage resources corresponding to the database node are recycled, 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.
[0141] In one implementation, when plog is used to store the data of the target transaction, the data is written to the storage resource in an append-write manner, and the indication information of the reclaim request is plogId and offset, the client can maintain a hash table locally and use the hash table to manage the usage of the storage resource. Fig. 9 As shown, the hash list includes multiple index blocks (chunks). Each chunk is used to store index information of data written through the same input / output interface (I / O interface) address. And each data writing process generates an index information. Each plog can store data corresponding to multiple chunks. The plogId in the hash list indicates the plog where the data is stored, the offset indicates the offset of the chunk in the current plog, and isFinalized indicates whether the data in the chunk can be recycled. False (such as Fig. 9 f) means it cannot be recycled, true (such as Fig. 9The t in the hash list indicates that it can be recycled. The hash list has a head and a tail. The nodes between the head and the tail represent all the chunks in the storage resource that have not been recycled. After the client receives the recycling request, it can compare the plogId and offset in the recycling request with the hash list and execute the corresponding processing strategy based on the comparison result. It mainly includes the following three situations:
[0142] In the first case, when the plogId in the recycle request is different from the plogId pointed to by the head in the hash list, and / or the offset in the recycle 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.
[0143] 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, move the head to the next chunk whose isFinalized is false in the order of the hash list.
[0144] 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 moving process, 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.
[0145] like Fig. 9 As shown in the figure, 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, move the head to Fig. 9 In the second chunk, since isFinalized in the second chunk is true, the head needs to be moved back again, that is, moved to Fig. 9 The third chunk in Fig. 9 The plogId of the third chunk in the moving head is 2, which is different from the plogId of the chunk pointed to by the head before the move, which is 1. Therefore, at this time, the client can send a request to the storage resource to instruct the storage resource to recycle the plog with plogId 1, so that the storage resource recycles the plog.
[0146] In summary, in the data management method of the database system provided in the embodiment of the present application, the first write operation log is persisted by the client, so that the database node can send a write response to the client without persisting the write operation log, which can facilitate the client to send the next write request as soon as possible, reduce the delay of the client in processing transactions, solve the problem of excessive delay in the client in processing transactions, and reduce the persistence load of the database node. In addition, the client can batch persist all write operation logs in a single transaction, which can reduce the number of persistence requests sent by the client to the storage resource, thereby reducing the total number of requests that the database system needs to send to process a single transaction, which can bring a higher limit throughput rate to the database system, for example, it can bring a 160% improvement to the limit performance. In addition, during the transaction processing process, 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 and avoid additional waste. It can achieve better throughput performance under the same degree of data contention load, such as achieving better performance under high-contention workload.
[0147] It should be noted that the sequence of steps of the data management method of the database system provided in the embodiment of the present application can be appropriately adjusted, and the steps can be increased or decreased accordingly according to the situation. Any technician familiar with the technical field can easily think of a change within the technical scope disclosed in this application, which should be included in the protection scope of this application, so it will not be repeated.
[0148] The following is an illustration of the hardware structure involved in the embodiments of the present application.
[0149] The 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, to implement the functions of a customer database node or storage resource. Fig.10 Schematic diagram of a computing device provided in an embodiment of the present application. Fig.10 As shown, 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 through the bus 1004.
[0150] Processor 1001 may include a general processor and / or a dedicated hardware chip. A general 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. A 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. In the implementation process, 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.
[0151] The memory 1002 is used to store computer programs, and the computer programs include an operating system 1002a and executable codes (i.e., program instructions) 1002b. The memory 1002 is, for example, a read-only memory or other types of static storage devices that can store static information and instructions, or a random access memory or other types of dynamic storage devices that can store 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 compressed optical disc, a laser disc, an optical disc, a digital versatile disc, a blue-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired executable code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. For example, the memory 1002 is used to store an outbound port queue, etc. The memory 1002 is, for example, independent and connected to the processor 1001 via a bus 1004. Or the memory 1002 and the processor 1001 are integrated together. The memory 1002 can store executable code. When the executable code stored in the memory 1002 is executed by the processor 1001, the processor 1001 is used to perform some or all functions of the data management method provided in the embodiment of the present application. For the implementation of the process executed by the processor 1001, please refer to the relevant description in the aforementioned embodiment. The memory 1002 may also include software modules and data required for other running processes such as the operating system.
[0152] The communication interface 1003 uses a transceiver module such as, but not limited to, a transceiver to achieve communication with other devices or communication networks. For example, the communication interface 1003 can be any one or any combination of the following devices: a network interface (such as an Ethernet interface), a wireless network card, and other devices with network access functions.
[0153] The bus 1004 is any type of communication bus for interconnecting the internal devices of the computing device (e.g., the memory 1002, the processor 1001, and the communication interface 1003). For example, a system bus. The embodiment of the present application takes the interconnection of the above-mentioned devices inside the computing device through the bus 1004 as an example. Optionally, the above-mentioned devices inside the computing device 1000 can also be connected to each other in communication with each other using other connection methods other than the bus 1004. For example, the above-mentioned devices inside the computing device 1000 are interconnected through an internal logical interface.
[0154] 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 to independently arrange each device on different chips or to integrate and arrange it 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 the parts not described in detail in a certain process, please refer to the relevant descriptions of other processes.
[0155] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product providing the program development platform includes one or more computer instructions, and when these computer program instructions are loaded and executed on a computing device, all or part of the functions of the data management method provided in the embodiments of the present application are implemented.
[0156] Furthermore, computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. 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.
[0157] The embodiment of the present application also provides 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 computing devices in the computing device cluster can also be terminal devices such as desktop computers, laptop computers, or smart phones.
[0158] Optionally, the structure of at least one computing device included in the computing device cluster can be found in Fig.10 The computing device 1000 is shown. 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.
[0159] In some possible implementations, the memory 1002 of one or more computing devices 1000 in the computing device cluster may also store partial instructions for executing the data management method. In other words, the combination of one or more computing devices 1000 may jointly execute instructions for executing the data management method.
[0160] It should be noted that the memory 1002 in different computing devices 1000 in the computing device cluster can store different instructions, which are respectively used to execute part of the functions of the database system. That is, the instructions stored in the memory 1002 in different computing devices 1000 can implement the functions of the client, database node and storage resource.
[0161] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.11 A possible implementation is shown. Fig.11 As shown, two computing devices 1100A and 1100B are connected via a network. Specifically, they are connected to the network 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 the computing device 1100A stores instructions for executing the functions of the client. At the same time, the memory 1106 in the computing device 1100B stores instructions for executing the functions of the database node.
[0162] It should be understood that Fig.11 The functions of the computing device 1100A shown in the figure can also be completed by multiple computing devices 1100. Similarly, the functions of the computing device 1100B can also be completed by multiple computing devices 1100. And the deployment mode of the modules used to implement the data management method in the computing device can also be adjusted according to the application requirements.
[0163] 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.
[0164] The embodiment of the present application also provides a computer program product including instructions. When the computer program product is executed on a computer, the computer implements the data management method provided by the embodiment of the present application.
[0165] A person 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 instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0166] 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, stored data, displayed data, 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 relevant countries and regions. For example, the original data and executable code involved in this application are all obtained with full authorization.
[0167] In the embodiments of the present application, the terms "first", "second" and "third" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance. The term "at least one" means one or more, and the term "plurality" means two or more, unless otherwise expressly defined.
[0168] The term "and / or" in this application is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0169] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the concept and principle of the present application shall be included in the protection scope 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 a fourth write operation log for which the participant node is responsible based on all the write operation logs, 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
Cited By
Database system and data management method therefor
EP4682734A1
Database system and data management method therefor
WO2024199464A1
Data access method, cloud service system, and device
WO2026137828A1
