Distributed transaction database recovery method, device, equipment and storage medium

By obtaining the sub-transaction status of the sub-processing nodes of the distributed transaction database and determining the data recovery operation, the problem of low recovery efficiency of the distributed transaction database is solved, and efficient data recovery and transaction processing are achieved.

CN113448767BActive Publication Date: 2024-08-23BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202010213878.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-03-24
Publication Date
2024-08-23
Estimated Expiration
2040-03-24

AI Technical Summary

Technical Problem

The data recovery efficiency of existing distributed transaction databases is low, which affects the efficiency of transaction processing.

Method used

By obtaining the status of the sub-transaction before the sub-processing node in the distributed transaction database goes down, determine the corresponding data recovery operation, including transaction termination or recovery in the unprepared state, and calling the global transaction manager to send recovery instructions in the prepared state. , and terminate the transaction when the recovery time exceeds the set time.

Benefits of technology

Significantly improves the data recovery efficiency of distributed transaction databases, saves recovery time, and ensures the consistency and atomicity of transaction processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113448767B
    Figure CN113448767B
Patent Text Reader

Abstract

The present invention discloses a distributed transaction database recovery method, device, equipment and storage medium, the method comprising: obtaining the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes, and determining the data recovery operation of the sub-transaction according to the transaction status of any sub-transaction of the sub-processing node, so as to realize the recovery of the distributed transaction database. Through the above method, the data recovery efficiency of the distributed transaction database can be effectively and significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and more specifically, to a distributed transaction database recovery method, a distributed transaction database recovery device, a distributed transaction database device and a computer storage medium. Background Art

[0002] At present, in order to improve the efficiency of transaction processing and reduce the cost of transaction processing, distributed transaction databases are usually used to jointly process global transactions. That is to say, a global transaction will be divided into different sub-transactions, and the sub-transactions will be handled by different transaction databases within the distributed system.

[0003] In actual applications, the distributed transaction database may experience downtime and other situations during the process of processing global transactions, resulting in data anomalies. In order to ensure the consistency and atomicity of transaction processing, data recovery of the distributed transaction database is required.

[0004] In the prior art, the data recovery method of the distributed transaction database has low recovery efficiency, which is not conducive to the efficiency of transaction processing of the distributed transaction database. Summary of the invention

[0005] An object of the present invention is to provide a new technical solution for distributed transaction database recovery.

[0006] According to a first aspect of the present invention, a distributed transaction database recovery method is provided, wherein the distributed transaction database includes a starting node and at least one sub-processing node, wherein the starting node and the sub-processing node are both used to process sub-transactions of a global transaction, including:

[0007] Acquire the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes;

[0008] A data recovery operation for any sub-transaction of the sub-processing node is determined according to the transaction status of the sub-transaction, so as to realize recovery of the distributed transaction database.

[0009] Optionally, the step of determining the data recovery operation for any sub-transaction of the sub-transaction according to the transaction status of the sub-transaction of the sub-processing node includes:

[0010] When the transaction state of the sub-transaction is in an unprepared state, data recovery is performed on the corresponding sub-transaction of the sub-processing node.

[0011] Optionally, when the transaction state of the sub-transaction is in an unprepared state, performing data recovery on the corresponding sub-transaction of the sub-processing node includes:

[0012] When the transaction state of the sub-transaction is in an unprepared state, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node;

[0013] Recover data for subtransactions after the transaction termination operation is executed.

[0014] Optionally, when the transaction status of the subtransaction is in an unprepared state, performing a transaction termination operation on the corresponding subtransaction of the sub-processing node includes:

[0015] When the transaction state of the sub-transaction is in an unprepared state, before calling the global transaction manager of the distributed transaction database, a transaction termination operation is performed on the corresponding sub-transaction of the sub-processing node.

[0016] Optionally, the step of determining the data recovery operation for any sub-transaction of the sub-transaction according to the transaction status of the sub-transaction of the sub-processing node includes:

