A redo log replay method, device, equipment and storage medium

By differentiating the REDO log replay rules for primary and backup databases in a shared storage database cluster, the problem of data page errors and loss during node failure restarts is solved, ensuring that data is restored to the correct state and achieving data integrity and consistency.

CN118295982BActive Publication Date: 2025-11-25WUHAN DAMENG DATABASE
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410468437.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-18
Publication Date
2025-11-25
Estimated Expiration
2044-04-18

AI Technical Summary

Technical Problem

In a shared storage database cluster environment, when a node fails and restarts, the replay of the REDO logs can cause errors in the data page content, which may lead to data loss, especially after a master-slave database switchover.

Method used

By obtaining log packets from the REDO log file, the replay rules are determined based on the database operating mode identifier carried in the log packet. The replay rules for the primary database and the standby database are distinguished to ensure that the replay process conforms to the LSN order and avoid data loss.

Benefits of technology

This ensures that when a node fails and restarts, the data is restored to its correct state before the failure, guaranteeing data integrity and consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118295982B_ABST
    Figure CN118295982B_ABST
Patent Text Reader

Abstract

The application discloses a REDO log replay method and device, equipment and a storage medium. The method comprises the following steps: when a current node is restarted after a failure, a REDO log file in the current node is acquired, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier; the replay rule corresponding to each REDO log package is determined according to the database running mode identifier carried by each REDO log package, so as to replay the REDO log package according to the replay rule corresponding to each REDO log package. Through the technical scheme of the application, the problem of replaying the REDO log under a shared storage cluster data daemon environment is solved, the data can be restored to the state before the node failure, and the correctness of the data is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of computer, and particularly relate to a REDO log replay method, device, equipment and storage medium. BACKGROUND

[0002] A shared storage database cluster (DMDSC) is a highly available cluster architecture, and multiple database instances are contained in the cluster environment. A user can connect any instance to start a transaction, modify data and generate a REDO log, and each instance independently maintains log information.

[0003] The shared storage database cluster environment has a scenario A: two nodes are restarted at the same time, replaying the REDO logs of the LSNs greater than the checkpoint LSNs stored in the respective internal storages, and thus causing the data page contents to be incorrect after the replay.

[0004] A data guardian system is a common solution for database high availability at present, and is usually composed of a master database and one or more standby databases. The standby database keeps data synchronization with the master database by replaying the REDO logs generated by the master database. When the standby database replays the log package of the master database, the master database node information is added in the log package header to identify that the log package is generated by replaying the log of the master database.

[0005] If the operations performed by different nodes of the shared storage database cluster environment involve different data pages, the LSN sizes of the REDO logs generated by the nodes do not have a certain size relationship.

[0006] The shared storage database cluster environment has a scenario B: If the master database of the data guardian environment is a shared storage database cluster, the standby database receives the REDO logs sent by multiple nodes at the same time, and may receive the log with a large LSN first and the log with a small LSN later. If the REDO log greater than the checkpoint LSN is replayed, data loss is likely to occur.

[0007] When the master and standby databases of the data guardian environment are both shared storage clusters, after the master and standby switching (the original standby database becomes the master database, and the original master database becomes the standby database), the standby database cluster environment may have the scenario that the scenarios A and B occur at the same time when the standby database cluster environment fails and restarts. SUMMARY

[0008] Embodiments of the present application provide a REDO log replay method, device, equipment and storage medium to solve the above problems, and can restore the data to the state before the node failure, and thus ensure the correctness of the data.

[0009] According to an aspect of the present application, a REDO log replay method is provided, comprising:

[0010] obtaining a REDO log file in the current node when the current node is restarted after a failure, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier;

[0011] determining a replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, and replaying the REDO log package according to the replay rule corresponding to each REDO log package.

[0012] According to another aspect of the present application, there is provided a REDO log replay device, comprising:

[0013] a REDO log file obtaining module, configured to obtain a REDO log file in the current node when the current node is restarted after a failure, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier;

[0014] a REDO log package replay module, configured to determine a replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, and replay the REDO log package according to the replay rule corresponding to each REDO log package.

[0015] According to another aspect of the present application, there is provided an electronic device, comprising:

[0016] at least one processor; and

[0017] a memory connected to the at least one processor in communication; wherein

