CN113778699A - Distributed transaction processing method, device, computer system and readable storage medium - Google Patents
Distributed transaction processing method, device, computer system and readable storage medium Download PDFInfo
- Publication number
- CN113778699A CN113778699A CN202011151868.3A CN202011151868A CN113778699A CN 113778699 A CN113778699 A CN 113778699A CN 202011151868 A CN202011151868 A CN 202011151868A CN 113778699 A CN113778699 A CN 113778699A
- Authority
- CN
- China
- Prior art keywords
- transaction
- remote
- instruction
- calling
- local
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 29
- 238000000034 method Methods 0.000 claims abstract description 182
- 230000008569 process Effects 0.000 claims abstract description 73
- 238000012545 processing Methods 0.000 claims abstract description 68
- 230000004044 response Effects 0.000 claims abstract description 24
- 230000015654 memory Effects 0.000 claims description 11
- 230000002159 abnormal effect Effects 0.000 claims description 6
- 239000003999 initiator Substances 0.000 description 42
- 238000004891 communication Methods 0.000 description 28
- 238000012546 transfer Methods 0.000 description 23
- 238000010586 diagram Methods 0.000 description 15
- 238000004590 computer program Methods 0.000 description 11
- 230000006870 function Effects 0.000 description 7
- 238000011161 development Methods 0.000 description 5
- 238000004458 analytical method Methods 0.000 description 4
- 239000003795 chemical substances by application Substances 0.000 description 4
- 230000007246 mechanism Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000000694 effects Effects 0.000 description 3
- 238000005096 rolling process Methods 0.000 description 3
- 238000010276 construction Methods 0.000 description 2
- 238000012423 maintenance Methods 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000004806 packaging method and process Methods 0.000 description 2
- 239000000758 substrate Substances 0.000 description 2
- WBEJYOJJBDISQU-UHFFFAOYSA-N 1,2-Dibromo-3-chloropropane Chemical compound ClCC(Br)CBr WBEJYOJJBDISQU-UHFFFAOYSA-N 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The present disclosure provides a distributed transaction processing method, apparatus, computer system and readable storage medium. The method comprises the following steps: creating a distributed transaction, wherein the distributed transaction comprises a local transaction and a remote calling transaction; invoking a local transaction; in the process of executing the local transaction, sending a calling instruction aiming at the remote calling transaction to the distributed system through a remote procedure calling protocol; receiving feedback information returned after the distributed system responds to the calling instruction to execute the remote calling transaction, wherein the feedback information is used for representing the execution result of the remote calling transaction; after the process of executing the local transaction is finished, determining an execution instruction aiming at the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction comprises a rollback instruction or a commit instruction; processing the local transaction in response to executing the instruction; and sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to realize the processing of the remote call transaction.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a distributed transaction processing method, apparatus, computer system, and readable storage medium.
Background
With the development of the internet and big data era, more and more services and other information are stored through a database, with the continuous increase of data volume, database division and table division are inevitably needed, and in order to ensure the consistency of different database tables aimed at by the same operation, a distributed transaction processing mechanism is introduced.
In the process of implementing the disclosed concept, the inventor finds that at least the following problems exist in the related art, namely the communication complexity and the distributed system architecture which are relied on by the distributed transaction are complex.
Disclosure of Invention
In view of the above, the present disclosure provides a distributed transaction processing method, apparatus, computer system and readable storage medium.
One aspect of the present disclosure provides a distributed transaction processing method, including: creating a distributed transaction, wherein the distributed transaction comprises a local transaction and a remote calling transaction; invoking the local transaction; in the process of executing the local transaction, sending a calling instruction aiming at the remote calling transaction to a distributed system through a remote procedure calling protocol; receiving feedback information returned by the distributed system after responding to the calling instruction to execute the remote calling transaction, wherein the feedback information is used for representing the execution result of the remote calling transaction; after the process of executing the local transaction is finished, determining an execution instruction aiming at the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction comprises a rollback instruction or a commit instruction; processing the local transaction in response to the execution instruction; and sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to realize the processing of the remote call transaction.
According to an embodiment of the present disclosure, in the process of executing the local transaction, sending a call instruction for the remote call transaction to a distributed system through a remote procedure call protocol includes: creating a global transaction identity for the distributed transaction; storing the global transaction identifier into a header file of the calling instruction; and sending the calling instruction of the header file containing the global transaction identifier to the distributed system through a remote procedure calling protocol.
According to an embodiment of the present disclosure, the remote invocation transactions are at least two, and the method further includes: and under the condition that feedback information returned after the distributed system responds to the calling instruction to execute at least one remote calling transaction contains rollback information, ending the process of executing the local transaction.
According to the embodiment of the present disclosure, after the process of executing the local transaction is finished, determining, according to the feedback information, an execution instruction for the local transaction and the remote invocation transaction includes: determining that the execution instruction is the rollback instruction when the feedback information comprises rollback information; and determining the execution instruction as the commit instruction under the condition that only commit information exists in the feedback information.
According to an embodiment of the present disclosure, processing the local transaction in response to the execution instruction includes: executing a transaction rollback operation on the local transaction if the execution instruction is the rollback instruction; and executing a transaction commit operation on the local transaction if the execution instruction is the commit instruction.
Another aspect of the present disclosure provides another distributed transaction processing method, wherein the distributed transaction includes a local transaction and a remote invocation transaction, the method including: receiving a calling instruction aiming at the remote calling transaction based on a remote procedure calling protocol, wherein the calling instruction is received in the process of executing the local transaction; responding to the calling instruction, executing the remote calling transaction, and outputting feedback information for representing an execution result of the remote calling transaction; sending the feedback information to a distributed system corresponding to the local affair through a remote process call protocol so that the distributed system corresponding to the local affair outputs an execution instruction aiming at the remote call affair according to the feedback information; receiving the execution instruction aiming at the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the process of executing the local transaction is finished, and the execution instruction comprises a rollback instruction or a commit instruction; and processing the remote invocation transaction in response to the execution instruction.
According to an embodiment of the present disclosure, the executing the remote call transaction in response to the call instruction, and outputting feedback information for characterizing an execution result of the remote call transaction includes: outputting the feedback information with rollback information under the condition that the process of executing the remote calling transaction is abnormal; and outputting the feedback information with the submission information under the condition that the process of executing the remote call transaction is normal.
According to an embodiment of the present disclosure, processing the remote call transaction in response to the execution instruction includes: executing a transaction rollback operation on the remote invocation transaction if the execution instruction is the rollback instruction; and executing a transaction commit operation on the remote invocation transaction if the execution instruction is the commit instruction.
Another aspect of the present disclosure provides a distributed transaction processing apparatus, including: the system comprises a creating module, a processing module and a processing module, wherein the creating module is used for creating distributed transactions, and the distributed transactions comprise local transactions and remote calling transactions; the calling module is used for calling the local affair; the first sending module is used for sending a calling instruction aiming at the remote calling transaction to a distributed system through a remote procedure calling protocol in the process of executing the local transaction; a first receiving module, configured to receive feedback information returned by the distributed system after the distributed system executes the remote invocation transaction in response to the invocation instruction, where the feedback information is used to characterize an execution result of the remote invocation transaction; a determining module, configured to determine, according to the feedback information, an execution instruction for the local transaction and the remote invocation transaction after a process of executing the local transaction is completed, where the execution instruction includes a rollback instruction or a commit instruction; a first processing module, configured to process the local transaction in response to the execution instruction; and the second sending module is used for sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to process the remote call transaction.
Another aspect of the present disclosure provides a distributed transaction processing apparatus, wherein the distributed transaction includes a local transaction and a remote invocation transaction, the apparatus includes: a second receiving module, configured to receive a call instruction for the remote call transaction based on a remote procedure call protocol, where the call instruction is received during execution of the local transaction; the execution module is used for responding to the calling instruction, executing the remote calling transaction and outputting feedback information for representing the execution result of the remote calling transaction; a third sending module, configured to send the feedback information to a distributed system corresponding to the local transaction through a remote procedure call protocol, so that the distributed system corresponding to the local transaction outputs an execution instruction for the remote procedure call transaction according to the feedback information; a third receiving module, configured to receive, based on a remote procedure call protocol, the execution instruction for the remote call transaction, where the execution instruction is received after a process of executing the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction; and the second processing module is used for responding to the execution instruction and processing the remote calling transaction.
Another aspect of the present disclosure provides a computer system comprising: one or more processors; memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method as described above when executed.
Another aspect of the disclosure provides a computer program comprising computer executable instructions for implementing the method as described above when executed.
According to the embodiment of the disclosure, the creation of the distributed transaction is adopted, and the distributed transaction comprises a local transaction and a remote calling transaction; invoking a local transaction; in the process of executing the local transaction, sending a calling instruction aiming at the remote calling transaction to the distributed system through a remote procedure calling protocol; receiving feedback information returned after the distributed system responds to the calling instruction to execute the remote calling transaction, wherein the feedback information is used for representing the execution result of the remote calling transaction; after the process of executing the local transaction is finished, determining an execution instruction aiming at the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction comprises a rollback instruction or a commit instruction; processing the local transaction in response to executing the instruction; and sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to realize a technical means for processing the remote call transaction, wherein the communication between the local transaction and the remote call transaction is realized through the remote procedure call protocol, and the remote call transaction can be simultaneously called and processed through the protocol, so that additional communication configuration is reduced, the technical problem of communication complexity is at least partially overcome, and the technical effect of reducing the communication complexity and even the distributed system architecture complexity is achieved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
fig. 1 schematically illustrates an exemplary system architecture to which a distributed transaction method may be applied, according to an embodiment of the present disclosure;
FIG. 2 schematically illustrates a flow diagram of a distributed transaction processing method for a transaction initiator party, in accordance with an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram of a distributed transaction processing method for transaction participant parties, in accordance with an embodiment of the present disclosure;
FIG. 4 schematically illustrates a system block diagram in which a complete distributed transaction processing method may be implemented, according to an embodiment of the present disclosure;
FIG. 5 schematically illustrates a flow chart of a method in which a complete distributed transaction may be implemented according to an embodiment of the present disclosure;
figure 6 schematically shows a block diagram of a distributed transaction processing apparatus for a transaction initiator side according to an embodiment of the present disclosure;
figure 7 schematically illustrates a block diagram of a distributed transaction processing apparatus for transaction participant parties, in accordance with an embodiment of the present disclosure; and
FIG. 8 schematically illustrates a block diagram of a computer system suitable for implementing a distributed transaction processing method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
In the background of the internet era, in order to complete functions required by a system, the architecture of the system is often very complex, for example, the system may be split into a plurality of distributed systems from an original single system, in which case, distributed transactions are very important to ensure the consistency of data in the distributed systems. The method for implementing distributed transactions of different enterprises and companies is usually implemented by adopting a method of maintaining the final consistency of the distributed transactions, or adopting a TCC (a distributed transaction processing mechanism, including three phases of Try, Confirm and Cancel) and the like.
However, in the process of implementing the disclosed concept, the inventor finds that the distributed transaction implemented by the prior art is complex in development and deployment and complex in system architecture. For example, some external frameworks have a large intrusion on the services of the system and are complex to implement, such as a TCC transaction framework, in order to achieve the purpose of distributed transactions, a service requirement needs to be completed by splitting into three steps, namely Try, Confirm and Cancel, each step needs to be carefully considered in depth for the services, and then the TCC transaction framework and the services are matched to achieve the final purpose. For another example, although some frameworks have improved service intrusion, the system introduces many components such as Redis (an open source database), extra Netty (a network application framework) communication, etc., which results in complex configuration of the system and inconvenience in communication and maintenance.
The embodiment of the disclosure provides a distributed transaction processing method, a device, a computer system and a readable storage medium. The method comprises the steps of creating a distributed transaction, wherein the distributed transaction comprises a local transaction and a remote calling transaction; invoking a local transaction; in the process of executing the local transaction, sending a calling instruction aiming at the remote calling transaction to the distributed system through a remote procedure calling protocol; receiving feedback information returned after the distributed system responds to the calling instruction to execute the remote calling transaction, wherein the feedback information is used for representing the execution result of the remote calling transaction; after the process of executing the local transaction is finished, determining an execution instruction aiming at the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction comprises a rollback instruction or a commit instruction; processing the local transaction in response to executing the instruction; and sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to realize the processing of the remote call transaction.
Fig. 1 schematically illustrates an exemplary system architecture 100 to which the distributed transaction method may be applied, according to an embodiment of the disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105, and the terminal devices 101, 102, 103 and the server 105 may all be regarded as a distributed system, and at least any two of them may form a distributed transaction therebetween. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, and/or social platform software.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background management server providing support for services accessed by users using the terminal devices 101, 102, 103. The background management server may analyze and otherwise process data such as the received user request, and feed back a processing result (for example, an instruction or feedback information obtained or generated according to the user request) to the terminal device.
It should be noted that the distributed transaction processing method provided by the embodiment of the present disclosure may be generally executed by the terminal device 101, 102, or 103, or may also be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the distributed transaction processing apparatus provided by the embodiment of the present disclosure may be disposed in the terminal device 101, 102, or 103, or disposed in another terminal device different from the terminal device 101, 102, or 103.
For example, the local transaction may be a transaction of any of terminal devices 101, 102, or 103 (e.g., terminal device 101, but not limited to), or a transaction of an external device associated with terminal device 101. Then, the terminal device 101 may locally perform the distributed transaction processing method provided by the embodiment of the present disclosure, or send the local transaction to another terminal device, a server, or a server cluster, and the other terminal device, the server, or the server cluster that receives the local transaction performs the distributed transaction processing method provided by the embodiment of the present disclosure.
Alternatively, the distributed transaction processing method provided by the embodiment of the present disclosure may also be executed by the server 105. Accordingly, the distributed transaction processing apparatus provided by the embodiments of the present disclosure may be generally disposed in the server 105. The distributed transaction processing method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the distributed transaction processing apparatus provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
For example, the remote invocation transaction may be a transaction in server 105 or a transaction of another server associated with server 105. Then, the server 105 may locally execute the distributed transaction processing method provided by the embodiment of the present disclosure, or send a remote invocation transaction to other terminal devices, servers, or server clusters, and execute the distributed transaction processing method provided by the embodiment of the present disclosure by the other terminal devices, servers, or server clusters receiving the remote invocation transaction.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Fig. 2 schematically shows a flow chart of a distributed transaction processing method for a transaction initiator side according to an embodiment of the present disclosure.
As shown in fig. 2, the method includes operations S201 to S207.
In operation S201, a distributed transaction is created, the distributed transaction including a local transaction and a remote invocation transaction.
According to the embodiment of the disclosure, a distributed transaction is created by a transaction initiator, for example, a transfer transaction initiated by an account a from the account a to an account B, the account a serves as the transaction initiator, the transfer operation and the transfer result for the account a are local transactions, software or a system related to the account B serves as a transaction participant, and the related operation for the account B is a remote call transaction which needs to be called when the local transaction of the account a is executed.
In operation S202, a local transaction is invoked.
According to the embodiment of the disclosure, the account A initiates a transfer service and calls a local transaction to start to execute a transfer operation, the calling of the local transaction may be, for example, calling and acquiring the account balance of the account A, and calling and executing a program segment for performing a transfer operation on the balance (i.e., subtracting the transfer amount from the current balance to obtain a balance value after transfer). It should be noted that the result of the transfer operation is not directly displayed on the user-visible interface, and only one of the program operations in the program implementing the local transaction (here, the related processing for the account a) is executed, and the final result display needs to be performed after all the programs for the local transaction and the remote call transaction are executed.
In operation S203, in the process of executing the local transaction, a call instruction for a remote call transaction is sent to the distributed system through the remote procedure call protocol.
According to the embodiment of the disclosure, in order to maintain consistency of data in distributed transactions (i.e. the a account and the B account), corresponding operations are generally required to be performed on the B account in the process of performing operations on the a account, and therefore, a transaction initiator (i.e. a party of the a account) inevitably needs to communicate with a system related to the B account. The RPC (remote procedure call) protocol is a protocol which is owned by a distributed system and can realize remote communication, and can be understood as a RPC framework carried by the distributed system to realize communication among remote services. In this embodiment, a call instruction for the B account (remote call transaction) is directly sent to the transaction participant side through the RPC protocol.
In operation S204, feedback information returned after the distributed system executes the remote invocation transaction in response to the invocation instruction is received, where the feedback information is used to characterize an execution result of the remote invocation transaction.
According to the embodiment of the disclosure, based on the data consistency requirement of the distributed transaction, the transaction initiator (the account party a) needs to receive the transaction execution result of the transaction participant (the account party B), and the receiving action is also implemented based on the RPC protocol so as to enter the next operation.
In operation S205, after the process of executing the local transaction is finished, an execution instruction for the local transaction and the remote invocation transaction is determined according to the feedback information, where the execution instruction includes a rollback instruction or a commit instruction.
According to the embodiment of the present disclosure, the process of executing the local transaction includes the above-mentioned operations S202 to S204, and the execution instructions for the local transaction and the remote invocation transaction (i.e., A, B account) are determined according to the transaction execution result of the transaction participant (B account party) obtained in operation S204. The rollback instruction may be, for example, a rollback instruction performed on a program executed in the present distributed transaction processing, and for example, the rollback instruction may be executed on a transfer operation in operation S202, so that an account balance of the account a in the program is restored to an original balance, and the like, and the commit instruction may be, for example, a commit instruction performed on the program executed in the present distributed transaction processing, and for example, the commit instruction may be executed on the transfer operation in operation S202, so that the account balance of the account a is based on a balance value after the transfer operation.
It should be noted that, the process of determining the execution instruction may also be, for example, determining according to the execution results of the local transaction and the remote invocation transaction at the same time.
In operation S206, the local transaction is processed in response to executing the instruction.
In operation S207, the execution instruction is sent to the distributed system corresponding to the remote invocation transaction through the remote procedure invocation protocol, so as to implement processing of the remote invocation transaction.
According to the embodiment of the present disclosure, after the execution instructions for the local transaction and the remote invocation transaction (i.e., A, B account) are determined through operation S205, the execution instructions are executed for both the local transaction and the remote invocation transaction to implement the processing of the distributed transaction. For example, a commit command may be executed for each account A, B to complete the transfer activity, or a rollback command may be executed for each account A, B to indicate that the transfer activity was not successfully completed. It should be noted that the execution instruction sent to the remote call transaction is also implemented by the RPC protocol.
According to the embodiment of the disclosure, remote communication of distributed transactions is realized through the RPC framework of the distributed transactions, other communication mechanisms are not required to be introduced, and communication dependence is reduced, so that the complexity of a distributed system is reduced, and the problem of complex development and deployment in the process of realizing the distributed transactions can be effectively solved.
The method illustrated in fig. 2 is further described below in conjunction with more specific examples.
According to an embodiment of the present disclosure, the above operation S203 includes: creating a global transaction identifier for the distributed transaction; storing the global transaction identifier into a header file of a call instruction; and sending the calling instruction of the header file containing the global transaction identifier to the distributed system through a remote procedure calling protocol.
According to the embodiment of the disclosure, when the RPC calls the remote method, a globally unique transaction ID (i.e., a global transaction identifier) is first created and stored in a header file of the RPC method for propagation throughout the distributed transaction. The RPC method may include, for example, a call instruction, and the global transaction identifier is used to determine which distributed transaction each operation is directed to, for example, in a case where the transfer application is initiated multiple times, it is necessary to determine which transfer transaction each operation is directed to through the global transaction identifier.
It should be noted that the RPC method is not limited to the above-mentioned call instruction, and may also be all information or instructions for implementing communication between the transaction initiator and the transaction participant, such as feedback information returned in operation S204, or an execution instruction in operation S207.
According to an embodiment of the present disclosure, the number of the remote invocation transactions is at least two, and the distributed transaction processing method further includes: and under the condition that the feedback information returned after the distributed system responds to the calling instruction to execute at least one remote calling transaction contains rollback information, ending the process of executing the local transaction.
According to an embodiment of the present disclosure, the above operation S205 includes: determining that the execution instruction is a rollback instruction under the condition that the feedback information comprises rollback information; and determining the execution instruction as a commit instruction under the condition that only the commit information exists in the feedback information.
According to the embodiment of the disclosure, the case that the execution process of the local transaction is ended may include, for example, a case that the local transaction is normally ended due to the end of the program after the local transaction and the remote call transaction are both normally executed, and a case that the local transaction and/or the remote call transaction is ended in the middle of the executed process due to the occurrence of the abnormal trigger interrupt operation. In any case, the final execution instruction needs to be determined according to the execution result of the remote call transaction after the local transaction is finished, or according to the execution results of the local transaction and the remote call transaction. The exception may include, for example, an external event or an exception caused by hardware, an exception caused by a program, and the like. In connection with specific embodiments, the exception may be, for example, the transfer amount exceeding a maximum transferable range, or the transfer being prohibited during a system maintenance phase, etc.
According to an embodiment of the present disclosure, the operation S206 includes: under the condition that the execution instruction is a rollback instruction, executing transaction rollback operation on the local transaction; and executing the transaction commit operation on the local transaction under the condition that the execution instruction is a commit instruction.
By adopting the Fail-Fast thinking, the transaction initiator directly ends the local transaction under the condition that the transaction initiator monitors that a transaction participant rolls back the transaction, so that the communication consumption of the subsequent transaction during rolling back can be effectively avoided, and the overall performance of the distributed transaction is improved.
It should be noted that, in the process of performing the distributed transaction processing method at the transaction initiator side, all the invocation and execution operations are only operations on the program, the execution result of the program is not really reflected on the user-visible interface, and the execution result of the program is really reflected on the user interface only when the subsequent processing operations are performed on the local transaction and the remote invocation transaction. The call, execution and processing operations for the transaction participant side follow the same definition.
Fig. 3 schematically shows a flow chart of a distributed transaction processing method for transaction participant parties according to an embodiment of the present disclosure.
As shown in fig. 3, the method includes operations S301 to S305.
In operation S301, a call instruction for a remote call transaction is received based on a remote procedure call protocol, where the call instruction is received during execution of a local transaction.
According to the embodiment of the present disclosure, the operation S301 receives, according to the operation S203, a call instruction sent by the transaction initiator through an RPC protocol. Referring to operation S203, the call instruction is sent during the execution of the local transaction, so that the complete execution process of the local transaction can be realized through the operation on the remote call transaction.
In operation S302, in response to the call instruction, the remote call transaction is executed, and feedback information for characterizing an execution result of the remote call transaction is output.
According to the embodiment of the present disclosure, the process of executing the remote call transaction is similar to the process of calling the local transaction in operation S202, and with reference to the foregoing embodiment, the process of executing the remote call transaction may be, for example, a process segment of calling and acquiring an account balance of the account B, and calling and executing a transfer operation on the account balance of the account B (adding the current balance of the account B to the transfer amount to obtain a balance value after transfer). It should be noted that the result of the transfer operation for the B account is not directly displayed on the user-visible interface, and only one of the program operations in the program implementing the remote call transaction (here, the related process for the B account) is executed, and the final result display also needs to be performed after all the programs for the local transaction and the remote call transaction are executed.
In operation S303, the feedback information is sent to the distributed system corresponding to the local transaction through the remote procedure call protocol, so that the distributed system corresponding to the local transaction outputs an execution instruction for the remote call transaction according to the feedback information.
According to the embodiment of the present disclosure, the operation S303 corresponds to the operations S204 to S205, and related embodiments thereof have been described above and are not repeated herein.
In operation S304, an execution instruction for the remote call transaction is received based on the remote procedure call protocol, where the execution instruction is received after the process of executing the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction.
In operation S305, a remote call transaction is processed in response to executing the instruction.
According to an embodiment of the present disclosure, the operations S304 to S305 correspond to the operation S207, and related embodiments thereof have been described above and are not repeated herein.
It should be noted that, as described in operations S303 and S304, the remote call transaction and the local transaction are both communicated via the RPC protocol.
According to the embodiment of the disclosure, remote communication of distributed transactions is realized through the RPC framework of the distributed transactions, other communication mechanisms are not required to be introduced, and communication dependence is reduced, so that the complexity of a distributed system is reduced, and the problem of complex development and deployment in the process of realizing the distributed transactions can be effectively solved.
According to an embodiment of the present disclosure, the above operation S302 includes: outputting feedback information with rollback information under the condition that the process of executing the remote call transaction is abnormal; and outputting feedback information with the commit information in case that the process of executing the remote call transaction is normal.
It should be noted that, the above-mentioned case where an exception occurs in the process of executing the remote invocation transaction may be, for example, a program segment which is invoked and executes an exception triggered due to an excessive transfer amount or a system reason, and in this case, the obtained feedback information includes rollback information for an operation related to the remote invocation transaction (B account). At this time, the feedback information received in operation S204 includes rollback information, and after receiving the feedback information with the rollback information, the transaction initiator may terminate the execution operation of the local transaction.
By the embodiment of the disclosure, when a transaction participant rolls back a transaction, the transaction participant rolls back the transaction first, and feeds back the result to the transaction initiator, and the transaction initiator directly ends the local transaction, so that communication consumption during the roll back of subsequent transactions can be effectively avoided, and the overall performance of the distributed transaction is improved.
According to an embodiment of the present disclosure, the above operation S305 includes: under the condition that the execution instruction is a rollback instruction, executing transaction rollback operation on the remote call transaction; and in the case that the execution instruction is a commit instruction, performing a transaction commit operation on the remote call transaction.
By combining the mutual operations of the transaction participants and the transaction initiator, the rationality processing of the whole distributed transaction can be realized on the premise of keeping the data consistency.
The method of fig. 2 and 3 is further described below with reference to fig. 4-5 in conjunction with the full embodiment.
Fig. 4 schematically illustrates a system block diagram in which a complete distributed transaction processing method may be implemented according to an embodiment of the present disclosure.
As shown in fig. 4, the distributed transaction may be formed, for example, by a combination of local transactions of each of system 1, system 2, and system 3. In which the system 1 is used as a transaction initiator (for example, the aforementioned account a), the systems 2 and 3 are used as transaction participants (for example, the aforementioned account B), and in the case that the transaction initiator (for example, the system 1) initiates a local transaction, the local transaction of the relevant transaction participants (for example, the systems 2 and 3) is invoked. Each system can comprise modules such as a database, a database connection pool, a connection agent, a local transaction and a transaction dispatch, and a global transaction coordination module can be arranged in a transaction initiator at the same time.
According to the embodiment of the present disclosure, the database may be, for example, a common database such as MySQL, Oracle, and the like. The database connection pool may be, for example, a common database connection pool such as a drain, a DBCP, c3p0, and the like, and is used to cache connections established by the database, so that the database with established connections can be directly searched from the database connection pool and directly called later without repeatedly establishing connections in the case that the database needs to be called. The Connection proxy (Connection proxy) returns the proxy object when the database Connection (Connection) is newly established, the proxy object is obtained from the database Connection pool, and the proxy object takes over the methods of submission, rollback, closing, setting automatic submission and the like of the Connection, so as to realize the control of the global transaction. The local transaction may be implemented, for example, by a Spring (a lightweight open source framework) transaction manager, the execution of which is handled by the connection broker. The transaction dispatch is responsible for the propagation of the global transaction ID, collects all transaction participant information, and decides to invoke a real business method, so that the operations of submitting, rolling back and the like of local transactions in the transaction initiator and the transaction participants are realized. The global transaction coordination is arranged in the transaction initiator and is responsible for executing the commit/rollback operation on the local transactions of the transaction initiator and the transaction participants, so that the commit or rollback of the global transactions (including the local transactions of all the transaction initiators and the transaction participants) is realized, and the consistency of the distributed transactions is ensured.
With the embodiment of the present disclosure, when the system where the transaction initiator is located initiates a distributed transaction, the local distributed transaction is executed, and the remote call transactions in the system where the transaction participants are located are sequentially called, and each system operates the database according to the normal flow, but does not perform the real data submission. And the global transaction coordination module in the transaction initiator initiates a real commit or rollback instruction according to the processing result aiming at the remote call transaction, and then each system carries out corresponding commit/rollback operation according to the instruction.
According to the embodiment of the disclosure, the global transaction coordination module is directly arranged in the transaction initiator system, so that the transaction initiator can be simultaneously responsible for coordination of the whole distributed transaction, an additional coordination module is not required to be introduced into the distributed system, and the complexity of the distributed system architecture is reduced.
By integrating the above embodiments, the whole process of the distributed transaction is realized based on the own RPC framework of the distributed system, and other additional communication is not required to be introduced, so that the complexity of distributed transaction deployment, development, distributed system architecture and the like can be further reduced.
Based on the system block diagram shown in fig. 4, fig. 5 schematically shows a flowchart of a method in which a complete distributed transaction processing may be implemented according to an embodiment of the present disclosure.
As shown in fig. 4 and 5, the method may include S501 to S509, for example.
In operation S501, a transaction is started.
According to the embodiment of the present disclosure, a local transaction is started by a transaction initiator, and the local transaction accesses a database after being started, where the process of accessing the database may include, for example, creating a connection in the local (i.e., the transaction initiator) database, caching the connection into a database buffer pool, generating an agent object, and taking over the methods of committing, rolling back, closing, and auto-committing the database connection by a connection agent through the agent object. It should be noted that, at this stage, the automatic commit is first set to the temporarily closed state when necessary, so that the commit process is not really performed in the process of calling and executing the commit operation subsequently.
In operation S502, a global transaction ID is created.
According to the embodiment of the present disclosure, the creation of the global transaction ID (i.e., the above-mentioned global transaction identifier) is responsible for the global transaction coordination module in the transaction initiator, so as to implement propagation throughout the distributed transaction.
In operation S503, a remote RPC method is intercepted, and a header file is set.
According to the embodiment of the disclosure, the transaction dispatching module in the transaction initiator sets the global transaction ID to a Header file Header of a remote RPC method (which may be specifically referred to as the call instruction for the remote call transaction), and an interceptor in the RPC framework acts simultaneously to intercept and store the call instruction for the remote call transaction, so that the transaction dispatching module of the transaction initiator stores a relationship between the global transaction ID and the intercepted call instruction, so as to determine an attribution transaction corresponding to each call instruction, and facilitate subsequent commit/rollback operations that may determine corresponding distributed transactions according to an execution condition of an actual distributed transaction.
It should be noted that the Header may include three parameters, i.e., Try, Commit, and Rollback, and in this embodiment, the Header sets Try to determine that the remote RPC method is the above-mentioned call instruction for the remote call transaction.
In operation S504, the Header is parsed.
According to the embodiment of the present disclosure, a transaction participant (i.e., a remote system) receives the remote RPC method of operation S503, parses Header information, and if it is parsed to obtain Try, determines that the remote RPC method is a call instruction for a remote call transaction in the transaction participant.
In operation S505, the target service method is called and executed, and feedback information is returned.
According to the embodiment of the disclosure, in the case that the remote RPC method is determined to be a call instruction for a remote call transaction, the remote call transaction (i.e. a local transaction of a transaction participant) is started, and a target business method is called. If the target business method is abnormal and the transaction needs Rollback (Rollback), the local transaction of the transaction participant rolls back, then returns feedback information to the transaction initiator, sets the local IP, the service port and the current global transaction ID of the current transaction participant in the Header of the response return (namely the feedback information) before returning, and sets the Rollback identification of the transaction participant in the Header of the feedback information. If the target business method is normal and the transaction needs to be submitted (Commit), the local transaction of the transaction participant is submitted (the transaction is not really submitted here), then feedback information is returned to the transaction initiator, the local IP, the service port and the current global transaction ID of the current transaction participant are set to the Header of the feedback information before returning, and the identifier to be submitted of the transaction participant is set in the Header of the feedback information.
In operation S506, the Header is parsed, and the local transaction is ended.
According to the embodiment of the present disclosure, the transaction initiator performs Header file (i.e., Header) analysis on the received feedback information in operation S505, obtains and records whether the transaction participant corresponding to the corresponding global transaction ID needs to be rolled back or committed through the analysis, and if the Header information indicates that the transaction participant needs to be rolled back, ends the local method of the transaction initiator in advance, does not execute the following logic (e.g., call other remote transactions, etc.), and ends the local transaction.
It should be noted that, if the rollback flag does not appear in the analysis structure of the Header information, the local method and the logic behind the local method are continuously executed until the local method is executed completely, or the local transaction is ended when the rollback flag appears in the next Header analysis.
In operation S507, it is determined to execute an instruction, and the local transaction is processed.
According to the embodiment of the disclosure, under the condition that the local transaction is ended, whether the transaction initiator and the transaction participant have the transaction identifier of rollback or not is checked according to the global transaction ID: under the condition that a rollback identifier exists, the local transaction of the transaction initiator performs real rollback, recovers an automatic submission method, releases database connection, and simultaneously sends a rollback instruction to other transaction participants to be submitted corresponding to the global transaction ID; and under the condition of no rollback identification, the local transaction of the transaction initiator is really submitted, an automatic submission method is recovered, the database connection is released, and meanwhile, a submission instruction is sent to other transaction participants to be submitted corresponding to the global transaction ID.
In operation S508, a remote method is called according to the execution instruction.
According to the embodiment of the disclosure, the remote RPC method is directly called again according to the IP and the service port of the transaction participant related to the global transaction ID, so as to realize the rollback and submission processing of the remote call transaction. Wherein, the directly called process may be, for example, direct connection through RPC framework dubbo, direct connection of JSF, http: // ip: and meanwhile, because the remote RPC method only carries out real submission/rollback operation on the service logic which is not really submitted/rolled before and does not execute new service logic, parameters of the remote RPC method (namely an execution instruction) can be directly transmitted to be empty.
It should be noted that in this embodiment, the Commit value or Rollback value is set in the Header of the remote RPC method according to the result in operation S507, so as to determine that the remote RPC method is the execution instruction sent to the remote call transaction.
In operation S509, the remote call transaction is processed.
According to the embodiment of the present disclosure, the transaction participant (i.e., the remote system) receives the execution instruction of operation S508, and accesses operation S504 described above, parses the Header information, where the result of parsing is Commit or Rollback, and then implements real Commit/Rollback processing on the remote invocation transaction through the connection broker of the transaction participant according to the result of parsing, and then resumes auto-Commit, and releases the database connection.
By the aid of the embodiment of the disclosure, when the distributed transaction is rolled back/submitted, the RPC framework of the service is adopted for communication, and dependence is reduced. The transaction initiator is responsible for the coordination of the distributed transactions, so that the complexity of the architecture is reduced. Meanwhile, when the transaction participants roll back, the transaction participants directly roll back and feed back the result to the transaction coordinator (namely the transaction initiator), so that the consumption of subsequent roll-back communication is reduced, and the overall performance of the distributed transaction is improved.
Fig. 6 schematically shows a block diagram of a distributed transaction processing arrangement for a transaction initiator side according to an embodiment of the present disclosure.
As shown in fig. 6, the distributed transaction apparatus 600 includes a creating module 610, a calling module 620, a first sending module 630, a first receiving module 640, a determining module 650, a first processing module 660, and a second sending module 670.
A creation module 610 for creating a distributed transaction, the distributed transaction including a local transaction and a remote invocation transaction.
And the calling module 620 is used for calling the local transaction.
A first sending module 630, configured to send, in the process of executing the local transaction, a call instruction for the remote call transaction to the distributed system through the remote procedure call protocol.
The first receiving module 640 is configured to receive feedback information returned after the distributed system responds to the call instruction and executes the remote call transaction, where the feedback information is used to represent an execution result of the remote call transaction.
The determining module 650 is configured to determine, according to the feedback information, an execution instruction for the local transaction and the remote call transaction after the process of executing the local transaction is finished, where the execution instruction includes a rollback instruction or a commit instruction.
The first processing module 660 is configured to process the local transaction in response to executing the instruction.
And the second sending module 670 is configured to send the execution instruction to the distributed system corresponding to the remote invocation transaction through the remote procedure call protocol, so as to implement processing on the remote invocation transaction.
According to an embodiment of the present disclosure, the first sending module includes a creating submodule, a storing submodule, and a sending submodule.
And the creating submodule is used for creating a global transaction identifier for the distributed transaction.
And the storage submodule is used for storing the global transaction identifier into a header file of the calling instruction.
And the sending submodule is used for sending the calling instruction of the header file containing the global transaction identifier to the distributed system through a remote procedure calling protocol.
According to an embodiment of the present disclosure, the number of the remote invocation transactions is at least two, and the distributed transaction processing apparatus further includes an ending module.
And the ending module is used for ending the process of executing the local transaction under the condition that feedback information returned after the distributed system responds to the calling instruction and executes at least one remote calling transaction contains rollback information.
According to an embodiment of the present disclosure, the determining module includes a first determining submodule and a second determining submodule.
And the first determining submodule is used for determining that the execution instruction is a rollback instruction under the condition that the feedback information comprises rollback information.
And the second determining submodule is used for determining that the execution instruction is the submission instruction under the condition that only the submission information exists in the feedback information.
According to an embodiment of the present disclosure, the first processing module includes a first rollback module and a first commit submodule.
And the first rollback module is used for executing the transaction rollback operation on the local transaction under the condition that the execution instruction is the rollback instruction.
And the first committing submodule is used for executing the transaction committing operation on the local transaction under the condition that the execution instruction is the committing instruction.
Fig. 7 schematically shows a block diagram of a distributed transaction processing arrangement for transaction participant parties, according to an embodiment of the present disclosure.
As shown in fig. 7, the distributed transaction apparatus 700 includes a second receiving module 710, an executing module 720, a third sending module 730, a third receiving module 740, and a second processing module 750.
A second receiving module 710, configured to receive a call instruction for a remote call transaction based on a remote procedure call protocol, where the call instruction is received during execution of a local transaction.
And the execution module 720 is configured to execute the remote call transaction in response to the call instruction, and output feedback information for characterizing an execution result of the remote call transaction.
A third sending module 730, configured to send the feedback information to the distributed system corresponding to the local transaction through the remote procedure call protocol, so that the distributed system corresponding to the local transaction outputs an execution instruction for the remote call transaction according to the feedback information.
The third receiving module 740 is configured to receive an execution instruction for the remote call transaction based on the remote procedure call protocol, where the execution instruction is received after the process of executing the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction.
The second processing module 750 is configured to process the remote call transaction in response to the execution instruction.
According to an embodiment of the present disclosure, the execution module includes a first execution submodule and a second execution submodule.
And the first execution submodule is used for outputting feedback information with rollback information under the condition that the process of executing the remote calling transaction is abnormal.
And the second execution submodule is used for outputting feedback information with the submission information under the condition that the process of executing the remote calling transaction is normal.
According to an embodiment of the present disclosure, the second processing module includes a second rollback submodule and a second commit submodule.
And the second rollback sub-module is used for executing the transaction rollback operation on the remote call transaction under the condition that the execution instruction is the rollback instruction.
And the second committing submodule is used for executing the transaction committing operation on the remote calling transaction under the condition that the execution instruction is the committing instruction.
Any number of modules, sub-modules, or at least part of the functionality of any number thereof according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules and sub-modules according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, sub-modules according to embodiments of the present disclosure may be implemented at least in part as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging the circuit, or in any one of three implementations, or in any suitable combination of any of the three. Alternatively, one or more of the modules, sub-modules according to embodiments of the disclosure may be implemented at least partly as computer program modules, which when executed may perform corresponding functions.
For example, any plurality of the creating module 610, the calling module 620, the first sending module 630, the first receiving module 640, the determining module 650, the first processing module 660, and the second sending module 670 may be combined and implemented in one module/sub-module, or any one of the modules/sub-modules may be split into a plurality of modules/sub-modules. Alternatively, at least part of the functionality of one or more of these modules/sub-modules may be combined with at least part of the functionality of other modules/sub-modules and implemented in one module/sub-module. According to an embodiment of the present disclosure, at least one of the creating module 610, the invoking module 620, the first sending module 630, the first receiving module 640, the determining module 650, the first processing module 660, and the second sending module 670 may be at least partially implemented as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementations of software, hardware, and firmware, or by a suitable combination of any of them. Alternatively, at least one of the creating module 610, the calling module 620, the first transmitting module 630, the first receiving module 640, the determining module 650, the first processing module 660, and the second transmitting module 670 may be at least partially implemented as a computer program module, which when executed, may perform a corresponding function.
It should be noted that, in the embodiment of the present disclosure, the distributed transaction processing apparatus portion corresponds to the distributed transaction processing method portion in the embodiment of the present disclosure, and the description of the distributed transaction processing apparatus portion specifically refers to the distributed transaction processing method portion, which is not described herein again.
FIG. 8 schematically illustrates a block diagram of a computer system suitable for implementing a distributed transaction processing method according to an embodiment of the present disclosure. The computer system illustrated in FIG. 8 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 8, a computer system 800 according to an embodiment of the present disclosure includes a processor 801 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage section 808 into a Random Access Memory (RAM) 803. The processor 801 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 801 may also include onboard memory for caching purposes. The processor 801 may include a single processing unit or multiple processing units for performing different actions of the method flows according to embodiments of the present disclosure.
In the RAM 803, various programs and data necessary for the operation of the system 800 are stored. The processor 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. The processor 801 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 802 and/or RAM 803. Note that the programs may also be stored in one or more memories other than the ROM 802 and RAM 803. The processor 801 may also perform various operations of method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program can be downloaded and installed from a network through the communication section 809 and/or installed from the removable medium 811. The computer program, when executed by the processor 801, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 802 and/or RAM 803 described above and/or one or more memories other than the ROM 802 and RAM 803.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.
Claims (12)
1. A distributed transaction processing method, comprising:
creating a distributed transaction, wherein the distributed transaction comprises a local transaction and a remote calling transaction;
invoking the local transaction;
in the process of executing the local transaction, sending a calling instruction aiming at the remote calling transaction to a distributed system through a remote procedure calling protocol;
receiving feedback information returned by the distributed system after responding to the calling instruction to execute the remote calling transaction, wherein the feedback information is used for representing the execution result of the remote calling transaction;
after the process of executing the local transaction is finished, determining an execution instruction aiming at the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction comprises a rollback instruction or a commit instruction;
processing the local transaction in response to the execution instruction; and
and sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to realize the processing of the remote call transaction.
2. The method of claim 1, wherein sending a call instruction for the remote call transaction to a distributed system via a remote procedure call protocol during execution of the local transaction comprises:
creating a global transaction identity for the distributed transaction;
storing the global transaction identifier into a header file of the calling instruction; and
and sending the calling instruction of the header file containing the global transaction identifier to the distributed system through a remote procedure calling protocol.
3. The method of claim 1, wherein the remote invocation transactions are at least two, the method further comprising:
and under the condition that feedback information returned after the distributed system responds to the calling instruction to execute at least one remote calling transaction contains rollback information, ending the process of executing the local transaction.
4. The method of claim 1, wherein determining, from the feedback information, execution instructions for the local transaction and the remote invocation transaction after the process of executing the local transaction is completed comprises:
determining that the execution instruction is the rollback instruction when the feedback information comprises rollback information; and
and determining the execution instruction as the submission instruction under the condition that only submission information exists in the feedback information.
5. The method of claim 1, wherein processing the local transaction in response to the execution instruction comprises:
executing a transaction rollback operation on the local transaction if the execution instruction is the rollback instruction; and
and executing a transaction commit operation on the local transaction if the execution instruction is the commit instruction.
6. A distributed transaction processing method, wherein the distributed transactions include local transactions and remote invocation transactions, the method comprising:
receiving a calling instruction aiming at the remote calling transaction based on a remote procedure calling protocol, wherein the calling instruction is received in the process of executing the local transaction;
responding to the calling instruction, executing the remote calling transaction, and outputting feedback information for representing an execution result of the remote calling transaction;
sending the feedback information to a distributed system corresponding to the local affair through a remote process call protocol so that the distributed system corresponding to the local affair outputs an execution instruction aiming at the remote call affair according to the feedback information;
receiving the execution instruction aiming at the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the process of executing the local transaction is finished, and the execution instruction comprises a rollback instruction or a commit instruction; and
and responding to the execution instruction, and processing the remote calling transaction.
7. The method of claim 6, wherein the executing the remote call transaction in response to the call instruction, outputting feedback information characterizing execution results of the remote call transaction comprises:
outputting the feedback information with rollback information under the condition that the process of executing the remote calling transaction is abnormal; and
and under the condition that the process of executing the remote call transaction is normal, outputting the feedback information with the submission information.
8. The method of claim 6, wherein processing the remote call transaction in response to the execution instruction comprises:
executing a transaction rollback operation on the remote invocation transaction if the execution instruction is the rollback instruction; and
and executing a transaction commit operation on the remote call transaction if the execution instruction is the commit instruction.
9. A distributed transaction processing apparatus, comprising:
the system comprises a creating module, a processing module and a processing module, wherein the creating module is used for creating distributed transactions, and the distributed transactions comprise local transactions and remote calling transactions;
the calling module is used for calling the local affair;
the first sending module is used for sending a calling instruction aiming at the remote calling transaction to a distributed system through a remote procedure calling protocol in the process of executing the local transaction;
a first receiving module, configured to receive feedback information returned by the distributed system after the distributed system executes the remote invocation transaction in response to the invocation instruction, where the feedback information is used to characterize an execution result of the remote invocation transaction;
a determining module, configured to determine, according to the feedback information, an execution instruction for the local transaction and the remote invocation transaction after a process of executing the local transaction is completed, where the execution instruction includes a rollback instruction or a commit instruction;
a first processing module, configured to process the local transaction in response to the execution instruction; and
and the second sending module is used for sending the execution instruction to a distributed system corresponding to the remote call transaction through a remote procedure call protocol so as to process the remote call transaction.
10. A distributed transaction processing apparatus, wherein the distributed transactions include local transactions and remote invocation transactions, the apparatus comprising:
a second receiving module, configured to receive a call instruction for the remote call transaction based on a remote procedure call protocol, where the call instruction is received during execution of the local transaction;
the execution module is used for responding to the calling instruction, executing the remote calling transaction and outputting feedback information for representing the execution result of the remote calling transaction;
a third sending module, configured to send the feedback information to a distributed system corresponding to the local transaction through a remote procedure call protocol, so that the distributed system corresponding to the local transaction outputs an execution instruction for the remote procedure call transaction according to the feedback information;
a third receiving module, configured to receive, based on a remote procedure call protocol, the execution instruction for the remote call transaction, where the execution instruction is received after a process of executing the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction; and
and the second processing module is used for responding to the execution instruction and processing the remote calling transaction.
11. A computer system, comprising:
one or more processors;
a memory for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-5 or 6-8.
12. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 5 or 6 to 8.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011151868.3A CN113778699A (en) | 2020-10-23 | 2020-10-23 | Distributed transaction processing method, device, computer system and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011151868.3A CN113778699A (en) | 2020-10-23 | 2020-10-23 | Distributed transaction processing method, device, computer system and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113778699A true CN113778699A (en) | 2021-12-10 |
Family
ID=78835101
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011151868.3A Pending CN113778699A (en) | 2020-10-23 | 2020-10-23 | Distributed transaction processing method, device, computer system and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113778699A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114785878A (en) * | 2022-04-24 | 2022-07-22 | 北京印象笔记科技有限公司 | Information extraction method and device, electronic equipment and computer readable storage medium |
CN116302845A (en) * | 2023-05-17 | 2023-06-23 | 建信金融科技有限责任公司 | Method and device for determining transaction operation mode, electronic equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107045454A (en) * | 2016-02-06 | 2017-08-15 | 华为技术有限公司 | Striding course distributed transaction control method and related system |
CN111008202A (en) * | 2018-10-08 | 2020-04-14 | 北京京东尚科信息技术有限公司 | Distributed transaction processing method and framework |
CN111651244A (en) * | 2020-07-01 | 2020-09-11 | 中国银行股份有限公司 | Processing system for distributed transactions |
CN111722946A (en) * | 2020-06-28 | 2020-09-29 | 深圳壹账通智能科技有限公司 | Distributed transaction processing method and device, computer equipment and readable storage medium |
-
2020
- 2020-10-23 CN CN202011151868.3A patent/CN113778699A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107045454A (en) * | 2016-02-06 | 2017-08-15 | 华为技术有限公司 | Striding course distributed transaction control method and related system |
CN111008202A (en) * | 2018-10-08 | 2020-04-14 | 北京京东尚科信息技术有限公司 | Distributed transaction processing method and framework |
CN111722946A (en) * | 2020-06-28 | 2020-09-29 | 深圳壹账通智能科技有限公司 | Distributed transaction processing method and device, computer equipment and readable storage medium |
CN111651244A (en) * | 2020-07-01 | 2020-09-11 | 中国银行股份有限公司 | Processing system for distributed transactions |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114785878A (en) * | 2022-04-24 | 2022-07-22 | 北京印象笔记科技有限公司 | Information extraction method and device, electronic equipment and computer readable storage medium |
CN116302845A (en) * | 2023-05-17 | 2023-06-23 | 建信金融科技有限责任公司 | Method and device for determining transaction operation mode, electronic equipment and storage medium |
CN116302845B (en) * | 2023-05-17 | 2023-08-15 | 建信金融科技有限责任公司 | Method and device for determining transaction operation mode, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108123996B (en) | Application management service instance | |
US10693816B2 (en) | Communication methods and systems, electronic devices, and computer clusters | |
US20150281035A1 (en) | Monitoring of Node.JS Applications | |
CN113778699A (en) | Distributed transaction processing method, device, computer system and readable storage medium | |
CN113010561B (en) | Data acquisition method and device based on super account book and computer system | |
KR101654479B1 (en) | Method and system for efficient call processing | |
CN115277855A (en) | Request processing method and device, electronic equipment and storage medium | |
CN113132400B (en) | Business processing method, device, computer system and storage medium | |
CN111654525A (en) | Hybrid cloud management method, device, equipment and medium | |
CN112882895A (en) | Health examination method, device, computer system and readable storage medium | |
CN113176907A (en) | Interface data calling method and device, computer system and readable storage medium | |
US7716523B2 (en) | End-to-end transactional protection for requests in a web application | |
CN112953769A (en) | Data transmission method, device, computer system and readable storage medium | |
CN117194068A (en) | Cross-process data transmission method, system, equipment and storage medium | |
CN110290139B (en) | Message transmission method and device | |
CN114095758B (en) | Cloud image intercepting method and related device | |
CN112565340B (en) | Service scheduling method, device, computer system and medium for distributed application | |
CN111325456B (en) | Asset data processing method and apparatus, computer system, and storage medium | |
CN115250276A (en) | Distributed system and data processing method and device | |
CN114780361A (en) | Log generation method, device, computer system and readable storage medium | |
CN113778631A (en) | Distributed transaction compensation method and device, electronic equipment and readable storage medium | |
CN113992750A (en) | Global transaction coordination method, device, equipment and medium | |
EP4030735A1 (en) | Method of data interaction, data interaction apparatus, electronic device and non-transitory computer readable storage medium | |
CN113347250B (en) | Data access method, data access device, electronic equipment and readable storage medium | |
CN118350814B (en) | Method, device, medium and equipment for generating distributed cross-protocol callback transaction |
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 |