Distributed transaction processing method and device
By determining and executing the order of methods and rollback parameters in distributed transaction processing, the data inconsistency caused by the failure of method execution in distributed transactions is solved, and the rollback compensation processing for distributed transactions is realized to ensure data consistency .
Patent Information
- Application Number
- CN202310835381.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-07
- Publication Date
- 2025-01-07
AI Technical Summary
The existing distributed transaction processing scheme cannot perform rollback compensation processing when a method fails to execute, resulting in inconsistent data.
By receiving a transaction execution request, determine the execution order and rollback parameters of the currently to be executed method, execute the method and determine whether it is successful or not. If it fails, perform rollback compensation processing. If it is successful, determine whether all methods are completed. If it is not completed, it is possible to determine whether all methods are completed. Continue to execute the remaining methods.
It realizes rollback compensation processing when the method execution fails in distributed transactions, ensuring data consistency.
Smart Images

Figure CN119271358A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of distributed systems, and in particular to a method and device for processing distributed transactions. Background Art
[0002] Distributed transactions refer to transactions implemented in distributed systems. Distributed transactions consist of multiple methods, and distributed transaction processing can be completed by executing multiple methods.
[0003] At present, the commonly used solutions for distributed transactions include: two-phase commit solution (2PC), compensation transaction solution (Try-Confirm-Cancel, TCC), etc. In the process of using existing distributed transaction solutions to process distributed transactions, when a method in a distributed transaction fails to execute, the existing distributed transaction solutions cannot perform rollback compensation processing, resulting in data inconsistency. Summary of the invention
[0004] The embodiments of the present application provide a method and device for processing distributed transactions, the main purpose of which is to roll back and compensate the distributed transaction when a method in the distributed transaction fails to execute, thereby ensuring data consistency of the distributed transaction.
[0005] In order to solve the above technical problems, the embodiments of the present application provide the following technical solutions:
[0006] In a first aspect, the present application provides a method for processing a distributed transaction, the method comprising:
[0007] Step S1: receiving a transaction execution request, wherein the transaction receiving request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods;
[0008] Step S2: determining the current method to be executed according to the execution order corresponding to the plurality of methods;
[0009] Step S3: Determine the rollback input parameter corresponding to the current method to be executed;
[0010] Step S4: Execute the current method to be executed;
[0011] Step S5: Determine whether the currently executed method is executed successfully; if the execution fails, obtain the rollback input parameters corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameters corresponding to each executed method; if the execution is successful, determine whether all the methods have been executed, if not, return to step S2.
[0012] In a second aspect, the present application further provides a distributed transaction processing device, including:
[0013] A receiving unit, configured to receive a transaction execution request, wherein the transaction receiving request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods;
[0014] A first determining unit, configured to determine a method to be currently executed according to an execution order corresponding to the plurality of methods;
[0015] A second determining unit, used to determine the rollback input parameter corresponding to the currently executed method;
[0016] An execution unit, configured to execute the method currently to be executed;
[0017] A judgment unit is used to judge whether the current method to be executed is executed successfully; when the current method to be executed fails, obtain the rollback input parameter corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method; when the current method to be executed is executed successfully, judge whether all the multiple methods are executed, if not, control the first determination unit, the second determination unit and the execution unit to continue to execute the remaining methods of the multiple methods.
[0018] In a third aspect, an embodiment of the present application provides a storage medium, wherein the storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the distributed transaction processing method described in the first aspect.
[0019] In a fourth aspect, an embodiment of the present application provides a distributed transaction processing device, the device comprising a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the distributed transaction processing method described in the first aspect is executed.
[0020] By means of the above technical solution, the technical solution provided by this application has at least the following advantages:
[0021] The present application provides a distributed transaction processing method and device. The present application can, after a target server receives a transaction execution request carrying a unique identifier corresponding to a target distributed transaction, first determine the current method to be executed according to the execution order corresponding to multiple methods included in the target distributed transaction by the target server; secondly, determine the rollback input parameter corresponding to the current method to be executed; thirdly, execute the current method to be executed; finally, after executing the current method to be executed, determine whether the current method to be executed is executed successfully. If the execution fails, obtain the rollback input parameter corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method. If the execution is successful, determine whether multiple methods are all executed. If all are executed, it means that the target distributed transaction has been processed. If not all are executed, continue to execute the remaining methods in the multiple methods according to the aforementioned method, so that when a method in the distributed transaction fails to execute, the distributed transaction can be rolled back and compensated, thereby ensuring the data consistency of the distributed transaction.
[0022] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] By reading the detailed description below with reference to the accompanying drawings, the above and other purposes, features and advantages of the exemplary embodiments of the present application will become easy to understand. In the accompanying drawings, several embodiments of the present application are shown in an exemplary and non-limiting manner, and the same or corresponding reference numerals represent the same or corresponding parts, wherein:
[0024] Figure 1 A flow chart of a distributed transaction processing method provided by an embodiment of the present application is shown;
[0025] Figure 2 A block diagram showing a distributed transaction processing device provided in an embodiment of the present application is shown;
[0026] Figure 3 A schematic diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0028] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in this application should have the common meanings understood by technicians in the field to which this application belongs.
[0029] The present application embodiment provides a method for processing distributed transactions, specifically as follows: Figure 1 As shown, the method includes:
[0030] 101. Receive a transaction execution request.
[0031] The transaction receiving request includes a unique identifier corresponding to the target distributed transaction. The target distributed transaction includes multiple methods. Any method can be a synchronous method or an asynchronous method. A corresponding preset rollback interface is pre-set for each method.
[0032] It should be noted that in the embodiment of the present application, the execution entity in each step is the target server.
[0033] In an embodiment of the present application, when the target server is required to execute a target distributed transaction, a transaction execution request carrying a unique identifier corresponding to the target distributed transaction can be sent to the target server. At this time, the target server can receive the transaction execution request.
[0034] 102. Determine a method to be currently executed according to the execution order corresponding to the multiple methods.
[0035] In an embodiment of the present application, after receiving a transaction execution request, the target server can determine the current method to be executed according to the execution order of multiple methods included in the target distributed transaction. For example, the target distributed transaction includes: method A, method B, method C, method D and method E, and the execution order of the multiple methods is: method A-1, method B-2, method C-3, method D-4 and method E-5. When the method is executed for the first time, the current method to be executed is method A. When the method is executed for the second time, the current method to be executed is method B….
[0036] 103. Determine the rollback input parameter corresponding to the current method to be executed.
[0037] In an embodiment of the present application, after determining the current method to be executed, the target server needs to determine the rollback input parameters corresponding to the current method to be executed, so that when the remaining methods among the multiple methods fail to be executed, the target distributed transaction can be rolled back and compensated based on the rollback input parameters corresponding to the current method to be executed.
[0038] 104. Execute the current method to be executed.
[0039] In an embodiment of the present application, after determining the rollback input parameter corresponding to the current method to be executed, the target server can execute the current method to be executed.
[0040] 105. Determine whether the current method to be executed is executed successfully; if the execution fails, obtain the rollback input parameter corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method; if the execution is successful, determine whether all multiple methods have been executed, if not, return to step 102.
[0041] Among them, the executed method is the method that has been successfully executed among multiple methods. For example, the target distributed transaction includes: method A, method B, method C, method D and method E. The corresponding execution order of the multiple methods is: method A-1, method B-2, method C-3, method D-4 and method E-5. When the current method to be executed is method C, the executed methods are method A and method B.
[0042] In an embodiment of the present application, after executing the current method to be executed, the target server needs to determine whether the current method to be executed is executed successfully; if the execution fails, the rollback input parameters corresponding to each executed method are obtained, and the target distributed transaction is rolled back and compensated according to the rollback input parameters corresponding to each executed method; if the execution is successful, it is determined whether multiple methods have been fully executed. If all of them have been completed, it means that the target distributed transaction has been processed. If not all of them have been executed, it returns to step 102 to continue executing the remaining methods in the multiple methods.
[0043] The embodiment of the present application provides a method for processing distributed transactions. After the target server receives a transaction execution request carrying a unique identifier corresponding to the target distributed transaction, the target server first determines the current method to be executed according to the execution order corresponding to multiple methods included in the target distributed transaction; secondly, determines the rollback input parameter corresponding to the current method to be executed; thirdly, executes the current method to be executed; finally, after executing the current method to be executed, determines whether the current method to be executed is executed successfully. If the execution fails, obtains the rollback input parameter corresponding to each executed method, and performs rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method. If the execution is successful, determines whether all the methods have been executed. If all have been executed, it means that the target distributed transaction has been processed. If not all have been executed, continue to execute the remaining methods in the multiple methods according to the aforementioned method, so that when a method in the distributed transaction fails to execute, the distributed transaction can be rolled back and compensated, thereby ensuring the data consistency of the distributed transaction.
[0044] Furthermore, in an embodiment of the present application, the specific process by which the target server determines the rollback input parameters corresponding to the currently executed method is as follows: first, determine the rollback method corresponding to the currently executed method according to the preset rollback interface corresponding to the currently executed method; second, obtain the preset rollback input parameters corresponding to the currently executed method according to the rollback method corresponding to the currently executed method; third, determine whether the rollback method corresponding to the currently executed method requires the pre-execution input parameters corresponding to the currently executed method; if necessary, obtain the pre-execution input parameters corresponding to the currently executed method, and substitute the pre-execution input parameters corresponding to the currently executed method into the preset rollback input parameters to obtain the rollback input parameters corresponding to the currently executed method; if not necessary, determine the preset rollback input parameters as the rollback input parameters corresponding to the currently executed method.
[0045] Furthermore, in an embodiment of the present application, after determining the rollback input parameters corresponding to the currently executed method, the target server can also store the execution sequence number, preset rollback interface name and rollback input parameters corresponding to the currently executed method in the method call table, so that when the execution of the remaining methods among multiple methods fails subsequently, the preset rollback interface name and rollback input parameters corresponding to the currently executed method can be obtained in the method call table.
[0046] Furthermore, in an embodiment of the present application, the specific process by which the target server obtains the rollback input parameters corresponding to each executed method is as follows: first, based on the execution order corresponding to the multiple methods and the execution sequence number corresponding to the current method to be executed, determine the one or more executed methods corresponding to the current method to be executed, that is, determine one or more methods among the multiple methods whose execution sequence number is smaller than the execution sequence number corresponding to the current method to be executed as the one or more executed methods corresponding to the current method to be executed; then, obtain the preset rollback interface name and rollback input parameters corresponding to each executed method in the method call table.
[0047] Furthermore, in an embodiment of the present application, the target server performs rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method. The specific process is as follows: first, call the preset rollback interface corresponding to each executed method according to the preset rollback interface name corresponding to each executed method to obtain the rollback method corresponding to each executed method; then, substitute the rollback input parameter corresponding to each executed method into its corresponding rollback method; finally, according to the execution order corresponding to the multiple methods, execute the rollback method corresponding to each executed method in reverse order. For example, the target distributed transaction includes: method A, method B, method C, method D and method E, and the execution order corresponding to the multiple methods is: method A-1, method B-2, method C-3, method D-4 and method E-5. The current method to be executed is method C, then the rollback method corresponding to method B is executed first, and then the rollback method corresponding to method A is executed.
[0048] Furthermore, as a response to the above Figure 1 In order to realize the method shown in the figure, another embodiment of the present application also provides a distributed transaction processing device. This device embodiment corresponds to the aforementioned method embodiment. For ease of reading, this device embodiment will no longer repeat the details of the aforementioned method embodiment one by one, but it should be clear that the device in this embodiment can correspond to all the contents of the aforementioned method embodiment. This device is used to perform rollback compensation processing on the distributed transaction when a method in the distributed transaction fails to execute, so as to ensure the data consistency of the distributed transaction, as shown in the following example. Figure 2 As shown, the device comprises:
[0049] A receiving unit 21 is configured to receive a transaction execution request, wherein the transaction receiving request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods;
[0050] A first determining unit 22, configured to determine a method to be currently executed according to an execution order corresponding to the plurality of methods;
[0051] A second determining unit 23, used to determine the rollback input parameter corresponding to the currently executed method;
[0052] An execution unit 24, configured to execute the method currently to be executed;
[0053] The judgment unit 25 is used to judge whether the current method to be executed is executed successfully; when the current method to be executed fails, the rollback input parameter corresponding to each executed method is obtained, and the target distributed transaction is rolled back and compensated according to the rollback input parameter corresponding to each executed method; when the current method to be executed is executed successfully, it is judged whether all the multiple methods are executed, and if not, the first determination unit 22, the second determination unit 23 and the execution unit 24 are controlled to continue to execute the remaining methods of the multiple methods.
[0054] Further, such as Figure 2 As shown, the second determining unit 23 is specifically used to: determine the rollback method corresponding to the current method to be executed according to the preset rollback interface corresponding to the current method to be executed;
[0055] Obtain the preset rollback input parameter corresponding to the current method to be executed according to the rollback method corresponding to the current method to be executed;
[0056] Determine whether the rollback method corresponding to the currently executed method requires the pre-execution input parameter corresponding to the currently executed method;
[0057] If necessary, obtain the pre-execution input parameter corresponding to the current method to be executed, and substitute the pre-execution input parameter corresponding to the current method to be executed into the preset rollback input parameter to obtain the rollback input parameter corresponding to the current method to be executed;
[0058] If not necessary, the preset rollback input parameter is determined as the rollback input parameter corresponding to the current method to be executed.
[0059] Further, such as Figure 2 As shown, the second determining unit 23 is further used to store the execution sequence number, the preset rollback interface name and the rollback input parameters corresponding to the current method to be executed in the method call table.
[0060] Further, such as Figure 2 As shown, the judgment unit 25 is specifically used to: determine one or more executed methods corresponding to the current method to be executed according to the execution order corresponding to the multiple methods and the execution sequence number corresponding to the current method to be executed; obtain the preset rollback interface name and rollback input parameters corresponding to each of the executed methods in the method call table.
[0061] Further, such as Figure 2 As shown, the judgment unit 25 is specifically used to: call the preset rollback interface corresponding to each of the executed methods according to the preset rollback interface name corresponding to each of the executed methods to obtain the rollback method corresponding to each of the executed methods; substitute the rollback input parameter corresponding to each of the executed methods into its corresponding rollback method; and execute the rollback method corresponding to each of the executed methods in reverse order according to the execution order corresponding to the multiple methods.
[0062] The embodiment of the present application provides a method and device for processing distributed transactions. The embodiment of the present application can, after a target server receives a transaction execution request carrying a unique identifier corresponding to a target distributed transaction, first determine the current method to be executed according to the execution order corresponding to multiple methods included in the target distributed transaction by the target server; secondly, determine the rollback input parameter corresponding to the current method to be executed; thirdly, execute the current method to be executed; finally, after executing the current method to be executed, determine whether the current method to be executed is executed successfully. If the execution fails, obtain the rollback input parameter corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method. If the execution is successful, determine whether all the methods have been executed. If all have been executed, it means that the target distributed transaction has been processed. If not all have been executed, continue to execute the remaining methods in the multiple methods according to the aforementioned method, so that when a method in the distributed transaction fails to execute, the distributed transaction can be rolled back and compensated, thereby ensuring the data consistency of the distributed transaction.
[0063] An embodiment of the present application provides a storage medium, which includes a stored program, wherein when the program is executed, the device where the storage medium is located is controlled to execute the above-mentioned distributed transaction processing method.
[0064] The storage medium may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one storage chip.
[0065] An embodiment of the present application also provides a distributed transaction processing device, which includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the above-mentioned distributed transaction processing method is executed.
[0066] The present application embodiment provides a device 30, such as Figure 3 As shown, the device 30 includes at least one processor 301, at least one memory 302 and a bus 303 connected to the processor 301; the processor 301 and the memory 302 communicate with each other through the bus 303; the processor 301 is used to call the program instructions in the memory 302 to execute the above-mentioned distributed transaction processing method. The device in this article can be a server, a PC, etc.
[0067] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes the following method steps: Step S1: receiving a transaction execution request, wherein the transaction reception request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods;
[0068] Step S2: determining the current method to be executed according to the execution order corresponding to the plurality of methods;
[0069] Step S3: Determine the rollback input parameter corresponding to the current method to be executed;
[0070] Step S4: Execute the current method to be executed;
[0071] Step S5: Determine whether the currently executed method is executed successfully; if the execution fails, obtain the rollback input parameters corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameters corresponding to each executed method; if the execution is successful, determine whether all the methods have been executed, if not, return to step S2.
[0072] Further, the step of determining the rollback input parameter corresponding to the currently executed method includes:
[0073] Determine the rollback method corresponding to the current method to be executed according to the preset rollback interface corresponding to the current method to be executed;
[0074] Obtain the preset rollback input parameter corresponding to the current method to be executed according to the rollback method corresponding to the current method to be executed;
[0075] Determine whether the rollback method corresponding to the currently executed method requires the pre-execution input parameter corresponding to the currently executed method;
[0076] If necessary, obtain the pre-execution input parameter corresponding to the current method to be executed, and substitute the pre-execution input parameter corresponding to the current method to be executed into the preset rollback input parameter to obtain the rollback input parameter corresponding to the current method to be executed;
[0077] If not necessary, the preset rollback input parameter is determined as the rollback input parameter corresponding to the current method to be executed.
[0078] Furthermore, the step of determining the rollback input parameter corresponding to the currently executed method further includes:
[0079] The execution sequence number, preset rollback interface name and rollback input parameters corresponding to the current method to be executed are stored in the method call table.
[0080] Furthermore, obtaining the rollback input parameter corresponding to each executed method includes:
[0081] Determine one or more executed methods corresponding to the current method to be executed according to the execution order corresponding to the plurality of methods and the execution sequence number corresponding to the current method to be executed;
[0082] Obtain the preset rollback interface name and rollback input parameters corresponding to each of the executed methods in the method call table.
[0083] Further, performing rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each of the executed methods includes:
[0084] Calling the preset rollback interface corresponding to each of the executed methods according to the preset rollback interface name corresponding to each of the executed methods to obtain the rollback method corresponding to each of the executed methods;
[0085] Substitute the rollback input parameter corresponding to each of the executed methods into its corresponding rollback method;
[0086] According to the execution order corresponding to the plurality of methods, the rollback method corresponding to each of the executed methods is executed in reverse order.
[0087] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0088] In a typical configuration, the device includes one or more processors (CPU), memory and bus. The device may also include input / output interface, network interface and the like.
[0089] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip. The memory is an example of a computer-readable medium.
[0090] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0091] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0092] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0093] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for processing distributed transactions, characterized in that: include: Step S1: receiving a transaction execution request, wherein the transaction receiving request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods; Step S2: determining the current method to be executed according to the execution order corresponding to the plurality of methods; Step S3: Determine the rollback input parameter corresponding to the current method to be executed; Step S4: Execute the current method to be executed; Step S5: Determine whether the currently executed method is executed successfully; if the execution fails, obtain the rollback input parameters corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameters corresponding to each executed method; if the execution is successful, determine whether all the methods have been executed, if not, return to step S2.
2. The method according to claim 1, characterized in that The step of determining the rollback input parameter corresponding to the currently executed method includes: Determine the rollback method corresponding to the current method to be executed according to the preset rollback interface corresponding to the current method to be executed; Obtain the preset rollback input parameter corresponding to the current method to be executed according to the rollback method corresponding to the current method to be executed; Determine whether the rollback method corresponding to the currently executed method requires the pre-execution input parameter corresponding to the currently executed method; If necessary, obtain the pre-execution input parameter corresponding to the current method to be executed, and substitute the pre-execution input parameter corresponding to the current method to be executed into the preset rollback input parameter to obtain the rollback input parameter corresponding to the current method to be executed; If not necessary, the preset rollback input parameter is determined as the rollback input parameter corresponding to the current method to be executed.
3. The method according to claim 2, characterized in that The step of determining the rollback input parameter corresponding to the currently executed method further includes: The execution sequence number, preset rollback interface name and rollback input parameters corresponding to the current method to be executed are stored in the method call table.
4. The method according to claim 3, characterized in that The step of obtaining the rollback input parameters corresponding to each executed method includes: Determine one or more executed methods corresponding to the current method to be executed according to the execution order corresponding to the plurality of methods and the execution sequence number corresponding to the current method to be executed; Obtain the preset rollback interface name and rollback input parameters corresponding to each of the executed methods in the method call table.
5. The method according to claim 4, characterized in that The step of performing rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each of the executed methods includes: Calling the preset rollback interface corresponding to each of the executed methods according to the preset rollback interface name corresponding to each of the executed methods to obtain the rollback method corresponding to each of the executed methods; Substitute the rollback input parameter corresponding to each of the executed methods into its corresponding rollback method; According to the execution order corresponding to the plurality of methods, the rollback method corresponding to each of the executed methods is executed in reverse order.
6. A distributed transaction processing device, characterized in that: include: A receiving unit, configured to receive a transaction execution request, wherein the transaction receiving request includes a unique identifier corresponding to a target distributed transaction, and the target distributed transaction includes multiple methods; A first determining unit, configured to determine a method to be currently executed according to an execution order corresponding to the plurality of methods; A second determining unit, used to determine the rollback input parameter corresponding to the currently executed method; An execution unit, configured to execute the method currently to be executed; A judgment unit is used to judge whether the current method to be executed is executed successfully; when the current method to be executed fails, obtain the rollback input parameter corresponding to each executed method, and perform rollback compensation processing on the target distributed transaction according to the rollback input parameter corresponding to each executed method; when the current method to be executed is executed successfully, judge whether all the multiple methods are executed, if not, control the first determination unit, the second determination unit and the execution unit to continue to execute the remaining methods of the multiple methods.
7. The device according to claim 6, characterized in that The second determining unit is specifically configured to: determine the rollback method corresponding to the currently to-be-executed method according to a preset rollback interface corresponding to the currently to-be-executed method; Obtain the preset rollback input parameter corresponding to the current method to be executed according to the rollback method corresponding to the current method to be executed; Determine whether the rollback method corresponding to the currently executed method requires the pre-execution input parameter corresponding to the currently executed method; If necessary, obtain the pre-execution input parameter corresponding to the current method to be executed, and substitute the pre-execution input parameter corresponding to the current method to be executed into the preset rollback input parameter to obtain the rollback input parameter corresponding to the current method to be executed; If not necessary, the preset rollback input parameter is determined as the rollback input parameter corresponding to the current method to be executed.
8. The device according to claim 7, characterized in that The second determining unit is further used to store the execution sequence number, the preset rollback interface name and the rollback input parameters corresponding to the current method to be executed in the method call table.
9. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is running, the device where the storage medium is located is controlled to execute the distributed transaction processing method described in any one of claims 1 to 5.
10. A distributed transaction processing device, characterized in that: The device includes a storage medium; and one or more processors, the storage medium is coupled to the processor, and the processor is configured to execute program instructions stored in the storage medium; when the program instructions are executed, the distributed transaction processing method described in any one of claims 1 to 5 is executed.