Search

CN-122019555-A - Distributed transaction data double-link reconciliation method, system, equipment and storage medium

CN122019555ACN 122019555 ACN122019555 ACN 122019555ACN-122019555-A

Abstract

The invention provides a distributed transaction data double-link reconciliation method, a system, equipment and a storage medium, wherein the method comprises the steps of sending a transaction message to a transaction platform through an SDK to start a distributed transaction and synchronously sending a delay message to a transaction reconciliation engine; the method comprises the steps of distributing global transaction IDs and branch transaction IDs after receiving messages, coordinating all participants to sequentially execute updating operation, transferring IDs in a calling process to achieve tracking, retrying according to a preset strategy if the retrying fails or needs to roll back, triggering compensation operation if the retrying fails or needs to roll back, scanning uncompleted transactions in a timing mode and restarting a flow, acquiring expected states of the transactions from a platform by a transaction reconciliation engine according to the global transaction IDs after the delayed messages arrive, acquiring actual data states by calling all participant query interfaces, comparing the expected states with the actual states by the engine, generating an alarm if the expected states are inconsistent, and executing the compensation operation by the reconciliation compensation cluster. The invention improves the data consistency through unified execution and independent account checking double guarantee.

Inventors

  • ZHANG XIAOYAN

Assignees

  • 携程计算机技术(上海)有限公司

Dates

Publication Date
20260512
Application Date
20260128

Claims (10)

  1. 1. The double-link reconciliation method of the distributed transaction data is characterized by comprising the following steps of: S110, the transaction initiator sends a transactional message to the transaction platform through the unified transaction SDK to start a distributed transaction, and synchronously sends a delay message to the transaction reconciliation engine; s120, the transaction platform receives the transactional information, allocates global transaction IDs for the transactions and branch transaction IDs for each transaction participant, coordinates the transaction participants to sequentially execute transaction update operation, and transparently transmits the global transaction IDs and the branch transaction IDs in the calling process so as to realize tracking; S130, if any transaction participant fails to execute, the transaction platform retries according to a preconfigured retry strategy; s140, if the transaction still fails after retrying or the transaction needs to roll back, the transaction platform triggers the transaction participant to execute corresponding compensation operation; s150, the transaction platform scans the transaction flow which is in progress and is not completed after overtime according to the task bottom mechanism at regular time, and restarts the flow; S160, when the delay message arrives at the transaction reconciliation engine, the transaction reconciliation engine receives the delay message, acquires the expected state of the transaction from the transaction platform according to the global transaction ID, and acquires the actual data state by calling a transaction participant query interface provided by each transaction participant; S170, the transaction reconciliation engine compares the expected state with the actual data state, generates an alarm if inconsistent is found, and calls the reconciliation compensation clusters which are independently deployed to execute compensation operation according to the need.
  2. 2. The method according to claim 1, wherein in step S110, the delay time of the transaction initiator sending the delay message is configured to trigger the reconciliation after the execution flow is completed, and the reconciliation operation by the transaction reconciliation engine supports the reconciliation in multiple dimensions including a reconciliation time window, a reconciliation frequency, and a reconciliation in transaction ID or service dimension.
  3. 3. The method according to claim 1, wherein in step S150, the task spam mechanism of the transaction platform includes: s151, periodically inquiring a persistent transaction state record; S152, identifying a transaction flow which is in progress and has a duration exceeding a preset threshold; s153, initiating transaction update call to the related transaction participants again to restart the flow.
  4. 4. The distributed transaction data duplex reconciliation method of claim 1, wherein in step S120, the transaction update operation performed by the transaction participant comprises an try, acknowledge and cancel phase, wherein cancel phase comprises the participant specific compensation logic, and wherein the compensation logic ensures idempotent.
  5. 5. The distributed transaction data dual-link reconciliation method of claim 1, wherein in step S170, the reconciliation compensation cluster is deployed and run independent of the transaction platform, and performs compensation operations that are isolated from compensation operations triggered by the transaction platform.
  6. 6. The distributed transaction data duplex reconciliation method of claim 1, further comprising, after step S170: S180, the transaction platform permanently records the execution state, the compensation state and the associated global transaction ID and branch transaction ID of all distributed transactions; S190, providing a query interface, and supporting the complete execution link and state of the query transaction according to the global transaction ID, the branch transaction ID or the service ID.
  7. 7. The distributed transaction data duplex link reconciliation method of claim 1, wherein the transaction initiator, the transaction platform and the transaction participants communicate and interface call through an integrated unified transaction SDK that encapsulates messaging, status reporting and interface call specifications.
  8. 8. A distributed transaction data double-link reconciliation system for implementing the distributed transaction data double-link reconciliation method of claim 1, comprising: The transaction initiator sends a transactional message to the transaction platform through the unified transaction SDK to start a distributed transaction, and synchronously sends the delayed message to the transaction reconciliation engine; The message receiving module is used for receiving the transactional message, distributing global transaction IDs for the transactions, distributing branch transaction IDs for all transaction participants, coordinating the transaction participants to sequentially execute transaction updating operation, and transmitting the global transaction IDs and the branch transaction IDs in a call process so as to realize tracking; The automatic retry module is used for retrying the transaction platform according to a preconfigured retry strategy if any transaction participant fails to execute; The failure rollback module is used for triggering the transaction participant to execute corresponding compensation operation if the transaction still fails after retrying or the transaction needs to rollback; the transaction platform scans the transaction flow which is in progress and is not completed after overtime according to the task bottom mechanism at regular time, and restarts the flow; The transaction reconciliation engine receives the delay message when the delay message reaches the transaction reconciliation engine, acquires the expected state of the transaction from the transaction platform according to the global transaction ID, and acquires the actual data state by calling a transaction participant query interface provided by each transaction participant; and the transaction reconciliation engine compares the expected state with the actual data state, generates an alarm if inconsistent is found, and calls the reconciliation compensation clusters which are independently deployed to execute compensation operation according to the requirement.
  9. 9. A distributed transaction data double-link reconciliation apparatus, comprising: A processor; a memory having stored therein executable instructions of the processor; wherein the processor is configured to perform the steps of the distributed transaction data double-link reconciliation method of any one of claims 1 to 7 via execution of the executable instructions.
  10. 10. A computer readable storage medium storing a program, wherein the program when executed by a processor implements the steps of the distributed transaction data double-link reconciliation method of any one of claims 1 to 7.