[0017] When the transaction state of the subtransaction is in the prepared state, calling the global transaction recovery instruction sent by the global transaction manager;

[0018] Data recovery is performed on the sub-transactions in the prepared state in the sub-processing node according to the global transaction recovery instruction.

[0019] Optionally, the method further comprises:

[0020] When the transaction state of the subtransaction is in an unprepared state, obtaining a recovery time required for the sub-processing node to recover the corresponding subtransaction, so as to determine whether the recovery time exceeds a set time;

[0021] When the transaction state of the sub-transaction is in an unprepared state, before calling the global transaction manager of the distributed transaction database, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node includes:

[0022] In the case where the transaction state of the subtransaction is in the unprepared state, when the recovery time exceeds the set time, the step of performing a transaction termination operation on the corresponding subtransaction of the sub-processing node before calling the global transaction manager of the distributed transaction database is executed.

[0023] Optionally, the method further includes a step of determining the set duration, including:

[0024] Get the maximum recovery time required for all sub-processing nodes to recover sub-transactions in the prepared state;

[0025] The maximum recovery time is used as the set time.

[0026] Optionally, before obtaining the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, the method further includes:

[0027] Monitoring whether a preset global transaction recovery event occurs in the distributed transaction database;

[0028] When the occurrence of the global transaction recovery event is detected, the sub-processing node is restored to the state before the downtime.

[0029] According to a second aspect of the present invention, a distributed transaction database recovery device is provided, wherein the distributed transaction database includes a starting node and at least one sub-processing node, wherein the starting node and the sub-processing node are both used to process sub-transactions of a global transaction, including:

[0030] An acquisition module, used to acquire the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes;

[0031] The recovery module is used to determine the data recovery operation of any sub-transaction of the sub-processing node according to the transaction status of the sub-transaction, so as to realize the recovery of the distributed transaction database.

[0032] According to a third aspect of the present invention, there is provided a distributed transaction database device, comprising a distributed transaction database recovery apparatus; or,

[0033] The device comprises: a processor and a memory;

[0034] The memory is used to store executable instructions, and the instructions are used to control the processor to execute the method according to any one of the first aspects.

[0035] According to a fourth aspect of the present invention, a computer storage medium is provided, wherein the storage medium stores computer instructions, and when the computer instructions in the storage medium are executed by a processor, the method described in any one of the first aspects is implemented.

[0036] In the process of restoring the distributed transaction database, the embodiment of the present invention first needs to obtain the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, and determine the data recovery operation of the sub-transaction according to the transaction status of any sub-transaction of the sub-processing node, so as to realize the recovery of the distributed transaction database. Through the above method, the data recovery efficiency of the distributed transaction database can be effectively and significantly improved.

[0037] Further features and advantages of the present invention will become apparent from the following detailed description of exemplary embodiments of the present invention with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the invention and, together with the description, serve to explain the principles of the invention.

[0039] Figure 1 is a block diagram of a hardware configuration of a distributed transaction database device provided by an embodiment of the present invention;

[0040] Figure 2 It is a flow chart of a distributed transaction database recovery method provided by an embodiment of the present invention;

[0041] Figure 3 It is a schematic diagram of a distributed transaction database recovery process provided by an embodiment of the present invention;

[0042] Figure 4 It is a structural schematic diagram of a distributed transaction database recovery device provided by an embodiment of the present invention;

[0043] Figure 5 It is a structural diagram of another distributed transaction database device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0044] Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present invention unless otherwise specifically stated.

[0045] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.

[0046] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered as part of the specification.

[0047] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0048] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0049] The distributed transaction database in this embodiment is composed of a group of databases, each of which is a sub-processing node. These sub-processing nodes are distributed in different areas, and the sub-processing nodes operate independently of each other to jointly process a global transaction for the distributed transaction database.

[0050] Based on the structure of the distributed transaction database, in the process of recovering a global transaction, the embodiment of the present invention can recover the subtransactions in an unprepared state in advance before calling the global transaction manager to recover the global transaction.

[0051] <Hardware Configuration>

