A method, device, equipment and storage medium for data page recovery

By traversing the data pages in the redo log and the active node cache, determining the status of the data page and deciding whether to repeat the log, the problem of slow data page recovery speed is solved and the availability of the database is improved.

CN115061850BActive Publication Date: 2025-04-15SHANGHAI DAMENG DATABASE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210798265.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-06
Publication Date
2025-04-15
Estimated Expiration
2042-07-06

AI Technical Summary

Technical Problem

In a shared storage cluster environment, the data page recovery speed is slow, resulting in the database being unavailable for a long time, reducing the database availability.

Method used

By traversing the redo log of the node and the data page in the active node cache, the first modification statistics and the second modification statistics are determined, the node data page status is judged based on these information, and whether it is necessary to repeat the redo log to complete the recovery of the data page.

Benefits of technology

Reduces the workload of replaying and reworking logs, and improves data recovery speed and database availability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115061850B_ABST
    Figure CN115061850B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for data page recovery. The method comprises: in response to an application instruction for recovering a data page of a failed node, traversing the redo log of the node to determine first modification statistics; traversing the data page in the cache of the active node to determine second modification statistics; based on the first modification statistics and the second modification statistics, determining the node data page status, wherein the data page status includes expired, to be replayed and latest; judging whether the node data page needs to replay the redo log according to the node data page status to complete the recovery of the data page of the failed node. The technical solution of the embodiment of the present invention reduces the workload of replaying the redo log and improves the data recovery speed and the availability of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of database technology, and in particular to a method, device, equipment and storage medium for recovering a data page. Background Art

[0002] The redo log records the modifications made to data pages by physical transactions. The writeahead log (WAL) mechanism ensures that when a data page is flushed to disk, the corresponding redo log has already been flushed to disk. If a failure causes data loss, the modifications to the data page can be redone by replaying the redo log, thereby restoring the data page. In a shared storage cluster (DSC) environment, each node can generate a redo log independently, and each redo record records the modifications made by different nodes to a specified offset on a data page.

[0003] Generally speaking, based on the cache exchange mechanism, DSC can achieve concurrency control when each node in the cluster accesses data pages, thereby synchronizing data pages between nodes and ensuring that each node always accesses the latest data page. When multiple nodes access and modify the same data page, different versions of the data page may exist in the cache of each node. If a node failure occurs in the cluster, for the active node, all modified data pages exist in the local cache or disk and are not lost. For the failed node, all the unflushed data in the local cache will be lost, and the redo log needs to be replayed to recover the lost data.

[0004] However, when replaying the redo log to recover the lost data, all the data pages in the active node cache that have not been flushed to disk are discarded, and then all the redo logs after the most recent checkpoint are replayed to restore the data pages to the latest state. Among them, the checkpoint is a database event, and its function is to write the data pages in the buffer to the disk in the order in which the data pages are modified, and dynamically adjust the relevant log sequence number (LSN) in this process. There is a common problem that the workload of replaying logs is large, the data recovery speed is slow, resulting in long-term database unavailability, which reduces the availability of the database. Summary of the invention

[0005] The present invention provides a method, device, equipment and storage medium for recovering a data page, so as to solve the problem of slow recovery speed of the data page.

[0006] In a first aspect, an embodiment of the present invention provides a method for recovering a data page, comprising:

[0007] In response to an application instruction to restore a data page of a failed node, traverse a redo log of the node to determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by modifying a data page of the node and a maximum log sequence number generated by modifying a data page of the active node;

[0008] Traversing the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page;

[0009] Determine a node data page status based on the first modification statistical information and the second modification statistical information, wherein the data page status includes expired, to be repeated, and latest;

[0010] According to the node data page status, it is determined whether the node data page needs to replay the redo log to complete the recovery of the failed node data page.

[0011] In a second aspect, an embodiment of the present invention provides a data page recovery device, including:

[0012] A first information determination module is used to respond to an application instruction for restoring a data page of a failed node, traverse a redo log of a node, and determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by a node modifying a data page and a maximum log sequence number generated by an active node modifying a data page;

[0013] A second information determination module, configured to traverse the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page;

[0014] A state determination module, configured to determine a node data page state based on the first modification statistical information and the second modification statistical information, wherein the data page state includes expired, to be repeated, and latest;

[0015] The redo log replay judgment module is used to judge whether the node data page needs to replay the redo log according to the node data page status, so as to complete the recovery of the failed node data page.

[0016] In a third aspect, an embodiment of the present invention provides an electronic device, the electronic device comprising:

[0017] at least one processor;

[0018] and a memory communicatively coupled to the at least one processor;

[0019] The memory stores a computer program executable by at least one processor, and the computer program is executed by at least one processor so that the at least one processor can execute the data page recovery method of the first aspect.

[0020] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a processor to implement the data page recovery method of the first aspect when executed.

