Distributed transaction processing method, device, computer system and readable storage medium

By using the remote procedure call protocol in distributed transaction processing to handle execution instructions for local and remote call transactions, the problems of complex communication and complex system architecture in distributed transaction processing are solved, and a simpler system architecture and more efficient communication are achieved. .

CN113778699BActive Publication Date: 2025-02-21BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011151868.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-23
Publication Date
2025-02-21
Estimated Expiration
2040-10-23

AI Technical Summary

Technical Problem

In the prior art, distributed transaction processing has problems such as complex communication and complex system architecture.

Method used

By creating distributed transactions, including local transactions and remote call transactions, the remote procedure call protocol is used to send call instructions during local transaction execution, receive feedback information, and determine execution instructions based on the feedback information to handle local and remote call transactions.

Benefits of technology

This method reduces the complexity of distributed systems, reduces communication complexity, and effectively solves the complex development and deployment problems in distributed transaction processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113778699B_ABST
    Figure CN113778699B_ABST
Patent Text Reader

Abstract

The present disclosure provides a distributed transaction processing method, device, computer system and readable storage medium. The method includes: creating a distributed transaction, the distributed transaction includes a local transaction and a remote call transaction; calling a local transaction; in the process of executing the local transaction, sending a call instruction for the remote call transaction to the distributed system through the remote procedure call protocol; receiving feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, the feedback information is used to characterize the execution result of the remote call transaction; after the process of executing the local transaction ends, determining the execution instruction for the local transaction and the remote call transaction according to the feedback information, the execution instruction includes a rollback instruction or a commit instruction; in response to the execution instruction, processing the local transaction; and sending the execution instruction to the distributed system corresponding to the remote call transaction through the remote procedure call protocol to realize the processing of the remote call transaction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a distributed transaction processing method, device, computer system and readable storage medium. Background Art

[0002] With the development of the Internet and the big data era, more and more business information is stored in databases. As the amount of data continues to increase, it is inevitable to shard the database and tables. In order to ensure the consistency of different database tables for the same operation, a distributed transaction processing mechanism is introduced.

[0003] In the process of implementing the concept of the present disclosure, the inventors discovered that there are at least the following problems in the related technology: the communication on which distributed transactions rely is complex and the distributed system architecture is complex. Summary of the invention

[0004] In view of this, the present disclosure provides a distributed transaction processing method, device, computer system and readable storage medium.

[0005] One aspect of the present disclosure provides a distributed transaction processing method, comprising: creating a distributed transaction, the distributed transaction comprising a local transaction and a remote call transaction; calling the local transaction; 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; receiving feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to characterize the execution result of the remote call transaction; after the process of executing the local transaction ends, determining execution instructions for the local transaction and the remote call transaction according to the feedback information, wherein the execution instructions include a rollback instruction or a commit instruction; processing the local transaction in response to the execution instruction; and sending the execution instruction to the distributed system corresponding to the remote call transaction through a remote procedure call protocol to realize processing of the remote call transaction.

[0006] 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 identifier for the distributed transaction; storing the global transaction identifier in a header file of the call instruction; and sending the call instruction containing the header file of the global transaction identifier to the distributed system through the remote procedure call protocol.

[0007] According to an embodiment of the present disclosure, there are at least two remote call transactions, and the method further includes: when feedback information returned by the distributed system after executing at least one of the remote call transactions in response to the call instruction contains rollback information, ending the process of executing the local transaction.

[0008] According to an embodiment of the present disclosure, after the process of executing the local transaction is completed, determining the execution instructions for the local transaction and the remote call transaction based on the feedback information includes: when there is rollback information in the feedback information, determining that the execution instruction is the rollback instruction; and when there is only commit information in the feedback information, determining that the execution instruction is the commit instruction.

[0009] According to an embodiment of the present disclosure, in response to the execution instruction, processing the local transaction includes: when the execution instruction is the rollback instruction, performing a transaction rollback operation on the local transaction; and when the execution instruction is the commit instruction, performing a transaction commit operation on the local transaction.

[0010] Another aspect of the present disclosure provides another distributed transaction processing method, wherein the distributed transaction includes a local transaction and a remote call transaction, and the method includes: receiving a call instruction for the remote call transaction based on a remote procedure call protocol, wherein the call instruction is received during the execution of the local transaction; in response to the call instruction, executing the remote call transaction, and outputting feedback information for representing the execution result of the remote call transaction; sending 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 call transaction according to the feedback information; receiving the execution instruction for the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction ends, and the execution instruction includes a rollback instruction or a commit instruction; and processing the remote call transaction in response to the execution instruction.

[0011] According to an embodiment of the present disclosure, in response to the calling instruction, the remote call transaction is executed, and the feedback information used to characterize the execution result of the remote call transaction is output, including: when an exception occurs in the process of executing the remote call transaction, the feedback information with rollback information is output; and when the process of executing the remote call transaction is normal, the feedback information with commit information is output.

[0012] According to an embodiment of the present disclosure, in response to the execution instruction, processing the remote call transaction includes: when the execution instruction is the rollback instruction, performing a transaction rollback operation on the remote call transaction; and when the execution instruction is the commit instruction, performing a transaction commit operation on the remote call transaction.

[0013] Another aspect of the present disclosure provides a distributed transaction processing device, including: a creation module, used to create a distributed transaction, the distributed transaction includes a local transaction and a remote call transaction; a calling module, used to call the local transaction; a first sending module, used to send a call instruction for the remote call transaction to a distributed system through a remote procedure call protocol during the execution of the local transaction; a first receiving module, used to receive feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to characterize the execution result of the remote call transaction; a determination module, used to determine the execution instructions for the local transaction and the remote call transaction according to the feedback information after the execution of the local transaction is completed, wherein the execution instructions include a rollback instruction or a commit instruction; a first processing module, used to process the local transaction in response to the execution instruction; and a second sending module, used to send the execution instruction to the distributed system corresponding to the remote call transaction through a remote procedure call protocol to realize the processing of the remote call transaction.