[0052] Figure 1 It is a block diagram of the hardware configuration of a distributed transaction database device provided in an embodiment of the present invention. The distributed transaction database device can be any sub-processing node of the distributed transaction database, or a device for recovery management set independently of the sub-processing node in the distributed transaction database. The device can be a server or a server cluster deployed in the cloud.

[0053] The distributed transaction database device 1000 may be a virtual machine or a physical machine. The distributed transaction database device 1000 may include a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500, an input device 1600, a speaker 1700, a microphone 1800, and the like. The processor 1100 may be a central processing unit CPU, a microprocessor MCU, and the like. The memory 1200 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, and the like. The interface device 1300 may include, for example, a USB interface, a headphone interface, and the like. The communication device 1400 may, for example, be capable of wired or wireless communication. The display device 1500 may be, for example, a liquid crystal display screen, a touch display screen, and the like. The input device 1600 may include, for example, a touch screen, a keyboard, and the like. The user may input / output voice information through the speaker 1700 and the microphone 1800.

[0054] In this embodiment, the memory 1200 is used to store computer program instructions, which are used to control the processor 1100 to operate to perform the recovery method according to any embodiment of the present invention. A technician can design the instruction according to the scheme disclosed in the present invention. How the instruction controls the processor 1100 to operate is well known in the art, so it will not be described in detail here.

[0055] Despite Figure 1In the figure, multiple devices are shown for the distributed transaction database device 1000, but the present invention may only involve some of the devices, for example, the distributed transaction database device 1000 only involves the memory 1200 and the processor 1100.

[0056] In the above description, a technician can design instructions according to the scheme disclosed in the present invention. How instructions control the processor to operate is well known in the art, so it will not be described in detail here.

[0057] <Method Example>

[0058] The embodiment of the present invention provides a distributed transaction database recovery method, such as Figure 2 As shown, the specific steps are as follows:

[0059] S201: Acquire the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database.

[0060] In practical applications, in order to improve the efficiency of transaction processing and reduce the cost of transaction processing, a distributed transaction database is usually used to process global transactions.

[0061] It should be noted that the distributed transaction database is composed of at least two sub-processing nodes. Exemplarily, the at least two sub-processing nodes in the distributed transaction database can be a starting node and at least one sub-processing node. In the process of the distributed transaction database processing a global transaction, the sub-transactions of the global transaction can be allocated to different sub-processing nodes according to the number of sub-processing nodes, that is, each sub-processing node can process one or more sub-transactions of the global transaction.

[0062] Furthermore, the distributed transaction database may encounter data anomalies while processing global transactions. In order to ensure the consistency and atomicity of transaction processing, the distributed transaction database needs to be restored to the state before executing the global transaction.

[0063] Furthermore, since the present invention aims to recover sub-transactions at different processing progress according to different processing methods for global transactions, thereby improving recovery efficiency, therefore, in an embodiment of the present invention, during the recovery of a distributed transaction database, it is first necessary to know the processing progress of the corresponding sub-transaction before the sub-processing node goes down.

[0064] Furthermore, since the status of a sub-transaction can reflect the processing progress of the sub-transaction by the sub-processing node when it crashes, in an embodiment of the present invention, in the process of recovering the distributed transaction database, it is first necessary to obtain the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database.

[0065] It should be noted here that the transaction status is the status of the sub-transaction processed by the sub-processing node before the crash, which can be an unprepared state or a prepared state. In addition, the status of the sub-transaction processed by the sub-processing node before the crash refers to the status of the sub-transaction processed by the sub-processing node just before the database crashes.

[0066] In addition, the unprepared state may be a state where data is not prepared or a state where operation is not prepared. Similarly, the prepared state may be a state where data is prepared or a state where operation is prepared.

[0067] It should also be noted that database recovery does not need to be performed in any case, but only needs to be performed in specific cases, such as database downtime. Therefore, in the embodiment of the present invention, before obtaining the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, it is necessary to monitor whether a preset global transaction recovery event occurs in the distributed transaction database, wherein the global transaction recovery event includes a distributed transaction database downtime, and there are many reasons for the distributed transaction database downtime, such as power outage, data anomaly or overload.