[0021] The data page recovery scheme provided by the embodiment of the present invention responds to the application instruction of recovering the data page of the failed node, traverses the redo log of the node, determines the first modification statistical information, wherein the node includes the active node and the failed node, the first modification statistical information includes the maximum log sequence number generated by the node modifying the data page and the maximum log sequence number generated by the active node modifying the data page, traverses the data pages in the active node cache, determines the second modification statistical information, wherein the second modification statistical information includes the maximum log sequence number of the data page and the maximum log sequence number of the data page that has been flushed to disk, determines the node data page status based on the first modification statistical information and the second modification statistical information, wherein the data page status includes expired, to be replayed and latest, and judges whether the node data page needs to replay the redo log according to the node data page status to complete the recovery of the failed node data page. By adopting the above technical solution, the first modification statistical information is determined according to the traversal result of the node's redo log, and then the second modification statistical information is determined according to the traversal result of the data page in the active node cache. Then, the node data page status is determined according to the first modification statistical information and the second modification statistical information. According to this status, it can be determined whether the node data page needs to replay the redo log, which reduces the workload of replaying the redo log and improves the data recovery speed and database availability.

[0022] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0024] Figure 1 is a flow chart of a method for data page recovery provided according to Embodiment 1 of the present invention;

[0025] Figure 2 is a flow chart of a method for data page recovery provided according to Embodiment 2 of the present invention;

[0026] Figure 3 is a structural schematic diagram of a data page recovery device provided according to Embodiment 3 of the present invention;

[0027] Figure 4 It is a schematic diagram of the structure of an electronic device provided according to Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In the description of the present invention, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are an "or" relationship. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] Embodiment 1

[0031] Figure 1A flowchart of a method for data page recovery provided in Embodiment 1 of the present invention is applicable to the case of recovering data pages. The method can be executed by a data page recovery device. The data page recovery device can be implemented in the form of hardware and / or software. The data page recovery device can be configured in an electronic device. The electronic device can be composed of two or more physical entities or one physical entity.

[0032] like Figure 1 As shown, a method for data page recovery provided by the first embodiment of the present invention specifically includes the following steps:

[0033] S101. In response to an application instruction for restoring a data page of a failed node, traverse the redo log of the node to determine first modification statistical information.

[0034] The nodes include active nodes and faulty nodes, and the first modification statistical information includes the maximum log sequence number generated when the node modifies the data page and the maximum log sequence number generated when the active node modifies the data page.

[0035] In this embodiment, after a node failure occurs in the DSC, for the active node, its modified data page is stored in the local cache or disk and is not lost. For the faulty node, if the modified data page is not flushed in the local cache, the modified data page will be completely lost. At this time, the lost data can be restored by replaying the redo log. By traversing the redo logs of the faulty node and the active node, the maximum log sequence number generated by all nodes modifying the data page and the maximum log sequence number generated by the active node modifying the data page can be obtained. Among them, the nodes in the DSC that can provide normal services to the outside can be called active nodes; nodes that cannot provide normal services can be called faulty nodes, such as nodes that have unexpected power outages, hardware failures, and internal program errors. Flushing the disk can be understood as saving the data page to the disk. The log sequence number can be understood as an integer value automatically maintained by the system, which has the characteristics of automatic increment and global uniqueness. Each log sequence number represents a physical transaction generated inside the system. When a node modifies a data page, the corresponding log sequence number will be recorded in the redo log.

[0036] S102: traverse the data pages in the active node cache to determine second modification statistical information.

[0037] The second modification statistical information includes the maximum log sequence number of the data page and the maximum log sequence number of the flushed data page.

[0038] In this embodiment, before the failure occurs, the active node may have synchronized the data pages of the failed node to the local cache through the cache exchange mechanism. Therefore, the active node cache may contain data modified by the failed node. By traversing the data pages in the active node cache, the maximum log sequence number of the data page and the maximum log sequence number of the data page that has been flushed to disk can be obtained.

[0039] S103. Determine the node data page status based on the first modification statistical information and the second modification statistical information.

[0040] The data page status includes expired, pending replay, and latest.

[0041] In this embodiment, the status of data pages of all nodes may be determined according to the first modification statistical information and the second modification statistical information, and different processing methods may be used for data pages in different statuses.

[0042] S104: According to the node data page status, determine whether the node data page needs to replay the redo log to complete the recovery of the failed node data page.

[0043] In this embodiment, the node data page in the state to be replayed can be subjected to the operation of replaying the redo log to complete the recovery of the failed node data page, and the node data page in the latest and expired state will not be subjected to the operation of replaying the redo log. When replaying the redo log, only the redo log corresponding to the lost data page needs to be replayed.