Description

Distributed transaction data double-link reconciliation method, system, equipment and storage medium Technical Field The invention relates to the field of distributed business processing, in particular to a distributed transaction data double-link reconciliation method, a system, equipment and a storage medium. Background In a distributed system, data inconsistency often occurs due to factors such as network delay, service timeout, system failure, etc. Especially in the scenarios involving funds transfer, such as settlement systems, payment systems, etc., data inconsistencies may not only lead to system availability problems, but also may cause a risk of funds loss. Ensuring consistency of distributed transactions has been a central challenge in distributed system architecture design and practice. In the prior art, the main ways for guaranteeing the consistency of distributed transactions comprise a first way and an asynchronous compensation mechanism based on a local Job table. Each business system maintains a Job table in a local database for recording business data and task states which need to be executed asynchronously, and then triggers compensation operation by timing task scanning of the Job table so as to ensure final consistency. However, this approach suffers from the significant drawbacks of first of all high code repetition, the need for each business system to implement similar logic for Job table management, task scanning, status updating, etc., resulting in a large number of repeated codes, and high development and maintenance costs. Secondly, the Job list of each system is not managed in a scattered way due to lack of unified management, unified monitoring and tracking cannot be performed, and when the problem of inconsistent data occurs, abnormal detection is difficult, and manual intervention is often needed for data restoration. And the compensation mechanism is imperfect, and when the timing task fails to execute or the system is abnormal, the effective automatic retry and compensation mechanism is lacking, manual intervention is still needed, and the oncall burden of operation and maintenance personnel is increased. And finally, the execution state tracking is lacking, the execution state of the business process cannot be completely recorded, and effective problem investigation and business audit are difficult to carry out. And secondly, guaranteeing final consistency based on the message queue. The method realizes asynchronous processing through the message queue, and guarantees final consistency by using a message persistence and retry mechanism. However, the method has the same problems that firstly, the message backlog causes short-time inconsistency, when the message backlog occurs in the message queue, the data can be in an inconsistent state in a short time, and the service scene with higher requirement on real-time performance can not be met. Secondly, the system lacks an active checking mechanism, only relies on reliable delivery of messages, and lacks an active data checking mechanism to verify data consistency, so that potential data inconsistency problems cannot be found and repaired in time. Thirdly, the compensation logic is dispersed, the compensation logic is still dispersed in each service system, a unified compensation strategy and mechanism are lacked, and the management complexity is high. In view of this, the present invention provides a distributed transaction data double-link reconciliation method, system, apparatus, and storage medium. Disclosure of Invention Aiming at the problems in the prior art, the invention aims to provide a distributed transaction data dual-link reconciliation method, a system, equipment and a storage medium, which overcome the difficulties in the prior art and promote the data consistency through unified execution and independent reconciliation dual-guarantee. The embodiment of the invention provides a distributed transaction data double-link reconciliation method, which comprises the following steps: S110, the transaction initiator sends a transactional message to the transaction platform through the unified transaction SDK to start a distributed transaction, and synchronously sends a delay message to the transaction reconciliation engine; s120, the transaction platform receives the transactional information, allocates global transaction IDs for the transactions and branch transaction IDs for each transaction participant, coordinates the transaction participants to sequentially execute transaction update operation, and transparently transmits the global transaction IDs and the branch transaction IDs in the calling process so as to realize tracking; S130, if any transaction participant fails to execute, the transaction platform retries according to a preconfigured retry strategy; s140, if the transaction still fails after retrying or the transaction needs to roll back, the transaction platform triggers the transaction participant to exec