[0068] Furthermore, since the embodiment of the present invention needs to obtain the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, after detecting that the database has crashed, the embodiment of the present invention will restore the sub-processing node to the state before the crash when the global transaction recovery event is detected, and then check the transaction status of the sub-transaction processed by the sub-processing node before the crash.

[0069] S202: Determine a data recovery operation for any sub-transaction of the sub-processing node according to the transaction status of the sub-transaction, so as to achieve recovery of the distributed transaction database.

[0070] Furthermore, in an embodiment of the present invention, after obtaining the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, it is necessary to determine a data recovery operation for the sub-transaction based on the transaction status of any sub-transaction of the sub-processing node to achieve recovery of the distributed transaction database.

[0071] Because in the actual database recovery process, for independent transactions, if an independent transaction is only handled by one sub-processing node, when the sub-transaction is in an unprepared state, the sub-processing node does not need to continue processing the independent transaction and directly recovers the independent transaction. When the sub-transaction is in a prepared state, after the sub-processing node is restored to the state before the downtime, it will continue to process the independent transaction first and then recover the independent transaction after the processing is completed. For global transactions, if a global transaction is handled by two sub-processing nodes, no matter the sub-transaction is in an unprepared state or a prepared state, it is necessary to restore the sub-processing nodes to the state before the downtime, and then directly recover the sub-transaction. It can be seen that no matter it is an independent transaction or a global transaction, as long as the sub-transaction is in an unprepared state, the sub-transaction will no longer be processed after it is restored to the state before the downtime. Based on this, in an embodiment of the present invention, when the sub-transaction state is in an unprepared state, data recovery is directly performed on the corresponding sub-transaction of the sub-processing node, without considering whether other sub-processing nodes have sub-transactions associated with them, and whether other sub-processing nodes have been restored to the state before the downtime. As long as a sub-processing node is restored to the state before the downtime and the transaction state of the corresponding sub-transaction of the sub-processing node is in an unprepared state, data recovery can be directly performed on the corresponding sub-transaction of the sub-processing node.

[0072] It should be noted that the embodiment of the present invention provides an implementation method for directly recovering data of the corresponding sub-transaction of the sub-processing node when the sub-transaction state is in the unprepared state, which is specifically as follows:

[0073] When the transaction state of the sub-transaction is in an unprepared state, a transaction termination operation is performed on the corresponding sub-transaction of the sub-processing node, and data recovery is performed on the sub-transaction after the transaction termination operation is performed.

[0074] In addition, the transaction termination operation is performed on the sub-transaction corresponding to the sub-processing node, and the transaction termination operation can be performed on the sub-transaction corresponding to the sub-processing node before the global transaction manager of the distributed transaction database is called.

[0075] Furthermore, when a sub-transaction is in an unprepared state, independent transactions and global transactions correspond to different recovery modes respectively, and different sub-processing nodes are independent of each other and do not know whether the currently executed transaction is an independent transaction or a sub-transaction in a global transaction. Therefore, in an embodiment of the present invention, it is necessary to call the global transaction manager to let the sub-processing node know whether the currently executed transaction is associated with transactions processed by other sub-processing nodes. Based on this, in an embodiment of the present invention, when the sub-transaction state is in a prepared state, the global transaction recovery instruction sent by the global transaction manager is called, and data of the sub-transaction in the prepared state in the sub-processing node is recovered according to the global transaction recovery instruction.

[0076] It should be noted that, in order to call the global transaction recovery instruction sent by the global transaction manager, all sub-processing nodes must have been restored to the state before the crash.

[0077] Through the above method, the data recovery efficiency of the distributed transaction database can be effectively greatly improved. Specifically, before calling the global transaction manager to recover the global transaction, the data of the sub-transaction in an unprepared state can be recovered in advance. There is no need to wait for all sub-processing nodes to be restored to the state before the downtime before recovering the data of the sub-transaction, which effectively saves the time and efficiency of distributed transaction database recovery.