[0014] Another aspect of the present disclosure provides another distributed transaction processing device, wherein the distributed transaction includes a local transaction and a remote call transaction, and the device includes: a second receiving module, used to receive a call instruction for the remote call transaction based on a remote procedure call protocol, wherein the call instruction is received during the execution of the local transaction; an execution module, used to execute the remote call transaction in response to the call instruction, and output feedback information used to characterize the execution result of the remote call transaction; a third sending module, used 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 the execution instruction for the remote call transaction according to the feedback information; the third receiving module, used to receive the execution instruction for the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction ends, and the execution instruction includes a rollback instruction or a commit instruction; and a second processing module, used to process the remote call transaction in response to the execution instruction.

[0015] Another aspect of the present disclosure provides a computer system, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0016] Another aspect of the present disclosure provides a computer-readable storage medium having computer-executable instructions stored thereon, which are used to implement the method described above when the instructions are executed.

[0017] Another aspect of the present disclosure provides a computer program, which includes computer executable instructions, and the instructions are used to implement the method described above when executed.

[0018] According to an embodiment of the present disclosure, a distributed transaction is created, and the distributed transaction includes a local transaction and a remote call transaction; a local transaction is called; in the process of executing the local transaction, a call instruction for the remote call transaction is sent to the distributed system through the remote procedure call protocol; feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction is received, wherein the feedback information is used to characterize the execution result of the remote call transaction; after the process of executing the local transaction is completed, the execution instruction for the local transaction and the remote call transaction is determined according to the feedback information, wherein the execution instruction includes a rollback instruction or a commit instruction; in response to the execution instruction, the local transaction is processed; and the execution instruction is sent to the distributed system corresponding to the remote call transaction through the remote procedure call protocol to implement the technical means for processing the remote call transaction. Since the communication between the local transaction and the remote call transaction is implemented through the remote procedure call protocol, the calling and processing of the remote call transaction can be implemented simultaneously through the protocol, reducing the additional communication configuration, so as to at least partially overcome the technical problem of complex communication, thereby achieving the technical effect of reducing the complexity of communication and even the complexity of the distributed system architecture. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:

[0020] Figure 1 An exemplary system architecture to which a distributed transaction processing method can be applied according to an embodiment of the present disclosure is schematically shown;

[0021] Figure 2 A flowchart of a distributed transaction processing method for a transaction initiator according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 3A flowchart of a distributed transaction processing method for transaction participants according to an embodiment of the present disclosure is schematically shown;

[0023] Figure 4 A system block diagram schematically shows a system block diagram that can implement a complete distributed transaction processing method according to an embodiment of the present disclosure;

[0024] Figure 5 A flowchart of a complete distributed transaction processing method according to an embodiment of the present disclosure is schematically shown;

[0025] Figure 6 A block diagram schematically shows a distributed transaction processing device for a transaction initiator according to an embodiment of the present disclosure;

[0026] Figure 7 A block diagram schematically shows a distributed transaction processing apparatus for a transaction participant according to an embodiment of the present disclosure; and

[0027] Figure 8 A block diagram of a computer system suitable for implementing a distributed transaction processing method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0028] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0030] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.

[0031] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0032] In the Internet era, in order to complete the functions required by the system, the system architecture is often very complex. For example, the original single system may be split into multiple distributed systems. In this case, in order to ensure the consistency of data in the distributed system, distributed transactions are very important. Different enterprises and companies often use distributed transaction implementation methods to maintain the eventual consistency of distributed transactions, or use TCC (a distributed transaction processing mechanism, including three stages of Try, Confirm, and Cancel) and other methods to implement it.

[0033] However, in the process of realizing the concept of the present disclosure, the inventors found that the distributed transactions implemented by the prior art are complex to develop and deploy, and the system architecture is complex. For example, some external frameworks have a large business intrusion on the system and are relatively complex to implement. For example, in order to achieve the purpose of distributed transactions and complete a business requirement, the TCC transaction framework needs to be split into three steps: Try, Confirm, and Cancel. Each step requires in-depth consideration of the business, and then the TCC transaction framework and the business are coordinated to achieve the ultimate goal. For another example, although some frameworks have improved business intrusion, they introduce numerous components such as Redis (an open source database) and additional Netty (a network application framework) communications into the system, which makes the system configuration complex, and communication and maintenance inconvenient.

[0034] The embodiments of the present disclosure provide a distributed transaction processing method, device, computer system and readable storage medium. The method includes creating a distributed transaction, the distributed transaction includes a local transaction and a remote call transaction; calling a local transaction; in the process of executing the local transaction, sending a call instruction for the remote call transaction to the distributed system through the remote procedure call protocol; receiving feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to characterize the execution result of the remote call transaction; after the process of executing the local transaction ends, determining the execution instruction for the local transaction and the remote call transaction according to the feedback information, wherein the execution instruction includes a rollback instruction or a commit instruction; in response to the execution instruction, processing the local transaction; and sending the execution instruction to the distributed system corresponding to the remote call transaction through the remote procedure call protocol to realize the processing of the remote call transaction.

[0035] Figure 1 The exemplary system architecture 100 to which the distributed transaction processing method according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.

[0036] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The terminal devices 101, 102, 103 and the server 105 may all be used as a distributed system, and a distributed transaction may be formed between any at least two of them. The network 104 is used to provide a medium for a communication link between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0037] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc.

[0038] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0039] The server 105 may be a server that provides various services, such as a background management server that provides support for services accessed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process received data such as user requests, and feed back processing results (such as instructions or feedback information obtained or generated according to user requests, etc.) to the terminal device.

[0040] It should be noted that the distributed transaction processing method provided in the embodiment of the present disclosure can generally be executed by the terminal device 101, 102 or 103, or can also be executed by other terminal devices different from the terminal device 101, 102 or 103. Accordingly, the distributed transaction processing apparatus provided in the embodiment of the present disclosure can be set in the terminal device 101, 102 or 103, or can be set in other terminal devices different from the terminal device 101, 102 or 103.

