Cross-cluster transaction message synchronization method and system
By configuring additional transaction message queues in the target data center, the problem of transaction status conflicts after cross-cluster synchronization is solved and more efficient cross-cluster synchronization is achieved.
Patent Information
- Application Number
- PCT/CN2023/143234
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-12-14
- Filing Date
- 2023-12-29
- Publication Date
- 2024-09-12
AI Technical Summary
After cross-cluster synchronization, three different transaction states caused status conflicts in the two clusters, resulting in poor cross-cluster synchronization effect.
Configure an additional transaction message queue in the target data center to store secondary transaction data in the source data center. By adding data from the semi-message queue and semi-message processing queue to the extra transaction message queue, you can avoid status conflicts and store them separately when needed. deal with.
This effectively avoids the problem of status conflicts between different transactions and improves the effect of cross-cluster synchronization.
Smart Images

Figure CN2023143234_12092024_PF_FP_ABST
Abstract
Description
A transaction message cross-cluster synchronization method and system Technical Field
[0001] The present invention relates to the field of IT and software technology, and in particular to a transaction message cross-cluster synchronization method and system. Background Art
[0002] Because the target cluster contains local messages and local transactions that need to be processed, and the source cluster's timed-out transactions need to be recovered, the message queue needs to recheck the timed-out transactions. This recheck may generate new partially processed messages or even time out. As a result, after cross-cluster synchronization, the three different transaction states will cause inconsistent states in the two clusters.
[0003] In the prior art, after cross-cluster synchronization, three different transaction states will cause state conflicts in two clusters, resulting in a technical problem of poor cross-cluster synchronization effect.
[0004] Summary of the Invention
[0005] The present application provides a transaction message cross-cluster synchronization method and system, which is used to solve the technical problem in the prior art that after cross-cluster synchronization, three different transaction states will cause state conflicts in two clusters, resulting in poor cross-cluster synchronization effect.
[0006] In view of the above problems, the present application provides a method and system for synchronizing transaction messages across clusters.
[0007] A first aspect of the present application provides a cross-cluster transaction message synchronization method, comprising: when a target data center receives first synchronization data from a source data center, obtaining a first synchronization data source queue; when the first synchronization data source queue belongs to a first half message queue or a first half message processing queue, adding the first synchronization data to an additional transaction message queue; when the first synchronization data source queue belongs to a first actual message queue, synchronizing the first synchronization data and adding it to a second actual message queue; wherein the first half message queue, the first half message processing queue, and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
[0008] The second aspect of the present application provides a transaction message cross-cluster synchronization system, including: a first processing unit, used to obtain a first synchronization data source queue when a target data center receives the first synchronization data from a source data center; a second processing unit, used to add the first synchronization data to an additional transaction message queue when the first synchronization data source queue belongs to a first half message queue or a first half message processing queue; a third processing unit, used to synchronize the first synchronization data and add it to a second actual message queue when the first synchronization data source queue belongs to a first actual message queue; wherein, the first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
[0009] One or more technical solutions provided in this application have at least the following technical effects or advantages:
[0010] The embodiment of the present application obtains the first synchronization data source queue when the target data center receives the first synchronization data from the source data center; when the first synchronization data source queue belongs to the first half message queue or the first half message processing queue, the first synchronization data is added to the additional transaction message queue; when the first synchronization data source queue belongs to the first actual message queue, the first synchronization data is synchronized and added to the second actual message queue; wherein, the first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center. The technical solution configures an additional transaction message queue in the target data center to store the secondary transaction data of the source data center. It effectively avoids the status conflict problem of different transactions and achieves the technical effect of improving the cross-cluster synchronization effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] FIG1 is a flow chart of a transaction message cross-cluster synchronization method provided by the present application;
[0012] FIG2 is a flow diagram of the transaction message principle in a transaction message cross-cluster synchronization method provided by this application;
[0013] FIG3 is a flow chart of a traditional cross-cluster synchronization method in a transaction message cross-cluster synchronization method provided by this application;
[0014] FIG4 is a schematic diagram of the structure of a transaction message cross-cluster synchronization system provided by this application.
[0015] Description of reference numerals: first processing unit 100 , second processing unit 200 , third processing unit 300 . DETAILED DESCRIPTION
[0016] This application provides a method and system for cross-cluster synchronization of transaction messages, aiming to address the existing technical problem of poor cross-cluster synchronization, where three different transaction states can cause state conflicts in two clusters after cross-cluster synchronization. By configuring an additional transaction message queue at the target data center to store secondary transaction data from the source data center, this effectively avoids state conflicts between different transactions and achieves the technical effect of improving cross-cluster synchronization.
[0017] Glossary:
[0018] Message queue: A middleware for asynchronous communication. Think of it like a post office. The sender passes the message to the post office, which then sends it to the specific message receiver (consumer). We don't need to worry about the specific sending process and time, and it won't interfere with other things.
[0019] Cross-cluster synchronization: This refers to synchronizing message data between two independently deployed message queue clusters. This is typically used in scenarios like active-active deployments, supporting dual writes to message queues.
[0020] Transactional messages refer to the simultaneous success or failure of production-side message sending events and local transaction events. Transactional messages are divided into two main phases: normal transaction sending and submission, and the transaction information compensation process.
[0021] Example 1
[0022] As shown in Figure 1, this application provides a method for synchronizing transaction messages across clusters, including:
[0023] In the traditional solution for synchronizing transaction messages across clusters, as shown in FIG2 , transaction messages are divided into committed transactions, rolled back transactions, and timed out transactions.
[0024] When a transaction message belongs to a committed transaction, it is divided into the prepare phase and the commit phase. During the prepare phase, a pre-processed message is stored in the semi-message queue. When the message producer executes the commit, a processed message is written to the semi-message processing queue to indicate that the transaction is completed.
[0025] When the transaction message belongs to a rolled-back transaction, it is divided into the prepare phase and the rollback phase. During the prepare phase, a pre-processed message is stored in the semi-message queue. When the rollback transaction is executed, the transaction execution is undone and a transaction end message is written in the semi-message processing queue to indicate that the transaction is complete.
[0026] When a transaction message belongs to a timed-out transaction, transaction review and recovery are required.
[0027] The above is the transaction message execution principle within the two clusters.
[0028] Furthermore, as shown in FIG3 , the traditional synchronization process of two clusters is as follows: the target cluster half-processes the message queue, while synchronizing the actual message queue and the half-processed message queue of the source cluster, resulting in a state conflict.
[0029] When the target data center receives the first synchronization data from the source data center, it obtains the first synchronization data source queue;
[0030] When the first synchronization data source queue belongs to the first half message queue or the first half message processing queue, adding the first synchronization data to the additional transaction message queue;
[0031] When the first synchronization data source queue belongs to the first actual message queue, synchronizing the first synchronization data and adding it to the second actual message queue;
[0032] The first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
[0033] In a preferred embodiment, an additional transaction message queue is configured in the target data center, and when the first synchronization data source queue of the first synchronization data from the source data center belongs to the first half message queue or the first half message processing queue, the first synchronization data is added to the additional transaction message queue.
[0034] When the first synchronization data source queue belongs to the first actual message queue, the first synchronization data is synchronized and added to the second actual message queue to avoid data in the first half message queue or the first half message processing queue causing an execution state conflict in the actual message queue.
[0035] Among them, the first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, the second actual message queue belongs to the target data center, and the first synchronization data source queue refers to the source queue of the first synchronization data in the source data center.
[0036] Furthermore, it also includes:
[0037] When a pre-processed message is generated, the source data center is placed in a preparation phase and the pre-processed message is stored in the first half message queue;
[0038] When the pre-processed message is submitted by the producer, a commit transaction instruction is generated, the actual message is stored in the first actual message queue, and a processing completion flag of the pre-processed message is generated and added to the first half message processing queue.
[0039] In a preferred embodiment, in the source data center, when the transaction message belongs to a committed transaction, it is divided into a prepare phase and a commit phase. During prepare, a pre-processed message is stored in the first half message queue. When the message producer executes commit, a processed message is written to the first half message processing queue to indicate that the transaction is completed, and the actual message submitted is stored in the first actual message queue.
[0040] Furthermore, it also includes:
[0041] When the submission of the pre-processed message times out, a submission timeout flag is generated and the message is added to the first half message processing queue.
[0042] In a preferred embodiment, at the source data center, when a transaction message belongs to a transaction with a commit timeout, a commit timeout flag is generated, indicating that the transaction message has timed out. The flag is added to the first half of the message processing queue and then synchronized to the additional transaction message processing queue at the target data center. This prevents transaction status conflicts at the target data center, and the additional transaction message processing queue is called separately when processing is required.
[0043] Furthermore, it also includes:
[0044] When the pre-processed message is rolled back, a transaction end identifier of the pre-processed message is generated and added to the first half message processing queue.
[0045] In a preferred embodiment, at the source data center, when a transaction message belongs to a transaction that is committed and rolled back, a transaction end marker for the pre-processed message is generated and added to the first half of the message processing queue. This is then synchronized to the additional transaction message processing queue at the target data center. To avoid transaction status conflicts at the target data center, the additional transaction message processing queue is called separately when processing is required.
[0046] Furthermore, it also includes:
[0047] When receiving a transaction recovery instruction, reading unprocessed transactions from the additional transaction message queue;
[0048] Furthermore, traversing the unprocessed transactions to perform recovery processing includes:
[0049] When the unprocessed transaction has a commit timeout flag, the unprocessed transaction is recovered in the first half message queue.
[0050] The unprocessed transactions are traversed to perform recovery processing.
[0051] In a preferred embodiment, a transaction recovery instruction refers to a control command requiring the recovery of a timed-out transaction. When issued by a user, unprocessed transactions are read from the additional transaction message queue; unprocessed transactions have a transaction end indicator, a processing complete indicator, an unprocessed indicator, or a commit timeout indicator. If a commit timeout indicator is present, the unprocessed transaction is recovered in the first half message queue and the transaction is executed to avoid transaction omissions.
[0052] In summary, the embodiments of the present application have at least the following technical effects:
[0053] The present invention provides a method and system for cross-cluster synchronization of transaction messages, aiming to address the existing technical problem of poor cross-cluster synchronization, where three different transaction states can cause state conflicts in two clusters after cross-cluster synchronization. By configuring an additional transaction message queue at the target data center to store secondary transaction data from the source data center, this effectively avoids state conflicts between different transactions and achieves the technical effect of improving cross-cluster synchronization.
[0054] Example 2
[0055] Based on the same inventive concept as the transaction message cross-cluster synchronization method in the aforementioned embodiment, as shown in FIG4 , the present application provides a transaction message cross-cluster synchronization system, including:
[0056] The first processing unit 100 is configured to obtain a first synchronization data source queue when the target data center receives the first synchronization data from the source data center;
[0057] The second processing unit 200 is configured to add the first synchronization data into an additional transaction message queue when the first synchronization data source queue belongs to the first half message queue or the first half message processing queue;
[0058] The third processing unit 300 is configured to synchronize the first synchronization data and add it to a second actual message queue when the first synchronization data source queue belongs to the first actual message queue;
[0059] The first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
[0060] Furthermore, the system further comprises:
[0061] a fourth processing unit, configured to, when generating a pre-processed message, place the source data center in a preparation phase and store the pre-processed message in the first half message queue;
[0062] The fifth processing unit is used to generate a commit transaction instruction when the pre-processed message is committed by the producer, store the actual message into the first actual message queue, and generate a processing completion flag for the pre-processed message and add it to the first half message processing queue.
[0063] Furthermore, the system further comprises:
[0064] The sixth processing unit is used to generate a submission timeout identifier when the submission of the pre-processed message times out, and add the identifier to the first half message processing queue.
[0065] Furthermore, the system further comprises:
[0066] The seventh processing unit is configured to generate a transaction end identifier for the pre-processed message when the pre-processed message is rolled back, and add the identifier to the first half message processing queue.
[0067] Furthermore, the system further comprises:
[0068] an eighth processing unit, configured to read unprocessed transactions from the additional transaction message queue when receiving a transaction recovery instruction;
[0069] The unprocessed transactions are traversed to perform recovery processing.
[0070] Furthermore, the system further comprises:
[0071] The ninth processing unit is configured to recover the unprocessed transaction in the first half message queue when the unprocessed transaction has a commit timeout flag.
[0072] This specification and drawings are merely illustrative of the present application and are intended to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Obviously, those skilled in the art may make various modifications and variations to this application without departing from the scope of this application. Thus, this application is intended to include such modifications and variations as fall within the scope of this application and its equivalents.
Claims
1. A transaction message cross-cluster synchronization method, characterized in that: include: When the target data center receives the first synchronization data from the source data center, a first synchronization data source queue is obtained; When the first synchronization data source queue belongs to the first half message queue or the first half message processing queue, adding the first synchronization data into the additional transaction message queue; When the first synchronization data source queue belongs to the first actual message queue, synchronizing the first synchronization data and adding it to the second actual message queue; The first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
2. The method according to claim 1, characterized in that Also includes: When a pre-processed message is generated, the source data center is placed in a preparation phase, and the pre-processed message is stored in the first half message queue; When the pre-processed message is submitted by the producer, a commit transaction instruction is generated, the actual message is stored in the first actual message queue, and a processing completion flag of the pre-processed message is generated and added to the first half message processing queue.
3. The method according to claim 1, characterized in that Also includes: When the submission of the pre-processed message times out, a submission timeout flag is generated and added to the first half message processing queue.
4. The method according to claim 1, characterized in that Also includes: When the pre-processed message is rolled back, a transaction end identifier of the pre-processed message is generated and added to the first half message processing queue.
5. The method according to claim 1, characterized in that Also includes: When receiving a transaction recovery instruction, reading unprocessed transactions from the additional transaction message queue; The unprocessed transactions are traversed to perform recovery processing.
6. The method according to claim 1, characterized in that Traversing the unprocessed transactions to perform recovery processing includes: When the unprocessed transaction has a submission timeout flag, the unprocessed transaction is recovered in the first half message queue.
7. A transaction message cross-cluster synchronization system, characterized in that: include: A first processing unit, configured to obtain a first synchronization data source queue when the target data center receives the first synchronization data from the source data center; a second processing unit, configured to add the first synchronization data into an additional transaction message queue when the first synchronization data source queue belongs to the first half message queue or the first half message processing queue; a third processing unit, configured to synchronize the first synchronization data and add the first synchronization data to a second actual message queue when the first synchronization data source queue belongs to the first actual message queue; The first half message queue, the first half message processing queue and the first actual message queue belong to the source data center, and the second actual message queue belongs to the target data center.
8. The system according to claim 7, characterized in that Also includes: a fourth processing unit, configured to place the source data center in a preparation stage when generating a pre-processed message, and store the pre-processed message in the first half message queue; The fifth processing unit is used to generate a transaction commit instruction when the pre-processed message is committed by the producer, store the actual message in the first actual message queue, and generate a processing completion mark of the pre-processed message and add it to the first half message processing queue. List.
9. The system according to claim 7, characterized in that Also includes: The sixth processing unit is used to generate a submission timeout flag and add the pre-processed message to the first half message processing queue when the submission timeout occurs.
10. The system according to claim 9, characterized in that Also includes: The seventh processing unit is used to generate a transaction end identifier of the pre-processed message when the pre-processed message is rolled back, and add the transaction end identifier to the first half message processing queue.
Citation Information
Patent Citations
Transaction processing method, device and equipment
CN111225012A
Distributed transaction processing method and device
CN111897825A
Task scheduling method, system, device and equipment based on message queue
CN114827278A
Transaction processing method and device, node equipment and storage medium
CN115098229A
Transaction message cross-cluster synchronization method and system
CN117851089A
Cited By
Transaction message cross-cluster synchronization method and system
CN117851089A
Transaction message cross-cluster synchronization method and system
CN117851089B