[0018] 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 to enable the at least one processor to execute the REDO log replay method according to any one of the embodiments of the present application.

[0019] According to another aspect of the present application, there is provided a computer readable storage medium, which stores computer instructions for enabling a processor to execute the REDO log replay method according to any one of the embodiments of the present application when executed by the processor.

[0020] The embodiment of the present application obtains the REDO log file in the current node when the current node is restarted, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier; the replay rule corresponding to each REDO log package is determined according to the database running mode identifier carried by each REDO log package, so that the REDO log package is replayed according to the replay rule corresponding to each REDO log package, the problem of replaying the REDO log in the shared storage cluster data daemon environment is solved, the data can be restored to the state before the node failure, and the correctness of the data is ensured.

[0021] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it used to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0023] Figure 1 is a flowchart of a REDO log replay method in the embodiments of the present application;

[0024] Figure 2 is a log file storage format diagram in the embodiments of the present application;

[0025] Figure 3 is a structure diagram of a REDO log replay device in the embodiments of the present application;

[0026] Figure 4 is a structure diagram of an electronic device in the embodiments of the present application. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of the present application.

[0028] It should be noted that the terms "first", "second", and the like in the description and in the claims of the present application and in the above-described drawings are used only for distinguishing between similar objects and do not necessarily have to describe a specific order or sequence. It should be understood that data thus used can be interchanged, where appropriate, so that the embodiments of the present application described herein can be carried out in other than the order shown or described herein. Furthermore, the terms "comprise" and "have", and any variations thereof, are intended to cover a non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a list of steps or units can not necessarily be limited to those steps or units that are clearly listed, but can include other steps or units that are not clearly listed or inherent to such processes, methods, products, or apparatus.

[0029] It can be understood that, before using the technical solutions disclosed in the embodiments of the present disclosure, the type of personal information involved in the present disclosure, the scope of use, the scene of use, etc. should be informed to the user and the authorization of the user should be obtained according to relevant laws and regulations.

[0030] Embodiment one

[0031] Figure 1 A flowchart of a REDO log replay method provided for an embodiment of the present application, the present embodiment can be applicable to the case of REDO log replay, and the method can be executed by a REDO log replay device in the embodiment of the present application. The device can be realized in the form of software and / or hardware. As shown in the figure, the method specifically comprises the following steps: Figure 1

[0032] S110, when the current node is restarted after failure, obtaining a REDO log file in the current node.

[0033] The REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier. Each REDO log package also carries a primary database term sequence number and a REDO log package offset in the REDO log file. The database running mode identifier, the primary database term sequence number, and the REDO log package offset in the REDO log file can all be written into the package header of the REDO log package.

[0034] The current node can be a node in a cluster, and the cluster can be a DSC cluster.

[0035] ​Specifically, when the current node is restarted after a failure, the REDO log file in the current node can be obtained in the following manner: when the primary database and the standby database are both shared storage clusters, after a switchover, when the node to which the standby database belongs is restarted after a failure, the REDO log file in the current node is obtained. When the current node is restarted after a failure, the REDO log file in the current node can also be obtained in the following manner: when the primary database is a shared storage cluster, when the standby database is restarted after a failure, the REDO log file in the current node is obtained.

[0036] S120, determine the replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, so as to replay the REDO log package according to the replay rule corresponding to each REDO log package.

[0037] Specifically, the manner of determining the replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package can be: if the database running mode identifier carried by the REDO log package is the primary database running mode, it is determined that the replay rule corresponding to the REDO log package is the primary database running mode REDO log package whose LSN is greater than the target checkpoint LSN; if the database running mode identifier carried by the REDO log package is the standby database running mode, it is determined that the replay rule corresponding to the REDO log package is the REDO log package of all standby database running modes.

[0038] Optionally, the manner of determining the replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, so as to replay the REDO log package according to the replay rule corresponding to each REDO log package, comprises:

[0039] if the database running mode identifier carried by the REDO log package is the primary database running mode, and the LSN of the REDO log package is greater than the target checkpoint LSN,

[0040] or,

[0041] if the database running mode identifier carried by the REDO log package is the standby database running mode,

[0042] the REDO log package is replayed.

