CN117742899A - Distributed transaction processing method, device and medium in distributed database - Google Patents

Distributed transaction processing method, device and medium in distributed database Download PDF

Info

Publication number
CN117742899A
CN117742899A CN202311521328.3A CN202311521328A CN117742899A CN 117742899 A CN117742899 A CN 117742899A CN 202311521328 A CN202311521328 A CN 202311521328A CN 117742899 A CN117742899 A CN 117742899A
Authority
CN
China
Prior art keywords
branch
state
distributed transaction
node
distributed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311521328.3A
Other languages
Chinese (zh)
Inventor
任济双
徐文锋
张鹏
付裕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinzhuan Xinke Co Ltd
Original Assignee
Jinzhuan Xinke Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jinzhuan Xinke Co Ltd filed Critical Jinzhuan Xinke Co Ltd
Priority to CN202311521328.3A priority Critical patent/CN117742899A/en
Publication of CN117742899A publication Critical patent/CN117742899A/en
Pending legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a distributed transaction processing method, equipment and a storage medium in a distributed database. The method comprises the following steps: acquiring a preparation command of a target branch of the distributed transaction; according to the preparation command, indicating a first manager node, and updating the branch state of the target branch; detecting whether the coordinator node is a node with the last set branch state as a preparation state in the distributed transaction according to the branch state of the target branch; submitting the distributed transaction when the coordinator node is the node with the last set branch state as the preparation state in the distributed transaction; when the distributed transaction is submitted successfully, a first manager node is indicated, and the branch state of the target branch is updated; and receiving a commit command of the target branch, feeding back completion of commit to the client, and indicating the first manager node to update the branch state of the target branch. The technical scheme of the embodiment of the invention can improve the accuracy of the distributed transaction processing.

Description