[0041] For example, the local transaction may be a transaction of any one of the terminal devices 101, 102, or 103 (for example, the terminal device 101, but not limited thereto), or a transaction of an external device associated with the terminal device 101. Then, the terminal device 101 may locally execute the distributed transaction processing method provided by the embodiment of the present disclosure, or send the local transaction to other terminal devices, servers, or server clusters, and the other terminal devices, servers, or server clusters that receive the local transaction may execute the distributed transaction processing method provided by the embodiment of the present disclosure.

[0042] Alternatively, the distributed transaction processing method provided in the embodiment of the present disclosure may also be executed by the server 105. Accordingly, the distributed transaction processing apparatus provided in the embodiment of the present disclosure may generally be arranged in the server 105. The distributed transaction processing method provided in the embodiment of the present disclosure may also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the distributed transaction processing apparatus provided in the embodiment of the present disclosure may also be arranged in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.

[0043] For example, the remote call transaction may be a transaction in the server 105, or a transaction of another server associated with the server 105. Then, the server 105 may locally execute the distributed transaction processing method provided by the embodiment of the present disclosure, or send the remote call transaction to another terminal device, server, or server cluster, and the other terminal device, server, or server cluster that receives the remote call transaction may execute the distributed transaction processing method provided by the embodiment of the present disclosure.

[0044] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0045] Figure 2 The flowchart of the distributed transaction processing method for the transaction initiator according to the embodiment of the present disclosure is schematically shown.

[0046] like Figure 2 As shown, the method includes operations S201 to S207.

[0047] In operation S201, a distributed transaction is created, where the distributed transaction includes a local transaction and a remote call transaction.

[0048] According to an embodiment of the present disclosure, a distributed transaction is created by a transaction initiator. For example, the distributed transaction is a transfer business from account A to account B initiated by account A. Account A acts as the transaction initiator, and the transfer operation and transfer result for account A are local transactions. The software or system related to account B acts as a transaction participant, and the related operations for account B are remote call transactions that need to be called when executing the local transaction of account A.

[0049] In operation S202 , a local transaction is called.

[0050] According to the embodiments of the present disclosure, while initiating a transfer service, account A calls a local transaction to start executing the transfer operation. The calling of the local transaction can, for example, be a program segment that calls and obtains the account balance of account A, and calls and executes a transfer operation on the balance (i.e., subtracting the transfer amount from the current balance to obtain the balance value after the transfer). It should be noted that the result of the transfer operation here will not be directly displayed on the user-visible interface. Here, only one of the program operations in the program that implements the local transaction processing (here, the relevant processing for account A) is executed. To achieve the final result display, it is necessary to display it after executing all programs for local transactions and remote call transactions.

[0051] In operation S203, during the execution of the local transaction, a call instruction for the remote call transaction is sent to the distributed system through the remote procedure call protocol.

[0052] According to the embodiments of the present disclosure, in order to maintain the consistency of data in a distributed transaction (i.e., account A and account B), it is usually necessary to perform corresponding operations on account B during the operation on account A. Therefore, the transaction initiator (i.e., account A) inevitably needs to communicate with the system related to account B. The RPC (Remote Procedure Call) protocol is a distributed system's own protocol that can realize remote communication. It can be understood that the distributed system comes with an RPC framework to realize communication between remote services. In this embodiment, a call instruction for account B (remote call transaction) is directly sent to the transaction participant through the RPC protocol.

[0053] In operation S204, feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction is received, wherein the feedback information is used to represent the execution result of the remote call transaction.

[0054] According to an embodiment of the present disclosure, based on the data consistency requirements of distributed transactions, the transaction initiator (account party A) also needs to receive the transaction execution results of the transaction participant (account party B). This receiving behavior is also implemented based on the RPC protocol in order to proceed to the next step.

[0055] In operation S205, after the process of executing the local transaction is completed, an execution instruction for the local transaction and the remote call transaction is determined according to the feedback information, wherein the execution instruction includes a rollback instruction or a commit instruction.

[0056] According to an embodiment of the present disclosure, the process of executing a local transaction includes the above-mentioned operations S202 to S204, and the execution instructions for the local transaction and the remote call transaction (i.e., accounts A and B) are determined according to the transaction execution result of the transaction participant (account B) obtained in operation S204. Among them, the rollback instruction is, for example, a rollback operation on the program that has been executed in the current distributed transaction processing process, for example, it may include executing a rollback instruction on the transfer operation in operation S202, so that the account balance of account A in the program is restored to the original balance, etc., and the commit instruction is, for example, a commit operation on the program that has been executed in the current distributed transaction processing process, for example, it may include executing a commit instruction on the transfer operation in operation S202, so that the account balance of account A is based on the balance value after the transfer operation.

[0057] It should be noted that the above process of determining the execution instruction may also be determined based on the execution results of the local transaction and the remote call transaction, for example.

[0058] In operation S206 , in response to the execution instruction, the local transaction is processed.

[0059] In operation S207, the execution instruction is sent to the distributed system corresponding to the remote call transaction through the remote procedure call protocol to process the remote call transaction.

[0060] According to an embodiment of the present disclosure, after the execution instructions for the local transaction and the remote call transaction (i.e., accounts A and B) are determined through operation S205, the execution instructions are executed on both the local transaction and the remote call transaction to realize the processing of the distributed transaction. For example, a commit instruction may be executed on both accounts A and B to complete the transfer behavior, or a rollback instruction may be executed on both accounts A and B to indicate that the above transfer behavior is not successfully completed. It should be noted that the execution instruction sent to the remote call transaction is also implemented through the RPC protocol.

[0061] Through the above-mentioned embodiments of the present disclosure, since the remote communication of distributed transactions is implemented through its own RPC framework without introducing other communication mechanisms, the communication dependence is reduced, thereby reducing the complexity of the distributed system and effectively solving the complex development and deployment problems when implementing distributed transactions.

[0062] The following is a more specific embodiment. Figure 2 The method shown is further explained.

[0063] According to an embodiment of the present disclosure, the above operation S203 includes: creating a global transaction identifier for a distributed transaction; storing the global transaction identifier in a header file of a calling instruction; and sending the calling instruction of the header file containing the global transaction identifier to a distributed system through a remote procedure call protocol.