[0078] In addition, it should be emphasized here that, since the present invention recovers the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database to recover the global transaction when the sub-transaction status is in the unprepared state, while the prior art recovers the corresponding sub-transaction of the sub-processing node only after all the sub-processing nodes are restored to the state before the downtime, it can be analyzed that, when the corresponding sub-transactions of all the sub-processing nodes are in the unprepared state, or when the corresponding sub-transactions of some sub-processing nodes are in the unprepared state and the corresponding sub-transactions of some sub-processing nodes are in the prepared state, only the sub-processing nodes can be recovered. The present invention can effectively save the time and efficiency of database recovery only when the recovery time required for the sub-processing node to recover the corresponding sub-transaction in the unprepared state exceeds the recovery time required to recover other sub-transactions in the prepared state. Therefore, before executing step S202, the embodiment of the present invention obtains the recovery time required for the sub-processing node to recover the corresponding sub-transaction when the sub-transaction state is the unprepared state, so as to determine whether the recovery time exceeds the set time. When the recovery time exceeds the set time, the step of performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database is executed.

[0079] It should be noted here that the recovery time required for the sub-processing node to recover the corresponding sub-transaction can be pre-set according to the recovery time required for the sub-processing node to recover the sub-transaction in history, or the recovery time can be based on the processing time before the sub-processing node processes the sub-transaction to a downtime state.

[0080] In addition, since only when the recovery time required for a sub-processing node to recover the corresponding sub-transaction in an unprepared state exceeds the recovery time required to recover other sub-transactions in a prepared state, the present invention can effectively save the time and efficiency of database recovery. Therefore, in an embodiment of the present specification, the set field of view can be determined by the following steps. Specifically, the maximum recovery time required for all sub-processing nodes to recover sub-transactions in a prepared state is obtained, and the maximum recovery time is used as the set time.

[0081] In order to more clearly explain the implementation process of the present invention, Figure 3 For further explanation, an example is given, assuming that the distributed transaction database includes four sub-processing nodes, namely sub-processing node 1, sub-processing node 2, sub-processing node 3 and sub-processing node 4, where sub-processing node 1 is the starting node. When the distributed transaction database is detected to be down, the distributed transaction database is restarted at time T0, and sub-processing node 1 starts to perform the operation of restoring to the state before the downtime, and restores to the state before the downtime at time T1. At this time, the transaction state of the sub-transaction processed by sub-processing node 1 is in the ready state;

[0082] Sub-processing node 2 starts to perform the operation of restoring to the state before the downtime, and restores to the state before the downtime at time T2. At this time, the sub-transaction state of the sub-transaction processed by sub-processing node 2 is unprepared. From time T2, sub-processing node 2 directly performs data recovery operation on the sub-transaction;

[0083] Sub-processing node 3 starts to perform the operation of restoring to the state before the downtime, and restores to the state before the downtime at time T3. At this time, the sub-transaction state of the sub-transaction processed by sub-processing node 3 is unprepared. Sub-processing node 2 directly performs the recovery operation on the sub-transaction. From time T3, sub-processing node 3 directly performs the data recovery operation on the sub-transaction.

[0084] Sub-processing node 4 starts to execute the operation of restoring to the state before the downtime, and restores to the state before the downtime at time T4. At this time, the sub-transaction state of the sub-transaction processed by sub-processing node 1 is in the ready state;

[0085] Starting from time T5, sub-processing node 1 calls the global transaction manager to send a global transaction recovery instruction to sub-processing node 1 and sub-processing node 4. Sub-processing node 1 receives the global transaction recovery instruction at time T6 and executes a sub-transaction recovery operation. Sub-processing node 4 receives the global transaction recovery instruction at time T6 and executes a sub-transaction data recovery operation. The solid line represents the processing process before each sub-processing node is restored to the downtime state, and the dotted line represents the sub-transaction recovery process.