[0044] A method for data page recovery provided by an embodiment of the present invention responds to an application instruction for recovering a data page of a failed node, traverses the redo log of the node, determines first modification statistical information, wherein the node includes an active node and a failed node, the first modification statistical information includes a maximum log sequence number generated by the node modifying the data page and a maximum log sequence number generated by the active node modifying the data page, traverses the data pages in the active node cache, determines second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the data page that has been flushed to disk, determines a node data page status based on the first modification statistical information and the second modification statistical information, wherein the data page status includes expired, to be replayed, and latest, and determines whether the node data page needs to replay the redo log based on the node data page status to complete the recovery of the failed node data page. The technical solution of the embodiment of the present invention determines the first modification statistical information according to the traversal result of the redo log of the node, and then determines the second modification statistical information according to the traversal result of the data page in the active node cache, and then determines the node data page status according to the first modification statistical information and the second modification statistical information. According to this status, it can be determined whether the node data page needs to replay the redo log, which reduces the workload of replaying the redo log and improves the data recovery speed and database availability.

[0045] Optionally, judging whether the node data page needs to replay the redo log according to the node data page status, including:

[0046] 1) If the status of the node data page is the latest, it is determined that the node data page does not need to replay the redo log, and the information corresponding to the node data page is removed from the first modification statistical information.

[0047] Specifically, if the status of the node data page is the latest, there is no need to replay the redo log, and the information corresponding to the node data page can be removed from the table or database corresponding to the first modified statistical information, so that when the first modified statistical information is re-determined next time, the first modified statistical information will also change accordingly.

[0048] 2) If the status of the node data page is to be replayed, it is determined that the node data page needs to replay the redo log.

[0049] 3) If the status of the node data page is expired, it is determined that the node data page does not need to replay the redo log, and the information corresponding to the node data page is removed from the shared storage cluster active node cache.

[0050] Specifically, if the status of the node data page is expired, there is no need to replay the redo log, and the relevant information of the node modifying the data page can be cleared from the shared storage cluster active node cache, that is, the information corresponding to the node data page is removed from the shared storage cluster active node cache.

[0051] The advantage of this setting is that it filters out expired data pages and the latest data pages, and only replays the redo logs for the data to be replayed, reducing the workload of replaying the redo logs and the IO time of loading data pages.

[0052] Embodiment 2

[0053] Figure 2 This is a flow chart of a method for recovering a data page provided in the second embodiment of the present invention. The technical solution of the embodiment of the present invention is further optimized on the basis of the above optional technical solutions, and provides a specific method for recovering a data page.

[0054] Optionally, traversing the redo log of the node to determine the first modification statistical information includes: traversing and parsing the redo log of the node to determine the first log sequence number, the second log sequence number and the node number of the node, wherein the first log sequence number is the maximum log sequence number generated by each node in the node to modify the data page, the second log sequence number is the maximum log sequence number generated by each active node in the active node to modify the data page, and the node contains multiple data pages; generating a first correspondence between the first log sequence number, the second log sequence number and the node number; according to the first correspondence, determining the maximum log sequence number generated by the node to modify the data page and the maximum log sequence number generated by the active node to modify the data page, so as to obtain the first modification statistical information. The advantage of such a setting is that by determining the first modification statistical information and the first correspondence, data support is provided for the subsequent determination of the pending replay state and the latest state of the node data page.

[0055] Optionally, traverse the data pages in the active node cache to determine the second modification statistical information, including: traverse and parse the data pages in the shared storage cluster active node cache, determine the third log sequence number, the fourth log sequence number and the node number of the active node, wherein the third log sequence number is the log sequence number generated by each active node in the active node when modifying the data page for the first time, and the fourth log sequence number is the maximum log sequence number generated by each active node in the active node when modifying the data page; generate a second correspondence between the third log sequence number, the fourth log sequence number and the node number of the active node; according to the second correspondence, determine the maximum log sequence number of the data page and the maximum log sequence number of the flushed data page to obtain the second modification statistical information. The advantage of such a setting is that, by determining the second modification statistical information and the second correspondence, data support is provided for the subsequent determination of the expiration status of the node data page.

[0056] Optionally, based on the first modification statistical information and the second modification statistical information, determining the node data page status includes: based on the first modification statistical information, if the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page, then determining that the node data page status is up to date; based on the first modification statistical information, if the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page, then determining that the node data page status is to be replayed; based on the second modification statistical information, determining whether the active node data page status is expired. The advantage of such a setting is that the node data page status is determined, which provides a basis for judging whether the node's redo log needs to be replayed later.

[0057] like Figure 2 As shown, a method for data page recovery provided by Embodiment 2 of the present invention specifically includes the following steps:

[0058] S201. In response to an application instruction for restoring a data page of a failed node, traverse and parse the redo log of the node to determine a first log sequence number, a second log sequence number, and a node number of the node.

[0059] The first log sequence number is the maximum log sequence number generated by each node in the node modifying the data page, the second log sequence number is the maximum log sequence number generated by each active node in the active node modifying the data page, and the node contains multiple data pages.

[0060] Exemplarily, by traversing the redo log of a node, a redo log hash table can be created based on the key value, and the table is recorded as REDO_HASH. By parsing the redo log, the LSN value of each modified data page and the corresponding node number can be obtained. The maximum LSN value of each node modifying the data page can be recorded as REDO_LSN, that is, the first log sequence number, and the maximum LSN value of each active node modifying the data page can be recorded as OK_LSN, that is, the second log sequence number. Among them, the key value includes the tablespace identifier, the file identifier, and the page number. In the redo log hash table, each key value corresponds to a hash item, and its corresponding hash item can be found through the key value. The corresponding REDO_LSN is recorded in each hash item.

[0061] S202: Generate a first corresponding relationship between the first log sequence number, the second log sequence number, and the node number.

[0062] Exemplarily, a correspondence relationship between REDO_LSN, OK_LSN, and the node number may be created, and this relationship is the first correspondence relationship.

[0063] S203. Determine, according to the first corresponding relationship, a maximum log sequence number generated when a node modifies a data page and a maximum log sequence number generated when an active node modifies a data page, to obtain first modification statistical information.

[0064] Exemplarily, according to the first corresponding relationship, the REDO_LSN and OK_LSN obtained in the previous step are traversed in order from low to high node numbers, and the largest REDO_LSN among all nodes can be determined, that is, the maximum log sequence number generated by the node modifying the data page, recorded as MAX_REDO_LSN, and the largest OK_LSN among all active nodes can be determined, that is, the maximum log sequence number generated by the active node modifying the data page, recorded as MAX_OK_LSN.

[0065] S204, traverse and parse the data pages in the cache of the active node of the shared storage cluster to determine the third log sequence number, the fourth log sequence number and the node number of the active node.

[0066] The third log sequence number is the log sequence number generated when each active node in the active nodes modifies the data page for the first time, and the fourth log sequence number is the maximum log sequence number generated when each active node in the active nodes modifies the data page.

[0067] Exemplarily, by traversing the data pages in the cache of the active nodes of the shared storage cluster, a cache page hash table can be created according to the key value, and the table is recorded as BUFFER_HASH. By parsing the data pages in the cache of the active nodes of the shared storage cluster, the LSN value of the first modification of the data page by each active node can be obtained, recorded as FIRST_MODIFY_LSN, that is, the third log sequence number, the maximum log sequence number generated by each active node modifying the data page can be obtained, recorded as PAGE_LSN, that is, the fourth log sequence number, and the corresponding node number can be obtained.

[0068] S205: Generate a second corresponding relationship between the third log sequence number, the fourth log sequence number, and the node number of the active node.

[0069] Exemplarily, a correspondence relationship among FIRST_MODIFY_LSN, PAGE_LSN, and the node number may be created, and this relationship is the second correspondence relationship.

[0070] S206. Determine the maximum log sequence number of the data page and the maximum log sequence number of the flushed data page according to the second corresponding relationship to obtain second modification statistical information.

[0071] Exemplarily, according to the second corresponding relationship, the FIRST_MODIFY_LSN and PAGE_LSN obtained in the previous step are traversed in order from low to high node numbers, and the maximum log sequence number of the data pages modified by all nodes can be determined, that is, the maximum log sequence number of the data page, recorded as MAX_PAGE_LSN, and the maximum log sequence number corresponding to the flushed data page can be determined, that is, the maximum log sequence number of the flushed data page, recorded as MAX_FLUSH_LSN.

[0072] Optionally, determining the maximum log sequence number of the flushed data page according to the second corresponding relationship includes:

[0073] 1) According to the second corresponding relationship, the third log sequence number and the fourth log sequence number are traversed in sequence, wherein the initial value of the maximum log sequence number of the flushed data page is zero.

[0074] Specifically, based on the second corresponding relationship, the third log sequence number and the fourth log sequence number may be traversed in sequence according to the order of the node numbers from low to high.

[0075] 2) If the third log sequence number is zero, it is determined that the data page corresponding to the current active node has been flushed to disk, and the log sequence number of the flushed data page of the current active node is determined as the fourth log sequence number corresponding to the current active node.

[0076] For example, if FIRST_MODIFY_LSN=0, that is, the third log sequence number is zero, it can be determined that the data page corresponding to the current active node has been flushed, and the FLUSH_LSN of the current active node can be set to the PAGE_LSN corresponding to the current active node, that is, FLUSH_LSN=PAGE_LSN. Among them, the third log sequence number does not exist in the case of being less than zero. If the third log sequence number is less than zero, an error will be reported.

[0077] 3) If the third log sequence number is not zero, traverse and parse the redo log of the node to determine the first log sequence number, the second log sequence number and the node number of the node, where the first log sequence number is the maximum log sequence number generated by each node in the node modifying the data page, and the second log sequence number is the maximum log sequence number generated by each active node in the active node modifying the data page, and the node contains multiple data pages.

[0078] Exemplarily, if FIRST_MODIFY_LSN≠0, that is, the third log sequence number is not zero, then the related operations of the above steps S201 to S202 are performed.

[0079] 4) Generate a first correspondence between the first log sequence number, the second log sequence number and the node number.

[0080] 5) Based on the first corresponding relationship, determine whether the third log sequence number is greater than the first log sequence number corresponding to the current active node. If so, determine the log sequence number of the flushed data page of the current active node as the first log sequence number corresponding to the current active node.