[0064] According to an embodiment of the present disclosure, when RPC calls a remote method, a globally unique transaction ID (i.e., a global transaction identifier) ​​is first created and stored in the header file of the RPC method for propagation in the entire 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 for. For example, when a transfer application is initiated multiple times, it is necessary to use the global transaction identifier to determine which transfer transaction each operation is for.

[0065] It should be noted that the RPC method is not limited to the above-mentioned calling instructions, and may also be, for example, feedback information returned by operation S204, or execution instructions in operation S207, and other information or instructions that realize communication between the transaction initiator and the transaction participants.

[0066] According to an embodiment of the present disclosure, there are at least two remote call transactions mentioned above, and the distributed transaction processing method mentioned above also includes: when the feedback information returned after receiving the distributed system's response to the above call instruction to execute at least one remote call transaction contains rollback information, the process of executing the local transaction is terminated.

[0067] According to an embodiment of the present disclosure, the above operation S205 includes: when the feedback information contains rollback information, determining that the execution instruction is a rollback instruction; and when the feedback information contains only commit information, determining that the execution instruction is a commit instruction.

[0068] According to the embodiments of the present disclosure, the situations in which the execution process of a local transaction ends may include, for example, the situation in which the local transaction ends normally due to the end of the program after both the local transaction and the remote call transaction are normally executed, and the situation in which the local transaction and / or the remote call transaction ends midway due to an exception triggering an interrupt operation during the execution process. In either case, the final execution instruction must be determined after the local transaction ends based on the execution result of the remote call transaction, or based on the execution results of the local transaction and the remote call transaction. The exceptions may include, for example, exceptions caused by external events or hardware, and exceptions caused by the program. In combination with the specific embodiments, the exception may, for example, be that the transfer amount exceeds the maximum range that can be transferred, or that the transfer is prohibited during the system maintenance phase.

[0069] According to an embodiment of the present disclosure, the operation S206 includes: when the execution instruction is a rollback instruction, executing a transaction rollback operation on the local transaction; and when the execution instruction is a commit instruction, executing a transaction commit operation on the local transaction.

[0070] Through the above-mentioned embodiments of the present disclosure, due to the adoption of the Fail-Fast concept, when the transaction initiator detects that a transaction participant rolls back the transaction, the local transaction is directly ended, which can effectively avoid the communication consumption when subsequent transactions are rolled back and improve the overall performance of distributed transactions.

[0071] It should be noted that in the process of the distributed transaction processing method performed by the transaction initiator, all the calling and executing operations are only operations on the program, and the execution results of the program are not really reflected on the user-visible interface. Only when the local transaction and the remote call transaction are processed later, the execution results of the program are really reflected on the user interface. The calling, executing and processing operations on the transaction participants follow the same definition.

[0072] Figure 3 The flowchart of the distributed transaction processing method for transaction participants according to an embodiment of the present disclosure is schematically shown.

[0073] like Figure 3 As shown, the method includes operations S301 to S305.

[0074] In operation S301, a call instruction for a remote call transaction is received based on a remote procedure call protocol, wherein the call instruction is received during the execution of a local transaction.

[0075] According to an embodiment of the present disclosure, operation S301 is followed by operation S203, and a call instruction sent by a transaction initiator is received through the RPC protocol. Referring to operation S203, the call instruction is sent during the execution of a local transaction, so that the complete execution process of the local transaction can be realized through the operation of the remote call transaction.

[0076] In operation S302 , in response to the calling instruction, a remote calling transaction is executed, and feedback information representing the execution result of the remote calling transaction is output.

[0077] According to the embodiments of the present disclosure, the execution process of the remote call transaction is similar to the process of calling the local transaction in the aforementioned operation S202. In combination with the aforementioned embodiments, the execution of the remote call transaction can be, for example, a program segment for calling and obtaining the account balance of account B, and calling and executing a transfer operation on the account balance of account B (adding the current balance of account B to the transfer amount to obtain the balance value after the transfer). It should be noted that the result of the transfer operation for account B here will not be directly displayed on the user-visible interface. Here, only one of the program operations in the program for implementing the remote call transaction processing (here, the relevant processing for account B) is executed. To achieve the final result display, it is also necessary to display it after all programs for local transactions and remote call transactions are executed.

[0078] 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.

[0079] According to an embodiment of the present disclosure, the operation S303 corresponds to the aforementioned operations S204 to S205, and the relevant embodiments thereof have been described above and will not be repeated here.

[0080] In operation S304, an execution instruction for the remote call transaction is received based on the remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction.

[0081] In operation S305 , in response to the execution instruction, the remote call transaction is processed.

[0082] According to an embodiment of the present disclosure, the above operations S304 to S305 correspond to the above operation S207, and the relevant embodiments thereof have been described above and will not be repeated here.

[0083] It should be noted that, as in the above operations S303 and S304, the communication between the remote call transaction and the local transaction is implemented through the RPC protocol.

[0084] Through the above-mentioned embodiments of the present disclosure, since the remote communication of distributed transactions is implemented through its own RPC framework without introducing other communication mechanisms, the communication dependence is reduced, thereby reducing the complexity of the distributed system and effectively solving the complex development and deployment problems when implementing distributed transactions.

[0085] According to an embodiment of the present disclosure, the above operation S302 includes: if an exception occurs during the execution of the remote call transaction, outputting feedback information with rollback information; and if the execution of the remote call transaction is normal, outputting feedback information with commit information.

[0086] It should be noted that the above-mentioned abnormal situation in the process of executing the remote call transaction may be, for example, calling and executing a program segment that triggers an abnormality due to a large transfer amount or system reasons. In this case, the feedback information obtained includes rollback information for operations related to the remote call transaction (account B). At this time, the feedback information received in the above-mentioned operation S204 includes rollback information. After the transaction initiator receives the feedback information with rollback information, it can terminate the execution operation of the local transaction.

[0087] Through the above-mentioned embodiments of the present disclosure, when there is a transaction participant that rolls back the transaction, it is rolled back first and the result is fed back to the transaction initiator, and the transaction initiator directly ends the local transaction, which can effectively avoid communication consumption when subsequent transactions are rolled back, thereby improving the overall performance of distributed transactions.