[0086] It should be noted here that in the embodiment of the present invention, steps S201-S202 can be implemented by any sub-processing node of the distributed transaction database as the starting node, or by a device for recovery management set up independently of the sub-processing node in the distributed transaction database to implement steps S201-S202.

[0087] <Device Example>

[0088] like Figure 4 As shown, this embodiment also provides a transaction processing device for a distributed transaction database, including:

[0089] The acquisition module 401 is used to acquire the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes;

[0090] The recovery module 402 is used to determine the data recovery operation of any sub-transaction of the sub-processing node according to the transaction status of the sub-transaction, so as to realize the recovery of the distributed transaction database.

[0091] The recovery module 402 is specifically configured to, when the transaction status of the sub-transaction is in an unprepared state, perform data recovery on the sub-transaction corresponding to the sub-processing node.

[0092] The recovery module 402 is further configured to, when the transaction state of the sub-transaction is in an unprepared state, perform a transaction termination operation on the corresponding sub-transaction of the sub-processing node; and perform data recovery on the sub-transaction after the transaction termination operation is performed.

[0093] The recovery module 402 is further configured to, when the transaction status of the sub-transaction is in an unprepared state, perform a transaction termination operation on the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database.

[0094] The recovery module 402 is specifically configured to, when the transaction state of the sub-transaction is in the prepared state, call the global transaction recovery instruction sent by the global transaction manager; and perform data recovery on the sub-transaction in the prepared state in the sub-processing node according to the global transaction recovery instruction.

[0095] The device also includes:

[0096] The judging module 403 is used to obtain the recovery time required for the sub-processing node to recover the corresponding sub-transaction when the transaction state of the sub-transaction is in the unprepared state, so as to judge whether the recovery time exceeds the set time;

[0097] The recovery module 402 is also used to, when the transaction status of the sub-transaction is in an unprepared state and the recovery duration exceeds a set duration, execute the step of performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database.

[0098] The device also includes:

[0099] The duration setting module 404 is used to obtain the maximum recovery duration required for all sub-processing nodes to recover the sub-transactions in the prepared state; and use the maximum recovery duration as the set duration.

[0100] The device also includes:

[0101] The monitoring module 405 is used to monitor whether a preset global transaction recovery event occurs in the distributed transaction database before the acquisition module 401 acquires the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database; when the occurrence of the global transaction recovery event is detected, the sub-processing node is restored to the state before the downtime.

[0102] <Equipment Embodiment>

[0103] The embodiment of the present invention also provides a distributed transaction database device, such as Figure 5 As shown, the distributed transaction database device includes the transaction processing device of the distributed transaction database in the above-mentioned device embodiment.

[0104] Alternatively, the distributed transaction database device includes a memory 501 and a processor 502. The memory is used to store executable instructions, and the instructions are used to control the processor to execute the method according to any one of the above method embodiments.

[0105] <Computer Storage Media>

[0106] The present invention also provides a computer storage medium, wherein the storage medium stores computer instructions. When the computer instructions in the storage medium are executed by a processor, the method described in any one of the above method embodiments is implemented.

[0107] The present invention may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present invention.

[0108] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: 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), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0109] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0110] The computer program instructions for performing the operation of the present invention may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present invention.

[0111] Various aspects of the present invention are described herein with reference to the flow charts and / or block diagrams of the methods, devices (systems) and computer program products according to embodiments of the present invention. It should be understood that each box of the flow chart and / or block diagram and the combination of each box in the flow chart and / or block diagram can be implemented by computer-readable program instructions.

[0112] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0113] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0114] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a part of a module, a program segment or an instruction, and a part of the module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.

[0115] Embodiments of the present invention have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements to the technology in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present invention is defined by the appended claims.

Claims