[0081] Exemplarily, according to the first corresponding relationship, the first log sequence number corresponding to the current node and the current data page can be found, that is, the first log sequence number corresponding to the current active node. If the third log sequence number is greater than the first log sequence number corresponding to the current active node, the log sequence number of the flushed data page of the current active node can be determined as the first log sequence number corresponding to the current active node, that is, FLUSH_LSN=REDO_LSN.

[0082] Optionally, if the third log sequence number is less than or equal to the first log sequence number corresponding to the current active node, the log sequence number of the flushed data page of the current active node remains the initial value zero.

[0083] Optionally, if the current node number and its corresponding REDO_LSN exist in the first corresponding relationship, but the current node number and its corresponding FIRST_MODIFY_LSN and PAGE_LSN do not exist in the second corresponding relationship, that is, the current active node data page does not exist in the shared storage cluster active node cache, but the current active node data page exists in the redo log, then the log sequence number of the flushed data page of the current active node can be determined as the first log sequence number corresponding to the current active node, that is, FLUSH_LSN=REDO_LSN.

[0084] 6) After the traversal is completed, based on the obtained log sequence numbers of the flushed data pages of the multiple currently active nodes, a set of log sequence numbers of the flushed data pages of the active node to be filtered is determined.

[0085] Specifically, the log sequence numbers of the flushed data pages of the multiple current active nodes obtained in the above steps can be combined into a set of log sequence numbers of the flushed data pages of the active node to be screened.

[0086] 7) Based on the log sequence number set, determine the maximum log sequence number of the flushed data page.

[0087] Specifically, the log sequence number set of the flushed data pages of the active node to be screened may be traversed to find the largest log sequence number, that is, to determine the largest log sequence number of the flushed data page.

[0088] S207. Based on the first modification statistical information, if the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page, it is determined that the node data page status is the latest.

[0089] Specifically, if MAX_REDO_LSN = MAX_OK_LSN, that is, the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page, it can be determined that the data page of this node is the latest data page and there is no need to replay the redo log, that is, the status of the data page of this node is the latest.

[0090] Optionally, if there is no node data page information in REDO_HASH, that is, there is no information in the redo log about any node modifying this data page, it can be determined that the data page of this node is the latest data page and there is no need to replay the redo log, that is, the status of the data page of this node is the latest.

[0091] S208. Based on the first modification statistics, if the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page, determine that the status of the node data page is to be replayed.

[0092] Specifically, if MAX_REDO_LSN > MAX_OK_LSN, that is, the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page, it can be determined that the data page of this node is a data page to be replayed and the redo log needs to be replayed, that is, the status of the data page of this node is to be replayed. Among them, there is no situation where the maximum log sequence number generated by the node modifying the data page is less than the maximum log sequence number generated by the active node modifying the data page. If there is such a situation, an error will be reported.

[0093] S209. Based on the second modification statistics, determine whether the status of the active node data page is expired.

[0094] Optionally, based on the second modification statistics, determining whether the status of the active node data page is expired includes: based on the second modification statistics and the second corresponding relationship, if the fourth log sequence number is less than the maximum log sequence number of the flushed data page, determine that the status of the active node data page is expired.

[0095] Specifically, if PAGE_LSN < MAX_FLUSH_LSN, that is, the fourth log sequence number is less than the maximum log sequence number of the flushed data page, it can be determined that the data page of this node is an expired data page and there is no need to replay the redo log, that is, the status of the data page of this node is expired.

[0096] Optionally, if the data page information of a node does not exist in REDO_HASH, that is, the redo log does not contain information about the node modifying the data page, but the data page information of the node exists in BUFFER_HASH, that is, the node cache contains information about the node modifying the data page, then it can be determined that the data page in the node cache is an expired data page and there is no need to replay the redo log, that is, the data page status of the node is expired.

[0097] In this embodiment, steps S207 to S209 may also be parallel steps, which is not limited here.

[0098] S210: If the status of the node data page is the latest, determine that the node data page does not need to replay the redo log, and remove the information corresponding to the node data page from the first modification statistical information.

[0099] S211. If the status of the node data page is to be replayed, it is determined that the node data page needs to replay the redo log.

[0100] S212: If the status of the node data page is expired, determine that the node data page does not need to replay the redo log, and remove the information corresponding to the node data page from the shared storage cluster active node cache.

[0101] The method for data page recovery provided by an embodiment of the present invention obtains a first log sequence number, a second log sequence number, a third log sequence number and a fourth log sequence number by traversing the redo log of the node and the data page in the active node cache after a node failure occurs, determines first modification statistical information and second modification statistical information according to the first log sequence number to the fourth log sequence number, and then determines the state of the node data page according to the first modification statistical information and the second modification statistical information. If the state of the node data page is to be replayed, the redo log of the node data page needs to be replayed to recover the lost data page, and the data page in the active node cache of the shared storage cluster is fully utilized, and the state of the node data page is identified, thereby reducing the workload of replaying the redo log and the IO time of loading the data page, and improving the speed of data recovery.

[0102] Embodiment 3

[0103] Figure 3 This is a schematic diagram of the structure of a data page recovery device provided by Embodiment 3 of the present invention. Figure 3 As shown, the device includes: a first information determination module 301, a second information determination module 302, a state determination module 303 and a log determination module 304, wherein:

[0104] A first information determination module is used to respond to an application instruction for restoring a data page of a failed node, traverse a redo log of a node, and determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by a node modifying a data page and a maximum log sequence number generated by an active node modifying a data page;

[0105] A second information determination module, configured to traverse the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page;

[0106] A state determination module, configured to determine a node data page state based on the first modification statistical information and the second modification statistical information, wherein the data page state includes expired, to be repeated, and latest;

[0107] The log judgment module is used to judge whether the node data page needs to replay the redo log according to the node data page status to complete the recovery of the failed node data page.

[0108] The data page recovery device provided by the embodiment of the present invention determines the first modification statistical information according to the traversal result of the redo log of the node, and then determines the second modification statistical information according to the traversal result of the data page in the active node cache, and then determines the node data page status according to the first modification statistical information and the second modification statistical information. According to this status, it can be determined whether the node data page needs to replay the redo log, thereby reducing the workload of replaying the redo log and improving the data recovery speed and database availability.

[0109] Optionally, the first information determination module includes:

[0110] a first log sequence number and node number determination unit, configured to traverse and parse the redo log of the node, determine a first log sequence number, a second log sequence number, and the node number of the node, wherein the first log sequence number is the maximum log sequence number generated by each node in the node modifying a data page, the second log sequence number is the maximum log sequence number generated by each active node in the active node modifying a data page, and the node includes multiple data pages;

[0111] A first correspondence generating unit, configured to generate a first correspondence between the first log sequence number, the second log sequence number and the node number;

[0112] The first information determination unit is used to determine, according to the first corresponding relationship, a maximum log sequence number generated by a node modifying a data page and a maximum log sequence number generated by an active node modifying a data page, so as to obtain first modification statistical information.

[0113] Optionally, the second information determination module includes:

[0114] The second log sequence number and node number determination unit is used to traverse and parse the data pages in the cache of the active node of the shared storage cluster, and determine the third log sequence number, the fourth log sequence number and the node number of the active node, wherein the third log sequence number is the log sequence number generated when each active node in the active node modifies the data page for the first time, and the fourth log sequence number is the maximum log sequence number generated when each active node in the active node modifies the data page;

[0115] A second correspondence generating unit, configured to generate a second correspondence between the third log sequence number, the fourth log sequence number and the node number of the active node;

[0116] The second information determination unit is used to determine the maximum log sequence number of the data page and the maximum log sequence number of the flushed data page according to the second corresponding relationship to obtain second modification statistical information.

[0117] Optionally, according to the second corresponding relationship, determining the maximum log sequence number of the flushed data page includes: according to the second corresponding relationship, traversing the third log sequence number and the fourth log sequence number in sequence, wherein the initial value of the maximum log sequence number of the flushed data page is zero; if the third log sequence number is zero, determining that the data page corresponding to the current active node has been flushed, and determining the log sequence number of the flushed data page of the current active node as the fourth log sequence number corresponding to the current active node; if the third log sequence number is not zero, traversing and parsing the redo log of the node to determine the first log sequence number, the second log sequence number and the node number of the node, wherein the first log sequence number is the maximum log sequence number generated by each node in the node modifying the data page, and the fourth log sequence number is the maximum log sequence number generated by each node in the node modifying the data page. The second log sequence number is the maximum log sequence number generated by modifying the data page of each active node in the active node, and the node includes multiple data pages; a first correspondence between the first log sequence number, the second log sequence number and the node number is generated; based on the first correspondence, whether the third log sequence number is greater than the first log sequence number corresponding to the current active node is determined; if so, the log sequence number of the flushed data page of the current active node is determined as the first log sequence number corresponding to the current active node; after the traversal is completed, based on the obtained log sequence numbers of the flushed data pages of the multiple current active nodes, a set of log sequence numbers of the flushed data pages of the active node to be filtered is determined; based on the set of log sequence numbers, the maximum log sequence number of the flushed data page is determined.

[0118] Optionally, a state determination module includes:

[0119] A latest status determination unit, configured to determine, based on the first modification statistical information, that the node data page status is latest if the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page;

[0120] a to-be-replayed state determining unit, configured to determine, based on the first modification statistical information, that the state of the node data page is to-be-replayed if the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page;

[0121] An expired status determination unit is used to determine whether the active node data page status is expired based on the second modification statistical information.

[0122] Optionally, determining whether the active node data page status is expired based on the second modification statistical information includes: based on the second modification statistical information and the second corresponding relationship, if the fourth log sequence number is less than the maximum log sequence number of the flushed data page, determining that the active node data page status is expired.

[0123] Optional, log judgment module, including:

[0124] a first determination unit for replaying redo logs, configured to determine that the node data page does not need to replay redo logs if the state of the node data page is the latest, and remove information corresponding to the node data page from the first modification statistical information;

[0125] A second determination unit for replaying the redo log is used to determine that the node data page needs to replay the redo log if the state of the node data page is to be replayed;

[0126] The third determination unit for replaying the redo log is used to determine that the node data page does not need to replay the redo log if the state of the node data page is expired, and remove the information corresponding to the node data page from the shared storage cluster active node cache.

[0127] The data page recovery device provided in the embodiment of the present invention can execute the data page recovery method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0128] Embodiment 4

[0129] Figure 4A schematic diagram of the structure of an electronic device 40 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0130] like Figure 4 As shown, the electronic device 40 includes at least one processor 41, and a memory connected to the at least one processor 41, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 to the random access memory (RAM) 43. In the RAM 43, various programs and data required for the operation of the electronic device 40 can also be stored. The processor 41, the ROM 42, and the RAM 43 are connected to each other through a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0131] A number of components in the electronic device 40 are connected to the I / O interface 45, including: an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0132] The processor 41 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 41 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 41 performs the various methods and processes described above, such as a method for data page recovery.

[0133] In some embodiments, the method of data page recovery can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 40 via the ROM 42 and / or the communication unit 49. When the computer program is loaded into the RAM 43 and executed by the processor 41, one or more steps of the method of data page recovery described above can be performed. Alternatively, in other embodiments, the processor 41 can be configured to perform the method of data page recovery in any other appropriate manner (for example, by means of firmware).

[0134] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0135] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0136] The computer device provided above can be used to execute the data page recovery method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0137] Embodiment 5

[0138] In the context of the present invention, a computer readable storage medium may be a tangible medium, wherein the computer executable instructions, when executed by a computer processor, are used to perform a method for data page recovery, the method comprising:

[0139] In response to an application instruction to restore a data page of a failed node, traverse a redo log of the node to determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by modifying a data page of the node and a maximum log sequence number generated by modifying a data page of the active node;

[0140] Traversing the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page;

[0141] Determine a node data page status based on the first modification statistical information and the second modification statistical information, wherein the data page status includes expired, to be repeated, and latest;

[0142] According to the node data page status, it is determined whether the node data page needs to replay the redo log to complete the recovery of the failed node data page.

[0143] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by an instruction execution system, device or equipment or used with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0144] The computer device provided above can be used to execute the data page recovery method provided in any of the above embodiments, and has corresponding functions and beneficial effects.

[0145] It is worth noting that in the embodiment of the above-mentioned data page recovery device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0146] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A method for recovering a data page, characterized in that: include: In response to an application instruction to restore a data page of a failed node, traverse a redo log of the node to determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by modifying a data page of the node and a maximum log sequence number generated by modifying a data page of the active node; Traversing the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page; Determine a node data page status based on the first modification statistical information and the second modification statistical information, wherein the data page status includes expired, to be repeated, and latest; According to the node data page status, determining whether the node data page needs to replay the redo log to complete the recovery of the failed node data page; The traversing the redo log of the node to determine the first modification statistical information includes: Traversing and parsing the redo log of the node, determining a first log sequence number, a second log sequence number, and a node number of the node, wherein the first log sequence number is a maximum log sequence number generated by each node in the node modifying a data page, the second log sequence number is a maximum log sequence number generated by each active node in the active node modifying a data page, and the node includes multiple data pages; Generate a first corresponding relationship between the first log sequence number, the second log sequence number and the node number; According to the first corresponding relationship, determine the maximum log sequence number generated by the node modifying the data page and the maximum log sequence number generated by the active node modifying the data page to obtain first modification statistical information; The traversing the data pages in the active node cache to determine the second modification statistical information includes: Traversing and parsing the data pages in the cache of the active nodes of the shared storage cluster, determining a third log sequence number, a fourth log sequence number and the node number of the active node, wherein the third log sequence number is the log sequence number generated when each of the active nodes modifies the data page for the first time, and the fourth log sequence number is the maximum log sequence number generated when each of the active nodes modifies the data page; Generate a second corresponding relationship between the third log sequence number, the fourth log sequence number and the node number of the active node; According to the second corresponding relationship, determine the maximum log sequence number of the data page and the maximum log sequence number of the flushed data page to obtain second modification statistical information; The determining the node data page state based on the first modification statistical information and the second modification statistical information includes: Based on the first modification statistical information, if the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page, then determining that the node data page state is up to date; Based on the first modification statistical information, if the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page, determining that the node data page state is to be replayed; Based on the second modification statistical information, determine whether the active node data page status is expired.

2. The method according to claim 1, characterized in that Determining the maximum log sequence number of the flushed data page according to the second corresponding relationship includes: According to the second corresponding relationship, the third log sequence number and the fourth log sequence number are traversed in sequence, wherein the initial value of the maximum log sequence number of the flushed data page is zero; If the third log sequence number is zero, it is determined that the data page corresponding to the current active node has been flushed to disk, and the log sequence number of the flushed data page of the current active node is determined as the fourth log sequence number corresponding to the current active node; If the third log sequence number is not zero, traverse and parse the redo log of the node to determine the first log sequence number, the second log sequence number and the node number of the node, wherein the first log sequence number is the maximum log sequence number generated by each node in the node modifying the data page, the second log sequence number is the maximum log sequence number generated by each active node in the active node modifying the data page, and the node contains multiple data pages; Generate a first correspondence between the first log sequence number, the second log sequence number and the node number; Based on the first corresponding relationship, determine whether the third log sequence number is greater than the first log sequence number corresponding to the current active node, and if so, determine the log sequence number of the flushed data page of the current active node as the first log sequence number corresponding to the current active node; After the traversal is completed, based on the obtained log sequence numbers of the flushed data pages of the multiple currently active nodes, a set of log sequence numbers of the flushed data pages of the active node to be filtered is determined; According to the log sequence number set, the maximum log sequence number of the flushed data page is determined.

3. The method according to claim 1, characterized in that The determining, based on the second modification statistical information, whether the active node data page status is expired includes: Based on the second modification statistical information and the second corresponding relationship, if the fourth log sequence number is less than the maximum log sequence number of the flushed data page, it is determined that the active node data page status is expired.

4. The method according to claim 1, characterized in that: The determining, according to the node data page state, whether the node data page needs to replay the redo log includes: If the state of the node data page is the latest, determining that the node data page does not need to replay the redo log, and removing information corresponding to the node data page from the first modification statistical information; If the state of the node data page is to be replayed, determining that the node data page needs to replay the redo log; If the status of the node data page is expired, it is determined that the node data page does not need to replay the redo log, and the information corresponding to the node data page is removed from the shared storage cluster active node cache.

5. A data page recovery device, characterized in that: include: A first information determination module is used to respond to an application instruction for restoring a data page of a failed node, traverse a redo log of a node, and determine first modification statistics information, wherein the node includes an active node and a failed node, and the first modification statistics information includes a maximum log sequence number generated by a node modifying a data page and a maximum log sequence number generated by an active node modifying a data page; A second information determination module, configured to traverse the data pages in the active node cache to determine second modification statistical information, wherein the second modification statistical information includes a maximum log sequence number of the data page and a maximum log sequence number of the flushed data page; A state determination module, configured to determine a node data page state based on the first modification statistical information and the second modification statistical information, wherein the data page state includes expired, to be repeated, and latest; A redo log replay judgment module is used to judge whether the node data page needs to replay the redo log according to the node data page status, so as to complete the recovery of the failed node data page; Wherein, the first information determination module includes: a first log sequence number and node number determination unit, configured to traverse and parse the redo log of the node, determine a first log sequence number, a second log sequence number, and the node number of the node, wherein the first log sequence number is the maximum log sequence number generated by each node in the node modifying a data page, the second log sequence number is the maximum log sequence number generated by each active node in the active node modifying a data page, and the node includes multiple data pages; A first correspondence generating unit, configured to generate a first correspondence between the first log sequence number, the second log sequence number and the node number; A first information determination unit, configured to determine, according to the first corresponding relationship, a maximum log sequence number generated by a node modifying a data page and a maximum log sequence number generated by an active node modifying a data page, so as to obtain first modification statistical information; The second information determination module includes: The second log sequence number and node number determination unit is used to traverse and parse the data pages in the cache of the active node of the shared storage cluster, and determine the third log sequence number, the fourth log sequence number and the node number of the active node, wherein the third log sequence number is the log sequence number generated when each active node in the active node modifies the data page for the first time, and the fourth log sequence number is the maximum log sequence number generated when each active node in the active node modifies the data page; A second correspondence generating unit, configured to generate a second correspondence between the third log sequence number, the fourth log sequence number and the node number of the active node; A second information determination unit, configured to determine a maximum log sequence number of a data page and a maximum log sequence number of a flushed data page according to the second corresponding relationship, so as to obtain second modification statistical information; A state determination module, comprising: A latest status determination unit, configured to determine, based on the first modification statistical information, that the node data page status is latest if the maximum log sequence number generated by the node modifying the data page is equal to the maximum log sequence number generated by the active node modifying the data page; a to-be-replayed state determining unit, configured to determine, based on the first modification statistical information, that the state of the node data page is to-be-replayed if the maximum log sequence number generated by the node modifying the data page is greater than the maximum log sequence number generated by the active node modifying the data page; An expired status determination unit is used to determine whether the active node data page status is expired based on the second modification statistical information.

6. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method for data page recovery according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method for data page recovery according to any one of claims 1 to 4 when executed.

Citation Information

Patent Citations

  • Log replay method and device, server and storage medium

    CN110442560A

  • Data page creation method and device, terminal equipment and storage medium

    CN111444147A