CN113296896B - Distributed transaction processing method, device and equipment - Google Patents

Distributed transaction processing method, device and equipment Download PDF

Info

Publication number
CN113296896B
CN113296896B CN202010526407.3A CN202010526407A CN113296896B CN 113296896 B CN113296896 B CN 113296896B CN 202010526407 A CN202010526407 A CN 202010526407A CN 113296896 B CN113296896 B CN 113296896B
Authority
CN
China
Prior art keywords
transaction
branch
distributed
distributed transaction
application server
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.)
Active
Application number
CN202010526407.3A
Other languages
Chinese (zh)
Other versions
CN113296896A (en
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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010526407.3A priority Critical patent/CN113296896B/en
Publication of CN113296896A publication Critical patent/CN113296896A/en
Application granted granted Critical
Publication of CN113296896B publication Critical patent/CN113296896B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing

Abstract

The embodiment of the application provides a distributed transaction processing method, a device and equipment, wherein the method comprises the following steps: under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction; and when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode. The application simplifies the implementation of the application server, and therefore the upgrading, operation and maintenance costs of the application server are reduced.

Description

Distributed transaction processing method, device and equipment
Technical Field
The present application relates to the field of computer technologies, and in particular, to a distributed transaction processing method, apparatus, and device.
Background
A distributed transaction may refer to a transaction in which operations involve multiple databases, the distributed transaction corresponds to multiple branch transactions, and each branch transaction may operate on a corresponding database.
Generally, in order to ensure consistency of distributed transactions during processing of the distributed transactions, the application server needs to determine whether to end the distributed transactions in a commit or rollback manner according to feedback information of each branch transaction. And when determining that the distributed transaction is ended in a rollback mode, the application server needs to control all the branch transactions to conduct rollback of the time-sharing transaction.
However, the way that the application server controls the branch transaction to commit or rollback to end the branch transaction has the problems of complex implementation of the application server and high upgrading, operation and maintenance costs.
Disclosure of Invention
The embodiment of the application provides a distributed transaction processing method, a distributed transaction processing device and distributed transaction processing equipment, and is used for solving the problems that an application server in the prior art is complex to implement and high in upgrading and operation and maintenance costs.
In a first aspect, an embodiment of the present application provides a distributed transaction processing method, which is applied to a transaction control server, and the method includes:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction;
and when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
In a second aspect, an embodiment of the present application provides a distributed transaction processing method, which is applied to an application server, and the method includes:
initiating a distributed transaction, the distributed transaction corresponding to a plurality of branch transactions;
and ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
In a third aspect, an embodiment of the present application provides a distributed transaction processing method, which is applied to a transaction control server, and the method includes:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment;
and when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
In a fourth aspect, an embodiment of the present application provides a distributed transaction processing method, which is applied to an application server, and the method includes:
initiating a distributed transaction corresponding to a transaction service request sent by user equipment, the distributed transaction corresponding to a plurality of branch transactions;
and ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
In a fifth aspect, an embodiment of the present application provides a distributed transaction processing apparatus, which is applied to a transaction control server, and the apparatus includes:
the determining module is used for determining a plurality of branch transactions corresponding to the distributed transactions under the condition that the application server initiates the distributed transactions;
and the control module is used for controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when the distributed transaction is determined to need to be ended so that the ending mode of the branch transaction is consistent with the target ending mode.
In a sixth aspect, an embodiment of the present application provides a distributed transaction processing apparatus, which is applied to an application server, and the apparatus includes:
an initiating module for initiating a distributed transaction, the distributed transaction corresponding to a plurality of branch transactions;
and the ending module is used for ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, and the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
In a seventh aspect, an embodiment of the present application provides a distributed transaction processing apparatus, which is applied to a transaction control server, and the method includes:
the determining module is used for determining a plurality of branch transactions corresponding to the distributed transactions under the condition that the application server initiates the distributed transactions; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment;
and the control module is used for controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when the distributed transaction is determined to need to be ended so that the ending mode of the branch transaction is consistent with the target ending mode.
In an eighth aspect, an embodiment of the present application provides a distributed transaction processing apparatus, which is applied to an application server, and the method includes:
the system comprises an initiating module, a processing module and a processing module, wherein the initiating module is used for initiating a distributed transaction corresponding to a transaction service request sent by user equipment, and the distributed transaction corresponds to a plurality of branch transactions;
and the ending module is used for ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, and the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
In a ninth aspect, an embodiment of the present application provides a transaction control server, including: a memory, a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of the first aspects.
In a tenth aspect, an embodiment of the present application provides an application server, including: a memory, a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of the second aspects.
In an eleventh aspect, an embodiment of the present application provides a transaction control server, including: a memory, a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of the third aspects.
In a twelfth aspect, an embodiment of the present application provides an application server, including: a memory, a processor; wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of the fourth aspects.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program, the computer program comprising at least one code, which is executable by a computer to control the computer to perform the method according to any one of the first aspect.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program, the computer program comprising at least one code, which is executable by a computer to control the computer to perform the method according to any one of the second aspect.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program, the computer program comprising at least one code, which is executable by a computer to control the computer to perform the method according to any one of the third aspects.
Embodiments of the present application also provide a computer-readable storage medium, which stores a computer program, where the computer program includes at least one code segment that can be executed by a computer to control the computer to perform the method according to any one of the fourth aspect.
Embodiments of the present application also provide a computer program, which is used to implement the method according to any one of the first aspect when the computer program is executed by a computer.
Embodiments of the present application also provide a computer program, which is used to implement the method according to any one of the second aspect when the computer program is executed by a computer.
Embodiments of the present application also provide a computer program, which is used to implement the method according to any one of the third aspect when the computer program is executed by a computer.
An embodiment of the present application further provides a computer program, which is used to implement the method according to any one of the fourth aspect when the computer program is executed by a computer.
According to the distributed transaction processing method, the device and the equipment provided by the embodiment of the application, the multiple branch transactions corresponding to the distributed transactions are determined under the condition that the application server initiates the distributed transactions, when the distributed transactions are determined to be required to be ended, the ending of the branch transactions corresponding to the distributed transactions is controlled based on the target ending mode of the distributed transactions, so that the ending mode of the branch transactions is consistent with the target ending mode, the transaction control server provides the service for ending control over the branch transactions corresponding to the distributed transactions to the application server after the application server initiates the distributed transactions, compared with the method that the application server controls the branch transactions to be submitted or rolled back to end the branch transactions, the implementation of the application server is simplified, and the upgrading, operation and maintenance costs of the application server are reduced.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1A and fig. 1B are schematic views of application scenarios according to an embodiment of the present application;
fig. 2 is a schematic flow chart of a distributed transaction processing method according to an embodiment of the present application;
FIG. 3 is a diagram of an application server implemented based on a TM module and a RM module according to an embodiment of the present application;
fig. 4 is a schematic diagram of a distributed transaction processing method provided by an application server shown in fig. 3 according to an embodiment of the present application;
fig. 5 is a schematic diagram of a distributed transaction processing method in an AT mode according to an embodiment of the present application;
fig. 6 is a schematic diagram of a distributed transaction processing method in XA mode according to an embodiment of the present application;
FIG. 7 is a diagram illustrating a distributed transaction processing method in TCC mode according to an embodiment of the present application;
fig. 8 is a schematic diagram of a distributed transaction processing method in the Saga mode according to an embodiment of the present application;
fig. 9 is a schematic diagram of a distributed transaction processing method in a mixed mode according to an embodiment of the present application;
fig. 10 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application;
fig. 11 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application;
fig. 12 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application;
fig. 13 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application;
fig. 14 is a schematic structural diagram of a distributed transaction processing apparatus according to an embodiment of the present application;
fig. 15 is a schematic structural diagram of a transaction control server according to an embodiment of the present application;
fig. 16 is a schematic structural diagram of a distributed transaction processing apparatus according to another embodiment of the present application;
fig. 17 is a schematic structural diagram of an application server according to an embodiment of the present application;
fig. 18 is a schematic structural diagram of a distributed transaction processing apparatus according to yet another embodiment of the present application;
fig. 19 is a schematic structural diagram of a transaction control server according to another embodiment of the present application;
fig. 20 is a schematic structural diagram of a distributed transaction processing apparatus according to yet another embodiment of the present application;
fig. 21 is a schematic structural diagram of an application server according to another embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The terminology used in the embodiments of the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the examples of this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, and "a" and "an" typically include at least two, but do not exclude the presence of at least one.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in an "or" relationship.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a good or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such good or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a commodity or system that includes the element.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
For the convenience of those skilled in the art to understand the technical solutions provided in the embodiments of the present application, a technical environment for implementing the technical solutions is described below.
A distributed transaction processing method commonly used in the related art mainly includes that an application server controls a branch transaction to commit or rollback to end the branch transaction, and there are problems of complex implementation of the application server and high upgrade, operation and maintenance costs.
Based on the actual technical requirements similar to those described above, the distributed transaction processing method provided by the application can simplify the implementation of the application server by using a technical means, and reduce the upgrading, operation and maintenance costs of the application server.
The following describes a distributed transaction processing method provided in various embodiments of the present application in detail through an exemplary application scenario.
As shown in fig. 1A, the user device 11 may send a service request to the application server 12 according to a user input, for example, the service request is sent by the user device 11 based on an e-commerce transaction task triggered by a user, the service request may specifically be an e-commerce service request, and the service request may include a commodity identifier, a user identifier, and a commodity number, of course, in other embodiments, the service request may also be of other types, which is not limited in this application. The user equipment 11 may be, for example, a mobile phone, a tablet computer, a notebook computer, or the like, and certainly, in other embodiments, the user equipment may also be other types of equipment, which is not limited in this application.
After receiving the service request, the application server 12 may complete a corresponding operation based on a transaction corresponding to the service request, where the application server 12 may include any form of data processing server such as a cloud server, a distributed server, and the like. Assuming that the service request corresponds to distributed transaction X, and distributed transaction X corresponds to branch transaction 1, branch transaction 2, and branch transaction 3, application server 12 may initiate distributed transaction X after receiving the service request, and after initiating distributed transaction X, application server 12 may call branch transaction 1, branch transaction 2, and branch transaction 3 to perform the corresponding operations by the branch transaction. As shown in FIG. 1A, branch transaction 1 and branch transaction 2 may manipulate data in database 13 during execution operations, and branch transaction 3 may manipulate data in database 14 during execution operations.
Taking the example that the service request is sent by the user device 11 based on the user-triggered e-commerce transaction task, branch transaction 1 corresponding to distributed transaction X may be used to provide inventory service, branch transaction 2 may be used to provide order service, and branch transaction 3 may be used to provide account service. Based on this, the application server 12 may invoke branch transaction 1 to deduct inventory based on the item identification and the amount of the item, may invoke branch transaction 2 to generate an order record based on the item identification, the amount of the item, and the user identification, and may invoke branch transaction 3 to deduct account balance based on the item identification, the amount of the item, and the user identification.
Specifically, the transaction control server 15 determines a plurality of branch transactions, namely branch transactions 1, 2, and 3, corresponding to the distributed transaction X when the application server 12 initiates the distributed transaction X, and controls the end of the branch transaction corresponding to the distributed transaction X based on a target end mode of the distributed transaction X when it is determined that the distributed transaction X needs to be ended, so that the end mode of the branch transaction is consistent with the target end mode. It will be appreciated that the target ending mode of the distributed transaction X may be Commit (Commit) or Rollback (Rollback). Accordingly, after initiating the distributed transaction X, the application server 12 may end the branch transaction corresponding to the distributed transaction X according to the control of the transaction control server 15. Based on this, on the basis of ensuring that the ending mode of the branch transaction corresponding to the distributed transaction X is consistent with the target ending mode of the distributed transaction, the transaction control server 15 can control the ending of the branch transaction corresponding to the distributed transaction in the application server 12, that is, the transaction control server 15 provides the service for controlling the ending of the branch transaction corresponding to the distributed transaction to the application server 12, and compared with the case that the application server 12 controls the branch transaction to commit or roll back to end the branch transaction, the implementation of the application server 12 is simplified, and therefore the upgrading and operation and maintenance costs of the application server 12 are reduced.
In fig. 1A, the application server 12 is taken as a stand-alone form, and optionally, the application server 12 may also be implemented in a distributed form. As shown in fig. 1B, the service request sent by the user equipment may correspond to a distributed transaction X, and a branch transaction 1, a branch transaction 2, and a branch transaction 3 corresponding to the distributed transaction X may be invoked by different application servers 12 for execution, where the application server 12 in communication with the user equipment 11 in the three application servers 12 of fig. 1B may communicate with the other two application servers 12. It should be noted that the distribution relationship of the branch transactions and the number of the application servers 12 in fig. 1B are examples.
It should be noted that, in fig. 1A and 1B, the number of the application servers 12 served by the transaction control server 15 is taken as an example, and it is understood that the number of the application servers 12 served by the transaction control server 15 may be plural.
It should be noted that, in fig. 1A and fig. 1B, the data of the branch transaction operation is stored in the database as an example, it is to be understood that the data of the branch transaction operation may also be stored in other locations than the database, for example, the data of the branch transaction operation may also be stored in a file storage system, which is not limited in this application. For convenience of description, the present application mainly takes the example that the data of the branch transaction operation is stored in the database, and the detailed description is given.
Some embodiments of the present application will be described in detail below with reference to the accompanying drawings. The embodiments described below and the features of the embodiments can be combined with each other without conflict.
Fig. 2 is a schematic flow diagram of a distributed transaction processing method according to an embodiment of the present application, and as shown in fig. 2, the method according to the embodiment may include:
step 201, an application server initiates a distributed transaction, wherein the distributed transaction corresponds to a plurality of branch transactions;
step 202, the transaction control server determines the multiple branch transactions corresponding to the distributed transaction when the application server initiates the distributed transaction;
step 203, when determining that the distributed transaction needs to be ended, the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode;
and step 204, the application server ends the branch transaction corresponding to the distributed transaction according to the control of the transaction control server.
In the embodiment of the present application, a distributed Transaction may also be referred to as a Global Transaction (Global Transaction), and there is a correspondence relationship between the distributed Transaction and a plurality of Branch transactions (Branch transactions). The application server may receive a service request sent by the user device 11, determine a distributed transaction corresponding to the service request, and initiate the distributed transaction.
After initiating a distributed transaction, the application server may invoke a plurality of branch transactions corresponding to the distributed transaction, where the plurality of branch transactions may be in a parallel relationship, or the plurality of branch transactions may also have an invoking relationship, which is not limited in this application. Multiple branch transactions corresponding to the distributed transaction can correspond to different databases, and the branch transactions are used for operating data in the corresponding databases.
Illustratively, as shown in FIG. 3, the application server 12 may include a Transaction Management (TM) module 12A and a plurality of Resource Management (RM) modules 12A, each of which may be implemented as a software module of the application server 12A and RM module 12B. Where TM module 12A may be used to define the boundaries of a distributed transaction, in one embodiment TM module 12A may define when to initiate the distributed transaction and when to end the distributed transaction. The RM module 12B may be used to define branch transactions, and in one embodiment the RM module 12B may define which branch transactions are specifically to be executed under a distributed transaction, and how the branch transactions are specifically executed. Multiple RM modules 12B may correspond one-to-one with multiple databases.
It should be noted that, for the scenario shown in fig. 1B, the boundary of the distributed transaction corresponding to the service request sent by a user equipment may be defined by the application server, which receives the service request sent by the user equipment, in the multiple application servers 12.
It should be noted that the specific implementation manner of the application server 12 in fig. 3 is only an example, and in other embodiments, the application server 12 may implement the distributed transaction and the corresponding branch transaction in other manners. For convenience of description, the following description will be mainly made by taking an example in which the application server 12 includes a TM module and an RM module.
Corresponding to fig. 3, the relationship of TM module 12A, RM module 12B, distributed transactions, and branch transactions may be as shown in fig. 4. Referring to fig. 4, in correspondence with a distributed transaction, TM module 12A may define an initiation boundary (i.e., when the distributed transaction is initiated) and an end boundary (i.e., when the distributed transaction is ended) of the distributed transaction, and after TM module 12A initiates the distributed transaction, corresponding operations may be performed by a branch transaction corresponding to the distributed transaction as defined by RM module 12B before the distributed transaction is ended.
It should be noted that, in fig. 4, for example, the number of RM modules 12B involved in one distributed transaction is two, and one RM module may define one or more branch transactions corresponding to the distributed transaction.
It should be noted that, since both TM module 12A and RM module 12B are implemented by an application server, the end boundary of the distributed transaction is defined by TM module 12A, so that the distributed transaction can be ended as early as possible. It will be appreciated that, alternatively, to simplify the implementation of TM module 12A, TM module 12A may define only the initiation boundary of the distributed transaction, while the end boundary may be controlled entirely by the transaction control server, e.g., the transaction control server may control the end of the distributed transaction after the transaction timeout time is reached.
The application server is in communication connection with the transaction control server, and the transaction control server can determine a plurality of branch transactions corresponding to the distributed transactions in the application server when the application server initiates the distributed transactions.
Illustratively, as shown in fig. 4, TM module 12A, upon initiating a distributed transaction, may send an initiation message to the transaction control server, which may be used to indicate initiation of the distributed transaction. The transaction control server may assign a transaction identification (which may be denoted as TID) to the distributed transaction initiated by TM module 12A based on the initiation message, the transaction identification being used to uniquely identify the distributed transaction, and return the transaction identification to TM module 12A. Thus, transaction control server and TM module 12A may determine that TM module 12A initiated the distributed transaction identified by the transaction identification, enabling both transaction control server and TM module 12A to align an understanding of the distributed transaction initiated by TM module 12A.
Referring to fig. 4, TM module 12A, after obtaining the transaction identification for the distributed transaction, may pass the transaction identification to RM module 12B so that RM module 12B may determine that the branch transaction corresponding to the distributed transaction initiated by TM module 12A is the branch transaction corresponding to the distributed transaction identified by the transaction identification, thereby enabling both the transaction control server and RM module 12B to align the understanding of the distributed transaction initiated by TM module 12A.
After RM module 12B obtains the transaction identification, as shown in fig. 4, RM module 12B may register the branch transaction corresponding to the distributed transaction identified by the transaction identification with the transaction control server. In one embodiment, RM module 12B may send a registration message to the transaction control server for a branch transaction corresponding to the distributed transaction, where the registration message may include the transaction identifier, and the transaction control server may assign a branch identifier (may be abbreviated as BID) to the branch transaction for which RM module 12B requested registration according to the registration message, where the branch identifier is used to uniquely identify the branch transaction of the distributed transaction, and return the branch identifier to RM module 12B. Thus, the transaction control server and RM module 12B may determine that the distributed transaction corresponds to a branch transaction identified by the branch identification, enabling both the transaction control server and RM module 12B to align an understanding of the branch transaction to which the distributed transaction corresponds.
As can be seen from fig. 4, the TM module 12A indicates to the transaction control server to initiate the distributed transaction, and the RM module 12B registers the branch transaction corresponding to the distributed transaction with the transaction control server, so that the transaction control server can determine a plurality of branch transactions corresponding to the distributed transaction initiated by the application server.
Alternatively, the application server may determine a correspondence between the distributed transaction initiated by the application server and the plurality of branch transactions, and send the correspondence to the transaction control server, so that the transaction control server can determine the plurality of branch transactions corresponding to the distributed transaction initiated by the application server. Based on this, in a multiple application server scenario, the application server needs to ensure the unique identification role of the transaction identification and the branch identification for the distributed transaction and its corresponding branch transaction.
Alternatively, the corresponding relationship between the distributed transaction initiated by the application server and the plurality of branch transactions may be determined by the application server and other devices except the transaction control server, in a manner similar to that determined by the transaction control server in fig. 4, and the corresponding relationship is sent to the transaction control server by the other devices, so that the transaction control server can determine the plurality of branch transactions corresponding to the distributed transaction initiated by the application server.
In this embodiment of the application, after initiating the distributed transaction, the application server may obtain an execution result of the branch transaction by executing an operation of the branch transaction corresponding to the distributed transaction, where the execution result may specifically be an execution failure or an execution success. It should be noted that the application server supports rollback of operations performed on branch transactions regardless of whether the execution of the branch transaction results in a successful execution or a failed execution.
In this embodiment of the present application, a processing procedure of a distributed transaction may be divided into two phases, where a first phase may obtain an execution result of the branch transaction for executing a corresponding operation of the branch transaction, and a second phase may determine a target ending manner of the distributed transaction based on the execution result of the branch transaction, and control ending of the branch transaction based on the target ending manner, so that an ending manner of the branch transaction is consistent with the target ending manner. The target ending manner of the distributed transaction may specifically be commit or rollback.
For example, when all the execution results of the branch transactions corresponding to the distributed transaction are successfully executed, it may be determined that the target ending manner of the distributed transaction is commit; when a branch transaction with an execution result of execution failure exists in the branch transactions corresponding to the distributed transaction, it may be determined that the target ending manner of the distributed transaction is rollback. Of course, in other embodiments, other manners may also be adopted to determine the target ending manner of the distributed transaction based on the execution result of the branch transaction, which is not limited in this application.
The end of the branch transaction is controlled based on the target end mode of the distributed transaction and is finished by the transaction control server. Specifically, when determining that the distributed transaction needs to be ended, the transaction control server may control the ending of the branch transaction corresponding to the distributed transaction based on the target ending manner of the distributed transaction, so that the ending manner of the branch transaction is consistent with the target ending manner.
Optionally, in the first phase, executing the branch transaction may complete a commit preparation operation. In the case that the branch transaction completes the commit preparation operation, further, in the second phase, the transaction control server may control the branch transaction to be committed if the target ending manner is commit, and in one embodiment, the transaction control server may send a commit command for the branch transaction to the application server, and the application server may perform a commit operation on the branch transaction according to the commit command of the branch transaction to implement the commit of the branch transaction; alternatively, the transaction control server may control the rollback of the branch transaction if the target termination mode is rollback, and in one embodiment, the transaction control server may send a rollback command for the branch transaction to the application server, and the application server may perform a rollback operation on the rollback transaction according to a commit command of the rollback transaction to implement the rollback of the branch transaction.
It should be noted that, since the branch transaction may indicate that the branch transaction has ended after performing the rollback operation or the commit operation according to the transaction control server, the rollback log for supporting rollback of the branch transaction does not need to be saved. Based on this, after the application server executes the rollback operation or the commit operation for a branch transaction according to the control of the transaction control server, the rollback log for supporting the rollback of the branch transaction may be deleted to save the storage space.
For example, as shown in fig. 4, in the second phase, the transaction control server may send a commit command for the branch transaction to RM module 12B, and RM module 12B may perform a commit operation on the branch transaction according to the commit command of the branch transaction to implement the commit of the branch transaction, where the commit command may include the transaction identifier of the distributed transaction and the branch identifier of the branch transaction to instruct RM module 12B to commit the branch transaction indicated by the transaction identifier + the branch identifier. Alternatively, as shown in fig. 4, in the second phase, the transaction control server may send a rollback command for the branch transaction to RM module 12B, and RM module 12B may perform a rollback operation on the branch transaction according to the rollback command of the branch transaction to implement the commit of the branch transaction, where the rollback command may include a transaction identifier of the distributed transaction and a branch identifier of the branch transaction to instruct RM module 12B to rollback the branch transaction indicated by the transaction identifier + the branch identifier.
Based on this, the execution result of the branch transaction is successful, and the successful execution of the commit preparation operation which can be rolled back by the branch transaction can be represented; the outcome of execution of a branch transaction is an execution failure, which may characterize a commit ready to execute failure that the branch transaction may roll back.
Alternatively, in the first phase, executing a branch transaction may complete a commit operation. In the second phase, in the case that the branch transaction completes the commit operation, the transaction control server may send a commit command for the branch transaction to the application server in the case that the target ending manner is commit, and the application server may perform a delete operation on the branch transaction according to the commit command of the branch transaction to delete the rollback log supporting rollback of the branch transaction; alternatively, the transaction control server may send a rollback command for the branch transaction to the application server, and the application server may perform a rollback operation on the rollback transaction according to a commit command of the rollback transaction to implement rollback of the branch transaction.
Based on this, the execution result of the branch transaction is successful, and the successful execution of the commit operation which can be rolled back by the branch transaction can be represented. Accordingly, the execution result of the branch transaction is an execution failure, which may characterize a commit operation execution failure that the branch transaction may roll back.
In this embodiment of the present application, optionally, the end of the distributed transaction may be triggered by the application server, that is, the application server may control an end boundary of the distributed transaction. Based on this, when determining that the distributed transaction needs to be ended, the application server may send an end message to the transaction control server, where the end message is used to indicate that the application server needs to end the distributed transaction. For example, referring to fig. 4, TM module 12A may send an end message to the transaction control server upon determining that the distributed transaction needs to be ended. Accordingly, before step 203, the transaction control server may receive an end message sent by the application server, and after receiving the end message, may control the end of the branch transaction corresponding to the distributed transaction based on the target end mode of the distributed transaction.
Further optionally, the target ending manner of the distributed transaction may be indicated by the application server, and based on this, the ending message may also be used to indicate the target ending manner. The ending message enables the application server to control the ending boundary of the distributed transaction, and the control capability of the application server for the distributed transaction is favorably ensured.
Alternatively, optionally, the application server may send the execution result of the branch transaction corresponding to the distributed transaction to the transaction control server, for example, referring to fig. 4, the RM module 12B may report the execution result of the branch transaction to the transaction control server. Further optionally, the transaction controller may determine a target ending manner of the distributed transaction based on an execution result of the branch transaction corresponding to the distributed transaction. The specific manner of determining the target ending manner of the distributed transaction according to the execution result of the branch transaction may refer to the foregoing related description, and is not described herein again.
Based on the foregoing detailed description, in a case that the target ending manner of the distributed transaction is commit, the transaction control server may send a commit command for the branch transaction corresponding to the distributed transaction to the application server, and in a case that the target ending manner of the distributed transaction is rollback, the transaction control server may send a rollback command for the branch transaction corresponding to the distributed transaction to the application server.
In one embodiment, the transaction control server may send a commit command or a rollback command for each of the plurality of branch transactions to which the distributed transaction corresponds, thereby facilitating simplified implementation.
Or, optionally, the sending, by the transaction control server, a rollback command for a branch transaction corresponding to the distributed transaction to the application server may specifically include: for each branch transaction in the multiple branch transactions, based on an execution result of each branch transaction, sending a rollback command for each branch transaction to the application server if it is determined that each branch transaction needs to perform a rollback operation. Based on the above, when the target ending mode is rollback, the rollback command can be sent for the branch transaction needing rollback operation, and the rollback command does not need to be sent for the branch transaction not needing rollback operation, so that the number of commands sent by the transaction control server to the application server can be reduced, and the bandwidth resources can be saved.
Considering that the execution result is the branch transaction successfully executed, when the target ending manner is rollback, rollback is usually required to be performed, so that when the distributed transaction ends in the rollback manner, the branch transaction corresponding to the distributed transaction also ends in the rollback manner. Based on this, the method provided in the embodiment of the present application may further include: and if the execution result of the branch transaction is successful, the transaction control server determines that the branch transaction needs to be rolled back.
Considering that a branch transaction implemented in a specific mode may be in a state of completed rollback if execution thereof results in execution failure, a rollback command may not need to be sent by the transaction control server for such branch transaction. Based on this, the method provided in the embodiment of the present application may further include: if the execution result of the branch transaction is execution failure and the transaction mode of the branch transaction is a first preset mode, the transaction control server determines that the branch transaction needs to be rolled back. The transaction mode of the branch transaction is a first preset mode, which can represent that the branch transaction is not finished to roll back when the execution result of the branch transaction is an execution failure. The first preset mode may be, for example, an Automatic Transaction (AT) mode, where the AT mode is a distributed Transaction mode provided by the open-source distributed Transaction framework data, and of course, in other embodiments, the first preset mode may also be another mode, which is not limited in this application.
Or, optionally, the sending, by the transaction control server, a commit command for the branch transaction corresponding to the distributed transaction to the application server may specifically include: for each of the plurality of branch transactions, sending a commit command to the application server for each of the branch transactions if it is determined that each of the branch transactions requires further operations. Based on the above, when the target ending mode is commit, the commit command can be sent for the branch transaction which needs to be further operated, and the commit command does not need to be sent for the branch transaction which does not need to be further operated, so that the number of commands sent to the application server by the transaction control server can be reduced, and the bandwidth resource can be saved.
A branch transaction may be a status of outstanding commit in the event that execution results in successful execution given that the branch transaction is implemented in a particular mode. For such branch transactions, the transaction control server may send a commit command for the branch transaction to commit. Based on this, the method provided in the embodiment of the present application may further include: and if the transaction mode of the branch transaction is a second preset mode, determining that the branch transaction needs to be further operated. The transaction mode of the branch transaction is a second preset mode, which can represent that the branch transaction is not completed and submitted under the condition that the execution result of the branch transaction is successful; the further operations include a commit operation to complete the commit of the branch transaction. The second preset mode may be, for example, a trial-Confirm-Cancel (TCC) mode, but in other embodiments, the second preset mode may also be other modes, which is not limited in this application.
Considering that a branch transaction implemented in a specific mode has a successful execution result, the branch transaction is in a committed state, but needs to be triggered by the transaction control server in real time to delete the rollback log for the branch transaction. For such branch transactions, the transaction control server may send a commit command for the branch transaction to perform further delete operations. Based on this, the method provided in the embodiment of the present application may further include: and if the transaction mode of the branch transaction is a third preset mode, determining that the branch transaction needs to be further operated. The transaction mode of the branch transaction is a third preset mode, which can represent that the branch transaction has completed a commit operation but needs to delete a rollback log for the branch transaction when the execution result of the branch transaction is successful; the further operations include a delete operation to delete the rollback log. The third preset mode may be, for example, an AT mode, and certainly, in other embodiments, the second preset mode may also be other modes, which is not limited in this application.
In addition, considering that there are also branch transactions implemented in a specific mode, in case the execution result is successful, the branch transactions are in a committed state and the rollback log does not need to be deleted. For such branch transactions, the transaction control server may not need to send a commit command. The specific mode may be, for example, a Saga mode, which may also be referred to as a Long-running-transaction (Long-running-transaction) mode, and of course, in other embodiments, the second preset mode may also be another mode, which is not limited in this application.
Hereinafter, the implementation of the embodiment of the present application will be specifically described by taking the example that the transaction mode of the branch transaction corresponding to the distributed transaction is AT mode, XA mode, TCC mode, and Saga mode.
Referring to fig. 5, when the transaction mode of the branch transaction is the AT mode, the interaction between the TM module, the RM module, and the transaction control server may specifically include the following steps:
first, TM module 12A sends an initiation message to the transaction control server when initiating a distributed transaction, and obtains the TID allocated by the transaction control server for the distributed transaction.
Second, the TM module 12A binds the TID of the distributed transaction to the branch transaction corresponding to the distributed transaction.
For example, the TM module 12A may pass the TID of the distributed transaction as a function entry parameter when invoking the distributed transaction implemented by the RM module 12B corresponding to the branch transaction, so as to implement binding the TID of the distributed transaction to the branch transaction corresponding to the distributed transaction.
Again, the RM module 12B operates as an AT module, and the processing sub-module of the RM module 12B may perform the following steps:
step a1, before executing a Structured Query Language (SQL) statement operation corresponding to a branch transaction corresponding to the distributed transaction, record mirror data of a data unit that needs to be operated by the SQL statement, where the mirror data may be marked as front mirror data.
Step A2, call the SQL statement to operate the corresponding database.
Step a3, after the SQL statement is called, the mirror image data of the data unit operated by the SQL statement is recorded again, and the mirror image data may be recorded as the mirror image data.
Step a4, register the branch transaction with the transaction control server, and obtain the BID allocated by the transaction control server for the branch transaction, so as to associate the branch transaction with the distributed transaction identified by the TID.
It should be noted that there is no restriction on the order between step a4 and step a 1-step A3.
Step A5, writing the TID of the distributed transaction, the BID of the branch transaction, and the front mirror image data and the back mirror image data of the branch transaction as rollback logs into a database corresponding to the RM module.
Step A6, commit locally to the branch transaction.
In step A7, after the branch transaction is committed, the RM module reports the execution result of the branch transaction, i.e. whether the local commit is successful or not, to the transaction control server.
TM module 12A then sends an end message to the transaction control server upon determining that the distributed transaction needs to be ended.
Wherein the end message may include the TID of the distributed transaction, the end message may be used to indicate that the target ending mode of the distributed transaction is commit or rollback.
Thereafter, the transaction control server sends an end command to the RM module 12B according to the end message.
Wherein the end command may include the TID of the distributed transaction and the BID of the branch transaction. In the case that the end message indicates that the target end mode is rollback, the end command may specifically be a rollback command; in the case that the end message indicates that the target end mode is commit, the end command may specifically be a commit command.
Further, the RM module searches for a corresponding rollback log record from the corresponding database according to an end command sent by the transaction control server.
Finally, the rollback sub-module of the RM module 12B may perform a rollback operation according to the rollback log if the end command is a rollback command; the commit submodule of the RM module 12B may perform a delete operation for deleting the rollback log in case the end command is a commit command.
Optionally, the RM module 12B may send the response result to the end command to the transaction control server, so that the transaction control server performs relevant statistics.
Referring to fig. 6, in the case that the transaction mode of the branch transaction is XA mode, the interaction between the TM module, the RM module, and the transaction control server may specifically include the following steps:
first, TM module 12A sends an initiation message to the transaction control server when initiating a distributed transaction, and obtains the TID allocated by the transaction control server for the distributed transaction.
Second, the TM module 12A binds the TID of the distributed transaction to the branch transaction corresponding to the distributed transaction.
It should be noted that the first two steps are similar to fig. 5, and are not described again here.
Again, the RM module 12B works as XA module:
step B1, register the branch transaction with the transaction control server and obtain the BID allocated by the transaction control server for the branch transaction, so as to associate the branch transaction with the distributed transaction identified by the TID.
And step B2, generating an identifier XID which is needed to be used by the operation database in the XA mode according to the BID, and starting the XA based on the XID.
And step B3, executing the SQL statement operation corresponding to the branch transaction to the database.
Step B4, close XA based on XID.
Step B5, an XA Prepare (Prepare) operation is performed.
Step B6, after the completion of the XA Prepare operation, reports the execution result of the branch transaction, i.e. whether XA Prepare succeeded or not, to the transaction control server.
TM module 12A then sends an end message to the transaction control server upon determining that the distributed transaction needs to be ended.
It should be noted that, for a specific description of this step, reference may be made to the corresponding description in fig. 5, and details are not repeated here.
Thereafter, the transaction control server sends an end command to the RM module 12B according to the end message.
It should be noted that, for a specific description of this step, reference may be made to the corresponding description in fig. 5, which is not described herein again.
Further, RM module 12B generates a corresponding XID based on the BID of the branch transaction.
Finally, the RM module 12B performs an XA rollback operation according to the generated XID in the case where the end command is a rollback command; RM module 12B performs an XA commit operation according to the generated XID in the event the end command is a submit command.
Optionally, the RM module 12B may send the response result to the end command to the transaction control server, so that the transaction control server performs relevant statistics.
Referring to fig. 7, in case that the transaction mode of the branch transaction is TCC mode, the interaction between the TM module, the RM module, and the transaction control server may specifically include the following steps:
first, TM module 12A sends an initiation message to the transaction control server when initiating a distributed transaction, and obtains the TID allocated by the transaction control server for the distributed transaction.
Second, the TM module 12A binds the TID of the distributed transaction to the branch transaction corresponding to the distributed transaction.
It should be noted that the first two steps are similar to fig. 5, and are not described again here.
Again, the RM module 12B operates according to the TCC module:
step C1, register the branch transaction with the transaction control server and obtain the BID allocated by the transaction control server for the branch transaction, so as to associate the branch transaction with the distributed transaction identified by the TID.
Step C2, call the predefined Try (Try) method and use BID as the input parameter to the Try method.
In step C3, after the Try method is executed, the RM module 12B reports the execution result of Try method to the transaction control server.
TM module 12A then sends an end message to the transaction control server upon determining that the distributed transaction needs to be ended.
It should be noted that, for a specific description of this step, reference may be made to the corresponding description in fig. 5, and details are not repeated here.
Thereafter, the transaction control server sends an end command to the RM module 12B according to the end message.
It should be noted that, for a specific description of this step, reference may be made to the corresponding description in fig. 5, which is not described herein again.
Further, the RM module 12B calls a predefined Confirm (Confirm) method in case the end command is a commit command, calls a predefined Cancel (Cancel) method in case the end command is a rollback command, and takes the BID as a method entry parameter.
Finally, the RM module 12B executes the Confirm method or the Cancel method.
Optionally, the RM module 12B may send the response result to the end command to the transaction control server, so that the transaction control server performs relevant statistics.
Referring to fig. 8, in the case that the transaction mode of the branch transaction is the Saga mode, the interaction among the TM module, the RM module, and the transaction control server may specifically include the following steps:
first, TM module 12A sends an initiation message to the transaction control server when initiating a distributed transaction, and obtains the TID allocated by the transaction control server for the distributed transaction.
Second, the TM module 12A binds the TID of the distributed transaction to the branch transaction corresponding to the distributed transaction.
It should be noted that the first two steps are similar to fig. 5, and are not described again here.
Again, RM module 12B works according to the Saga module:
step D1, register the branch transaction with the transaction control server, and obtain the BID allocated by the transaction control server for the branch transaction, so as to associate the branch transaction with the distributed transaction identified by the TID.
Step D2, calling the predefined forward implementation method and using BID as the entry parameter of the forward implementation method to execute the forward operation of the branch transaction.
In step D3, after the forward operation is completed, the RM module 12B reports the execution result of the forward operation to the transaction control server.
TM module 12A then sends an end message to the transaction control server upon determining that the distributed transaction needs to be ended.
It should be noted that, for a specific description of this step, reference may be made to the corresponding description in fig. 5, which is not described herein again.
Thereafter, the transaction control server sends an end command to the RM module 12B according to the end message.
As shown in fig. 8, the end command sent by the transaction control server to RM module 12B is a rollback command, i.e. when the target end mode is a commit mode, the transaction control server does not need to send a commit command to RM module 12B.
Further, the RM module 12B invokes a predefined reverse implementation method according to the end command sent by the transaction control server, and uses the BID as an entry parameter of the reverse implementation method to execute a reverse rollback operation of the branch transaction.
Similarly, the RM module 12B may send the response result to the end command to the transaction control server for the transaction control server to make relevant statistics.
In the embodiment of the present application, the transaction modes of the multiple branch transactions may be the same, for example, the transaction modes of the multiple branch transactions in fig. 5 are all AT mode, the multiple branch transactions in fig. 6 are all XA mode, the multiple branch transactions in fig. 7 are all TCC mode, and the multiple branch transactions in fig. 8 are all Saga mode.
Alternatively, optionally, the transaction modes of the multiple branch transactions may be different, that is, the distributed transaction may be implemented as a mixed mode, and the flexibility of implementing the branch transactions corresponding to the distributed transaction may be improved by the difference in the transaction modes of the multiple branch transactions, so that a developer may flexibly design the respective transaction modes of the distributed transaction corresponding to the branch transactions according to requirements.
Taking a TCC mode and an AT mode as an example, as shown in fig. 9, one RM module involved in the distributed transaction may operate according to the AT mode, another RM module involved in the distributed transaction may operate according to the TCC mode, and the specific manner in which the RM module operates according to a single mode in the mixed mode shown in fig. 9 may refer to the foregoing description in fig. 5 and fig. 7, and is not described herein again.
By the distributed transaction processing method provided by the embodiment of the application, the application server initiates the distributed transaction, the transaction control server determines a plurality of branch transactions corresponding to the distributed transaction when the application server initiates the distributed transaction, and controls the ending of the branch transactions corresponding to the distributed transaction based on the target ending mode of the distributed transaction when the distributed transaction needs to be ended, the application server ends the branch transactions corresponding to the distributed transaction according to the control of the transaction control server, and the transaction control server can control the ending of the branch transactions corresponding to the distributed transaction in the application server on the basis of ensuring that the ending mode of the branch transactions corresponding to the distributed transaction is consistent with the target ending mode of the distributed transaction, namely, the transaction control server provides the service for controlling the ending of the branch transactions corresponding to the distributed transaction to the application server, compared with the method that the application server controls the branch transaction to be submitted or rolled back to finish the branch transaction, the implementation of the application server is simplified, and the upgrading, operation and maintenance cost of the application server is reduced.
Fig. 10 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application, where an execution subject of the embodiment may be the transaction control server 15 in fig. 1A and 1B. As shown in fig. 10, the method of the present embodiment may include:
step 101, under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction;
and step 102, when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
It should be noted that, for specific contents of this embodiment, reference may be made to related descriptions at the transaction control server side in the embodiment shown in fig. 2, and details are not described here again.
According to the distributed transaction processing method provided by the embodiment of the application, under the condition that the application server initiates the distributed transaction, the multiple branch transactions corresponding to the distributed transaction are determined, when the distributed transaction is determined to be required to be ended, the ending of the branch transaction corresponding to the distributed transaction is controlled based on the target ending mode of the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode, the transaction control server provides the service for ending control of the branch transaction corresponding to the distributed transaction to the application server after the application server initiates the distributed transaction, compared with the condition that the application server controls the branch transaction to be submitted or rolled back to end the branch transaction, the implementation of the application server is simplified, and the upgrading and operation and maintenance costs of the application server are reduced.
Fig. 11 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application, where an execution subject of this embodiment may be the application server 12 in fig. 1A or the application server 12 in fig. 1B that communicates with a user equipment. As shown in fig. 11, the method of this embodiment may include:
step 111, initiating a distributed transaction, wherein the distributed transaction corresponds to a plurality of branch transactions;
and 112, ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
It should be noted that, for specific contents of this embodiment, reference may be made to related descriptions of the application server side in the embodiment shown in fig. 2, and details are not described here again.
According to the distributed transaction processing method provided by the embodiment of the application, the distributed transaction is initiated, the branch transaction corresponding to the distributed transaction is ended according to the control of the transaction control server, when the distributed transaction is determined to be ended, the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode, the service for ending the branch transaction provided by the application server by using the transaction control server is realized, the implementation of the application server is simplified, and the upgrading, operation and maintenance costs of the application server are reduced.
Fig. 12 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application, where an execution subject of the embodiment may be the transaction control server 15 in fig. 1A and 1B. As shown in fig. 12, the method of this embodiment may include:
step 121, determining a plurality of branch transactions corresponding to the distributed transaction when the application server initiates the distributed transaction; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment;
and step 122, when it is determined that the distributed transaction needs to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
It should be noted that, in this embodiment, a service request is a transaction service request in an e-commerce scenario, so that a distributed transaction in this embodiment corresponds to a transaction request sent by a user equipment, and specific contents of the distributed transaction processing may refer to related description on the transaction control server side in the embodiment shown in fig. 2, which is not described herein again.
By the distributed transaction processing method provided by the embodiment of the application, under the condition that the application server initiates the corresponding distributed transaction based on the transaction service request sent by the user equipment, a plurality of branch transactions corresponding to the distributed transaction are determined, when the distributed transaction is determined to be required to be ended, the ending of the branch transaction corresponding to the distributed transaction is controlled based on the target ending mode of the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode, the transaction control server provides the service for ending control over the branch transaction corresponding to the distributed transaction to the application server after the application server initiates the distributed transaction corresponding to the transaction service request, compared with the method that the application server in a shopping mall controls the branch transaction to be submitted or rolled back to end the branch transaction, the implementation of the application server in a shopping mall is simplified, and therefore, the upgrading, operation and maintenance costs of the application server in the E-market scene are reduced.
Fig. 13 is a flowchart illustrating a distributed transaction processing method according to another embodiment of the present application, where an execution subject of this embodiment may be the application server 12 in fig. 1A or the application server 12 in fig. 1B that communicates with a user equipment. As shown in fig. 13, the method of this embodiment may include:
step 131, initiating a distributed transaction corresponding to a transaction service request sent by a user equipment, wherein the distributed transaction corresponds to a plurality of branch transactions;
and step 132, ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
It should be noted that, in this embodiment, the service request is a transaction service request in an e-commerce scenario, so that the distributed transaction in the embodiment of the present application corresponds to a transaction request sent by a user equipment, and specific contents of the distributed transaction processing may refer to related description of the application server side in the embodiment shown in fig. 2, which is not described herein again.
The distributed transaction processing method provided by the embodiment of the application initiates the distributed transaction corresponding to the transaction service request sent by the user equipment, and ends the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, and the transaction control server controls the end of the branch transaction corresponding to the distributed transaction based on the target end mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the end mode of the branch transaction is consistent with the target end mode, the service of ending the branch transaction provided by the application server under the E-market scene by using the transaction control server is realized, the realization of the application server under the E-market scene is simplified, and the upgrading, operation and maintenance costs of the application server under the E-market scene are reduced.
Fig. 14 is a schematic structural diagram of a distributed transaction processing apparatus according to an embodiment of the present application; referring to fig. 14, this embodiment provides a distributed transaction processing apparatus, which may execute the method on the transaction control server side in the above-mentioned distributed transaction processing method, and specifically, the distributed transaction processing apparatus may include:
a determining module 141, configured to determine, when an application server initiates a distributed transaction, multiple branch transactions corresponding to the distributed transaction;
and the control module 142 is configured to, when it is determined that the distributed transaction needs to be ended, control the ending of the branch transaction corresponding to the distributed transaction based on the target ending manner of the distributed transaction, so that the ending manner of the branch transaction is consistent with the target ending manner.
Optionally, the apparatus further comprises: a first receiving module, configured to receive an end message sent by the application server, where the end message is used to indicate that the application server needs to end the distributed transaction.
Optionally, the end message is further used to indicate the target end mode.
Optionally, the control module 142 is specifically configured to send a rollback command for the branch transaction corresponding to the distributed transaction to the application server when the target ending manner is rollback.
Optionally, the apparatus further comprises: a second receiving module, configured to receive an execution result of the branch transaction corresponding to the distributed transaction sent by the application server;
the control module 142 is configured to send a rollback command for the branch transaction corresponding to the distributed transaction to the application server, and specifically includes: for each branch transaction in the multiple branch transactions, based on an execution result of each branch transaction, sending a rollback command for each branch transaction to the application server if it is determined that each branch transaction needs to perform a rollback operation.
Optionally, the control module 142 is further configured to determine that the branch transaction needs to be rolled back if the execution result of the branch transaction is successful or the execution result of the branch transaction is failed and the transaction mode of the branch transaction is the first preset mode; and when the transaction mode of the branch transaction is a first preset mode and the execution result of the branch transaction is the execution failure, the branch transaction is not finished to roll back.
Optionally, the control module 142 is specifically configured to send, to the application server, a commit command for the branch transaction corresponding to the distributed transaction, when the target ending manner is commit.
Optionally, the control module 142 is configured to send, to the application server, a commit command for the branch transaction corresponding to the distributed transaction, and specifically includes: for each of the plurality of branch transactions, sending a commit command to the application server for each of the branch transactions if it is determined that each of the branch transactions requires further operations.
Optionally, the control module 142 is further configured to determine that the branch transaction needs to be further operated if the transaction mode of the branch transaction is a second preset mode; the transaction mode of the branch transaction is a second preset mode, and the branch transaction is not completed and submitted under the condition that the execution result of the branch transaction is the execution success; the further operations include a commit operation to complete the commit of the branch transaction.
Optionally, the control module 142 is further configured to determine that the branch transaction needs to be further operated if the transaction mode of the branch transaction is a third preset mode; when the transaction mode of the branch transaction is a third preset mode, which represents that the execution result of the branch transaction is successful, the branch transaction completes the commit operation but needs to delete the rollback log for the branch transaction; the further operations include a delete operation to delete the rollback log.
Optionally, the transaction modes of the plurality of branch transactions are different.
Optionally, the number of the application servers is multiple.
The apparatus shown in fig. 14 may execute the method of the transaction control server side in the above method embodiment, and reference may be made to the related description of the above method embodiment for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the description in the above method embodiment, and are not described herein again.
In one possible implementation, the architecture of the distributed transaction device shown in FIG. 14 may be implemented as a transaction control server. As shown in fig. 15, the transaction control server may include: a processor 151 and a memory 152. Wherein, the memory 152 is used for storing a program supporting the transaction control server to execute the distributed transaction processing method provided in the above method embodiments, and the processor 151 is configured to execute the program stored in the memory 152.
The program comprises one or more computer instructions, wherein the one or more computer instructions, when executed by the processor 151, enable the following steps to be performed:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction;
and when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
Optionally, the processor 151 is further configured to execute all or part of the steps of the transaction control server side in the foregoing method embodiment.
The transaction control server may further include a communication interface 153 configured to communicate with other devices or a communication network.
Fig. 16 is a schematic structural diagram of a distributed transaction processing apparatus according to another embodiment of the present application; referring to fig. 16, this embodiment provides a distributed transaction processing apparatus, which may execute the method on the application server side in the above-mentioned distributed transaction processing method, and specifically, the distributed transaction processing apparatus may include:
an initiating module 161 configured to initiate a distributed transaction, where the distributed transaction corresponds to a plurality of branch transactions;
and an ending module 162, configured to end the branch transaction corresponding to the distributed transaction according to control of the transaction control server, where the transaction control server controls ending of the branch transaction corresponding to the distributed transaction based on a target ending manner of the distributed transaction when it is determined that the distributed transaction needs to be ended, so that an ending manner of the branch transaction is consistent with the target ending manner.
Optionally, the apparatus further includes a first sending module, configured to send an end message to the transaction control server when it is determined that the distributed transaction needs to be ended, where the end message is used to indicate that the application server needs to end the distributed transaction.
Optionally, the end message is further used to indicate the target end mode.
Optionally, when the target ending manner is rollback, the ending module 162 is specifically configured to receive a rollback command, which is sent by the transaction control server and is for the branch transaction corresponding to the distributed transaction; and performing a rollback operation on the branch transaction based on a rollback command of the branch transaction.
Optionally, the apparatus further includes a second sending module, configured to send an execution result of the branch transaction corresponding to the distributed transaction to the transaction control server, so that the transaction control server sends a rollback command for the branch transaction according to the execution result of the branch transaction when it is determined that the branch transaction needs to be rolled back.
Optionally, the execution result of the branch transaction is that the execution succeeds to represent that the commit operation that the branch transaction can roll back is successfully executed; the execution result of the branch transaction characterizes a commit operation execution failure that the branch transaction may roll back for an execution failure.
Optionally, the execution result of the branch transaction is successful execution of a commit preparation operation that successfully characterizes the rollback of the branch transaction; the execution result of the branch transaction characterizes a commit ready to execute failure for which the branch transaction may roll back for an execution failure.
Optionally, the ending module 162 is specifically configured to receive a commit command, which is sent by the transaction control server and is for the branch transaction corresponding to the distributed transaction; and performing further operations on the branch transaction based on a commit command of the branch transaction.
Optionally, the further operation comprises: a commit operation to complete the branch transaction commit, and/or a delete operation to delete the rollback log.
Optionally, the transaction modes of the plurality of branch transactions are different.
The apparatus shown in fig. 16 may perform the method of the application server side in the above method embodiment, and reference may be made to the related description of the above method embodiment for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the description in the above method embodiment, and are not described herein again.
In one possible implementation, the architecture of the distributed transaction device shown in FIG. 16 may be implemented as an application server. As shown in fig. 17, the application server may include: a processor 171 and a memory 172. The memory 172 is used for storing a program supporting the application server to execute the distributed transaction processing method provided in the above method embodiment, and the processor 171 is configured to execute the program stored in the memory 172.
The program comprises one or more computer instructions which, when executed by the processor 171, is capable of performing the steps of:
initiating a distributed transaction, the distributed transaction corresponding to a plurality of branch transactions;
and ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
Optionally, the processor 171 is further configured to perform all or part of the steps of the application server side in the foregoing method embodiment.
The application server may further include a communication interface 173 for communicating with other devices or a communication network.
Fig. 18 is a schematic structural diagram of a distributed transaction processing apparatus according to yet another embodiment of the present application; referring to fig. 18, this embodiment provides a distributed transaction processing apparatus, which may execute the method on the transaction control server side in the above-mentioned distributed transaction processing method, and specifically, the distributed transaction processing apparatus may include:
a determining module 181, configured to determine, when the application server initiates a distributed transaction, multiple branch transactions corresponding to the distributed transaction; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment;
and the control module 182 is configured to, when it is determined that the distributed transaction needs to be ended, control ending of a branch transaction corresponding to the distributed transaction based on a target ending manner of the distributed transaction, so that an ending manner of the branch transaction is consistent with the target ending manner.
The apparatus shown in fig. 18 may execute the method of the transaction control server side in the above method embodiment, and reference may be made to the related description of the above method embodiment for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the description in the above method embodiment, and are not described herein again.
In one possible implementation, the architecture of the distributed transaction device shown in FIG. 18 may be implemented as a transaction control server. As shown in fig. 19, the transaction control server may include: a processor 191 and a memory 192. The memory 192 is configured to store a program supporting the transaction control server to execute the distributed transaction processing method provided in the foregoing method embodiment, and the processor 191 is configured to execute the program stored in the memory 192.
The program comprises one or more computer instructions which, when executed by the processor 191, are capable of performing the steps of:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment;
and when the distributed transaction is determined to need to be ended, controlling the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction so that the ending mode of the branch transaction is consistent with the target ending mode.
Optionally, the processor 191 is further configured to perform all or part of the steps of the transaction control server side in the foregoing method embodiment.
The transaction control server may further include a communication interface 193 for communicating with other devices or a communication network.
Fig. 20 is a schematic structural diagram of a distributed transaction processing apparatus according to yet another embodiment of the present application; referring to fig. 20, this embodiment provides a distributed transaction processing apparatus, which may execute the method on the application server side in the above-mentioned distributed transaction processing method, and specifically, the distributed transaction processing apparatus may include:
an initiating module 201, configured to initiate a distributed transaction corresponding to a transaction service request sent by a user equipment, where the distributed transaction corresponds to multiple branch transactions;
an ending module 202, configured to end the branch transaction corresponding to the distributed transaction according to control of a transaction control server, where the transaction control server controls, when it is determined that the distributed transaction needs to be ended, ending of the branch transaction corresponding to the distributed transaction based on a target ending manner of the distributed transaction, so that an ending manner of the branch transaction is consistent with the target ending manner.
The apparatus shown in fig. 20 may perform the method of the application server side in the above method embodiment, and reference may be made to the related description of the above method embodiment for a part not described in detail in this embodiment. The implementation process and technical effect of the technical solution refer to the description in the above method embodiment, and are not described herein again.
In one possible implementation, the architecture of the distributed transaction device shown in FIG. 20 may be implemented as an application server. As shown in fig. 21, the application server may include: a processor 211 and a memory 212. Wherein, the memory 212 is used for storing the program supporting the application server to execute the application server side of the distributed transaction processing method provided in the above method embodiments, and the processor 211 is configured to execute the program stored in the memory 212.
The program comprises one or more computer instructions, wherein the one or more computer instructions, when executed by the processor 211, are capable of performing the steps of:
initiating a distributed transaction corresponding to a transaction service request sent by user equipment, the distributed transaction corresponding to a plurality of branch transactions;
and ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server, wherein the transaction control server controls the ending of the branch transaction corresponding to the distributed transaction based on the target ending mode of the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
Optionally, the processor 211 is further configured to perform all or part of the steps of the application server side in the foregoing method embodiments.
The application server may further include a communication interface 213 for the application server to communicate with other devices or a communication network.
In addition, the present application provides a computer storage medium for storing computer software instructions for a transaction control server, which includes a program for executing the distributed transaction processing method in the foregoing method embodiment, where the program is related to the transaction control server side.
The embodiment of the present application provides a computer storage medium, which is used for storing computer software instructions for an application server, and contains a program involved in executing the application server side of the distributed transaction processing method in the above method embodiment.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course, can also be implemented by a combination of hardware and software. With this understanding in mind, the above-described technical solutions and/or portions thereof that contribute to the prior art may be embodied in the form of a computer program product, which may be embodied on one or more computer-usable storage media having computer-usable program code embodied therein (including but not limited to disk storage, CD-ROM, optical storage, etc.).
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both permanent and non-permanent, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
Finally, it should be noted that: the above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

Claims (32)

1. A distributed transaction processing method is applied to a transaction control server, and is characterized by comprising the following steps:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction; the distributed transaction is initiated by the application server based on a service request sent by user equipment, the application server comprises a transaction management module and a resource management module, the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
when the distributed transaction is determined to need to be ended, sending a rollback or commit command corresponding to a target ending mode for the branch transaction corresponding to the distributed transaction to the application server so as to control the ending of the branch transaction corresponding to the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode;
the method further comprises the following steps: and determining the target ending mode based on the execution result of the branch transaction corresponding to the distributed transaction.
2. The method of claim 1, further comprising:
and receiving an end message sent by the application server, wherein the end message is used for indicating that the application server needs to end the distributed transaction.
3. The method of claim 2, wherein the end message is further configured to indicate the target end mode.
4. The method of any of claims 1-3, wherein controlling the end of the branch transaction corresponding to the distributed transaction based on the target end mode of the distributed transaction comprises:
and sending a rollback command for the branch transaction corresponding to the distributed transaction to the application server under the condition that the target ending mode is rollback.
5. The method of claim 4, wherein prior to sending the rollback command to the application server for the branch transaction corresponding to the distributed transaction, further comprising:
receiving an execution result of a branch transaction corresponding to the distributed transaction and sent by the application server;
the sending, to the application server, a rollback command for a branch transaction corresponding to the distributed transaction includes:
for each branch transaction in the multiple branch transactions, based on an execution result of each branch transaction, sending a rollback command for each branch transaction to the application server if it is determined that each branch transaction needs to perform a rollback operation.
6. The method of claim 5, further comprising:
if the execution result of the branch transaction is successful and the target ending mode is rollback, or the execution result of the branch transaction is failed and the transaction mode of the branch transaction is a first preset mode, determining that the branch transaction needs to be rolled back;
and when the transaction mode of the branch transaction is a first preset mode and the execution result of the branch transaction is the execution failure, the branch transaction is not finished to roll back.
7. The method of any of claims 1-3, wherein controlling the end of the branch transaction corresponding to the distributed transaction based on the target end mode of the distributed transaction comprises:
and sending a commit command aiming at the branch transaction corresponding to the distributed transaction to the application server under the condition that the target ending mode is commit.
8. The method of claim 7, wherein sending a commit command to the application server for the branch transaction corresponding to the distributed transaction comprises:
for each of the plurality of branch transactions, sending a commit command to the application server for each of the branch transactions if it is determined that each of the branch transactions requires further operations.
9. The method of claim 8, further comprising:
if the transaction mode of the branch transaction is a second preset mode, determining that the branch transaction needs to be further operated;
the transaction mode of the branch transaction is a second preset mode, and the branch transaction is not completed and submitted under the condition that the execution result of the branch transaction is the execution success; the further operations include a commit operation to complete the commit of the branch transaction.
10. The method of claim 8, further comprising:
if the transaction mode of the branch transaction is a third preset mode, determining that the branch transaction needs to be further operated;
the transaction mode of the branch transaction is a third preset mode, and the branch transaction completes the commit operation but needs to delete the rollback log of the branch transaction when the execution result of the branch transaction is successful; the further operations include a delete operation to delete the rollback log.
11. The method of claim 1, wherein the plurality of branch transactions differ in transaction pattern.
12. The method of claim 1, wherein the number of the application servers is plural.
13. A distributed transaction processing method applied to an application server is characterized by comprising the following steps:
initiating a distributed transaction corresponding to a service request sent by user equipment, wherein the distributed transaction corresponds to a plurality of branch transactions; the application server comprises a transaction management module and a resource management module, wherein the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
receiving a rollback or submission command which is sent by a transaction control server and corresponds to a target ending mode and aims at the branch transaction corresponding to the distributed transaction, and controlling the ending of the branch transaction corresponding to the distributed transaction according to the command; the target ending mode is determined by the transaction control server based on the execution result of the branch transaction corresponding to the distributed transaction, and the transaction control server sends the command to the application server to control the ending of the branch transaction corresponding to the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
14. The method of claim 13, further comprising:
and when determining that the distributed transaction needs to be ended, sending an ending message to the transaction control server, wherein the ending message is used for indicating that the application server needs to end the distributed transaction.
15. The method of claim 14, wherein the end message is further used to indicate the target end mode.
16. The method according to any one of claims 13 to 15, wherein in a case that the target ending manner is rollback, the ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server includes:
receiving a rollback command which is sent by the transaction control server and aims at the branch transaction corresponding to the distributed transaction;
performing a rollback operation on a branch transaction based on a rollback command for the branch transaction.
17. The method of claim 16, wherein before receiving the rollback command sent by the transaction control server for the branch transaction corresponding to the distributed transaction, further comprising:
and sending an execution result of the branch transaction corresponding to the distributed transaction to the transaction control server, so that the transaction control server sends a rollback command for the branch transaction under the condition that the branch transaction is determined to need rollback operation according to the execution result of the branch transaction.
18. The method of claim 17, wherein the branch transaction executed results in a successful execution and the target ending manner is a rollback of a commit operation that characterizes the branch transaction as being rollback is successful; the execution result of the branch transaction characterizes a commit operation execution failure that the branch transaction may roll back for an execution failure.
19. The method of claim 17, wherein the outcome of execution of a branch transaction is successful and the target-ending manner is successful execution of a commit preparation operation that rollback characterizes the branch transaction as being rollback; the execution result of the branch transaction characterizes a commit preparation operation execution failure that the branch transaction may roll back for an execution failure.
20. The method according to any one of claims 14 to 15, wherein in a case that the target ending manner is commit, the ending the branch transaction corresponding to the distributed transaction according to the control of the transaction control server includes:
receiving a commit command which is sent by the transaction control server and aims at the branch transaction corresponding to the distributed transaction;
further operations are performed on the branch transaction based on a commit command of the branch transaction.
21. The method of claim 20, wherein the further operations comprise: a commit operation to complete the branch transaction commit, and/or a delete operation to delete the rollback log.
22. The method of claim 13, wherein the plurality of branch transactions differ in transaction pattern.
23. A distributed transaction processing method is applied to a transaction control server, and is characterized by comprising the following steps:
under the condition that an application server initiates a distributed transaction, determining a plurality of branch transactions corresponding to the distributed transaction; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment, the application server comprises a transaction management module and a resource management module, the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
when the distributed transaction is determined to need to be ended, sending a rollback or commit command corresponding to a target ending mode for the branch transaction corresponding to the distributed transaction to the application server so as to control the ending of the branch transaction corresponding to the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode;
the method further comprises the following steps: and determining the target ending mode based on the execution result of the branch transaction corresponding to the distributed transaction.
24. A distributed transaction processing method applied to an application server is characterized by comprising the following steps:
initiating a distributed transaction corresponding to a transaction service request sent by user equipment, the distributed transaction corresponding to a plurality of branch transactions; the application server comprises a transaction management module and a resource management module, wherein the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
receiving a rollback or submission command which is sent by a transaction control server and corresponds to a target ending mode and aims at the branch transaction corresponding to the distributed transaction, and controlling the ending of the branch transaction corresponding to the distributed transaction according to the command; the target ending mode is determined by the transaction control server based on the execution result of the branch transaction corresponding to the distributed transaction, and the transaction control server sends the command to the application server to control the ending of the branch transaction corresponding to the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
25. A distributed transaction processing device applied to a transaction control server, the device comprising:
the determining module is used for determining a plurality of branch transactions corresponding to the distributed transactions under the condition that the application server initiates the distributed transactions; the distributed transaction is initiated by the application server based on a service request sent by user equipment, the application server comprises a transaction management module and a resource management module, the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
the control module is used for sending a rollback or commit command corresponding to a target ending mode aiming at the branch transaction corresponding to the distributed transaction to the application server when the distributed transaction is determined to need to be ended so as to control the ending of the branch transaction corresponding to the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode;
the determining module is further configured to determine the target ending manner based on an execution result of the branch transaction corresponding to the distributed transaction.
26. A distributed transaction processing apparatus applied to an application server, the apparatus comprising:
the system comprises an initiating module, a processing module and a processing module, wherein the initiating module is used for initiating a distributed transaction corresponding to a service request sent by user equipment, and the distributed transaction corresponds to a plurality of branch transactions; the application server comprises a transaction management module and a resource management module, wherein the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
the ending module is used for receiving a rollback or submission command which is sent by the transaction control server and corresponds to the target ending mode and aims at the branch transaction corresponding to the distributed transaction, and controlling the branch transaction corresponding to the distributed transaction to be ended according to the command; the target ending mode is determined by the transaction control server based on the execution result of the branch transaction corresponding to the distributed transaction, and the transaction control server sends the command to the application server when determining that the distributed transaction needs to be ended so as to control the ending of the branch transaction corresponding to the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode.
27. A distributed transaction processing device applied to a transaction control server, the device comprising:
the determining module is used for determining a plurality of branch transactions corresponding to the distributed transactions under the condition that the application server initiates the distributed transactions; the distributed transaction is correspondingly initiated by the application server based on a transaction service request sent by user equipment, the application server comprises a transaction management module and a resource management module, the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
the control module is used for sending a rollback or commit command corresponding to a target ending mode aiming at the branch transaction corresponding to the distributed transaction to the application server when the distributed transaction is determined to need to be ended so as to control the ending of the branch transaction corresponding to the distributed transaction, so that the ending mode of the branch transaction is consistent with the target ending mode;
the determining module is further configured to determine the target ending manner based on an execution result of the branch transaction corresponding to the distributed transaction.
28. A distributed transaction processing apparatus applied to an application server, the apparatus comprising:
the system comprises an initiating module, a processing module and a processing module, wherein the initiating module is used for initiating a distributed transaction corresponding to a transaction service request sent by user equipment, and the distributed transaction corresponds to a plurality of branch transactions; the application server comprises a transaction management module and a resource management module, wherein the transaction management module is used for defining the time for initiating the distributed transaction, and the resource management module is used for defining the branch transaction corresponding to the distributed transaction and the execution process of the branch transaction corresponding to the distributed transaction;
the ending module is used for receiving a rollback or submission command which is sent by the transaction control server and corresponds to the target ending mode and aims at the branch transaction corresponding to the distributed transaction, and controlling to end the branch transaction corresponding to the distributed transaction according to the command; the target ending mode is determined by the transaction control server based on the execution result of the branch transaction corresponding to the distributed transaction, and the transaction control server sends the command to the application server to control the ending of the branch transaction corresponding to the distributed transaction when determining that the distributed transaction needs to be ended, so that the ending mode of the branch transaction is consistent with the target ending mode.
29. A transaction control server, comprising: a memory, a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of claims 1 to 12.
30. An application server, comprising: a memory, a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of any of claims 13 to 22.
31. A transaction control server, comprising: a memory, a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of claim 23.
32. An application server, comprising: a memory, a processor; wherein the memory is to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the method of claim 24.
CN202010526407.3A 2020-06-09 2020-06-09 Distributed transaction processing method, device and equipment Active CN113296896B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010526407.3A CN113296896B (en) 2020-06-09 2020-06-09 Distributed transaction processing method, device and equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010526407.3A CN113296896B (en) 2020-06-09 2020-06-09 Distributed transaction processing method, device and equipment

Publications (2)

Publication Number Publication Date
CN113296896A CN113296896A (en) 2021-08-24
CN113296896B true CN113296896B (en) 2022-05-06

Family

ID=77318656

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010526407.3A Active CN113296896B (en) 2020-06-09 2020-06-09 Distributed transaction processing method, device and equipment

Country Status (1)

Country Link
CN (1) CN113296896B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816681B (en) * 2022-03-29 2024-04-26 江苏中交车旺科技有限公司 Insurance business data processing method and device, electronic equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106557514A (en) * 2015-09-29 2017-04-05 中兴通讯股份有限公司 A kind of distributed transaction rollback method and device
CN110019443A (en) * 2017-09-08 2019-07-16 阿里巴巴集团控股有限公司 Non-relational database transaction methods, device and electronic equipment
CN110532068A (en) * 2019-07-18 2019-12-03 政采云有限公司 A kind of management method of distributed transaction
CN110888718A (en) * 2019-11-27 2020-03-17 武汉虹旭信息技术有限责任公司 Method and device for realizing distributed transaction
CN111045794A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Distributed transaction processing method, device, system, computer equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9667475B2 (en) * 2014-02-28 2017-05-30 Red Hat, Inc. Systems and methods for communicating information of participants registered with a sub-coordinator during distributed transaction processing
CN105988862B (en) * 2015-02-04 2019-06-21 阿里巴巴集团控股有限公司 Distributed transaction processing method and device
CN106156119A (en) * 2015-04-07 2016-11-23 阿里巴巴集团控股有限公司 A kind of distributed transaction communication means, system and device
CN108845866B (en) * 2018-06-28 2021-06-29 创新先进技术有限公司 Method and apparatus for processing distributed transactions

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106557514A (en) * 2015-09-29 2017-04-05 中兴通讯股份有限公司 A kind of distributed transaction rollback method and device
CN110019443A (en) * 2017-09-08 2019-07-16 阿里巴巴集团控股有限公司 Non-relational database transaction methods, device and electronic equipment
CN110532068A (en) * 2019-07-18 2019-12-03 政采云有限公司 A kind of management method of distributed transaction
CN110888718A (en) * 2019-11-27 2020-03-17 武汉虹旭信息技术有限责任公司 Method and device for realizing distributed transaction
CN111045794A (en) * 2019-12-17 2020-04-21 深圳前海环融联易信息科技服务有限公司 Distributed transaction processing method, device, system, computer equipment and storage medium

Also Published As

Publication number Publication date
CN113296896A (en) 2021-08-24

Similar Documents

Publication Publication Date Title
TWI746905B (en) Block chain-based smart contract calling method and device, and electronic equipment
US20230247090A1 (en) Dynamic execution resource selection for customized workflow tasks
JP7086065B2 (en) Application link extension methods, devices, and systems
US20140344123A1 (en) Dynamically modifying workload patterns in a cloud
US9912759B2 (en) Dynamically generating solution stacks
CN112835688A (en) Distributed transaction processing method, device and storage medium
CN111262897B (en) Service call routing processing method, device and system
CN112817995B (en) Data processing method and device, electronic equipment and storage medium
CN113760311A (en) Micro-service deployment method, device and medium
CN111143023A (en) Resource changing method and device, equipment and storage medium
US10956142B2 (en) Distributing a composite application
CN113296896B (en) Distributed transaction processing method, device and equipment
CN111415146A (en) Resource data processing method, device and equipment
US11755301B2 (en) Deployment of cloud infrastructures using a cloud management platform
CN106034148B (en) Rapid information interaction method, local server, remote server and system
CN108346095B (en) Management and control method, device and equipment of combined system and computer readable storage medium
WO2021013185A1 (en) Virtual machine migration processing and strategy generation method, apparatus and device, and storage medium
CN112564956A (en) Remote upgrading method, equipment and device for client and storage medium
US11422791B2 (en) Upgrading a sequence of microservices in a cloud computing environment
CN115776515A (en) Software service providing method, device and equipment
CN113469814A (en) Method and device for determining transaction duration data
CN117076007B (en) Method and device for reducing intrusion of middle platform architecture codes and middle platform system
CN112994959B (en) Service test control system, method, device and storage medium
CN111131538B (en) Access control method and access control system
CN116028064A (en) Git-based code processing method, system, equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20230530

Address after: Room 1-2-A06, Yungu Park, No. 1008 Dengcai Street, Sandun Town, Xihu District, Hangzhou City, Zhejiang Province

Patentee after: Aliyun Computing Co.,Ltd.

Address before: Box 847, four, Grand Cayman capital, Cayman Islands, UK

Patentee before: ALIBABA GROUP HOLDING Ltd.