Distributed transaction processing method, device and medium in distributed database
Technical Field
The present invention relates to the field of database technologies, and in particular, to a method, an apparatus, and a medium for processing distributed transactions in a distributed database.
Background
Along with the progress of the science and technology in China, the application of computers is gradually wide, and great convenience is brought to the life of people.
People can store various types of data through a database in a computer, and can perform operations such as adding, deleting, searching or modifying the data in the database.
In the data processing process of the database, a coordinator can generate fault downtime, so that the problem of inconsistent data in the database is caused, and the data processing accuracy is reduced.
Disclosure of Invention
The invention provides a distributed transaction processing method, equipment and medium in a distributed database, so as to improve the accuracy and efficiency of the distributed transaction processing.
In a first aspect, an embodiment of the present invention provides a method for processing a distributed transaction in a distributed database, where the method is applied to a coordinator node, and the method includes:
acquiring a preparation command of a target branch of the distributed transaction;
according to the preparation command, indicating a first manager node, and updating the branch state of the target branch;
detecting whether the coordinator node is a node with the last set branch state as a preparation state in the distributed transaction according to the branch state of the target branch;
submitting the distributed transaction when the coordinator node is the node with the last set branch state as the preparation state in the distributed transaction;
When the distributed transaction is submitted successfully, a first manager node is indicated, and the branch state of the target branch is updated;
and receiving a commit command of the target branch, feeding back completion of commit to the client, and indicating the first manager node to update the branch state of the target branch.
In a second aspect, an embodiment of the present invention provides a method for processing a distributed transaction in a distributed database, where the method is applied to a first manager node, and the method includes:
updating the branch state of the target branch of the distributed transaction when determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the preparation command;
when the coordinator node is determined to be the node with the last set branch state as the preparation state in the distributed transaction, updating the branch state of the target branch so that the coordinator node is the node with the last set branch state as the preparation state in the distributed transaction;
updating the branch state of the target branch of the distributed transaction when determining that the coordinator node succeeds in submitting the distributed transaction and updates the branch state of the target branch of the distributed transaction;
upon determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the commit command, the branch state of the target branch of the distributed transaction is updated.
In a third aspect, an embodiment of the present invention provides a distributed transaction processing device in a distributed database, where the device includes:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the distributed transaction method in the distributed database of any of the embodiments of the present invention.
In a fourth aspect, embodiments of the present invention provide a computer readable storage medium storing computer instructions for causing a processor to execute a method for implementing a distributed transaction in a distributed database according to any of the embodiments of the present invention.
According to the technical scheme, the first manager node is indicated according to the preparation command by acquiring the preparation command of the target branch of the distributed transaction, so that the branch state of the target branch is updated, the branch state is updated in real time, and the accuracy of distributed transaction processing is improved; submitting the distributed transaction when the coordinator node is the node which is finally set with the preparation state in the distributed transaction, and feeding back the preparation success to the client when the distributed transaction is successfully submitted, so as to realize the pre-submission in the preparation stage; the method has the advantages that the method can accelerate the completion of the submission by receiving the submission command of the target branch, feeding back the completion of the submission to the client and updating the branch state of the target branch, and can ensure the accuracy of the submitted content and divide the state more finely only when the last coordinator node is ready to complete, thereby being beneficial to finer distributed transaction processing and improving the reliability of the distributed transaction processing.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for distributed transaction processing in a distributed database according to a first embodiment of the present invention;
FIG. 2 is a flow chart of a method for distributed transaction processing in a distributed database according to a second embodiment of the present invention;
FIG. 3 is a flow chart of a method for distributed transaction processing in a distributed database according to a third embodiment of the present invention;
FIG. 4 is a flow chart of a method for distributed transaction processing in a distributed database according to an embodiment of the present invention;
FIG. 5 is a flow chart of a method for distributed transaction processing in a distributed database according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a distributed transaction processing arrangement in a distributed database according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a distributed transaction processing arrangement in a distributed database according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a distributed transaction processing system in a distributed database provided in accordance with an embodiment of the present invention;
fig. 9 is a schematic diagram of a distributed transaction processing device in a distributed database according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
In the technical scheme of the embodiment of the invention, the acquisition, storage, application and the like of the distributed transaction and the like in the related distributed database are in accordance with the regulations of related laws and regulations, and the public order harmony is not violated.
Example 1
Fig. 1 is a flowchart of a method for processing distributed transactions in a distributed database according to a first embodiment of the present invention. The embodiment of the invention can be applied to the case of distributed transaction processing in a distributed database, and the method can be executed by distributed transaction processing devices in the distributed database, wherein the distributed transaction processing devices in the distributed database can be realized in the form of hardware and/or software.
Referring to the distributed transaction processing method in the distributed database shown in fig. 1, the method includes:
s101, acquiring a preparation command of a target branch of the distributed transaction.
Wherein the prepare command may be an operation request sent to the coordinator node for the client. By way of example, the clients of the plurality of devices may include mobile phone apps, computer applications, computer browsers, and the like. A client may be a computer program that performs one or more specific tasks, and that may interact with a user, typically with a visual user interface. A distributed transaction may be multiple computing operations performed by different devices on the same account, and a distributed transaction may be multiple computing operations performed by the same device on the same account. Clients configured on different devices may perform different operations on the same distributed transaction, one client may have at least one branch, the same distributed transaction has at least one branch, and different communication links correspond to different branches. The target branch may be a branch currently being processed by the coordinator node.
The coordinator node of the execution main body in the embodiment of the invention is a node associated with a database. The nodes associated with the database can be computing nodes for processing database data, can be management nodes for managing the nodes associated with the database, and can also be data nodes for managing partial data in the database. For example, an originally huge database can be converted into a plurality of small databases, and each small database is responsible for one data node, so that concurrency performance and expandability of the databases are improved. Databases include, but are not limited to: goldenDB distributed database, HBase distributed database, mongoDB distributed database, and the like. The coordinator node may be a node that receives information and transmits the information after processing the information. The client establishes a link with the coordinator node to form a multi-branch link, and different branches can operate the same distributed transaction; distributed transactions may be represented by xa_gid, branch transactions by xa_bid, a xa_gid may have multiple xa_bid, each representing a separate branch, transactions on a respective branch may be executed, and all xa_bid's complete execution may be followed by commit of xa_gid.
In one example, the coordinator node (CN 1) obtains a prepare command sent by the branch xa_bid1 in the distributed transaction xa_gid through the Wireshark packet-grabbing tool.
S102, according to the preparation command, the first manager node is instructed, and the branch state of the target branch is updated.
Wherein the first manager node may be a management node that manages the nodes associated with the database. The branch state may be the processing state of the target branch xa_bid in the distributed transaction xa_gid.
Specifically, according to the preparation command sent by the target branch xa_bid of the distributed transaction xa_gid, the coordinator node indicates the first manager node to enable the first manager node to update the branch state of the coordinator node for the target branch xa_bid, so that the branch state of the target branch xa_bid of the distributed transaction xa_gid is updated in real time, and analysis of the distributed transaction xa_gid processing process is facilitated.
In one example, the target branch (xa_bid 1) sends a prepare command for the distributed transaction xa_gid, and the coordinator node (CN 1) instructs the first manager node (GTM 1) to update the branch status of xa_bid 1.
S103, detecting whether the coordinator node is a node with the last set branch state as a preparation state in the distributed transaction according to the branch state of the target branch.
Wherein the ready state may be a state in which a processing operation of the target branch xa_bid in the distributed transaction xa_gid is completed.
Specifically, the distributed transaction xa_gid includes at least one branch transaction xa_bid, where multiple branch transactions xa_bid may be processed by different coordinator nodes, and the first manager node updates the branch state of the target branch xa_bid in the branch transaction xa_gid that is processed by each coordinator node correspondingly, and detects which coordinator node is the node in the distributed transaction xa_gid that sets the branch state of the last target branch xa_bid to be a ready state.
In one example, the distributed transaction xa_gid contains two branches, xa_bid1 and xa_bid2.GTM1 updates the branch state of XA_BID1 sent by XA_BID1. GTM1 updates the branch state of XA_BID2 sent by XA_BID2. If the update of the branch state of xa_bid1 is completed with priority, and the update is completed after the branch state of xa_bid2, the coordinator node (CN 2) is the last node in the distributed transaction xa_gid to set the branch state to the ready state.
S104, submitting the distributed transaction when the coordinator node is the node with the last set branch state as the ready state in the distributed transaction.
Specifically, the coordinator node updates the branch state of the branch xa_bid in the distributed transaction xa_gid according to the preparation command, and updates the branch state to the preparation state. When the coordinator node is the node that last set the ready state, the distributed transaction xa_gid is committed.
In one example, the target branch may be represented by (XA_BID), with three branches of the distributed transaction XA_GID, XA_BID1, XA_BID2, and XA_BID3, respectively. There are three coordinator nodes, namely coordinator node (CN 1), coordinator node (CN 2) and coordinator node (CN 3). The coordinator node updates the branch state of the branch xa_bid in the distributed transaction according to the preparation command, CN1 updates xa_bid1, CN2 updates xa_bid2, and CN3 updates xa_bid3. And after the XA_BID1 and the XA_BID2 are set to be ready, setting the XA_BID3 to be ready, and submitting the distributed transaction XA_GID by the CN3 for the node which is finally set to be ready, wherein the XA_BID1, the XA_BID2 and the XA_BID3.
S105, when the distributed transaction is submitted successfully, the first manager node is indicated, and the branch state of the target branch is updated.
Specifically, when the coordinator node submits the distributed transaction xa_gid successfully, the coordinator node instructs the first manager node to update the branch state of the target branch in xa_gid.
In one example, when the coordinator node (CN 1) submits the distributed transaction XA_GID successfully, the coordinator node instructs the first manager node to update the branch state of the branch XA_BID1 in the distributed transaction XA_GID.
S106, receiving a commit command of the target branch, feeding back completion of commit to the client, and indicating the first manager node to update the branch state of the target branch.
Wherein the commit command may be a commit request sent by the branch xa_bid in the distributed transaction xa_gid to the coordinator node for the distributed transaction. Ways in which the coordinator node feeds back commit completion to the client include, but are not limited to: popup prompts, mail prompts, web page prompts, or the like.
In one example, the coordinator node (CN 1) receives the commit command sent by xa_bid1 and feeds back to the client that the commit is complete. The coordinator node (CN 1) instructs the first manager node to update the branch status of xa_bid 1.
According to the technical scheme, the first manager node is indicated according to the preparation command by acquiring the preparation command of the target branch of the distributed transaction, so that the branch state of the target branch is updated, the branch state is updated in real time, and the accuracy of distributed transaction processing is improved; when the coordinator node is the node of the final setting preparation state in the distributed transaction, submitting the distributed transaction, and improving the submitting efficiency of the distributed transaction; and receiving a submitting command of the target branch, feeding back the completion of the submitting to the client, and updating the branch state of the target branch, wherein the accuracy of the submitted content can be ensured when the last coordinator node is ready to complete, and the state is divided more finely, so that the distributed transaction processing is more refined, and the reliability of the distributed transaction processing is improved.
Optionally, after submitting the distributed transaction, the method further comprises: when the distributed transaction commits to fail, a rollback operation is performed.
The rollback operation may be a program or data processing error, and is the act of restoring the program or data to the last correct state. Rollback includes program rollback and data rollback types.
Specifically, after feeding back completion of the commit to the client and updating the branch state of the branch xa_bid in the distributed transaction xa_gid, the coordinator node receives a commit command sent by the client for the branch xa_bid in the distributed transaction xa_gid, and performs commit of the distributed transaction xa_gid; executing rollback operation when the submission in the distributed transaction XA_GID fails, and re-submitting the distributed transaction XA_GID; when the distributed transaction XA_GID commits successfully, no rollback operation is executed, and the next operation is continued.
In one example, the coordinator node (CN 1) performs the commit of the distributed transaction xa_gid after feeding back the commit completion to the client and updating the branch state of the branch xa_bid1 in the distributed transaction xa_gid, where the CN1 receives the commit command of the client for the distributed transaction xa_gid. And acquiring the commit result of the distributed transaction XA-GID as a commit failure, executing a rollback operation by the CN1, and re-submitting the distributed transaction XA-GID.
A commit command sent by a client for a branch in a distributed transaction is received; and when the branch commit fails in the distributed transaction, the rollback operation is executed, which is beneficial to the distributed transaction re-processing and improves the reliability of the distributed transaction processing.
Optionally, before the preparation command of the target branch of the distributed transaction is acquired, the method further comprises: acquiring a distributed transaction and a start command; according to the start command, indicating a first manager node, creating a target branch of the distributed transaction, and a branch state of the target branch; database operation is carried out on the distributed transaction; when the operation of the distributed transaction is completed and an end command is received, the branch state of the target branch is updated according to the end command.
Wherein the start command may be a request sent by the client to the coordinator node to start the processing of branch xa_bid in the distributed transaction xa_gid. The end command may be a request sent by the client to the coordinator node to end the processing of branch xa_bid in the distributed transaction xa_gid.
Specifically, before acquiring a preparation command sent by a client for a branch xa_bid in a distributed transaction xa_gid, the coordinator node acquires the distributed transaction xa_gid and a start command sent by the client; according to the start command, the coordinator node instructs the first manager node to create the branch xa_bid of the distributed transaction xa_gid and the branch state of the branch xa_bid of the distributed transaction xa_gid; the coordinator node performs database operation on branches XA_BID in the distributed transaction XA_GID; the operation of the distributed transaction XA_GID is completed, and the coordinator node receives an ending command sent by the client; upon completion of the command, the coordinator node instructs the first manager node to update the branch state of the branch xa_bid of the distributed transaction xa_gid.
In one example, a coordinator node (CN 1) acquires a distributed transaction xa_gid and a start command sent by a client before acquiring a prepare command sent by the client for a branch xa_bid in the distributed transaction xa_gid; upon a start command, CN1 instructs a first manager node (GTM 1) to create a branch XA_BID of the distributed transaction XA_GID and a branch state of the branch XA_BID of the distributed transaction XA_GID; CN1 performs database operation on branch XA_BID in distributed transaction XA_GID; the operation of branching XA_BID in the distributed transaction XA_GID is completed, and CN1 receives an ending command sent by the client; based on the end command, CN1 instructs GTM1 to update the branch state of branch XA_BID.
By acquiring distributed transactions and start commands; according to the start command, the first manager node creates a branch state of a branch of the distributed transaction; when a start command fed back by the first manager node is received to be completed, performing database operation on branches of the distributed transaction; the operation of the branch of the distributed transaction is completed, and an ending command sent by the client is received; and the first manager node is instructed to update the branch state according to the end command, so that the operation of the branches of the distributed transaction is more refined, the state of the client can be acquired in time, and the analysis and the processing of the distributed transaction are facilitated.
Example two
Fig. 2 is a flowchart of a method for processing distributed transactions in a distributed database according to a second embodiment of the present invention. The embodiment of the invention optimizes and improves the distributed transaction processing operation on the basis of the embodiment.
Further, the method for processing the distributed transaction in the distributed database is refined into the method for processing the distributed transaction in the distributed database, and the method further comprises the following steps: acquiring the current state time of a target branch; the current state time is the time to update the branch state of the target branch; calculating the processing time length between the current state time and the current real time; comparing the processing time length with a timeout time length threshold value, and detecting whether to execute rollback operation according to the comparison result so as to perfect the operation of distributed transaction processing in the distributed database.
In the embodiments of the present invention, the descriptions of other embodiments may be referred to in the portions not described in detail.
Referring to fig. 2, a method for processing distributed transactions in a distributed database includes:
s201, acquiring a preparation command of a target branch of the distributed transaction.
S202, according to the preparation command, the first manager node is instructed, and the branch state of the target branch is updated.
S203, detecting whether the coordinator node is the node with the branch state set at the last in the distributed transaction as the preparation state according to the branch state of the target branch.
S204, submitting the distributed transaction when the coordinator node is the node with the last set branch state as the ready state in the distributed transaction.
S205, acquiring the current state time of a target branch; the current state time is the time to update the branch state of the target branch.
Specifically, the current time when the first manager node updates the branch state is taken as the current state time sent by the first manager node to the coordinator node.
In one example, the current first manager node (GTM 1) updates the branch state of branch xa_bid in distributed transaction xa_gid for XX minutes XX seconds when XX is XX yearly XX month XX day XX, and the current state time sent by the first manager node (GTM 1) to coordinator node (CN 1) is XX minutes XX seconds when XX is XX yearly XX month XX day XX.
S206, calculating the processing duration between the current state time and the current real time.
The current real time may be the current real time acquired by the current coordinator node. The processing duration may be the length of time between the current state time and the current real time.
Specifically, the coordinator node obtains the current state time and the current real time, and takes the absolute value of the difference between the current state time and the current real time as the value of the processing time.
In one example, the current state time is 2 minutes 2 seconds of 2 days of 2 months of XX years, the current real time is 2 minutes 5 seconds of 2 days of 2 months of 2 days of XX years, the absolute value of the difference between the current state time and the current real time is obtained, and the value of the processing duration is 3 seconds.
S207, comparing the processing time length with a timeout time length threshold, and detecting whether to execute rollback operation according to the comparison result.
The timeout period threshold may be a preset time length.
Specifically, the coordinator node compares the processing duration with a timeout duration threshold, and detects whether to execute the rollback operation according to the comparison result. Executing rollback operation when the processing time length is greater than the timeout time length threshold; when the processing time is less than the timeout time threshold, no rollback operation is performed.
In one example, the timeout period threshold is 2 seconds, the processing period is 3 seconds, the coordinator node compares the processing period with the timeout period threshold to obtain that the processing period is greater than the timeout period threshold, and the coordinator node obtains that the comparison result is that the rollback operation is executed.
S208, when the distributed transaction is submitted successfully, the first manager node is indicated, and the branch state of the target branch is updated.
S209, receiving a commit command of the target branch, feeding back completion of commit to the client, and indicating the first manager node to update the branch state of the target branch.
The embodiment of the invention obtains the current state time; the current state time is the time of updating the branch state of the first manager node, which is favorable for calculating the update time length of the branch state and acquiring the branch state of the branch in the distributed transaction; calculating the processing time between the current state time and the current real time to obtain branches of the distributed transaction with abnormal processing time, avoiding abnormal situations which are not actively reported in long-time processing, and improving the reliability of the distributed transaction processing; and comparing the processing time length with a timeout time length threshold, detecting whether to execute rollback operation according to the comparison result, and executing corresponding operation aiming at different comparison results, thereby improving the accuracy and reliability of distributed transaction processing.
Optionally, after feeding back completion of commit to the client and updating the branch state of the target branch, the method further includes: receiving a rollback command of a target branch; and executing the rollback operation according to the rollback command, and updating the branch state of the target branch.
The rollback command may be a request sent by the client to restore the program to the correct state last time.
Specifically, after feeding back completion of submission to the client and updating the branch state of the branch xa_bid in the distributed transaction xa_gid, the coordinator node receives a rollback command sent by the client; and executing the rollback operation according to the rollback command. When the coordinator node receives the rollback command sent by the client, a rollback operation is performed, and the branch state of the branch xa_bid in the distributed transaction xa_gid is updated.
In one example, the coordinator node (CN 1) receives a rollback command sent by the client after feeding back completion of commit to the client and updating the branch state of the branch xa_bid in the distributed transaction xa_gid; CN1 receives rollback command sent by client, executes rollback operation, and updates branch state of branch XA_BID in distributed transaction XA_GID.
Receiving a rollback command sent by a client; and executing the rollback operation according to the rollback command and updating the branch state of the branch in the distributed transaction, thereby being beneficial to timely acquiring the state of the client executing the rollback command and improving the accuracy of the distributed transaction processing.
Example III
Fig. 3 is a flowchart of a method for processing distributed transactions in a distributed database according to a third embodiment of the present invention. The embodiment of the invention can be applied to the case of distributed transaction processing in a distributed database, and the method can be executed by distributed transaction processing devices in the distributed database, wherein the distributed transaction processing devices in the distributed database can be realized in the form of hardware and/or software.
Referring to the distributed transaction processing method in the distributed database shown in fig. 3, the method includes:
s301, when determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the preparation command, updating the branch state of the target branch of the distributed transaction.
The execution subject of the embodiment of the invention is a first manager node. Specifically, the first manager node updates the branch state of the branch xa_bid in the distributed transaction xa_gid according to the prepare command sent by the target branch xa_bid of the distributed transaction xa_gid.
In one example, a first manager node (GTM 1) updates the branch state of branch XA_BID1 in a distributed transaction XA_GID based on a prepare command sent by a target branch XA_BID1 of the distributed transaction XA_GID.
And S302, when the coordinator node is determined to be the node with the last set branch state as the preparation state in the distributed transaction, updating the branch state of the target branch so that the coordinator node is the node with the last set branch state as the preparation state in the distributed transaction.
Specifically, when the first manager node determines that the coordinator node is the last node for setting the preparation state for the client, the branch state of the target branch is updated, and the coordinator node is the node in the distributed transaction xa_gid for which the branch state is set to be the preparation state last.
In one example, after CN1 sets the branch state of branch xa_bid1 in distributed transaction xa_gid, CN2 sets the branch state of branch xa_bid2 in distributed transaction xa_gid without other nodes to be set in branch state, and then the first manager node (GTM 1) determines that CN2 is the node in the last set ready state.
S303, updating the branch state of the target branch of the distributed transaction when determining that the coordinator node succeeds in submitting the distributed transaction and updating the branch state of the target branch of the distributed transaction.
Specifically, when the coordinator node submits a branch xa_bid in the distributed transaction xa_gid successfully, the first manager node updates the branch state of the branch xa_bid in the distributed transaction xa_gid.
In one example, upon successful commit of branch xa_bid in distributed transaction xa_gid by coordinator node (CN 1), first manager node (GTM 1) updates the branch state of branch xa_bid in distributed transaction xa_gid.
S304, when the coordinator node is determined to update the branch state of the target branch of the distributed transaction according to the commit command, updating the branch state of the target branch of the distributed transaction.
Specifically, when a commit command sent by the client for the branch xa_bid in the distributed transaction xa_gid is received, the branch state of the branch xa_bid in the distributed transaction xa_gid is updated.
In one example, a first manager node (GTM 1) upon receiving a commit command sent by client 1 for distributed transaction XA_GID, GTM1 updates the branch state of branch XA_BID in distributed transaction XA_GID.
According to the technical scheme, when the coordinator node is determined to update the branch state of the target branch of the distributed transaction according to the preparation command, the branch state of the target branch of the distributed transaction is updated, and the operation of the branch state of the branch in the distributed transaction is refined, so that the distributed transaction processing analysis is facilitated; when the coordinator node is determined to be the node with the final set preparation state, updating the branch state of the target branch, and determining the updating progress of the branch state; when the distributed transaction is submitted successfully, the branch state of the branch in the distributed transaction is updated, so that the branch state of the branch in the distributed transaction can be acquired in time; when a commit command sent by a client for the distributed transaction is received, the branch state of the branch in the distributed transaction is updated, so that the branch state of the branch in the distributed transaction is updated in time, and the reliability of the distributed transaction is improved.
Optionally, in determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the preparation command, updating the branch state of the target branch of the distributed transaction includes: updating the branch state of the target branch to a first preparation state; when the branch states of all branches of the distributed transaction are determined to be the first preparation state, updating the branch state of the last branch updated to the first preparation state to the second preparation state; the second readiness state corresponds to a node in the distributed transaction that last set the branch state to readiness state.
Wherein the first ready state is used to indicate that a branch state of a branch of a distributed transaction is a ready-to-complete state. The second ready state is used to indicate that the branch states of all branches of the same distributed transaction are ready to complete states.
Specifically, different coordinator nodes have different branch states for branches xa_bid in the same distributed transaction xa_gid; updating the branch state of the coordinator node for the branch xa_bid in the distributed transaction xa_gid to a first preparation state; when all branch states of the distributed transaction XA_GID are determined to be the first preparation state, updating the last branch state updated to the first preparation state to the second preparation state; the first manager node determines that the branch state is the coordinator node corresponding to the second preparation state as the node of the last set preparation state.
In one example, as shown in FIG. 4, operations of the distributed transaction (XA_GID) include a START state setting (XA START), an END state setting (XA END), a ready state setting (XA PREPARE), a COMMIT (XA COMMIT), and a ROLLBACK (XA ROLLBACK).
When the branch xa_bid in the distributed transaction xa_gid of branch one executes XA START, the first manager node will first check whether the branch xa_bid in the current distributed transaction xa_gid exists, if not, create a branch xa_bid in the distributed transaction xa_gid, and set the STATUS to status_start; if branch xa_bid already exists in distributed transaction xa_gid (branch two executes XA START), add new branch xa_bid and set state to status_start, and so on. Each branch separately executes a respective SQL statement and when XA END operations are performed, the current branch state is set to status_end. Each branch executes an XA preparation for commit preparation phase after XA END, the branches of XA preparation are executed, the state is set to a first preparation state (p 1), identifying that the current branch can commit. When the Coordinator Node (CN) finds that the branch status of all branches is set to p1, changing the branch status of the last executed XA PREPARE from p1 to a second ready status (p 2); all branches, as long as the branch state of one branch becomes p2, indicate that the preparation phase has been completed at this time. The CN calls the corresponding DN to execute the submission and initiates the submission. The CN sets the branch state from p2 to status_pre_commit. When the client sends a COMMIT instruction, the CN sets the state as STATUS_COMMIT, performs formal COMMIT, and releases XA and other information. When DN submits and returns failure response, CN sets state as STATUS_ROLLBACK, rolls back, and releases XA information.
As shown in fig. 5, when the CN receives the END command, the GTM is instructed to set xa_gid state to status_end, the GTM records the current state TIME end_time of the CN at this TIME, and before the CN performs the next action, the GTM returns end_time to the CN, and the CN decides whether timeout rollback is needed according to the end_time returned by the GTM and the current real TIME cur_time. When the CN sends the p2 state to the GTM, the GTM records the TIME PREPARE ALL TIME of the CN at the moment, and when the CN executes the next action, the GTM returns the PREPARE ALL TIME to the CN, and the CN decides whether overtime rollback is needed or not according to the PREPARE ALL TIME returned by the GTM and the current TIME CUR TIME. In a special scenario, after the client executes XA END or XA preparation, because of CN failure or other reasons, no XA COMMIT or XA ROLLBACK action is caused, which causes DN blocking; the GTM will set a timer to check the state of xa_gid and end_time and prepare_all_time at regular TIME, and when timeout occurs, the CN is driven to perform rollback operation.
Updating a branch state of a coordinator node for a branch in the distributed transaction to a first preparation state; different coordinator nodes have different branch states for the same distributed transaction; when all branch states of the distributed transaction are determined to be the first preparation state, updating the last branch state updated to be the first preparation state to be the second preparation state; and determining the branch state as the coordinator node corresponding to the second preparation state as the node of the last preparation state, so as to prevent premature data processing and improve the consistency of the data.
Optionally, updating the branch state of the target branch of the distributed transaction includes: the branch state of the target branch of the distributed transaction is synchronized to the second manager node.
Wherein the second manager node may be a management node that manages the nodes associated with the database.
Specifically, the branch state of the branch xa_bid in the distributed transaction xa_gid is synchronized to a second manager node, which has the same information as the first manager node. After the first manager node receives the data sent by the coordinator node, the first manager node sends a synchronization message to the second manager node except for local storage, so that the branch XA_BID information in the distributed transaction XA_GID between the first manager node and the second manager node is kept consistent. When the first manager node fails, the second manager node is started to execute the operation which is not executed by the first manager node. After the second manager node completes synchronization, a response message may be returned to the first manager node.
In one example, the branch state of the distributed transaction xa_gid is a second ready state, and the first manager node synchronizes the branch state of the distributed transaction xa_gid to the second manager node, which also has information that the branch state of the distributed transaction xa_gid is the second ready state.
By synchronizing the branch state of the branch in the distributed transaction to the second manager node, if a fault occurs in the first manager node, the second manager node is started to execute the operation which is not executed by the first manager node, which is beneficial to improving the reliability of the distributed transaction processing.
Example IV
Fig. 6 is a schematic structural diagram of a distributed transaction processing device in a distributed database according to a fourth embodiment of the present invention. The embodiment of the invention is applicable to the case of distributed transaction processing in a distributed database, the device can execute the distributed transaction processing method in the distributed database, and the device can be realized in a form of hardware and/or software.
Referring to fig. 6, a distributed transaction processing apparatus in a distributed database includes: a command acquisition module 601, a branch update module 602, a preparation information setting module 603, a transaction commit module 604, a status update module 605, and a feedback commit module 606, wherein,
a command obtaining module 601, configured to obtain a preparation command of a target branch of a distributed transaction;
the branch update module 602 is configured to instruct the first manager node to update the branch status of the target branch according to the preparation command.
A preparation information setting module 603, configured to detect, according to a branch state of a target branch, whether a coordinator node is a node in the distributed transaction, where the branch state is set to a preparation state last;
a transaction commit module 604, configured to commit the distributed transaction when the coordinator node is a node in which a branch state is set to a ready state in the distributed transaction last;
a state update module 605, configured to instruct the first manager node to update the branch state of the target branch when the distributed transaction commits successfully;
the feedback submission module 606 is configured to receive a submission command of the target branch, and feedback the completion of the submission to the client, and instruct the first manager node to update the branch status of the target branch.
According to the technical scheme, the first manager node is indicated according to the preparation command by acquiring the preparation command of the target branch of the distributed transaction, so that the branch state of the target branch is updated, the branch state is updated in real time, and the accuracy of distributed transaction processing is improved; when the coordinator node is the node of the final setting preparation state in the distributed transaction, submitting the distributed transaction, and improving the submitting efficiency of the distributed transaction; and receiving a submitting command of the target branch, feeding back the completion of the submitting to the client, and updating the branch state of the target branch, wherein the accuracy of the submitted content can be ensured when the last coordinator node is ready to complete, and the state is divided more finely, so that the distributed transaction processing is more refined, and the reliability of the distributed transaction processing is improved.
Optionally, the distributed transaction processing apparatus further includes:
the state receiving module is used for acquiring the current state time of the target branch; the current state time is the time to update the branch state of the target branch;
the time length calculation module is used for calculating the processing time length between the current state time and the current real time;
and the result detection module is used for comparing the processing time length with the timeout time length threshold value and detecting whether to execute rollback operation or not according to the comparison result.
Optionally, after the transaction commit module 604, the method further includes:
and the operation execution module is used for executing rollback operation when the distributed transaction commit fails.
Optionally, before the command obtaining module 601, the method further includes:
the command acquisition module is used for acquiring the distributed transaction and the start command;
the branch creation module is used for indicating the first manager node to create a target branch of the distributed transaction and a branch state of the target branch according to the start command;
the transaction operation module is used for carrying out database operation on the distributed transaction;
and the information management module is used for updating the branch state of the target branch according to the ending command when the operation of the distributed transaction is completed and the ending command is received.
Optionally, after the status update module 605, the method further includes:
the rollback command receiving module is used for receiving a rollback command of the target branch;
and the branch state updating module is used for executing the rollback operation according to the rollback command and updating the branch state of the target branch.
The distributed transaction processing device provided by the embodiment of the invention can execute the distributed transaction processing method in the distributed database provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the distributed transaction processing method in the distributed database.
Example five
Fig. 7 is a schematic structural diagram of a distributed transaction processing device in a distributed database according to a fifth embodiment of the present invention. The embodiment of the invention is applicable to the case of distributed transaction processing in a distributed database, the device can execute a distributed transaction processing method in the distributed database, the device can be realized in a form of hardware and/or software, and the device can be configured in a distributed transaction processing system in the distributed database.
Referring to fig. 7, a distributed transaction processing apparatus in a distributed database includes: an information sending module 701, a transaction commit module 702, a successful commit module 703, and a commit command receiving module 704, wherein,
An information sending module 701, configured to update a branch state of a target branch of the distributed transaction when determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the preparation command;
the transaction submitting module 702 is configured to update, when determining that the coordinator node is a node in the distributed transaction in which the branch state is set to be the ready state last, the branch state of the target branch so that the coordinator node is a node in the distributed transaction in which the branch state is set to be the ready state last;
a successful commit module 703, configured to update a branch state of a target branch of the distributed transaction when it is determined that the coordinator node is successful in committing the distributed transaction and updates the branch state of the target branch of the distributed transaction;
the commit command receiving module 704 is configured to update a branch state of a target branch of the distributed transaction when it is determined that the coordinator node updates the branch state of the target branch of the distributed transaction according to the commit command.
Optionally, the information sending module 701 includes:
a first state updating unit for updating the branch state of the target branch to a first preparation state;
a second state updating unit, configured to update, when it is determined that the branch states of all branches of the distributed transaction are the first preparation states, the branch state of the branch updated to the first preparation state last to the second preparation state; the second preparation state corresponds to a node in the distributed transaction, wherein the node is last provided with a branch state as the preparation state;
Optionally, the information sending module 701 includes:
and the data synchronization unit is used for synchronizing the branch state of the target branch of the distributed transaction to the second manager node.
The distributed transaction processing device in the distributed database provided by the embodiment of the invention can execute the distributed transaction processing method in the distributed database provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of executing the distributed transaction processing method in the distributed database.
Example six
Fig. 8 is a schematic structural diagram of a distributed transaction processing system in a distributed database according to a sixth embodiment of the present invention. The embodiment of the invention can be applied to the case of distributed transaction processing in a distributed database.
Referring to the distributed transaction processing system shown in fig. 8, comprising: client (1) 801, client (2) 802, client (n) 803, coordinator (CN 1) 804, coordinator (CN 2) 805, coordinator (CNn) 806, participant (DN 1) 807, participant (DN 2) 808, participant (DNn) 809, first manager node (GTM 1) 810, and second manager node (GTM 2) 811; coordinator (CN 1) 804, coordinator (CN 2) 805 and coordinator (CNn) 806 implement the distributed transaction method in the distributed database as described in the first aspect; client (1) 801, client (2) 802, client (n) 803, coordinator (CN 1) 804, coordinator (CN 2) 805, coordinator (CNn) 806, participant (DN 1) 807, participant (DN 2) 808, participant (DNn) 809, first manager node (GTM 1) 810 and second manager node (GTM 2) 811. Wherein,
The client (1) 801, the client (2) 802 and the client (n) 803 are respectively in communication connection with the coordinator (CN 1) 804, the coordinator (CN 2) 805 and the coordinator (CNn) 806 to form a multi-branch link, different branches can operate the same distributed transaction, and the distributed transaction is submitted after all the distributed transactions are executed.
After the coordinator (CN 1) 804, the coordinator (CN 2) 805 and the coordinator (CNn) 806 receive the data sent by the client (1) 801, the client (2) 802 and the client (n) 803, corresponding distributed transaction states are set according to different distributed transaction flows, and the state messages are sent to the first manager node (GTM 1) 810 for storage.
The first manager node (GTM 1) 810 is communicatively connected to the second manager node (GTM 2) 811, and the second manager node (GTM 2) 811 backs up data of the first manager node (GTM 1) 810.
The second manager node (GTM 2) 811 returns a reply message to the first manager node (GTM 1) 810.
The first manager node (GTM 1) 810 transmits pre-commit information to the coordinator (CN 1) 804, coordinator (CN 2) 805, and coordinator (CNn) 806.
Coordinator (CN 1) 804, coordinator (CN 2) 805 and coordinator (CNn) 806 send SQL statements to corresponding participants (DN 1) 807, participant (DN 2) 808 and participant (DNn) 809.
Participant (DN 1) 807, participant (DN 2) 808 and participant (DNn) 809 return response messages to coordinator (CN 1) 804, coordinator (CN 2) 805 and coordinator (CNn) 806.
Coordinator (CN 1) 804, coordinator (CN 2) 805 and coordinator (CNn) 806 feed back messages to the corresponding client (1) 801, client (2) 802 and client (n) 803.
In one example, the client (1) is communicatively connected to a coordinator (CN 1). After receiving the data sent by the client (1), the coordinator (CN 1) sets a corresponding distributed transaction state according to the distributed transaction flow, and sends a state message to the first manager node (GTM 1) for storage. The second manager node (GTM 2) backs up data of the first manager node (GTM 1). The second manager node (GTM 2) returns a reply message to the first manager node (GTM 1). The first manager node (GTM 1) sends pre-commit information to the coordinator (CN 1). The coordinator (CN 1) sends an SQL statement to the corresponding participant (DN 1). The participant (DN 1) returns a reply message to the coordinator (CN 1). The coordinator (CN 1) feeds back the message to the corresponding client (1).
According to the distributed transaction processing system provided by the embodiment of the invention, the coordinator (CN 1), the coordinator (CN 2) and the coordinator (CNn) are used for acquiring the preparation command sent by the client for the distributed transaction, so that the acquisition of different requests sent by the client for different distributed transactions is facilitated; according to the preparation command, the preparation state setting information is sent to the first manager node, so that the first manager node updates the branch states of the coordinator (CN 1), the coordinator (CN 2) and the coordinator (CNn) aiming at the distributed transaction, the update of the branch states is facilitated in real time, and the accuracy of the distributed transaction processing is improved; when a coordinator (CN 1), a coordinator (CN 2) and a coordinator (CNn) are nodes with a final set preparation state, pre-submitting information fed back by a first manager node is received, distributed transactions are submitted, and when the distributed transactions are submitted successfully, the client is fed back that preparation is successful, so that pre-submitting in a preparation stage is realized; the method has the advantages that the method receives the commit command sent by the client for the distributed transaction, feeds back the commit completion to the client, and updates the branch state of the distributed transaction, so that the commit is completed before the commit, the completion speed of the commit can be increased, the accuracy of the contents of the commit can be ensured only when the last coordinator prepares to complete, the state is finely divided, the distributed transaction processing is more refined, and the reliability of the distributed transaction processing is improved.
Example seven
Fig. 9 shows a schematic diagram of a distributed transaction device 900 in a distributed database that may be used to implement an embodiment of the present invention.
As shown in fig. 9, the distributed transaction processing device 900 in the distributed database includes at least one processor 901, and a memory communicatively connected to the at least one processor 901, such as a Read Only Memory (ROM) 902, a Random Access Memory (RAM) 903, etc., in which a computer program executable by the at least one processor is stored, and the processor 901 may perform various suitable actions and processes according to the computer program stored in the Read Only Memory (ROM) 902 or the computer program loaded from the storage unit 908 into the Random Access Memory (RAM) 903. In RAM903, various programs and data required for operation of the distributed transaction device 900 in a distributed database may also be stored. The processor 901, the ROM902, and the RAM903 are connected to each other by a bus 904. An input/output (I/O) interface 905 is also connected to the bus 904.
A plurality of components in the distributed transaction device 900 in the distributed database are connected to the I/O interface 905, including: an input unit 906 such as a keyboard, a mouse, or the like; an output unit 907 such as various types of displays, speakers, and the like; a storage unit 908 such as a magnetic disk, an optical disk, or the like; and a communication unit 909 such as a network card, modem, wireless communication transceiver, or the like. The communication unit 909 allows the distributed transaction device 900 in the distributed database to exchange information/data with other devices through a computer network such as the internet and/or various telecommunication networks.
Processor 901 may be a variety of general and/or special purpose processing components with processing and computing capabilities. Some examples of processor 901 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, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 901 performs the various methods and processes described above, such as a distributed transaction method in a distributed database.
In some embodiments, the distributed transaction method in the distributed database may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 908. In some embodiments, some or all of the computer program may be loaded and/or installed onto the distributed transaction device 900 in a distributed database via the ROM902 and/or the communication unit 909. When the computer program is loaded into RAM903 and executed by processor 901, one or more steps of the distributed transaction method in the distributed database described above may be performed. Alternatively, in other embodiments, processor 901 may be configured to perform the distributed transaction method in the distributed database in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above can be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), complex Programmable Logic Devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may 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. The computer readable storage medium may 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, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, 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.
To provide for interaction with a user, the systems and techniques described here can be implemented on a distributed transaction device in a distributed database having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and pointing device (e.g., a mouse or trackball) through which a user can provide input to a distributed transaction device in a distributed database. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background 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 here), or any combination of such background, 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: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically 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. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical host and VPS (Virtual Private Server ) service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method of distributed transaction processing in a distributed database, for use in a coordinator node, the method comprising:
acquiring a preparation command of a target branch of the distributed transaction;
according to the preparation command, the first manager node is instructed to update the branch state of the target branch;
detecting whether the coordinator node is a node with the last set branch state as a preparation state in the distributed transaction according to the branch state of the target branch;
Submitting the distributed transaction when the coordinator node is the node with the branch state being the preparation state finally set in the distributed transaction;
when the distributed transaction is submitted successfully, indicating the first manager node to update the branch state of the target branch;
and receiving a commit command of the target branch, feeding back completion of commit to the client, and indicating the first manager node to update the branch state of the target branch.
2. The method as recited in claim 1, further comprising:
acquiring the current state time of the target branch; the current state time is a time to update a branch state of the target branch;
calculating the processing time length between the current state time and the current real time;
and comparing the processing time length with a timeout time length threshold value, and detecting whether to execute rollback operation according to a comparison result.
3. The method of claim 1, further comprising, after committing the distributed transaction:
and executing rollback operation when the distributed transaction commits to fail.
4. The method of claim 1, further comprising, prior to the fetching of the prepare command for the target branch of the distributed transaction:
Acquiring a distributed transaction and a start command;
according to the start command, indicating a first manager node, creating a target branch of the distributed transaction, and a branch state of the target branch;
database operation is carried out on the distributed transaction;
and when the operation of the distributed transaction is completed and a received ending command is received, updating the branch state of the target branch according to the ending command.
5. The method of claim 1, further comprising, after feeding back commit completion to the client and updating the branch state of the target branch:
receiving a rollback command of the target branch;
and executing rollback operation according to the rollback command, and updating the branch state of the target branch.
6. A method of distributed transaction processing in a distributed database, for use in a first manager node, the method comprising:
updating the branch state of a target branch of a distributed transaction when determining that a coordinator node updates the branch state of the target branch of the distributed transaction according to a preparation command;
updating the branch state of the target branch when the coordinator node is determined to be the node of which the branch state is set to be the preparation state last in the distributed transaction, so that the coordinator node is the node of which the branch state is set to be the preparation state last in the distributed transaction;
Updating the branch state of the target branch of the distributed transaction when determining that the coordinator node succeeds in submitting the distributed transaction and updates the branch state of the target branch of the distributed transaction;
upon determining that the coordinator node updates the branch state of the target branch of the distributed transaction according to the commit command, the branch state of the target branch of the distributed transaction is updated.
7. The method of claim 6, wherein updating the branch state of the target branch of the distributed transaction upon determining that the coordinator node updates the branch state of the target branch of the distributed transaction based on the prepare command comprises:
updating the branch state of the target branch to a first preparation state;
updating the branch state of the last branch updated to the first preparation state to the second preparation state when the branch states of all branches of the distributed transaction are determined to be the first preparation state; the second readiness state corresponds to a node in the distributed transaction that last set a branch state to a readiness state.
8. The method of claim 6, wherein updating the branch state of the target branch of the distributed transaction comprises:
The branch state of the target branch of the distributed transaction is synchronized to a second manager node.
9. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the distributed transaction method in the distributed database of any of claims 1-8.
10. A computer readable storage medium storing computer instructions for causing a processor to perform the method of distributed transaction processing in a distributed database according to any of claims 1-8.
CN202311521328.3A 2023-11-15 2023-11-15 Distributed transaction processing method, device and medium in distributed database Pending CN117742899A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311521328.3A CN117742899A (en) 2023-11-15 2023-11-15 Distributed transaction processing method, device and medium in distributed database

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311521328.3A CN117742899A (en) 2023-11-15 2023-11-15 Distributed transaction processing method, device and medium in distributed database