[0088] According to an embodiment of the present disclosure, the above operation S305 includes: when the execution instruction is a rollback instruction, performing a transaction rollback operation on the remote call transaction; and when the execution instruction is a commit instruction, performing a transaction commit operation on the remote call transaction.

[0089] By combining the operations between the transaction participants and the transaction initiators mentioned above, the reasonable processing of the entire distributed transaction can be achieved while maintaining data consistency.

[0090] Reference below Figure 4-5 , and combined with the complete implementation example Figure 2 and Figure 3 The method shown is further explained.

[0091] Figure 4 A system block diagram that can implement a complete distributed transaction processing method according to an embodiment of the present disclosure is schematically shown.

[0092] like Figure 4As shown, a distributed transaction can be formed by combining the local transactions of system 1, system 2 and system 3. Among them, system 1 is the transaction initiator (for example, the aforementioned account A), and system 2 and system 3 are transaction participants (for example, the aforementioned account B). When the transaction initiator (such as system 1) initiates a local transaction, the local transactions of the relevant transaction participants (such as system 2 and system 3) will be called. Each system can include modules such as database, database connection pool, connection agent, local transaction and transaction dispatch, and a global transaction coordination module can also be set in the transaction initiator at the same time.

[0093] According to the embodiments of the present disclosure, the database may be, for example, a common database such as MySQL, Oracle, etc. The database connection pool may be, for example, a common database connection pool such as Druid, DBCP, c3p0, etc., which is used to cache the established connections of the database, so that when the database needs to be called later, the database with the established connection can be directly found from the database connection pool and called directly without repeatedly establishing the connection. The connection proxy returns a proxy object when a new database connection is created. The proxy object is obtained from the database connection pool, and the proxy object takes over the methods of committing, rolling back, closing, setting auto-commit, etc. of the Connection to realize the control of global transactions. For example, a local transaction may be implemented by a Spring (a lightweight open source framework) transaction manager, and the execution of local transactions is handled by a connection proxy. Transaction dispatch is responsible for the propagation of the global transaction ID, and collects all transaction participant information, as well as decides to call the real business method, to realize the operations of committing, rolling back, etc. of the local transactions in the transaction initiator and the transaction participants. The global transaction coordination is set in the transaction initiator, which is responsible for performing commit / rollback operations on the local transactions of the transaction initiator and transaction participants, and then realizing the commit or rollback of the global transaction (including the local transactions of all transaction initiators and transaction participants) to ensure the consistency of distributed transactions.

[0094] In combination with the above-mentioned embodiments 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 transaction in the system where the transaction participants are located is called in sequence, and each system operates the database according to the normal process, but does not perform real data submission. The global transaction coordination module in the transaction initiator initiates a real submission or rollback instruction according to the processing result of the remote call transaction, and then each system performs the corresponding submission / rollback operation according to this instruction.

[0095] Through the above-mentioned embodiments of the present disclosure, since the global transaction coordination module is directly set in the transaction initiator system, the transaction initiator can be responsible for the coordination of the entire distributed transaction at the same time, thereby eliminating the need to introduce additional coordination modules in the distributed system, thereby reducing the complexity of the distributed system architecture.

[0096] In summary of the above embodiments, since the entire process of distributed transactions is implemented based on the distributed system's own RPC framework and no other additional communications need to be introduced, the complexity of distributed transaction deployment, development, and distributed system architecture can be further reduced.

[0097] based on Figure 4 The system block diagram shown in Figure 5 A flowchart of a complete distributed transaction processing method according to an embodiment of the present disclosure is schematically shown.

[0098] Combination Figure 4 and Figure 5 As shown, the method may include, for example, S501 to S509.

[0099] In operation S501 , a transaction is started.

[0100] According to an embodiment of the present disclosure, a transaction initiator opens a local transaction, and after the local transaction is opened, the database is accessed. The process of accessing the database may include, for example, creating a connection to the local (i.e., transaction initiator) database, caching the connection in a database buffer pool, generating a proxy object, and the connection proxy takes over the methods of committing, rolling back, closing, and automatically committing the database connection through the proxy object. It should be noted that at this stage, when necessary, the automatic commit is first set to a temporarily closed state so that the commit process is not actually performed in the subsequent calling and executing of the commit operation.

[0101] In operation S502, a global transaction ID is created.

[0102] According to an embodiment of the present disclosure, the global transaction coordination module in the transaction initiator is responsible for creating the global transaction ID (ie, the global transaction identifier) ​​to implement propagation of the global transaction ID in the entire distributed transaction.

[0103] In operation S503, the remote RPC method is intercepted and a header file is set.

[0104] According to an embodiment of the present disclosure, the transaction dispatching module in the transaction initiator sets the above-mentioned global transaction ID to the header file Header of the remote RPC method (here, for example, it can be specifically referred to as the above-mentioned call instruction for the remote call transaction), and the interceptor in the RPC framework takes effect at the same time to intercept and save the call instruction for the remote call transaction, so that the relationship between the global transaction ID and the intercepted call instruction is saved in the transaction dispatching module of the transaction initiator, so as to facilitate the determination of the transaction corresponding to each call instruction, and at the same time facilitate the subsequent determination of the commit / rollback operation of the corresponding distributed transaction according to the actual execution status of the distributed transaction.

[0105] It should be noted that the Header may include three parameters, for example, Try, Commit and Rollback. In this embodiment, by setting Try=true in the Header, it is determined that the remote RPC method is the above-mentioned call instruction for the remote call transaction.

[0106] In operation S504, the Header is parsed.

[0107] According to an embodiment of the present disclosure, a transaction participant (ie, a remote system) receives the remote RPC method of operation S503 and parses the Header information. If the parsed result is Try=true, the remote RPC method is determined to be a call instruction for a remote call transaction in the transaction participant.

[0108] In operation S505, the target business method is called and executed, and feedback information is returned.

