Method for recovering data, apparatus for recovering data, and computing device cluster
By utilizing the third computing node to broadcast logs and collect messages in the database system, and the first computing node to recover data pages in parallel, the problem of excessively long business waiting time caused by a large number of replay logs was solved, ensuring business continuity.
Patent Information
- Application Number
- PCT/CN2025/092273
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-07-12
- Filing Date
- 2025-04-30
- Publication Date
- 2026-01-15
AI Technical Summary
In a database system, when a compute node fails, the large number of replay logs can cause business requests to wait for too long, potentially leading to business interruption.
By collecting messages through broadcast logs from the third compute node after a failure of the second compute node, the first compute node can recover data pages in parallel, reducing waiting time.
This reduces service waiting time and avoids service interruption when restoring data at faulty nodes, thus improving system response speed.
Smart Images

Figure CN2025092273_15012026_PF_FP_ABST
Abstract
Description
A data recovery method, a data recovery device, and a cluster of computing devices.
[0001] This application claims priority to Chinese Patent Application No. 2024109404606, filed on July 12, 2024, entitled "A Data Recovery Method, Data Recovery Device and Computing Equipment Cluster", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of computer technology, and in particular to a data recovery method, a data recovery device, and a computing device cluster. Background Technology
[0003] Currently, when a computing node in a database system fails, the recovery node in the database system can recover the data pages stored by the failed node by replaying the logs generated by the failed node, thereby avoiding the loss of data before the failure occurred.
[0004] During the replay process on the recovery node, if a business request needs to access a data page stored on the failed node, the request must wait for the recovery node to finish replaying all logs. If the recovery node replays a large number of logs and the replay time is long, this will increase the waiting time for business requests, which may lead to business interruption if the waiting time is too long. Summary of the Invention
[0005] This application provides a data recovery method, a data recovery device, and a computing equipment cluster, which can solve the problem that business may be interrupted due to a large number of replay logs.
[0006] Firstly, this application provides a data recovery method. This method can be applied to a database system, which includes a first computing node and a second computing node. The method includes: after a failure of the second computing node, the first computing node receives a business request requesting operation on a first data page; if it is determined that the first data page is stored on the second computing node, or if it is determined that the first data page is in a recovery state, the first computing node recovers the first data page according to a first log of the second computing node, the first log including historical operation information performed by the second computing node on the first data page.
[0007] In the above solution, if the first data page required by the business request is stored on the second compute node, or if the first data page is in a recovery state, it indicates that the first compute node cannot obtain the latest version of the first data page in the database system. In this case, the first compute node needs to perform data recovery, that is, recover the first data page based on the first log of the faulty node (i.e., the second compute node). This can reduce the business waiting time and thus avoid the problem of business interruption due to long waiting time.
[0008] In one possible implementation, before the first computing node recovers the first data page based on the first log of the second computing node, the method further includes: the first computing node broadcasting a log collection message; the database system further includes a third computing node; the third computing node is used to recover multiple data pages stored by the second computing node based on multiple second logs of the second computing node, wherein the multiple second logs include the first log and the multiple data pages include the first data page; the third computing node receives the log collection message and sends the first log to the first computing node based on the log collection message.
[0009] In the above scheme, after the second computing node fails, and the third computing node acts as a recovery node for the second computing node to restore data, the first computing node can obtain the second computing node's first log from the third computing node via broadcast. Upon receiving the broadcast message, the third computing node sends the first log to the first computing node. Through the cooperation of the third and first computing nodes, the first computing node can obtain the first log for subsequent data recovery.
[0010] In one possible implementation, the log collection message includes an identifier of a first data page, and the third computing node sends the first log to the first computing node according to the log collection message, including: determining the log metadata corresponding to the identifier of the first data page in the log metadata set according to the identifier of the first data page, the log metadata set being generated based on multiple second logs, the log metadata set including the identifiers of multiple data pages and their corresponding log metadata; and determining the first log according to the log metadata corresponding to the identifier of the first data page.
[0011] In the above scheme, after the third computing node obtains multiple second logs from the second computing node, it can generate a log metadata set, which allows it to find the first log more quickly after receiving a broadcast message.
[0012] In one possible implementation, the database system further includes a storage system storing log files of each computing node in the database system. The method further includes: after a second computing node fails, a third computing node receives a takeover message indicating the recovery of the second computing node's data, the takeover message including a log file identifier of the second computing node; the third computing node retrieves the log file of the second computing node from the storage system based on the log file identifier of the second computing node, and parses the log file of the second computing node to obtain multiple second logs.
[0013] In the above scheme, after receiving the message instructing the third computing node to take over the second computing node, the third computing node can obtain the logs of the second computing node from the storage system based on the log file identifier in the message.
[0014] In one possible implementation, the first computing node includes a first execution unit and a second execution unit.
[0015] The first execution unit is used to recover the data stored in the second computing node based on multiple second logs of the second computing node, including the first log.
[0016] The second execution unit is used to receive service requests and, when it is determined that the first data page is stored on the second computing node or that the first data page is in a recovery state, to recover the first data page based on the first log of the second computing node.
[0017] Before recovering the first data page based on the first log of the second computing node, the method further includes: the second execution unit determining the log metadata corresponding to the identifier of the first data page in the log metadata set based on the identifier of the first data page, the log metadata set being generated by the first execution unit based on multiple second logs, the log metadata set including the identifiers of multiple data pages and their corresponding log metadata; the second execution unit determining the first log based on the log metadata corresponding to the identifier of the first data page.
[0018] In the above scheme, when the second computing node fails and the first computing node acts as a recovery node for the second computing node to restore data, the first computing node runs at least two tasks in parallel, executed by different execution units. One task is to replay the logs of the second computing node at the log granularity to restore data. The other task is to restore data according to the needs of received business requests.
[0019] In one possible implementation, the database system further includes a storage system storing log files of each computing node in the database system. The method further includes: after a second computing node fails, a first execution unit receives a takeover message, which includes a log file identifier of the second computing node; the first execution unit retrieves the log file of the second computing node from the storage system based on the log file identifier of the second computing node, and parses the log file of the second computing node to obtain multiple second logs.
[0020] In the above scheme, after receiving a message instructing the first execution unit of the first computing node to take over the second computing node, it can obtain the logs of the second computing node from the storage system according to the log file identifier in the message.
[0021] In one possible implementation, before the first computing node recovers the first data page based on one or more first logs, the method further includes: the first computing node determining a base version based on log sequence numbers in multiple historical versions of the first data page, the base version being used to recover the first data page, wherein the log sequence number in the base version is greater than the log sequence number in other historical versions among the multiple historical versions.
[0022] In one possible implementation, before the first computing node determines the base version based on the log sequence number in multiple historical versions of the first data page, the method further includes: the first computing node broadcasting a data collection message, the data collection message including an identifier of the first data page, and the database system further including a fourth computing node; the fourth computing node receiving the data collection message and sending historical versions of the first data page stored by the fourth computing node to the first computing node based on the identifier of the first data page.
[0023] In the above scheme, the first computing node can obtain historical versions of the first data page stored by other nodes in the system by broadcasting messages, and then find the base version for recovery among these historical versions.
[0024] In one possible implementation, before the first compute node determines the base version based on the log sequence number in multiple historical versions of the first data page, the method further includes: the first compute node obtaining historical versions of the first data page stored in the storage system from the storage system of the database system.
[0025] In one possible implementation, after receiving a service request, the method further includes: a first computing node determining a storage location identifier for a first data page; and, if the storage location identifier of the first data page does not indicate a second computing node, the first computing node obtaining the first data page based on the storage location identifier of the first data page, wherein the first data page includes a status identifier, which indicates whether the first data page is in a recovery state.
[0026] In the above scheme, when the status identifier of the first data page indicates that the data page is in a recovery state, it means that the data page is not the latest version and the first computing node needs to perform data recovery.
[0027] In one possible implementation, where the storage location identifier of the first data page represents the first computing node, the first computing node obtaining the first data page according to the storage location identifier of the first data page includes: the second execution unit of the first computing node obtaining the first data page from the page storage space of the first computing node according to the identifier of the first data page, and the first execution unit of the first computing node being used to modify the status identifier in the first data page in the case of restoring the first data page, wherein the modified status identifier indicates that it is in the restoration state.
[0028] In one possible implementation, where the storage location identifier of the first data page represents a third computing node, the first computing node obtaining the first data page based on the storage location identifier of the first data page includes: the first computing node sending a data acquisition message to the third computing node, the third computing node modifying the status identifier in the first data page in the case of restoring the first data page, the modified status identifier indicating that it is in a recovery state; and the third computing node sending the first data page to the first computing node based on the data acquisition message.
[0029] In one possible implementation, the first computing node stores a page directory of the database system. The first computing node determines the storage location identifier of the first data page by: the first computing node obtaining the page directory from the storage space of the first computing node; and the first computing node querying the page directory according to the identifier of the first data page to obtain the storage location identifier of the first data page.
[0030] In one possible implementation, before the first computing node restores the first data page, the method further includes: the first computing node modifying the storage location identifier of the first data page in the page directory, wherein the modified storage location identifier represents the first computing node.
[0031] In the above scheme, the page directory is stored in the first computing node. The first computing node can obtain the storage location identifier of the first data page and modify the page directory by querying the page directory.
[0032] In one possible implementation, the database system further includes multiple memory nodes, each used to store one or more page directories of the database system. The first computing node determines the storage location identifier of the first data page by: the first computing node determining a hash value based on the identifier of the first data page, the hash value being mapped to the first memory node among the multiple memory nodes; the first computing node sending a query message to the first memory node, the query message including the identifier of the first data page; the first memory node receiving the query message, querying the page directory stored in the first memory node based on the identifier of the first data page to obtain the storage location identifier of the first data page, and sending it to the first computing node.
[0033] In one possible implementation, before the first computing node restores the first data page, the method further includes: the first computing node sending a modification message to the first memory node, the modification message including an identifier of the first data page; the first memory node receiving the modification message and modifying the storage location identifier of the first data page in the page directory stored by the first memory node according to the identifier of the first data page, the modified storage location identifier representing the first computing node.
[0034] In the above scheme, the page directory is stored in the memory node of the database system. The first computing node can obtain the storage location identifier of the first data page and modify the page directory by sending a message to the memory node.
[0035] In one possible implementation, the first computing node recovering the first data page based on the first log of the second computing node includes: if the log sequence number in the base version of the first data page is less than the log sequence number of the first log, operating on the base version according to historical operation information.
[0036] Secondly, this application provides a data recovery apparatus. The apparatus includes a receiving module and a recovery module.
[0037] The receiving module is used to receive business requests after a failure occurs in the second computing node of the database system. The business requests are used to request operations on the first data page.
[0038] The recovery module is used to recover the first data page based on the first log of the second computing node when it is determined that the first data page is stored on the second computing node or when it is determined that the first data page is in a recovery state. The first log includes historical operation information of the second computing node on the first data page.
[0039] In one possible implementation, before recovering the first data page based on the first log of the second computing node, the recovery module is further configured to: broadcast a log collection message; the database system further includes a third computing node; the third computing node is configured to recover multiple data pages stored by the second computing node based on multiple second logs of the second computing node, wherein the multiple second logs include the first log and the multiple data pages include the first data page; the third computing node receives the log collection message and sends the first log based on the log collection message.
[0040] In one possible implementation, the log collection message includes an identifier of a first data page, and the third computing node sends the first log to the first computing node according to the log collection message, including: determining the log metadata corresponding to the identifier of the first data page in the log metadata set according to the identifier of the first data page, the log metadata set being generated based on multiple second logs, the log metadata set including the identifiers of multiple data pages and their corresponding log metadata; and determining the first log according to the log metadata corresponding to the identifier of the first data page.
[0041] In one possible implementation, the first computing node includes a first execution unit and a second execution unit. The first execution unit is used to recover data stored in the second computing node based on multiple second logs of the second computing node, the multiple second logs including the first log.
[0042] The receiving module and the recovery module are applied in the second execution unit. The second execution unit is used to receive service requests and, when it is determined that the first data page is stored in the second computing node or when it is determined that the first data page is in a recovery state, to recover the first data page according to the first log of the second computing node.
[0043] Before recovering the first data page based on the first log of the second computing node, the recovery module is further configured to: determine the log metadata corresponding to the identifier of the first data page in the log metadata set based on the identifier of the first data page, the log metadata set being generated by the first execution unit based on multiple second logs, the log metadata set including the identifiers of multiple data pages and their corresponding log metadata; and determine the first log based on the log metadata corresponding to the identifier of the first data page.
[0044] In one possible implementation, before recovering the first data page based on one or more first logs, the recovery module is further configured to: determine a base version based on log sequence numbers in multiple historical versions of the first data page, the base version being used to recover the first data page, wherein the log sequence number in the base version is greater than the log sequence number in other historical versions among the multiple historical versions.
[0045] In one possible implementation, before determining the base version based on the log sequence number in multiple historical versions of the first data page, the recovery module is further configured to: broadcast a data collection message, the data collection message including an identifier of the first data page, and the database system further including a fourth computing node; the fourth computing node receives the data collection message and sends the historical versions of the first data page stored by the fourth computing node to the first computing node based on the identifier of the first data page.
[0046] In one possible implementation, before determining the base version based on the log sequence number in multiple historical versions of the first data page, the recovery module is further configured to: obtain historical versions of the first data page stored in the storage system from the database system's storage system.
[0047] In one possible implementation, after receiving a service request, the recovery module is further configured to: determine the storage location identifier of the first data page; and, if the storage location identifier of the first data page does not indicate the second computing node, obtain the first data page based on the storage location identifier of the first data page, wherein the first data page includes a status identifier, the status identifier being used to indicate whether the first data page is in a recovery state.
[0048] In one possible implementation, where the storage location identifier of the first data page represents the first computing node, the recovery module is further configured to: obtain the first data page from the page storage space of the first computing node according to the identifier of the first data page, and the first execution unit of the first computing node is configured to modify the status identifier in the first data page when recovering the first data page, wherein the modified status identifier indicates that it is in a recovery state.
[0049] In one possible implementation, where the storage location identifier of the first data page represents a third computing node, the recovery module is further configured to: send a data acquisition message to the third computing node; the third computing node is configured to modify the status identifier in the first data page when recovering the first data page, the modified status identifier indicating that it is in a recovery state; and the third computing node sends the first data page to the first computing node according to the data acquisition message.
[0050] In one possible implementation, the first computing node stores the page directory of the database system, and the recovery module is further configured to: obtain the page directory from the storage space of the first computing node; query the page directory according to the identifier of the first data page to obtain the storage location identifier of the first data page.
[0051] In one possible implementation, before the first computing node restores the first data page, the recovery module is further configured to: modify the storage location identifier of the first data page in the page directory, wherein the modified storage location identifier represents the first computing node.
[0052] In one possible implementation, the database system further includes multiple memory nodes, each used to store one or more page directories of the database system. The recovery module is further configured to: determine a hash value based on the identifier of the first data page, the hash value being mapped to the first memory node among the multiple memory nodes; send a query message to the first memory node, the query message including the identifier of the first data page; the first memory node receives the query message, queries the page directory stored in the first memory node based on the identifier of the first data page to obtain the storage location identifier of the first data page, and sends it to the first computing node.
[0053] In one possible implementation, before the first computing node restores the first data page, the recovery module is further configured to: send a modification message to the first memory node, the modification message including the identifier of the first data page; the first memory node receives the modification message and modifies the storage location identifier of the first data page in the page directory stored by the first memory node according to the identifier of the first data page, the modified storage location identifier representing the first computing node.
[0054] In one possible implementation, the recovery module is further configured to: operate on the base version based on historical operation information when the log sequence number in the base version of the first data page is less than the log sequence number of the first log.
[0055] Thirdly, this application provides a computing device cluster. The computing device cluster includes at least one computing device, each computing device including a processor and a memory. The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, causing the computing device cluster to perform the methods provided in the first aspect or any possible implementation thereof.
[0056] Fourthly, a computer-readable storage medium is provided, wherein instructions are stored therein, which, when executed on a cluster of computing devices, cause the cluster of computing devices to perform the method provided by the first aspect or any possible implementation thereof.
[0057] Fifthly, a computer program product comprising instructions is provided, which, when executed on a cluster of computing devices, cause the execution of the method provided by the first aspect or any possible implementation thereof.
[0058] Any of the devices, computing equipment clusters, computer storage media, or computer program products provided above are used to execute the methods provided above. Therefore, the beneficial effects they can achieve can be referred to the beneficial effects of the corresponding solutions in the corresponding methods provided above, and will not be repeated here. Attached Figure Description
[0059] Figure 1 is a schematic diagram of the structure of a database system provided in an embodiment of this application;
[0060] Figure 2 is a flowchart of a data recovery method provided in an embodiment of this application;
[0061] Figure 3 is a schematic diagram of communication between nodes performing the method shown in Figure 2 according to an embodiment of this application;
[0062] Figure 4 is a flowchart of another data recovery method based on business requests provided in an embodiment of this application;
[0063] Figure 5 is a flowchart of data recovery performed in the method shown in Figure 4 according to an embodiment of this application;
[0064] Figure 6 is a schematic diagram of communication between nodes performing the method shown in Figure 4 according to an embodiment of this application;
[0065] Figure 7 is a schematic diagram of communication between nodes performing the method shown in Figure 4 according to another embodiment of this application;
[0066] Figure 8 is a schematic diagram of another database system provided in an embodiment of this application;
[0067] Figure 9 is a schematic diagram of a data recovery device for performing the method shown in Figure 2 according to an embodiment of this application;
[0068] Figure 10 is a schematic diagram of a data recovery device for performing the method shown in Figure 4 according to an embodiment of this application;
[0069] Figure 11 is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0070] Figure 12 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;
[0071] Figure 13 is a schematic diagram of the connection between computing devices in a computing device cluster provided in an embodiment of this application. Detailed Implementation
[0072] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be described below with reference to the accompanying drawings.
[0073] In the description of the embodiments of this application, the words "exemplary," "for example," or "for instance" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplary," "for example," or "for instance" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the words "exemplary," "for example," or "for instance" is intended to present the relevant concepts in a specific manner.
[0074] In the description of the embodiments in this application, the term "and / or" is merely a description of the association relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, B existing alone, and A and B existing simultaneously. Furthermore, unless otherwise stated, the term "multiple" means two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals.
[0075] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The terms "comprising," "including," "having," and their variations all mean "including but not limited to," unless otherwise specifically emphasized.
[0076] Before introducing the embodiments of this application, the terms mentioned in the embodiments of this application will be explained.
[0077] A historical version of a data page refers to the state of a data page in a database at a specific point in time or before the latest operation. To maintain data consistency and integrity, database systems may retain historical versions of data pages. These historical versions can be stored on compute nodes and / or storage nodes within the database system. In other words, multiple historical versions of a single data page may exist in a database system. For example, if a compute node retrieves a data page from a storage node but has not yet written the modified data page back to the storage node, the storage node stores the historical version of that data page. Similarly, if compute node A retrieves a data page from a storage node but has not yet written the modified data page back to the storage node, and compute node B retrieves the same data page from compute node A as needed, compute node A can store the historical version of that data page.
[0078] The latest version of a data page refers to the state of a data page in the database at the current point in time or after the latest operation. In a database system, when a user or application performs operations on a data page, the database system modifies the corresponding data page to reflect these changes. The database system uses a page directory to record the storage location of the latest version of a data page. Specifically, the page directory records the mapping relationship between the identifier of a data page and the identifier of its storage location. The database system can store one or more page directories.
[0079] Next, the application scenarios of the embodiments of this application will be described with reference to the accompanying drawings.
[0080] Figure 1 is a schematic diagram of the structure of a database system provided in an embodiment of this application. As shown in Figure 1, the database system can adopt a storage separation architecture, that is, the database system includes a computing system and a storage system.
[0081] The computing system is used to perform operations such as data querying, data updating, and data deletion based on business requests from clients of the database system. The computing system may include one or more computing nodes, such as computing nodes N1 to N3 as shown in Figure 1. It should be understood that the computing nodes in the database system are not limited to the three computing nodes shown in Figure 1, and may include other numbers of computing nodes. These computing nodes may include, but are not limited to, servers or virtual instances deployed on servers.
[0082] The client can be deployed on the user's terminal device, and the computing node and the client can be connected via a wired or wireless network. The terminal device can include, but is not limited to, personal computers, laptops, smartphones, tablets, and portable wearable devices. This application does not specifically limit the type of terminal device. Furthermore, this application does not specifically limit the operating system running on the terminal device. That is, the terminal devices involved in this application can run electronic devices including, but not limited to, those running iOS, Android, Windows, HarmonyOS, or other operating systems.
[0083] A storage system is used to store data from a database system. This data may include, but is not limited to, business data and system logs. A storage system may include one or more storage nodes. In cases involving multiple storage nodes, the storage system may employ a centralized system, a distributed system, or a combination of both. Each storage node may store some or all of the database system's data. Business data may be organized and stored in the form of data pages, while system logs may be organized and stored in the form of files. System logs may include error logs, write-ahead logs, etc.
[0084] In the database system shown in Figure 1, the compute nodes in the computing system can read or write data from the storage nodes in the storage system as needed. For example, a compute node can read data pages from the storage system and write generated log files to the storage system. Generally, to reduce the number of times the compute node retrieves data from the storage system and speed up the processing of business requests, the compute node can cache the data pages retrieved from the storage system. Thus, the compute node stores one or more cached data pages as shown in Figure 1. Since the cache space of the compute node is limited, the compute node needs to write the cached data pages back to the storage system according to a certain mechanism.
[0085] In the database system shown in Figure 1, each compute node maintains a distributed lock manager and a page directory (PD) as global state information for the database system. Compute nodes can determine the storage location of the data pages they are operating on through the page directory. Before performing operations on a data page, the distributed lock manager can lock the data page to prevent multiple nodes from operating on it simultaneously. Additionally, each compute node includes a logging system. The logging system generates corresponding logs when a compute node operates on a data page, and then writes these logs to the storage system in file format. Furthermore, the logging system can record log file identifiers for each log file. These log file identifiers uniquely identify each log file.
[0086] It should be noted that the structure of the database system shown in Figure 1 is not limited to the nodes in the aforementioned computing and storage systems. In specific application scenarios, the database system may also include other types of devices or nodes that implement other functions. Furthermore, each computing node may also include other types of components that implement other functions.
[0087] When a compute node in the database system shown in Figure 1 fails (hereinafter referred to as the failed node), the failed node may contain cached data pages that have not yet been written back to the storage system, i.e., dirty pages. In other words, the latest version of these data pages is stored on the failed node, and other compute nodes cannot obtain the latest version of these data pages from other parts of the database system. Therefore, after a compute node failure, the database system needs to recover these data pages to avoid data loss.
[0088] In related technologies, after a compute node fails, other nodes in the database system (hereinafter referred to as recovery nodes) take over the logs generated by the failed node, such as write-ahead logs, and then replay these logs one by one according to the log sequence number, thereby recovering the dirty pages stored by the failed node. Specifically, each time a compute node in the database system performs an operation on a data page, it generates a log containing historical operation information for that data page.
[0089] In a database system, all logs share a unified sequence number, but the sequence numbers of all logs containing historical operation information for a single data page are not necessarily consecutive. In this related technology, if a client needs to access a dirty page stored by a failed node, to ensure the client has the latest version, it must wait for the recovery node to finish replaying all logs it will be taking over. In other words, the client can only access the desired data page after the recovery node's replay is complete. In this scenario, if the number of logs is large, the recovery node's replay time will be long, resulting in a longer waiting time for the client. If the client's waiting time exceeds a certain threshold, it may cause an interruption of the database system's operations.
[0090] Therefore, this application provides a data recovery method that can solve the above problems.
[0091] In the data recovery method provided in this application embodiment, when a first computing node in the database system receives a business request and determines that the business request accesses a first data page, if it is determined that a second computing node storing the first data page has failed, or that the first data page is in a recovery state, the first computing node recovers the first data page based on one or more first logs. The first logs include historical operation information performed on the first data page. This method allows the computing node to recover data pages stored by the failed node as needed according to the business request, eliminating the need for the business to wait for all logs of the failed node to be replayed. The method provided in this application embodiment can reduce business waiting time and solve the problem of business interruption due to long waiting times.
[0092] The data recovery method provided in the embodiments of this application will be described below with reference to the accompanying drawings.
[0093] Figure 2 is a flowchart of a data recovery method provided in an embodiment of this application.
[0094] As shown in Figure 2, the method may include steps S201-S204. This method can be applied to the database system shown in Figure 1 and is executed by the detection node and the recovery node. The following describes each step in Figure 2. It should be noted that the following description of each step uses the example of computing node N2 and computing node N3 shown in Figure 1 as the fault node and recovery node, respectively. The fault node is the aforementioned second computing node. It should be understood that in other embodiments, the fault node and recovery node can also be other computing nodes in the database system; for example, the recovery node can be computing node N1.
[0095] S201, the detection node determines that the computing node N2 has failed and sends a takeover message to the recovery node.
[0096] The detection node is used to detect whether a computing node in the database system has failed. The detection node in this step can include any computing node in the database system shown in Figure 1, except for computing node N2. This application embodiment does not impose specific limitations on the method by which the detection node detects whether a computing node has failed.
[0097] After the detection node determines that compute node N2 has failed, as shown in Figure 3, it can send a takeover message to compute node N3. This takeover message is used to set compute node N3 as the recovery node for compute node N2, in order to recover the data stored on compute node N2. In this step, the detection node can determine the recovery node for compute node N2 based on the load information of other compute nodes in the database system, thus avoiding the impact of data recovery tasks on the business operations of the recovery node.
[0098] S202, the recovery node receives the takeover message and retrieves the log file of compute node N2 from the storage system based on the log file identifier of compute node N2 in the takeover message.
[0099] In the database system shown in Figure 1, each compute node can generate a second log when operating on data pages. This second log can be, for example, a write-ahead log. As shown in Figure 3, each compute node's log system can organize its generated second logs into files and store these log files in the storage system. In this implementation, the storage system stores the log files of each compute node. Each log file is generated by a compute node and is identified and distinguished by a unique log file identifier. For example, as shown in Figure 3, the storage system may include log file R1 for compute node N1, log file R2 for compute node N2, and log file R3 for compute node N3. Each compute node's log system can record its own log file identifier, allowing it to retrieve its own log file from the storage system using this identifier.
[0100] The takeover message may include the log file identifier of compute node N2. This identifier identifies the log file of compute node N2. Thus, the recovery node can obtain the log file of compute node N2 using this identifier. Upon receiving the takeover message, as shown in Figure 3, compute node N3 can read the log file R2 of compute node N2 from the storage system based on the log file identifier.
[0101] S203, the recovery node constructs a log metadata set based on the log files of compute node N2.
[0102] After obtaining the log file of compute node N2, compute node N3 can parse the log file to obtain multiple second logs within the log file of compute node N2. The second logs may include the log sequence number of the second log, historical operation information performed by compute node N2 on one or more data pages, and the identifier of the one or more data pages, among other information.
[0103] After obtaining multiple second logs from compute node N2, compute node N3 can determine multiple third logs among the second logs based on the target log sequence number of compute node N2 and the log sequence numbers of each second log. The log sequence number of the third log is greater than the target log sequence number of compute node N2. The target log sequence number of compute node N2 is the log sequence number of the last log written to disk by compute node N2. A log written to disk means that the data page recorded in the log has been written back to the storage system; that is, the latest version of the data page is stored in the storage system. In other words, among the multiple second logs of compute node N2, the data page recorded in the second log whose log sequence number is less than the target log sequence number has already been written back to the storage system, and compute node N2 does not need to perform data recovery for that data page.
[0104] The database system's storage system may store a control file, which can include checkpoint information for the database system. This checkpoint information can include the target log sequence number for each compute node. Thus, compute node N3 can obtain the database system's checkpoint information from the storage system, thereby obtaining the target log sequence number for compute node N2.
[0105] After obtaining multiple third logs from compute node N2, compute node N3 can generate a log metadata set. Specifically, this log metadata set includes identifiers for multiple data pages and the log metadata corresponding to each data page identifier. These multiple data pages are dirty pages stored on compute node N2 that have not yet been written back to the storage system. Each log includes historical operation information performed by compute node N2 on the data page. The log metadata of the first log may include information such as the log position, log size, and log sequence number of the first log. The log position of the first log includes the starting position of the first log in the storage space of compute node N3.
[0106] The aforementioned log metadata set is used by compute node N3 or other compute nodes in the database system to restore data pages as needed after receiving a business request from a client. This process will be described in detail later with reference to Figure 4, and will not be repeated here.
[0107] S204, the recovery node replays the logs in the order of the log sequence numbers in the multiple third logs to recover the multiple data pages stored in the compute node N2.
[0108] When replaying a third log, compute node N3 can broadcast a data collection message. This message includes the identifier of the target data page in the third log, to collect historical versions of that target data page, and to retrieve those historical versions from the storage system. After obtaining multiple historical versions of the target data page, compute node N3 determines the base version for data recovery from these versions and then executes the historical operation information for the target data page from the third log on that base version. The historical versions of the target data page include log sequence numbers. Compute node N3 can compare the log sequence numbers across multiple historical versions and use the version with the largest sequence number as the base version for the target data page.
[0109] In this embodiment, data recovery at the log granularity and data recovery triggered by business requests are performed concurrently by compute node N3. Therefore, before executing the historical operation information of the target data page in the third log, compute node N3 can compare the log sequence number in the base version of the target data page with the log sequence number of the third log to determine whether to replay the third log. For example, if the log sequence number in the base version of the target data page is equal to or greater than the log sequence number of the third log, compute node N3 will not replay the third log; otherwise, it will replay the third log. In the case where it is determined not to replay the third log, compute node N3 continues to process the next third log with a log sequence number greater than the first third log. In the case where it is determined to replay the third log, compute node N3 modifies the storage location identifier of the data page in the page directory of the database system. The modified storage location identifier of the data page represents compute node N3.
[0110] In the method shown in Figure 2 above, steps S202 to S204 can be executed by one execution unit of the recovery node or by multiple execution units of the recovery node. Step S204 can be executed by one execution unit of the recovery node or by multiple execution units of the recovery node, that is, the logs of the faulty node are distributed to multiple execution units for replay. Having multiple execution units of the recovery node execute S204 together, allowing the recovery node to replay the logs of the faulty node in parallel, can improve data recovery efficiency. Where the recovery node includes multiple processors or multiple cores, the execution unit can include the processor or core of the recovery node. The execution unit can also include a process or thread of the processor or core. This application embodiment does not impose specific limitations on the execution unit.
[0111] The method shown in Figure 2 above ensures that the data of the failed node is not lost when a computing node in the database system fails. This is achieved by having a designated recovery node restore the data of the failed node. In this embodiment, the recovery node can provide business services to users while restoring data; that is, client business requests can connect to the recovery node. In other words, the recovery node can execute data recovery tasks and business tasks in parallel.
[0112] After introducing the process of restoring data from a faulty node, the following section describes the on-demand data recovery triggered by a service, based on the method embodiment shown in Figure 2 and in conjunction with Figure 4.
[0113] Figure 4 is a flowchart of a data recovery method provided in an embodiment of this application.
[0114] As shown in Figure 4, the method may include steps S401-S402 as follows. This method can be applied to the database system shown in Figure 1. Next, the steps shown in Figure 4 will be described. It should be noted that the following description of each step is based on the example where the first computing node and the second computing node are computing node N1 and computing node N2, respectively. It should be understood that in other embodiments, the first computing node can also be other computing nodes in the database system; for example, the recovery node can be computing node N3.
[0115] S401, the first computing node receives a service request, which is used to request an operation on the first data page.
[0116] After compute node N2 fails, compute node N1 can receive service requests sent by clients. These requests may include an identifier for a first data page and / or operation information for that first data page. Compute node N1 can determine that the service request accesses the first data page, i.e., requests to perform operations on the first data page, based on the identifier in the service request.
[0117] S402, when the first computing node determines that the first data page is stored on the second computing node or that the first data page is in a recovery state, it recovers the first data page according to the first log of the second computing node. The first log includes historical operation information of the second computing node on the first data page.
[0118] Specifically, computing node N1 can be implemented through steps S4021 to S4026 as shown in Figure 5, which is how S402 is achieved. The steps shown in Figure 5 are described below.
[0119] S4021, compute node N1 queries the page directory of the database system based on the identifier of the first data page to obtain the storage location identifier of the first data page.
[0120] The page directory of a database system records the mapping between the identifiers of each data page and their storage locations. In other words, each compute node in the database system can determine the storage location of the latest version of a data page by querying the page directory. Because compute nodes cache data pages, the storage location of the latest version of a data page can be either a compute node or a storage node within the database system. When the latest version of a data page is stored on a compute node, that data page is considered a dirty page that has not yet been written back to the storage system.
[0121] Specifically, as shown in Figure 1, the page directory can be stored in each computing node. When the page directory is stored in each computing node, it can be stored in the storage space of the computing node. Computing node N1 can query the page directory based on the identifier of the first data page to obtain the storage location identifier of the first data page. This storage space may include the cache or memory of the computing node. In other embodiments, the page directory of the database system can also be stored in the storage system of the database system. When the page directory is stored in the storage system, it can be stored centrally on one storage node or distributed across multiple storage nodes. Of course, the storage system can also store one or more copies of the page directory through a backup mechanism to ensure the security of the page directory. The copies of the page directory can also be stored on one storage node, distributed across multiple storage nodes, or stored in other devices outside the database system. When the page directory is stored in the storage system, computing node N1 can generate a query message based on the identifier of the first data page and send the query message to the storage system. The query message may include the identifier of the first data page. The storage node in the storage system receives the query message, queries the page directory based on the identifier of the first data page in the query message, obtains the storage location identifier of the first data page, and then sends it to the compute node N1.
[0122] In this embodiment, the storage location identifier of the first data page represents the computing node storing the first data page. Since the recovery node modifies the storage location identifier of the first data page in the page directory before determining whether to recover it, the modified storage location identifier represents the recovery node. Therefore, in practice, the storage location identifier of the first data page obtained by computing node N1 may represent computing node N2, or the recovery node of computing node N2. In other words, when the recovery node has not started recovering the first data page, the storage location identifier of the first data page represents computing node N2. When the recovery node of computing node N2 starts recovering the first data page, the storage location identifier of the first data page represents the recovery node of computing node N2.
[0123] The recovery node for compute node N2 can include any compute node in the database system other than compute node N2. The recovery node can be compute node N3 mentioned in the embodiment shown in Figure 2, or it can be compute node N1.
[0124] In the case where the storage location identifier of the first data page represents compute node N2, if compute node N1 is aware that compute node N2 has failed, it can execute step S4023 to enter the recovery process for the first data page. Alternatively, if compute node N2 has not failed, or compute node N1 is unaware that compute node N2 has failed, compute node N1 can send a data retrieval message to compute node N2. In this case, if compute node N2 fails or becomes unable to communicate with compute node N1, compute node N1 will receive a message indicating a communication failure with compute node N2. After determining that compute node N2 has failed, compute node N1 can execute step S4023 to enter the recovery process for the first data page.
[0125] In the case where the storage location identifier of the first data page indicates the recovery node of compute node N2, compute node N2 executes step S4022.
[0126] S4022, compute node N1 obtains the first data page according to the storage location identifier of the first data page, determines that the first data page is in the recovery state according to the status identifier in the first data page, and executes S4023.
[0127] When the recovery node is compute node N3 or another compute node, compute node N1 retrieves the first data page based on its storage location identifier by sending a data retrieval message to compute node N3. The data retrieval message may include the identifier of the first data page. Compute node N3 or the other compute node receives the data retrieval message and sends the first data page to compute node N1 based on the identifier of the first data page in the data retrieval message.
[0128] When the recovery node is compute node N1, the compute node N1 obtains the first data page according to the storage location identifier of the first data page, which includes: obtaining the first data page from the storage space of compute node N1 according to the storage location identifier of the first data page.
[0129] After obtaining the first data page, compute node N1 can obtain a status identifier from the first data page and determine whether it is in a recovery state based on this status identifier. When the status identifier of the first data page indicates that it is in a recovery state, the first data page obtained by compute node N1 is not the latest version of the first data page. Compute node N1 cannot process business requests based on this version, therefore compute node N1 executes S4023 to enter the recovery process of the first data page.
[0130] S4023, compute node N1 obtains the historical version of the first data page and determines the base version based on the historical version of the first data page.
[0131] To ensure the security of data in the database system, compute nodes can store historical versions of data pages.
[0132] As shown in Figure 6, compute node N1 can broadcast a data collection message to obtain a historical version of the first data page (page1) from other compute nodes in the database system. The data collection message may include an identifier for the first data page. Taking compute node N4 as an example, as shown in Figure 6, after receiving the data collection message, compute node N4 can retrieve the historical version of the first data page stored in its storage space based on the identifier of the first data page, and then send the historical version to compute node N1. Compute node N1 can also read the historical version of the first data page from its own storage space based on the identifier of the first data page. It should be noted that the embodiments of this application do not impose specific limitations on the time and method of compute nodes storing historical versions of data pages. That is, compute nodes can store historical versions of data pages through backup mechanisms, mirroring mechanisms, and / or redundancy mechanisms.
[0133] As shown in Figure 6, compute node N1 can also send a data read message to the storage system to obtain a historical version of the first data page (page1) stored in the storage system. The data read message can also include the identifier of the first data page. As shown in Figure 6, after receiving the data read message, the storage system can determine the historical version of the first data page stored in the storage system based on the identifier of the first data page, and then send that historical version to compute node N1.
[0134] When there are multiple historical versions of the first data page, compute node N1 can compare the log sequence numbers among these versions and use the version with the largest sequence number as the base version of the first data page. When there is only one historical version of the first data page, compute node N1 can use that single historical version as the base version. The base version of the first data page is used for subsequent recovery of the first data page.
[0135] S4024, compute node N1 obtains the first log. The first log includes historical operation information of compute node N2 on the first data page.
[0136] In the case where the storage location identifier of the first data page represents compute node N2 or another compute node (e.g., compute node N3), as shown in Figure 6, compute node N1 can generate the log collection message based on the identifier of the first data page and then broadcast the log collection message. Here, compute node N3 acts as the recovery node for compute node N2. After receiving the log collection message, compute node N3 can determine the log metadata corresponding to the identifier of the first data page from the log metadata set determined in the embodiment shown in Figure 2, based on the identifier of the first data page in the log collection message. Then, it retrieves the first log from the storage space of compute node N3 based on the log metadata and sends the first log to compute node N1.
[0137] In the case where the storage location identifier of the first data page indicates that compute node N1 is the recovery node of compute node N2, compute node N1 may include the first execution unit and the second execution unit shown in FIG7. The first execution unit may be used to execute the steps of the recovery node execution in the embodiment shown in FIG2. The second execution unit may be used to execute the steps of compute node N1 execution in the embodiment shown in FIG4. Thus, the second execution unit can determine the log metadata corresponding to the identifier of the first data page in the log metadata set determined in the embodiment shown in FIG2 according to the identifier of the first data page, then obtain the first log from the storage space of compute node N1 according to the log metadata, and then send the first log to compute node N1.
[0138] S4025, compute node N1 operates on the base version of the first data page based on the historical operation information in the first log to obtain the latest version of the first data page.
[0139] In cases involving multiple first logs, compute node N1 can sort these first logs according to their log sequence numbers in ascending order. Then, it can replay the sorted first logs on the base version of the first data page to obtain the latest version of the first data page. After obtaining the latest version of the first data page, compute node N1 can perform operations on this latest version based on the operation information in the business request.
[0140] Before replaying the sorted first-order log, compute node N1 can modify the storage location identifier of the first data page in the page directory. The modified storage location identifier of the first data page represents compute node N1. Compute node N1 can also send the modified page directory to other compute nodes in the database system.
[0141] In the aforementioned related technologies, the data recovery task of the faulty node is entirely performed by the recovery node. When the recovery node replays a large number of logs, the service waiting time is also long, which may lead to service interruption. In the method embodiment shown in Figure 4 above, the computing node recovers the data pages stored by the faulty node on demand according to the service request, which can reduce the service waiting time and avoid service interruption.
[0142] As shown in Figure 8, the database system described in Figure 1 can also include a memory system. This memory system stores one or more page directories of the database system. The memory system can include one or more memory nodes. When the memory system includes multiple memory nodes, such as memory nodes M1 and M2 shown in Figure 8, the one or more page directories of the database system can be distributed across these memory nodes. Thus, a memory node stores one or more page directories of the database system, or a portion of the page directories. Each memory node can also include a distributed lock manager. Before a compute node needs to operate on a data page, the memory node can lock the data page through the distributed lock manager, preventing multiple compute nodes from operating on the data page simultaneously.
[0143] In the database system shown in Figure 8, the hash value corresponding to the identifier of each data page can be mapped to a memory node. The page directory stored in the memory node to which the hash value corresponding to the identifier of a data page is mapped includes the storage location identifier of that data page. Thus, when the method embodiment shown in Figure 4 is applied to the database system shown in Figure 8, the computing node N1, in executing S4021 above, can determine the hash value based on the identifier of the first data page. When the hash value maps to the memory node M1 shown in Figure 8, the computing node N1 sends a query message to the memory node M1 to obtain the storage location identifier of the first data page. The query message may include the identifier of the first data page. The memory node M1 receives the query message, queries the stored page directory based on the identifier of the first data page in the query message, obtains the storage location identifier of the first data page, and then sends it to the computing node N1.
[0144] Based on the method embodiment shown in Figure 2, this application embodiment also provides a data recovery device.
[0145] Figure 9 is a schematic diagram of a data recovery device 900 provided in an embodiment of this application. This data recovery device 900 is used to implement the steps in the method embodiment shown in Figure 2 above.
[0146] As shown in Figure 9, the data recovery device 900 may include a detection module 901 and a recovery module 902. The detection module 901 can be deployed in the aforementioned detection node, or it can be distributed across multiple detection nodes. When the detection module 901 is distributed across multiple nodes, the multiple nodes jointly implement the function of the detection module 901. Similarly, the recovery module 902 can be deployed in the aforementioned recovery node, or it can be distributed across multiple recovery nodes. When the recovery module 902 is distributed across multiple nodes, the multiple nodes jointly implement the function of the recovery module 902.
[0147] The detection module 901 is used to determine that the computing node N2 has failed and to send a takeover message to the recovery node.
[0148] The recovery module 902 is used to obtain the log file of compute node N2 from the storage system according to the log file identifier of compute node N2 in the takeover message, construct a log metadata set according to the log file of compute node N2, and perform log replay in the order of log sequence numbers in multiple third logs to recover multiple data pages stored by compute node N2.
[0149] It should be noted that the data recovery device 900 provided in the embodiment shown in Figure 9 is only illustrated by the division of the above-mentioned functional modules when executing the data recovery method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the data recovery device 900 can be divided into different functional modules to complete all or part of the functions described above. In addition, the data recovery device 900 provided in the above embodiment and the data recovery method embodiment shown in Figure 2 belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0150] Based on the method embodiment shown in FIG4, this application embodiment also provides a data recovery device.
[0151] Figure 10 is a schematic diagram of a data recovery device 1000 provided in an embodiment of this application. This data recovery device 1000 is used to implement the various steps in the method embodiment shown in Figure 4 above.
[0152] As shown in Figure 10, the data recovery device 1000 may include a receiving module 1001 and a recovery module 1002. The receiving module 1001 can be deployed in the aforementioned detection node, or it can be distributed across multiple detection nodes. When the receiving module 1001 is distributed across multiple nodes, the multiple nodes jointly implement the function of the receiving module 1001. Similarly, the recovery module 1002 can be deployed in the aforementioned recovery node, or it can be distributed across multiple recovery nodes. When the recovery module 1002 is distributed across multiple nodes, the multiple nodes jointly implement the function of the recovery module 1002.
[0153] The receiving module 1001 is used to receive a service request after the computing node N2 of the database system fails. The service request is used to request an operation on the first data page.
[0154] The recovery module 902 is used to recover the first data page according to the first log of the computing node N2 when it is determined that the first data page is stored in the computing node N2 or when it is determined that the first data page is in a recovery state. The first log includes historical operation information of the computing node N2 on the first data page.
[0155] It should be noted that the data recovery device 1000 provided in the embodiment shown in Figure 10 is only illustrated by the division of the above-mentioned functional modules when executing the data recovery method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the data recovery device 1000 can be divided into different functional modules to complete all or part of the functions described above. In addition, the computing device provided in the above embodiment and the data recovery method embodiment shown in Figure 4 belong to the same concept, and the specific implementation process can be found in the method embodiment, which will not be repeated here.
[0156] Figure 11 is a schematic diagram of the hardware structure of a computing device 1100 provided in an embodiment of this application.
[0157] The computing device 1100 can be a computing node in the aforementioned database system. Referring to Figure 11, the computing device 1100 includes a processor 1101, a memory 1102, a communication interface 1103, and a bus 1104. The processor 1101, memory 1102, and communication interface 1103 are connected to each other via the bus 1104. The processor 1101, memory 1102, and communication interface 1103 can also be connected using other methods besides the bus 1104.
[0158] The memory 1102 can be various types of storage media, such as random access memory (RAM), read-only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, hard disk, etc.
[0159] The processor 1101 may be a general-purpose processor, which can be a processor that performs specific steps and / or operations by reading and executing contents stored in memory (e.g., memory 1102). For example, the general-purpose processor may be a central processing unit (CPU). The processor 1101 may include at least one circuit to perform all or part of the steps of the data recovery method provided in the embodiments shown in FIG2 or FIG4.
[0160] The communication interface 1103 includes input / output (I / O) interfaces, physical interfaces, and logical interfaces for interconnecting devices within the computing device 1100, as well as interfaces for interconnecting the computing device 1100 with other devices (such as other computing devices or user equipment). The physical interface can be an Ethernet interface, a fiber optic interface, an ATM interface, etc.
[0161] The bus 1104 can be any type of communication bus used to interconnect the processor 1101, memory 1102 and communication interface 1103, such as a system bus.
[0162] The aforementioned devices can be disposed on separate chips, or at least partially or entirely on the same chip. Whether to dispose of the devices independently on different chips or integrate them on one or more chips often depends on the needs of the product design. This application does not limit the specific implementation of the aforementioned devices.
[0163] The computing device 1100 shown in Figure 11 is merely an example. In the implementation process, the computing device 1100 may also include other components, which will not be listed one by one in this article.
[0164] Based on the computing device shown in Figure 11, this application embodiment also provides a computing device cluster.
[0165] Figure 12 is a schematic diagram of the structure of a computing device cluster 1200 provided in an embodiment of this application. The computing device cluster 1200 can be used to run the database system shown in Figure 1 or Figure 8.
[0166] The computing device cluster 1200 includes at least one computing device 1100 as shown in Figure 11. The computing device 1100 can be a server, such as a central server, an edge server, or a local server in a local data center.
[0167] The memory 1102 of at least one computing device 1100 in the computing device cluster 1200 may contain the same instructions for performing the methods shown in FIG2 and / or FIG4.
[0168] In some possible implementations, the memory 1102 of one or more computing devices 1100 in the computing device cluster 1200 may also store partial instructions for executing the methods shown in FIG2 and / or FIG4. In other words, a combination of one or more computing devices 1100 can jointly execute the instructions for executing the methods shown in FIG2 and / or FIG4.
[0169] It should be noted that the memory 1102 in different computing devices 1100 within the computing device cluster can store different instructions, which are used to execute certain functions of the data recovery device 900. That is, the instructions stored in the memory 1102 of different computing devices 1100 can implement the functions of one or more modules in the detection module 901 and the recovery module 902.
[0170] Similarly, the memory 1102 in different computing devices 1100 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the data recovery device 1000. That is, the instructions stored in the memory 1102 of different computing devices 1100 can implement the functions of one or more modules in the receiving module 1001 and the recovery module 1002.
[0171] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc.
[0172] Figure 13 illustrates one possible implementation. As shown in Figure 13, two computing devices 1100A and 1100B are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this type of possible implementation, the memory 1102 in computing device 1100A stores instructions for implementing the functions of the data recovery device 900. Simultaneously, the memory 1102 in computing device 1100B stores instructions for implementing the functions of the data recovery device 1000. It should be understood that the functions of computing device 1100A shown in Figure 13 can also be performed by multiple computing devices 1100. Similarly, the functions of computing device 1100B can also be performed by multiple computing devices 1100.
[0173] This application also provides a computer program product containing instructions. The computer program product may be a software or program product containing instructions, capable of running on a computing device or stored on any usable medium. When the computer program product is run on at least one computing device, it causes the at least one computing device to perform the data recovery method shown in FIG2 and / or FIG4.
[0174] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that a computing device can store, or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct a computing device to perform the data recovery method shown in FIG2 and / or FIG4.
[0175] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data recovery method, characterized in that, Applied to a database system, the database system including a first computing node and a second computing node, the method includes: After the second computing node fails, the first computing node receives a service request, which is used to request an operation on the first data page; If it is determined that the first data page is stored on the second computing node, or if it is determined that the first data page is in a recovery state, the first computing node recovers the first data page according to the first log of the second computing node, wherein the first log includes historical operation information performed by the second computing node on the first data page.
2. The method according to claim 1, characterized in that, After receiving the service request, the method further includes: The first computing node determines whether to restore the first data page based on the storage location identifier of the first data page and / or the status identifier in the first data page, wherein the status identifier is used to indicate whether it is in a restoration state; In the case where the storage location identifier of the first data page represents the first computing node and the status identifier in the first data page indicates that it is not in a recovery state, the first computing node does not recover the first data page.
3. The method according to claim 1 or 2, characterized in that, Before the first computing node recovers the first data page based on the first log of the second computing node, the method further includes: The first computing node broadcasts log collection messages, and the database system also includes a third computing node; The third computing node receives the log collection message and sends the first log to the first computing node according to the log collection message. The third computing node is used to recover multiple data pages stored by the second computing node according to multiple second logs of the second computing node. The multiple second logs include the first log, and the multiple data pages include the first data page.
4. The method according to claim 3, characterized in that, The log collection message includes the identifier of the first data page, and the third computing node sends the first log to the first computing node according to the log collection message, including: Based on the identifier of the first data page, the log metadata corresponding to the identifier of the first data page is determined in the log metadata set. The log metadata set is generated based on the plurality of second logs, and the log metadata set includes the identifiers of the plurality of data pages and their corresponding log metadata. The first log is determined based on the log metadata corresponding to the identifier of the first data page.
5. The method according to any one of claims 1-4, characterized in that, The first computing node includes a first execution unit and a second execution unit; The first execution unit is configured to recover the data stored in the second computing node based on a plurality of second logs of the second computing node, wherein the plurality of second logs includes the first log; The second execution unit is used to receive the service request, and to restore the first data page according to the first log of the second computing node when it is determined that the first data page is stored in the second computing node or when it is determined that the first data page is in a recovery state; Before recovering the first data page based on the first log of the second computing node, the method further includes: The second execution unit determines the log metadata corresponding to the identifier of the first data page in the log metadata set based on the identifier of the first data page. The log metadata set is generated by the first execution unit based on the plurality of second logs. The second execution unit determines the first log based on the log metadata corresponding to the identifier of the first data page.
6. The method according to any one of claims 1-5, characterized in that, Before the first computing node recovers the first data page based on one or more first logs, the method further includes: The first computing node determines a base version based on the log sequence number in multiple historical versions of the first data page. The base version is used to restore the first data page, and the log sequence number in the base version is greater than the log sequence number in other historical versions among the multiple historical versions.
7. The method according to claim 6, characterized in that, Before the first computing node determines the base version based on the log sequence number in multiple historical versions of the first data page, the method further includes: The first computing node broadcasts a data collection message, which includes the identifier of the first data page. The database system also includes a fourth computing node. The fourth computing node receives the data collection message and sends the historical version of the first data page stored by the fourth computing node to the first computing node according to the identifier of the first data page.
8. The method according to claim 6 or 7, characterized in that, Before the first computing node determines the base version based on the log sequence number in multiple historical versions of the first data page, the method further includes: The first computing node obtains the historical version of the first data page stored in the storage system of the database system.
9. The method according to any one of claims 2-8, characterized in that, The method further includes: In the case where the storage location identifier of the first data page does not indicate the second computing node, the first computing node obtains the first data page based on the storage location identifier of the first data page.
10. The method according to claim 9, characterized in that, In the case where the storage location identifier of the first data page represents the first computing node, the first computing node obtains the first data page based on the storage location identifier of the first data page, including: The second execution unit of the first computing node obtains the first data page from the page storage space of the first computing node according to the identifier of the first data page. The first execution unit of the first computing node is used to modify the status identifier in the first data page when the first data page is restored. The modified status identifier indicates that it is in the restoration state.
11. The method according to claim 9, characterized in that, In the case where the storage location identifier of the first data page represents a third computing node, the first computing node obtains the first data page based on the storage location identifier of the first data page, including: The first computing node sends a data acquisition message to the third computing node; The third computing node sends the first data page to the first computing node based on the data acquisition message.
12. The method according to any one of claims 2-11, characterized in that, The first computing node stores the page directory of the database system, and the method further includes: The first computing node obtains the page directory from its own storage space; The first computing node queries the page directory based on the identifier of the first data page to obtain the storage location identifier of the first data page.
13. The method according to claim 12, characterized in that, Before the first computing node recovers the first data page, the method further includes: The first computing node modifies the storage location identifier of the first data page in the page directory, and the modified storage location identifier represents the first computing node.
14. The method according to any one of claims 2-11, characterized in that, The database system further includes multiple memory nodes, each of which is used to store one or more page directories of the database system. The method further includes: The first computing node determines a hash value based on the identifier of the first data page, and the hash value is mapped to the first memory node among the plurality of memory nodes; The first computing node sends a query message to the first memory node, the query message including the identifier of the first data page; The first memory node receives the query message, queries the page directory stored in the first memory node according to the identifier of the first data page, obtains the storage location identifier of the first data page, and sends it to the first computing node.
15. The method according to claim 14, characterized in that, Before the first computing node recovers the first data page, the method further includes: The first computing node sends a modification message to the first memory node, the modification message including the identifier of the first data page; The first memory node receives the modification message and modifies the storage location identifier of the first data page in the page directory stored by the first memory node according to the identifier of the first data page. The modified storage location identifier represents the first computing node.
16. The method according to any one of claims 6-15, characterized in that, The first computing node recovers the first data page based on the first log of the second computing node, including: If the log sequence number in the base version of the first data page is less than the log sequence number of the first log, the base version is operated on according to the historical operation information.
17. A data recovery device, characterized in that, The device includes: The receiving module is configured to receive a service request after a failure occurs in the second computing node of the database system, the service request being used to request an operation on the first data page; The recovery module is used to recover the first data page based on the first log of the second computing node when it is determined that the first data page is stored on the second computing node or when it is determined that the first data page is in a recovery state. The first log includes historical operation information performed by the second computing node on the first data page.
18. A computing device cluster, characterized in that, The system includes at least one computing device, each computing device including a processor and a memory, wherein the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to implement the method of any one of claims 1 to 16.
19. A computer-readable storage medium, characterized in that, Includes instructions that, when executed on a computing device cluster, cause the computing device cluster to perform the method of any one of claims 1 to 16.
20. A computer program product, characterized in that, Includes instructions that, when executed on a computing device cluster, cause the computing device cluster to perform the method of any one of claims 1 to 16.
Citation Information
Patent Citations
Recovering pages of database
CN104937556A
Fault recovery method, apparatus and device for database node, and storage medium
CN114297003A
Data recovery method and device
CN116266175A
Data processing system, data processing method and device and related equipment
CN117931831A
Remote direct memory access (RDMA)-based recovery of dirty data in remote memory
US11436112B1