[0043] It should be noted that the data page is a basic unit of data storage in a database management system, and is a basic unit of data access, modification, and I / O. A relational database management system usually uses a REDO log to ensure data correctness. Any operation that modifies a data page will generate a REDO log inside the system, and through the WAL (Write-Ahead Logging) mechanism, the modified data page will be written to the disk only after the REDO log is flushed. LSN (Log Sequence Number) is a BIGINT type value maintained inside the database management system, used to identify the REDO log record. Each LSN value represents a collection of data modification operations inside the database management system; the data page header registers the LSN value of the REDO log generated by modifying the data page. The REDO log is generally stored in the log file in the format of a log package RLOG_PKG. In a single-node database, LSN has the characteristics of automatic increment and global uniqueness. When a data modification generates a REDO log, the system assigns an LSN value, and the size of the LSN value represents the order of data modification. When the system fails to restart, the REDO log is replayed from small to large according to the LSN value starting from the checkpoint offset, so that the data can be restored to the state before the system failure according to the data modification order. The checkpoint (CHECKPOINT) is an important concept of the REDO log, which includes the checkpoint offset and the checkpoint LSN. The purpose of adjusting the checkpoint is to release the REDO log space. When adjusting the checkpoint offset, it is necessary to ensure that all data pages with LSN less than the checkpoint LSN are flushed to the disk.

[0044] Specifically, if the database running mode identifier carried by the REDO log package is the primary database running mode, and the LSN of the REDO log package is greater than the target checkpoint LSN, the way to replay the REDO log package can be: obtaining the target checkpoint LSN, if the database running mode identifier carried by the REDO log package is the primary database running mode, and the LSN of the REDO log package is greater than the target checkpoint LSN, then replaying the REDO log package.

[0045] Specifically, if the database running mode identifier carried by the REDO log package is the standby database running mode, the way to replay the REDO log package can be: replaying the REDO log package with the database running mode identifier carried in the REDO log file in the current node being the standby database running mode.

[0046] In one specific example, when the current node is restarted after a failure, REDO log files in the current node are obtained, wherein the REDO log files include at least one REDO log package, and each REDO log package carries a database running mode identifier; a first set of REDO log packages with a database running mode identifier as a primary database running mode and / or a second set of REDO log packages with a database running mode identifier as a standby database running mode are obtained; a target checkpoint LSN is obtained; REDO log packages in the first set of REDO log packages with an LSN greater than the target checkpoint LSN are replayed; and all REDO log packages in the second set of REDO log packages are replayed.

[0047] Optionally, when a REDO log package carries a database running mode identifier as a primary database running mode and the LSN of the REDO log package is greater than the target checkpoint LSN, before the REDO log package is replayed, the method further includes:

[0048] Obtaining registration information corresponding to all nodes in the cluster;

[0049] Determining a checkpoint information adjustment order corresponding to the current node according to the registration information corresponding to all nodes in the cluster;

[0050] Adjusting checkpoint information corresponding to the current node based on the checkpoint information adjustment order corresponding to the current node and the registration information corresponding to the current node, wherein the checkpoint information includes a checkpoint LSN;

[0051] Determining the maximum checkpoint LSN in the checkpoint LSNs corresponding to all nodes in the cluster as the target checkpoint LSN.

[0052] The registration information includes a primary database term sequence number carried by the REDO log package and an offset of the REDO log package in the REDO log file.

[0053] The checkpoint information includes a checkpoint LSN, and the checkpoint information can further include a checkpoint offset.

[0054] Specifically, the registration information corresponding to all nodes in the cluster can be obtained in the following manner: each node in the cluster scans online logs from the start of an instance to obtain REDO log files in each node, each node determines the registration information of the node according to the locally stored REDO log files, and through communication between the nodes, each node can obtain the registration information of other nodes in the cluster except the node itself.

[0055] Specifically, the method for determining the checkpoint LSN adjustment order corresponding to the current node according to the registration information corresponding to all nodes in the cluster can be: comparing the registration information of the current node with the registration information of other nodes in the cluster to obtain the checkpoint LSN adjustment order corresponding to the current node. In this way, it can be ensured that the global log replay can be performed in the order of the primary database term number from small to large during the log replay.

[0056] Optionally, the registration information corresponding to all nodes in the DSC cluster is obtained, including:

[0057] The primary database term number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file are obtained.

[0058] The registration information corresponding to the current node is generated according to the primary database term number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file.

[0059] Specifically, the method for obtaining the primary database term number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file can be: reading the primary database term number and the offset of the REDO log package in the REDO log file from the package header of the REDO log package.