[0109] According to an embodiment of the present disclosure, when it is determined that the above-mentioned remote RPC method is a call instruction for a remote call transaction, the remote call transaction (i.e., the local transaction of the transaction participant) is opened and the target business method is called. If the target business method is abnormal and the transaction needs to be rolled back (Rollback), the local transaction of the transaction participant is rolled back, and then feedback information is returned to the transaction initiator, and the local IP, service port, and current global transaction ID of the current transaction participant are set to the Header of the response return (i.e., feedback information) before returning, and the rollback flag of the transaction participant is set in the Header of the feedback information. If the target business method is normal and the transaction needs to be committed (Commit), the local transaction of the transaction participant is committed (here, it is not actually committed), and then feedback information is returned to the transaction initiator, and the local IP, service port, and current global transaction ID of the current transaction participant are set to the Header of the feedback information before returning, and the pending commit flag of the transaction participant is set in the Header of the feedback information.

[0110] In operation S506, the Header is parsed and the local transaction ends.

[0111] According to an embodiment of the present disclosure, the transaction initiator parses the header file (i.e., Header) for the feedback information received in operation S505, obtains and records through the parsing whether the transaction participant corresponding to the corresponding global transaction ID needs to roll back or commit, and if the Header information indicates that the transaction participant needs to roll back, the local method of the transaction initiator is terminated in advance, and the subsequent logic (such as calling other remote transactions, etc.) is no longer executed, thereby terminating the local transaction.

[0112] It should be noted that if the rollback mark does not appear in the parsed structure of the Header information, the local method and its subsequent logic will continue to be executed until the local method is executed, or if the rollback mark appears in the next Header parsing, the local transaction will be ended.

[0113] In operation S507, it is determined to execute the instruction and process the local transaction.

[0114] According to an embodiment of the present disclosure, when a local transaction ends, it is checked whether there is a rollback transaction identifier among the transaction initiator and the transaction participants based on the global transaction ID: if there is a rollback identifier, the local transaction of the transaction initiator is truly rolled back, and the automatic commit method is restored, the database connection is released, and a rollback instruction is sent to other transaction participants to be committed corresponding to the global transaction ID; if there is no rollback identifier, the local transaction of the transaction initiator is truly committed, and the automatic commit method is restored, the database connection is released, and a commit instruction is sent to other transaction participants to be committed corresponding to the global transaction ID.

[0115] In operation S508 , the remote method is called according to the execution instruction.

[0116] According to the embodiments of the present disclosure, the remote RPC method is directly called again according to the IP and service port of the transaction participant related to the global transaction ID to implement the rollback and commit processing of the remote call transaction. The direct call process can be implemented, for example, through the direct connection of the RPC framework dubbo, the direct connection of JSF, http: / / ip:port, etc. At the same time, because this remote RPC method only performs a real commit / rollback operation on the business logic that was not actually committed / rolled back before, and does not execute new business logic, the parameters of the remote RPC method (i.e., the execution instruction) can be directly passed as empty.

[0117] It should be noted that, in this embodiment, Commit=true or Rollback=true is set in the Header of the remote RPC method according to the result in operation S507 to determine that the remote RPC method is an execution instruction sent to the remote call transaction.

[0118] In operation S509, the remote call transaction is processed.

[0119] According to an embodiment of the present disclosure, a transaction participant (i.e., a remote system) receives an execution instruction of operation S508, and accesses the above-mentioned operation S504 to parse the Header information. Obviously, the parsing result here is Commit=true or Rollback=true. Then, according to the parsing result, the real commit / rollback processing of the remote call transaction is implemented through the connection agent of the transaction participant, and then the automatic commit is restored to release the database connection.

[0120] Through the above-mentioned embodiments of the present disclosure, when the distributed transaction is rolled back / committed, the RPC framework communication of the business itself is adopted to reduce the dependency. The transaction initiator itself is responsible for the coordination of the distributed transaction, which reduces the complexity of the architecture. At the same time, when the transaction participant rolls back, the rollback is directly performed and the result is fed back to the transaction coordinator (i.e., the transaction initiator), which reduces the subsequent rollback communication consumption and improves the overall performance of the distributed transaction.

[0121] Figure 6 A block diagram of a distributed transaction processing apparatus for a transaction initiator according to an embodiment of the present disclosure is schematically shown.

[0122] like Figure 6 As shown, the distributed transaction processing device 600 includes a creation module 610, a calling module 620, a first sending module 630, a first receiving module 640, a determination module 650, a first processing module 660 and a second sending module 670.

[0123] The creation module 610 is used to create a distributed transaction, which includes a local transaction and a remote call transaction.

[0124] The calling module 620 is used to call a local transaction.

[0125] The first sending module 630 is used to send a call instruction for a remote call transaction to the distributed system through a remote procedure call protocol during the execution of a local transaction.

[0126] The first receiving module 640 is used to receive feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to represent the execution result of the remote call transaction.

[0127] The determination module 650 is used to determine the execution instruction for the local transaction and the remote call transaction according to the feedback information after the execution of the local transaction is completed, wherein the execution instruction includes a rollback instruction or a commit instruction.

[0128] The first processing module 660 is used to process the local transaction in response to the execution instruction.

[0129] The second sending module 670 is used to send the execution instruction to the distributed system corresponding to the remote call transaction through the remote procedure call protocol, so as to process the remote call transaction.

[0130] According to an embodiment of the present disclosure, the above-mentioned first sending module includes a creating submodule, a storing submodule and a sending submodule.

[0131] Create a submodule to create a global transaction identifier for distributed transactions.

[0132] The storage submodule is used to store the global transaction identifier in the header file of the calling instruction.

[0133] The sending submodule is used to send the calling instruction of the header file containing the global transaction identifier to the distributed system through the remote procedure call protocol.

[0134] According to an embodiment of the present disclosure, there are at least two remote call transactions, and the distributed transaction processing apparatus further includes an end module.

[0135] The end module is used to end the process of executing the local transaction when the feedback information returned after receiving the distributed system's response to the call instruction to execute at least one remote call transaction contains rollback information.

[0136] According to an embodiment of the present disclosure, the above-mentioned determination module includes a first determination submodule and a second determination submodule.

[0137] The first determination submodule is used to determine that the execution instruction is a rollback instruction when the feedback information contains rollback information.

[0138] The second determination submodule is used to determine that the execution instruction is a submission instruction when there is only submission information in the feedback information.

[0139] According to an embodiment of the present disclosure, the first processing module includes a first rollback submodule and a first commit submodule.

[0140] The first rollback submodule is used to execute a transaction rollback operation on a local transaction when the execution instruction is a rollback instruction.

[0141] The first commit submodule is used to perform a transaction commit operation on the local transaction when the execution instruction is a commit instruction.

[0142] Figure 7 A block diagram of a distributed transaction processing apparatus for transaction participants according to an embodiment of the present disclosure is schematically shown.

[0143] like Figure 7 As shown, the distributed transaction processing device 700 includes a second receiving module 710, an execution module 720, a third sending module 730, a third receiving module 740 and a second processing module 750.

[0144] The second receiving module 710 is used to receive a call instruction for a remote call transaction based on a remote procedure call protocol, wherein the call instruction is received during the execution of a local transaction.

[0145] The execution module 720 is used to execute the remote call transaction in response to the call instruction, and output feedback information representing the execution result of the remote call transaction.

[0146] The third sending module 730 is used 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.

[0147] The third receiving module 740 is used to receive an execution instruction for a remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction.

[0148] The second processing module 750 is used to process the remote call transaction in response to the execution instruction.

[0149] According to an embodiment of the present disclosure, the above-mentioned execution module includes a first execution submodule and a second execution submodule.

[0150] The first execution submodule is used to output feedback information with rollback information when an exception occurs during the execution of the remote call transaction.

[0151] The second execution submodule is used to output feedback information with submission information when the process of executing the remote call transaction is normal.

[0152] According to an embodiment of the present disclosure, the second processing module includes a second rollback submodule and a second commit submodule.

[0153] The second rollback submodule is used to perform a transaction rollback operation on the remote call transaction when the execution instruction is a rollback instruction.

[0154] The second commit submodule is used to perform a transaction commit operation on the remote call transaction when the execution instruction is a commit instruction.

[0155] According to the modules and submodules of the embodiments of the present disclosure, any multiple or at least part of the functions of any multiple thereof can be implemented in one module. According to the modules and submodules of the embodiments of the present disclosure, any one or more thereof can be split into multiple modules for implementation. According to the modules and submodules of the embodiments of the present disclosure, any one or more thereof can 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 can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, according to the modules and submodules of the embodiments of the present disclosure, one or more thereof can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0156] For example, any multiple of the creation module 610, the calling module 620, the first sending module 630, the first receiving module 640, the determination module 650, the first processing module 660, and the second sending module 670 can be combined in one module / submodule for implementation, or any one of the modules / submodules can be split into multiple modules / submodules. Alternatively, at least part of the functions of one or more of these modules / submodules can be combined with at least part of the functions of other modules / submodules and implemented in one module / submodule. According to an embodiment of the present disclosure, at least one of the creation module 610, the call module 620, the first sending module 630, the first receiving module 640, the determination module 650, the first processing module 660 and the second sending module 670 can 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 can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the creation module 610, the call module 620, the first sending module 630, the first receiving module 640, the determination module 650, the first processing module 660 and the second sending module 670 can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.

[0157] It should be noted that the distributed transaction processing device part in the embodiment of the present disclosure corresponds to the distributed transaction processing method part in the embodiment of the present disclosure. The description of the distributed transaction processing device part specifically refers to the distributed transaction processing method part, which will not be repeated here.

[0158] Figure 8 A block diagram of a computer system suitable for implementing a distributed transaction processing method according to an embodiment of the present disclosure is schematically shown. Figure 8 The computer system shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0159] like Figure 8 As shown, the computer system 800 according to the embodiment of the present disclosure includes a processor 801, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 802 or the program loaded from the storage part 808 to the random access memory (RAM) 803. The processor 801 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 801 may also include an 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 flow according to the embodiment of the present disclosure.

[0160] In RAM 803, various programs and data required for the operation of system 800 are stored. Processor 801, ROM 802 and RAM 803 are connected to each other through bus 804. Processor 801 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 802 and / or RAM 803. It should be noted that the program can also be stored in one or more memories other than ROM 802 and RAM 803. Processor 801 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.

[0161] According to an embodiment of the present disclosure, the system 800 may further include an input / output (I / O) interface 805, which is also connected to the bus 804. The system 800 may further include one or more of the following components connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.

[0162] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the processor 801, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0163] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.

[0164] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, apparatus, or device.

[0165] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 802 and / or the RAM 803 described above and / or one or more memories other than the ROM 802 and the RAM 803 .

[0166] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.

[0167] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.

Claims

1. A distributed transaction processing method, comprising: Creating a distributed transaction, wherein the distributed transaction includes a local transaction and a remote call transaction, wherein the local transaction represents a local transaction of a transaction initiator, and the remote call transaction represents a local transaction of a transaction participant; Invoking the local transaction; In the process of executing the local transaction, a call instruction for the remote call transaction is sent to the distributed system through the remote procedure call protocol, so as to call the target business method based on the transaction participant, and when it is determined that the target business method is abnormal, the remote call transaction is falsely rolled back, and then feedback information including the rollback identifier of the transaction participant and the current global transaction identifier in the header file is returned to the transaction initiator; and when it is determined that the target business method is normal, the remote call transaction is falsely committed, and then feedback information including the pending commit identifier of the transaction participant and the current global transaction identifier in the header file is returned to the transaction initiator; Receiving feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to represent the execution result of the remote call transaction; After the execution of the local transaction is completed, determining execution instructions for the local transaction and the remote call transaction according to the feedback information, wherein the execution instructions include a rollback instruction or a commit instruction; In response to the execution instruction, the local transaction is processed, including: according to the global transaction identifier, checking whether there is a rollback identifier among the transaction initiators, and if there is a rollback identifier, truly rolling back the local transaction, and if there is no rollback identifier, truly committing the local transaction; and The execution instruction is sent to a distributed system corresponding to the remote call transaction through a remote procedure call protocol to process the remote call transaction.

2. The method according to claim 1, wherein: In the process of executing the local transaction, sending a call instruction for the remote call transaction to the distributed system through the remote procedure call protocol includes: For the distributed transaction, create a global transaction identifier; storing the global transaction identifier in a header file of the calling instruction; and The calling instruction of the header file including the global transaction identifier is sent to the distributed system through a remote procedure call protocol.