Publications (1)

Publication Number Publication Date
CN117742899A true CN117742899A (en) 2024-03-22

Family

ID=90258086

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311521328.3A Pending CN117742899A (en) 2023-11-15 2023-11-15 Distributed transaction processing method, device and medium in distributed database

Country Status (1)

Country Link
CN (1) CN117742899A (en)

Similar Documents

Publication Publication Date Title
CN102073540B (en) Distributed affair submitting method and device thereof
US20230012642A1 (en) Method and device for snapshotting metadata, and storage medium
CN114328132A (en) Method, device, equipment and medium for monitoring state of external data source
CN116756135B (en) Data cleaning method, device, equipment and medium
CN114780022B (en) Method and device for realizing additional writing operation, electronic equipment and storage medium
CN117742899A (en) Distributed transaction processing method, device and medium in distributed database
US11500857B2 (en) Asynchronous remote calls with undo data structures
CN114691781A (en) Data synchronization method, system, device, equipment and medium
CN113360689A (en) Image retrieval system, method, related device and computer program product
CN115907358B (en) Method, device and system for processing tasks to be handled and electronic equipment
CN114780021B (en) Copy repairing method and device, electronic equipment and storage medium
CN118503298B (en) Data processing method, device, equipment and storage medium based on double caches
CN118152095A (en) Device switching method, device, equipment and medium for database service
CN117520456A (en) Data synchronization method and device, electronic equipment and storage medium
CN116405544A (en) Micro-service data processing method and device, electronic equipment and medium
CN116974825A (en) Backup method, device, equipment and storage medium
CN115629910B (en) Transaction recovery method, device, database node and medium
CN114637738A (en) Data visibility judgment method and device, database node and medium
CN113569144B (en) Method, device, equipment, storage medium and program product for searching promotion content
CN115640361A (en) Data processing method, device, equipment and storage medium between isomorphic databases
CN116302371A (en) Transaction visibility judging method, device, equipment and storage medium
CN116431394A (en) Checkpoint construction method and device, electronic equipment and storage medium
CN115934738A (en) Distributed data writing method, device, equipment and storage medium
CN115454725A (en) Database backup method and device, electronic equipment and storage medium
CN118227709A (en) Breakpoint processing method, device, equipment and medium in database synchronization

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination