Distributed transaction processing method
Through timing tasks and reverse operation mechanisms, the performance bottlenecks and single-point failure problems of traditional distributed transaction processing methods in large-scale distributed systems are solved, and efficient reliability and data consistency of distributed transaction processing are achieved. It is suitable for Application scenarios that have a certain tolerance for exceptional rollback data consistency but emphasize final consistency.
Patent Information
- Application Number
- CN202411208189.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2024-11-22
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional distributed transaction processing methods have performance bottlenecks and single point of failure problems in large-scale distributed systems, and rely on the coordinator reliability and network communication reliability impacts are unpredictable.
Using timing tasks instead of traditional coordinators, the timing coordinator scans and performs reverse operations to ensure transaction consistency and failure recovery by creating aggregated operation data and reverse operation data.
It realizes efficient and reliable distributed transaction processing, ensures data consistency and failure recovery, especially in the case of network instability or system failure to ensure the ultimate data consistency to the maximum extent, and improves system stability and business continuity.
Smart Images

Figure CN119003101A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, in particular to a distributed transaction processing method. Background Art
[0002] With the development of cloud computing and big data technology, distributed systems are becoming more and more common. In such an environment, it is crucial to ensure that transactions across multiple nodes can be executed correctly, that is, to achieve ACID (atomicity, consistency, isolation, durability) characteristics. Although traditional protocols such as two-phase commit can ensure transaction consistency, their performance bottlenecks and single point failure problems are becoming increasingly prominent in large-scale distributed systems.
[0003] Although there are many distributed transaction solutions, such as Seata, LCN, etc. (the basic implementation ideas of Seata and LCN are the same, the only difference is the rollback method. LCN uses the proxy data source to close the connection and temporarily does not commit the local transaction (neither commit nor rollback), but it is easy to cause deadlock; Seata uses undo_log to reversely generate SQL statements to achieve rollback), but these solutions all need to rely on a coordinator. The coordinator service itself must also be reliable, and the communication with each service network must also be reliable, otherwise the impact caused is unpredictable.
[0004] The information disclosed in this background technology section is only intended to deepen the understanding of the overall background technology of the present invention, and should not be regarded as acknowledging or suggesting in any form that the information constitutes the prior art already known to those skilled in the art. Summary of the invention
[0005] In view of the defects existing in the prior art, the purpose of the present invention is to provide a distributed transaction processing method, which replaces the traditional coordinator with a scheduled task to ensure the final consistency of the transaction after the execution failure. The distributed transaction processing is efficient and reliable, and meets the needs of data consistency and fault recovery in the distributed system.
[0006] In order to achieve the above purpose, the technical solution adopted by the present invention is:
[0007] A distributed transaction processing method, characterized in that the method comprises:
[0008] When a business process is invoked, firstly, summary operation data representing the entire business process is created;
[0009] Each time a service is called and the call is successful, a corresponding service reverse operation data is inserted into the summary operation data to implement the rollback operation after a business exception.
[0010] After all the service calls are completed, determine whether the business process is executed successfully. If it is executed successfully, delete the summary operation data; if it fails, read the reverse operation data in the summary operation data and perform reverse operations on all services;
[0011] Determine whether the reverse operation is successfully executed. If it is successfully executed, delete the summary operation data; if it fails, update the status mark in the summary operation data to failure.
[0012] Based on the above technical solution, the service is called by remote calling.
[0013] Based on the above technical solution, the summary operation data includes: business execution status, TID (ID for tracking the entire business process), and data creation time.
[0014] On the basis of the above technical solution, a timing coordinator is set to periodically scan and summarize the operation data, and determine whether it is necessary to perform reverse operations on all services according to the execution status of the business process.
[0015] On the basis of the above technical solution, when executing the reverse operation, each time the reverse operation is completed, it is determined whether the execution is successful, and the determination result is written into the summary operation data.
[0016] When all judgment results are successful, the timing coordinator updates the status mark in the summary operation data to success and ends the rollback operation;
[0017] When the judgment result of a certain reverse operation is failure, the timing coordinator continues to call the reverse operation of the corresponding service until the judgment result is success.
[0018] The distributed transaction processing method described in the present invention has the following beneficial effects:
[0019] By replacing the traditional coordinator with scheduled tasks, the eventual consistency of transactions after execution failure is guaranteed. Distributed transaction processing is efficient and reliable, meeting the needs of data consistency and fault recovery in distributed systems.
[0020] The present invention combines the timed rollback strategy and technology to ensure that even in the case of network instability or system failure, the final consistency of data can be guaranteed to the greatest extent, thereby improving the overall stability of the system and business continuity.
[0021] The present invention realizes an efficient and reliable distributed transaction processing mechanism, effectively solves the problem of data inconsistency in a distributed environment, and is particularly suitable for application scenarios that have a certain tolerance for abnormal rollback data consistency but emphasize final consistency. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The present invention has the following accompanying drawings:
[0023] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0024] Figure 1 A flow chart of business execution of a distributed transaction processing method described in the present invention.
[0025] Figure 2 A flowchart of the reverse operation of a distributed transaction processing method described in the present invention. DETAILED DESCRIPTION
[0026] The present invention is further described in detail below in conjunction with the accompanying drawings. The detailed description is an explanation made in conjunction with the exemplary embodiments of the present invention, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those skilled in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0027] like Figure 1 As shown, the present invention provides a distributed transaction processing method, the method comprising:
[0028] When a business process is invoked, firstly, summary operation data representing the entire business process is created;
[0029] Each time a service is called and the call is successful, a corresponding service reverse operation data is inserted into the summary operation data to implement the rollback operation after a business exception.
[0030] For example: Calling service A: Execute the operations related to service A; after the call is successful, insert the reverse operation data of A into the summary operation data: the reverse operation data required when service A rolls back the operation; Calling service B: Execute the operations related to service B; after the call is successful, insert the reverse operation data of B into the summary operation data: the reverse operation data required when service B rolls back the operation; Calling service C: Execute the operations related to service C; after the call is successful, insert the reverse operation data of C into the summary operation data: the reverse operation data required when service C rolls back the operation;
[0031] After all the service calls are completed, determine whether the business process is executed successfully. If it is executed successfully, delete the summary operation data; if it fails, read the reverse operation data in the summary operation data and perform reverse operations on all services;
[0032] Determine whether the reverse operation is successfully executed. If it is successfully executed, delete the summary operation data; if it fails, update the status mark in the summary operation data to failure.
[0033] This embodiment can ensure the atomicity of each operation step. If any intermediate step fails, a reverse operation will be performed to roll back to the initial state and record the corresponding operation data.
[0034] Based on the above technical solution, the service is called by remote calling.
[0035] The aforementioned calls to service A, service B, and service C are all made in a remote calling manner.
[0036] Based on the above technical solution, the summary operation data includes: business execution status, TID (ID for tracking the entire business process), and data creation time.
[0037] Based on the above technical solution, Figure 2 As shown, a timing coordinator is set to periodically scan and summarize the operation data, and determine whether it is necessary to perform reverse operations on all services according to the execution status of the business process.
[0038] Compared with the traditional distributed transaction processing method, this embodiment does not need to rely on complex coordinators, but achieves transaction consistency through scheduled tasks and reverse operations, thereby improving processing efficiency and reliability. After combining the scheduled rollback strategy and technology, this embodiment can maximize the final consistency of data in the event of network instability or system failure, thereby improving the overall stability of the system and business continuity.
[0039] On the basis of the above technical solution, when executing the reverse operation, each time the reverse operation is completed, it is determined whether the execution is successful, and the determination result is written into the summary operation data.
[0040] When all judgment results are successful, the timing coordinator updates the status mark in the summary operation data to success and ends the rollback operation;
[0041] When the judgment result of a certain reverse operation is failure, the timing coordinator continues to call the reverse operation of the corresponding service until the judgment result is success.
[0042] The main function of the timing coordinator is to regularly check the unfinished summary operation data, which is associated with the reverse operation data of each service. It is responsible for triggering and managing the reverse operation process of each service to ensure that the reverse operation of each service can be successfully executed, thereby ensuring the data processing consistency and integrity of the entire system.
[0043] When all reverse operation calls are successful, the summary operation data status will be updated to success, and the rollback operation of a business method is completed.
[0044] The contents not described in detail in this specification belong to the prior art known to professional and technical personnel in this field.
[0045] The above description is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiment. Any equivalent modifications or changes made by those skilled in the art based on the contents disclosed by the present invention should be included in the protection scope recorded in the claims.
Claims
1. A distributed transaction processing method, characterized in that: The method comprises: When a business process is invoked, firstly, summary operation data representing the entire business process is created; Each time a service is called and the call is successful, a corresponding service reverse operation data is inserted into the summary operation data to implement the rollback operation after a business exception. After all the service calls are completed, determine whether the business process is executed successfully. If it is executed successfully, delete the summary operation data; if it fails, read the reverse operation data in the summary operation data and perform reverse operations on all services; Determine whether the reverse operation is successfully executed. If it is successfully executed, delete the summary operation data; if it fails, update the status mark in the summary operation data to failure.
2. A distributed transaction processing method according to claim 1, characterized in that: Call the service via remote call.
3. A distributed transaction processing method according to claim 1, characterized in that: The summary operation data includes: business execution status, TID (ID for tracking the entire business process), and data creation time.
4. A distributed transaction processing method according to claim 1, characterized in that: Set up a timer coordinator to periodically scan and summarize the operation data, and determine whether reverse operations need to be performed on all services based on the execution status of the business process.
5. A distributed transaction processing method according to claim 1, characterized in that: When performing a reverse operation, each time a reverse operation is completed, it is determined whether the execution is successful and the determination result is written into the summary operation data. When all judgment results are successful, the timing coordinator updates the status mark in the summary operation data to success and ends the rollback operation; When the judgment result of a certain reverse operation is failure, the timing coordinator continues to call the reverse operation of the corresponding service until the judgment result is success.