1. A method for recovering a distributed transaction database, wherein the distributed transaction database comprises a starting node and at least one sub-processing node, wherein both the starting node and the sub-processing node are used to process sub-transactions of a global transaction, wherein: The method comprises: Acquire the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes; Determining a data recovery operation for any sub-transaction of the sub-processing node according to the transaction status of the sub-transaction to achieve recovery of the distributed transaction database, including: when the transaction status of the sub-transaction is an unprepared state, performing data recovery on the corresponding sub-transaction of the sub-processing node; When the transaction state of the sub-transaction is in an unprepared state, performing data recovery on the corresponding sub-transaction of the sub-processing node includes: When the transaction state of the sub-transaction is in an unprepared state, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node; Perform data recovery on the sub-transaction after the transaction termination operation is executed; When the transaction state of the sub-transaction is in an unprepared state, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node includes: When the transaction status of the sub-transaction is in an unprepared state, when the recovery time required for the sub-processing node to recover the corresponding sub-transaction exceeds a set time, a step of performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database is executed.

2. The method according to claim 1, characterized in that: The step of determining the data recovery operation of any sub-transaction of the sub-transaction according to the transaction status of the sub-processing node further includes: When the transaction state of the subtransaction is in the prepared state, calling the global transaction recovery instruction sent by the global transaction manager; Data recovery is performed on the sub-transactions in the prepared state in the sub-processing node according to the global transaction recovery instruction.

3. The method according to claim 1, characterized in that The method further comprises: When the transaction state of the subtransaction is in the unprepared state, the recovery time required for the sub-processing node to recover the corresponding subtransaction is obtained to determine whether the recovery time exceeds a set time.

4. The method according to claim 1, characterized in that: The method further comprises the step of determining the set duration, comprising: Get the maximum recovery time required for all sub-processing nodes to recover sub-transactions in the prepared state; The maximum recovery time is used as the set time.

5. The method according to any one of claims 1 to 4, characterized in that: Before obtaining the transaction status of the sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, the method further includes: Monitoring whether a preset global transaction recovery event occurs in the distributed transaction database; When the occurrence of the global transaction recovery event is detected, the sub-processing node is restored to the state before the downtime.

6. A distributed transaction database recovery device, the distributed transaction database comprising a starting node and at least one sub-processing node, the starting node and the sub-processing node are both used to process sub-transactions of a global transaction, including: An acquisition module, used for acquiring the transaction status of a sub-transaction processed by any of the sub-processing nodes in the distributed transaction database, wherein the transaction status is the status of the sub-transaction processed by the sub-processing node before the sub-processing node crashes; A recovery module, used to determine a data recovery operation for any sub-transaction of the sub-processing node according to the transaction state of the sub-transaction, so as to realize the recovery of the distributed transaction database; The recovery module is used for recovering data of the corresponding sub-transaction of the sub-processing node when the transaction state of the sub-transaction is in an unprepared state; When the transaction state of the sub-transaction is in an unprepared state, performing data recovery on the corresponding sub-transaction of the sub-processing node includes: When the transaction state of the sub-transaction is in an unprepared state, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node; Perform data recovery on the sub-transaction after the transaction termination operation is executed; When the transaction state of the sub-transaction is in an unprepared state, performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node includes: When the transaction status of the sub-transaction is in an unprepared state, when the recovery time required for the sub-processing node to recover the corresponding sub-transaction exceeds a set time, a step of performing a transaction termination operation on the corresponding sub-transaction of the sub-processing node before calling the global transaction manager of the distributed transaction database is executed.

7. A distributed transaction database device, comprising the distributed transaction database recovery device according to claim 6; or, The device comprises: Processor and memory; The memory is used to store executable instructions, and the instructions are used to control the processor to execute the method according to any one of claims 1-5.

8. A computer storage medium, wherein the storage medium stores computer instructions, and when the computer instructions in the storage medium are executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Distributed transaction committing failure handling method, device and system

    CN103559245A

  • Database transaction processing system and method

    CN106156174A

  • A method and apparatus for backing up data

    CN109144785A

  • Distributed transaction processing method, distributed system and computer readable storage medium

    CN109669809A

  • Distributed database data processing method and device, storage medium and electronic device

    CN110019469A