3. The method according to claim 1, wherein: The number of remote call transactions is at least two, and the method further comprises: In a case where the feedback information returned by the distributed system after executing at least one of the remote call transactions in response to the call instruction includes rollback information, the process of executing the local transaction is terminated.

4. The method according to claim 1, wherein: After the execution of the local transaction is completed, determining the execution instructions for the local transaction and the remote call transaction according to the feedback information includes: In a case where the feedback information contains rollback information, determining that the execution instruction is the rollback instruction; and When the feedback information contains only submission information, the execution instruction is determined to be the submission instruction.

5. The method according to claim 1, wherein: In response to the execution instruction, processing the local transaction includes: When the execution instruction is the rollback instruction, performing a transaction rollback operation on the local transaction; and When the execution instruction is the commit instruction, a transaction commit operation is performed on the local transaction.

6. A distributed transaction processing method, wherein: The distributed transaction includes a local transaction and a remote call transaction, the local transaction represents a local transaction of a transaction initiator, and the remote call transaction represents a local transaction of a transaction participant. The method includes: Receiving a call instruction for the remote call transaction based on a remote procedure call protocol, wherein the call instruction is received during the execution of the local transaction; In response to the call instruction, the remote call transaction is executed, and feedback information for characterizing the execution result of the remote call transaction is output, including: based on the transaction participant calling the target business method, and in the case where it is determined that the target business method is abnormal, the remote call transaction is falsely rolled back, and then feedback information including the rollback identifier of the transaction participant and the current global transaction identifier in the header file is returned to the transaction initiator; and in the case where it is determined that the target business method is normal, the remote call transaction is falsely committed, and then feedback information including the pending commit identifier of the transaction participant and the current global transaction identifier in the header file is returned to the transaction initiator; Sending 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 call transaction according to the feedback information, wherein a header file of the execution instruction includes a rollback flag and a pending commit flag; Receiving the execution instruction for the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction; and In response to the execution instruction, the remote call transaction is processed, including: performing a real commit process or a rollback process on the remote call transaction according to a parsing result of a header file of the execution instruction.

7. The method according to claim 6, wherein: The executing the remote call transaction in response to the call instruction and outputting feedback information representing the execution result of the remote call transaction includes: In the event that an exception occurs during the execution of the remote call transaction, outputting the feedback information with rollback information; and When the process of executing the remote call transaction is normal, the feedback information with submission information is output.

8. The method according to claim 6, wherein: In response to the execution instruction, processing the remote call transaction includes: In a case where the execution instruction is the rollback instruction, performing a transaction rollback operation on the remote call transaction; and In a case where the execution instruction is the commit instruction, a transaction commit operation is performed on the remote call transaction.

9. A distributed transaction processing device, comprising: A creation module, used to create a distributed transaction, wherein the distributed transaction includes a local transaction and a remote call transaction, wherein the local transaction represents a local transaction of a transaction initiator, and the remote call transaction represents a local transaction of a transaction participant; A calling module, used for calling the local transaction; A first sending module is used to send a call instruction for the remote call transaction to the distributed system through the remote procedure call protocol during the execution of the local transaction, so as to call the target business method based on the transaction participant, and when it is determined that the target business method is abnormal, perform a false rollback on the remote call transaction, and then return feedback information including the rollback identifier of the transaction participant and the current global transaction identifier in the header file to the transaction initiator, and when it is determined that the target business method is normal, perform a false commit on the remote call transaction, and then return feedback information including the pending commit identifier of the transaction participant and the current global transaction identifier in the header file to the transaction initiator; A first receiving module, configured to receive feedback information returned by the distributed system after executing the remote call transaction in response to the call instruction, wherein the feedback information is used to represent the execution result of the remote call transaction; A determination module, configured to determine, after the execution of the local transaction is completed, execution instructions for the local transaction and the remote call transaction according to the feedback information, wherein the execution instructions include a rollback instruction or a commit instruction; A first processing module is configured to process the local transaction in response to the execution instruction, including: checking whether there is a rollback identifier among the transaction initiators according to the global transaction identifier, and if there is a rollback identifier, truly rolling back the local transaction, and if there is no rollback identifier, truly committing the local transaction; and The second sending module is used to send the execution instruction to the distributed system corresponding to the remote call transaction through the remote procedure call protocol, so as to process the remote call transaction.

10. A distributed transaction processing device, wherein: The distributed transaction includes a local transaction and a remote call transaction, wherein the local transaction represents a local transaction of a transaction initiator, and the remote call transaction represents a local transaction of a transaction participant. 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, wherein the call instruction is received during the execution of the local transaction; an execution module, configured to execute the remote call transaction in response to the call instruction, and output feedback information for characterizing the execution result of the remote call transaction, including: based on the transaction participant calling the target business method, and in the case where it is determined that the target business method is abnormal, performing a false rollback on the remote call transaction, and then returning feedback information including the rollback identifier of the transaction participant and the current global transaction identifier in the header file to the transaction initiator, and in the case where it is determined that the target business method is normal, performing a false commit on the remote call transaction, and then returning feedback information including the pending commit identifier of the transaction participant and the current global transaction identifier in the header file to the transaction initiator; 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 call transaction according to the feedback information, wherein a header file of the execution instruction includes a rollback flag and a pending commit flag; a third receiving module, configured to receive the execution instruction for the remote call transaction based on a remote procedure call protocol, wherein the execution instruction is received after the execution of the local transaction is completed, and the execution instruction includes a rollback instruction or a commit instruction; and The second processing module is used to process the remote call transaction in response to the execution instruction, including: performing real commit processing or rollback processing on the remote call transaction according to the parsing result of the header file of the execution instruction.

11. A computer system comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method of any one of claims 1 to 5 or 6 to 8.

12. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method of any one of claims 1 to 5 or 6 to 8.

Citation Information

Patent Citations

  • Distributed transaction processing method and framework

    CN111008202A

  • Distributed transaction processing method and device, computer equipment and readable storage medium

    CN111722946A