[0060] Specifically, the method for generating the registration information corresponding to the current node according to the primary database term number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file can be: obtaining the primary database term number carried by each REDO log package in the REDO log file stored in the current node, obtaining the offset of the REDO log package carrying the same primary database term number in the log file, and generating the registration information corresponding to the current node according to the primary database term number carried by each REDO log package in the REDO log file and the offset of the REDO log package carrying the same primary database term number in the log file.

[0061] Optionally, the checkpoint information adjustment order corresponding to the current node is determined according to the registration information corresponding to all nodes in the DSC cluster, including:

[0062] The minimum primary database term number in the registration information corresponding to each node in the cluster is obtained.

[0063] The checkpoint information adjustment order corresponding to each node in the DSC cluster is determined according to the minimum primary database term number in the registration information corresponding to each node.

[0064] Specifically, the way of obtaining the minimum primary database term sequence number in the registration information corresponding to each node in the cluster can be: if the primary database term sequence numbers in the registration information corresponding to each node are sorted in ascending order (for example, the registration information is (1, offset_1) (2, offset_2) … (N, offset_n)), the first primary database term sequence number (for example, 1) in the registration information corresponding to each node is obtained, and the first primary database term sequence number in the registration information corresponding to each node is determined as the minimum primary database term sequence number in the registration information corresponding to each node.

[0065] Specifically, the way of determining the checkpoint information adjustment order corresponding to each node in the DSC cluster according to the minimum primary database term sequence number in the registration information corresponding to each node can be: determining the checkpoint information adjustment order corresponding to each node in the DSC cluster according to the minimum primary database term sequence number in the registration information corresponding to each node according to the adjustment rule (only the node with the minimum primary database term sequence number in the cluster can first adjust the checkpoint information).

[0066] In a specific example, if the cluster includes: node A, node B and node C, and the minimum primary database term sequence number in the registration information corresponding to node A is 1, the minimum primary database term sequence number in the registration information corresponding to node B is 2, and the minimum primary database term sequence number in the registration information corresponding to node C is 3, it is determined that the checkpoint information adjustment order is that node A adjusts first, node B adjusts after node A adjusts, and node C adjusts after node B adjusts. If the minimum primary database term sequence number in the registration information corresponding to node A is 1, the minimum primary database term sequence number in the registration information corresponding to node B is 1, and the minimum primary database term sequence number in the registration information corresponding to node C is 3, it is determined that the checkpoint information adjustment order is that node A and node B adjust first, and node C adjusts after node A and node B adjust.

[0067] Optionally, adjusting the checkpoint information corresponding to the current node based on the checkpoint LSN adjustment order corresponding to the current node and the registration information corresponding to the current node comprises:

[0068] Obtaining the offset of the REDO log package with the minimum primary database term sequence number in the registration information corresponding to the current node in the REDO log file;

[0069] Adjusting the checkpoint information corresponding to the current node based on the checkpoint information adjustment order corresponding to the current node and the offset of the REDO log package with the minimum primary database term sequence number in the registration information corresponding to the current node in the REDO log file.

[0070] Specifically, the method for adjusting the checkpoint information of the current node based on the checkpoint information adjustment sequence and the offset of the REDO log package with the smallest primary database term sequence number in the registration information of the current node in the REDO log file can be: after the checkpoint information of the previous node is adjusted based on the checkpoint information adjustment sequence, the checkpoint information of the current node is adjusted based on the offset of the REDO log package with the smallest primary database term sequence number in the registration information of the current node in the REDO log file.

[0071] In a specific example, if the checkpoint information adjustment sequence is that node A is adjusted first, node B is adjusted after node A, and node C is adjusted after node B, the checkpoint information of node A is adjusted based on the offset of the REDO log package with the smallest primary database term sequence number in the registration information of node A in the REDO log file, the checkpoint information of node B is adjusted based on the offset of the REDO log package with the smallest primary database term sequence number in the registration information of node B in the REDO log file after the checkpoint information of node A is adjusted, and the checkpoint information of node C is adjusted based on the offset of the REDO log package with the smallest primary database term sequence number in the registration information of node C in the REDO log file after the checkpoint information of node B is adjusted.

[0072] Optionally, after the checkpoint information of the current node is adjusted based on the checkpoint LSN adjustment sequence and the registration information of the current node, the method further comprises:

[0073] The primary database term sequence number and the offset of the REDO log package in the REDO log file carried by the REDO log package with the smallest primary database term sequence number in the registration information of the current node are deleted.

[0074] In one specific example, if the cluster includes: node A, node B, and node C, and the minimum primary database term sequence number in the registration information corresponding to node A is 1, the minimum primary database term sequence number in the registration information corresponding to node B is 2, and the minimum primary database term sequence number in the registration information corresponding to node C is 3, it is determined that the checkpoint information adjustment sequence is that node A is adjusted first, node B is adjusted after node A is adjusted, and node C is adjusted after node B is adjusted. If the registration information corresponding to node A is: (1, offset_1) (2, offset_2)... (N, offset_n), the minimum primary database term sequence number in the registration information corresponding to node A is 1, the registration information corresponding to node B is: (2, offset_2)... (N, offset_n), the minimum primary database term sequence number in the registration information corresponding to node B is 2, and the registration information corresponding to node C is: (3, offset_2)... (N, offset_n), the minimum primary database term sequence number in the registration information corresponding to node C is 3, it is determined that the checkpoint information adjustment sequence is that node A is adjusted first, node B is adjusted after node A is adjusted, and node C is adjusted after node B is adjusted, and after node A adjusts the checkpoint information corresponding to node A according to offset_1, the registration information corresponding to node A is: (2, offset_2)... (N, offset_n).

[0075] In another specific example, the shared storage database cluster environment has the following scenario (scenario A):

[0076] 1. Node 0 EP0 modifies data page P1 (assuming modifying a record value to "aaa") LSN = 8000, checkpoint LSN = 7000;

[0077] 2. Node 1 EP1 modifies data page P1 LSN = 10000 (modifying the same record to "bbb"), adjusts checkpoint LSN = 11000;

[0078] 3. Node EP0 / EP1 fails and restarts at the same time, EP0 modifies P1 log LSN (8000) which is greater than the checkpoint LSN (7000), and needs to be replayed; EP1 modifies P1 log LSN (10000) which is less than the checkpoint LSN (11000), and does not need to be replayed.

[0079] 4. The above scenario will cause the latest data of data page P1 to be "aaa" instead of "bbb".

[0080] 5. The method for solving the above-mentioned abnormal scenario is that when the shared storage data cluster environment node adjusts the checkpoint LSN, all other active node data pages with LSN less than the checkpoint LSN are required to be flushed; the cluster is restarted, all instance online logs are scanned first to obtain the maximum checkpoint LSN (referred to as max_ckpt_lsn, which is 11000 in the above-mentioned scenario) of all nodes, and only the REDO log with LSN greater than max_ckpt_lsn is replayed when the REDO log of each node is replayed.

[0081] If the primary database is a shared storage database cluster, the standby database will receive REDO logs sent by multiple nodes at the same time, and may first receive the log with EP0 LSN=12000 and then receive the log with EP1 LSN=10000. The following scenario (scenario B) exists:

[0082] 1. The standby database receives the log with EP0 LSN=12000 of the primary database, and adjusts the checkpoint LSN=11000;

[0083] 2. The standby database receives the log with EP1 LSN=10000 of the primary database;

[0084] 3. The standby database fails, and since the checkpoint LSN 11000 is greater than 10000, the log with EP1 LSN=10000 is not replayed, resulting in data loss.

[0085] 4. The method for solving the above-mentioned abnormal scenario is that for the data daemon environment, the standby database ignores the LSN value of the REDO log when it is restarted, and replays all REDO logs after the checkpoint offset.

[0086] When the primary and standby databases of the data daemon environment are both shared storage clusters, after the primary and standby databases are switched (the original standby database becomes the primary database, and the original primary database becomes the standby database), the standby database cluster environment may fail and restart, and the above-mentioned scenarios A and B may occur at the same time. The solutions to the two scenarios conflict (scenario A requires comparing the LSN size, and scenario B ignores the LSN size), and it is difficult to determine whether the REDO log needs to be replayed or ignored based on the existing rules.

[0087] In order to solve the above-mentioned problems, the embodiment of the present application proposes the following solutions:

[0088] A db_open_id attribute is added to identify the primary database term sequence number, which is increased by one each time the system is started or switched from a standby database to a primary database; and the db_open_id is written into the log header during system operation and REDO log generation.

[0089] The DSC cluster node scans the online log from instance startup, and registers information of the latest log package of the same db_open_id (including: log package offset in the log file, db_open_id). The registration information is stored in a linked list form.

[0090] If the log package storage format in the log file is as shown in Figure 2 The scanning registration information is (1, offset_1) (2, offset_2)... (N, offset_n).

[0091] When the nodes in the DSC cluster adjust the checkpoint information, global comparison of all nodes is required, and only the node with the smallest db_open_id can adjust the checkpoint first, to ensure that the global log replay can be performed according to the primary database term sequence from small to large during log replay.

[0092] For example: EP0 needs to adjust the checkpoint offset to a certain position, and can only be adjusted to the smallest offset in the registration information (such as offset_1 in the above example). If the adjustment is successful, the primary database term sequence and the REDO log package offset in the REDO log file of the REDO log package with the smallest primary database term sequence of the adjusted primary database are removed from the registration linked list.

[0093] After the above processing, the coexistence of scenarios A and B can be processed simultaneously according to a unified rule: when the system fails to restart and replay the REDO log, if the log package is generated in the primary database running mode, only the REDO log with an LSN greater than the target checkpoint LSN is replayed; if the log package is generated in the standby database running mode, it is all replayed.

[0094] The technical scheme of the embodiment, when the current node fails to restart, acquires the REDO log file in the current node, wherein the REDO log file includes at least one REDO log package, and each REDO log package carries a database running mode identifier; determines the replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, to replay the REDO log package according to the replay rule corresponding to each REDO log package, which can solve the problem of replaying the REDO log in the shared storage cluster data guardian environment.

[0095] Embodiment two

[0096] Figure 3 A structure diagram of a REDO log replay device provided by the embodiment of the application. The embodiment can be applicable to the case of REDO log replay, and the device can be realized in the software and / or hardware mode, and can be integrated in any device providing the REDO log replay function, such as a computer. Figure 3As shown, the REDO log replay device specifically comprises a REDO log file acquisition module 310 and a REDO log package replay module 320.

[0097] The REDO log file acquisition module is configured to acquire a REDO log file in the current node when the current node is restarted after a failure, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier.

[0098] The REDO log package replay module is configured to determine a replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, and replay the REDO log package according to the replay rule corresponding to each REDO log package.

[0099] The product can execute the method provided by any embodiment of the application, and has the corresponding function modules and beneficial effects of the execution method.

[0100] Embodiment three

[0101] Figure 4 A structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular telephones, smartphones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the applications described and / or claimed in this document.

[0102] As Figure 4 As shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is in communication with the at least one processor 11, wherein the memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0103] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0104] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized 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 11 performs various methods and processes described above, such as the REDO log replay method.

[0105] In some embodiments, the REDO log replay method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the REDO log replay method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the REDO log replay method by any other appropriate means, such as by means of firmware.

[0106] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0107] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, enables the functions / acts specified in the flowcharts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package and partially on a remote machine or entirely on a remote machine or server.

[0108] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0109] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0110] The systems and techniques described herein can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described herein, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0111] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0112] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be performed in parallel, in series, or in a different order, and the present disclosure is not limited in this regard.

[0113] The specific embodiments described above are not intended to limit the scope of the present disclosure. Those skilled in the art will understand that various modifications, combinations, sub-combinations, and alternatives can be made to the specific embodiments without departing from the spirit and principles of the present disclosure. Any further modifications, equivalents, alternatives, and / or improvements made to the specific embodiments described above are intended to fall within the scope of the present disclosure.

Claims

1. A REDO logging method, characterized in that, The method comprises the following steps: When the current node is restarted after a failure, a REDO log file in the current node is obtained, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier; A replay rule corresponding to each REDO log package is determined according to the database running mode identifier carried by each REDO log package, so that the REDO log package is replayed according to the replay rule corresponding to each REDO log package; The replay rule corresponding to each REDO log package is determined according to the database running mode identifier carried by each REDO log package, so that the REDO log package is replayed according to the replay rule corresponding to each REDO log package, comprising: If the database running mode identifier carried by the REDO log package is a primary database running mode, and the LSN of the REDO log package is greater than a target checkpoint LSN, wherein the primary database is a shared storage database cluster; Or, If the database running mode identifier carried by the REDO log package is a standby database running mode, wherein the standby database simultaneously receives REDO log packages sent by multiple nodes; The REDO log package is replayed; If the database running mode identifier carried by the REDO log package is a primary database running mode, and the LSN of the REDO log package is greater than a target checkpoint LSN, before the REDO log package is replayed, the method further comprises the following steps: Obtain registration information corresponding to all nodes in the cluster, wherein the registration information comprises a primary database term sequence number; Determine a checkpoint information adjustment order corresponding to the current node according to the registration information corresponding to all nodes in the cluster; Adjust the checkpoint information corresponding to the current node based on the checkpoint LSN adjustment order corresponding to the current node and the registration information corresponding to the current node, wherein the checkpoint information comprises a checkpoint LSN; Determine the maximum checkpoint LSN in the checkpoint LSNs corresponding to all nodes in the cluster as the target checkpoint LSN.

2. The method of claim 1, wherein, Obtain registration information corresponding to all nodes in the DSC cluster, comprising: Obtain the primary database term sequence number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file; Generate the registration information corresponding to the current node according to the primary database term sequence number carried by each REDO log package in the REDO log file stored in the current node and the offset of the REDO log package in the REDO log file.

3. The method of claim 1, wherein, Determine the checkpoint information adjustment order corresponding to the current node according to the registration information corresponding to all nodes in the DSC cluster, comprising: Obtain the minimum primary database term sequence number in the registration information corresponding to each node in the cluster; Determine the checkpoint information adjustment order corresponding to each node in the DSC cluster according to the minimum primary database term sequence number in the registration information corresponding to each node.

4. The method of claim 1, wherein, Adjust the checkpoint information corresponding to the current node based on the checkpoint LSN adjustment order corresponding to the current node and the registration information corresponding to the current node, comprising: Obtain the offset of the REDO log package with the minimum primary database term sequence number in the registration information corresponding to the current node in the REDO log file; adjust the checkpoint information corresponding to the current node based on the checkpoint information adjustment sequence corresponding to the current node and the registration information corresponding to the current node, wherein the checkpoint information comprises a checkpoint LSN.

5. The method of claim 4, wherein, After adjusting the checkpoint information corresponding to the current node based on the checkpoint LSN adjustment sequence corresponding to the current node and the registration information corresponding to the current node, the method further comprises: deleting the primary database term sequence number and the offset of the REDO log package in the REDO log file carried by the REDO log package with the smallest primary database term sequence number in the registration information corresponding to the current node.

6. A REDO log replay apparatus, characterized by comprising: comprises: a REDO log file obtaining module, configured to obtain a REDO log file in a current node when the current node is restarted, wherein the REDO log file comprises at least one REDO log package, and each REDO log package carries a database running mode identifier; a REDO log package replay module, configured to determine a replay rule corresponding to each REDO log package according to the database running mode identifier carried by each REDO log package, and replay the REDO log package according to the replay rule corresponding to each REDO log package; the REDO log package replay module is specifically configured to: if the database running mode identifier carried by the REDO log package is a primary database running mode, and the LSN of the REDO log package is greater than a target checkpoint LSN, wherein the primary database is a shared storage database cluster; or, if the database running mode identifier carried by the REDO log package is a standby database running mode, wherein the standby database simultaneously receives REDO log packages sent by multiple nodes; then replay the REDO log package; the method further comprises: a registration information obtaining module, configured to obtain registration information corresponding to all nodes in a cluster, wherein the registration information comprises a primary database term sequence number; a sequence adjustment module, configured to determine a checkpoint information adjustment sequence corresponding to the current node according to the registration information corresponding to all nodes in the cluster; a checkpoint information adjustment module, configured to adjust the checkpoint information corresponding to the current node based on the checkpoint information adjustment sequence corresponding to the current node and the registration information corresponding to the current node, wherein the checkpoint information comprises a checkpoint LSN; a target checkpoint LSN determining module, configured to determine the maximum checkpoint LSN among the checkpoint LSNs corresponding to all nodes in the cluster as the target checkpoint LSN.

7. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the REDO log replay method in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to execute the REDO log replay method in any one of claims 1-5 when executed.

Citation Information

Patent Citations

  • Data processing method and device for shared storage database, equipment and medium

    CN111046024A