Transaction message cross-cluster synchronization method and system
By configuring an additional transaction message queue in the target data center, the problem of state conflict after cross-cluster synchronization is resolved, and more efficient cross-cluster synchronization is achieved.
Patent Information
- Application Number
- CN202311720402.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-14
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2043-12-14
AI Technical Summary
After cross-cluster synchronization, the three different transaction states cause state conflicts in the two clusters, resulting in poor synchronization performance.
Configure an additional transaction message queue in the target data center to store secondary transaction data from the source data center, and process transaction messages in different states to avoid conflicts.
This effectively avoids conflicts between different transaction states and improves the efficiency of cross-cluster synchronization.
Smart Images

Figure CN117851089B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of IT and software technology, in particular to a transaction message cross-cluster synchronization method and system. BACKGROUND
[0002] Since the target cluster includes local messages, local transactions need to be processed, while the timeout transactions of the source cluster need to be recovered, and the message queue needs to be checked back for the timeout transactions. The check back may generate new half-message processing messages, and may also be checked back for timeout. After cross-cluster synchronization, the three different transaction states will cause state inconsistency conflicts in the two clusters.
[0003] In the prior art, after cross-cluster synchronization, the three different transaction states will cause state conflicts in the two clusters, resulting in the technical problem of poor cross-cluster synchronization effect. SUMMARY
[0004] The present application provides a transaction message cross-cluster synchronization method and system, which is used to solve the technical problem of poor cross-cluster synchronization effect caused by the state conflicts in the two clusters after cross-cluster synchronization in the prior art.
[0005] In view of the above problems, the present application provides a transaction message cross-cluster synchronization method and system.
[0006] In a first aspect of the present application, a transaction message cross-cluster synchronization method is provided, comprising: when a target data center receives first synchronization data of 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 into 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 into 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.
[0007] In a second aspect of the present application, a transaction message cross-cluster synchronization system is provided, comprising: a first processing unit configured to obtain a first synchronization data source queue when a target data center receives first synchronization data from a 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 a first half message queue or a first half message processing queue; and a third processing unit configured to synchronize the first synchronization data and add the first synchronization data into 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.
[0008] The one or more technical solutions provided in the present application have at least the following technical effects or advantages:
[0009] The technical solution of the present application has the following advantages: when a target data center receives first synchronization data from a source data center, a first synchronization data source queue is obtained; when the first synchronization data source queue belongs to a first half message queue or a first half message processing queue, the first synchronization data is added into an additional transaction message queue; when the first synchronization data source queue belongs to a first actual message queue, the first synchronization data is synchronized and added into 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. By configuring an additional transaction message queue in the target data center, the minor transaction data of the source data center is stored. The state conflict problem of different transactions is effectively avoided, and the technical effect of improving the cross-cluster synchronization effect is achieved. BRIEF DESCRIPTION OF DRAWINGS
[0010] Figure 1 A transaction message cross-cluster synchronization method flowchart is provided in the present application.
[0011] Figure 2 A transaction message principle flowchart in a transaction message cross-cluster synchronization method is provided in the present application.
[0012] Figure 3 A traditional cross-cluster synchronization method flowchart in a transaction message cross-cluster synchronization method is provided in the present application.
[0013] Figure 4 A structure diagram of a transaction message cross-cluster synchronization system is provided in the present application.
[0014] Explanation of reference signs: first processing unit 100, second processing unit 200, third processing unit 300. DETAILED DESCRIPTION
[0015] The present application provides a transaction message cross-cluster synchronization method and system, which is used to solve the technical problem that the cross-cluster synchronization effect is poor due to the state conflict caused by the three different transaction states in the two clusters after cross-cluster synchronization. By configuring an additional transaction message queue in the target data center, the secondary transaction data of the source data center is stored. The state conflict problem of different transactions is effectively avoided, and the technical effect of improving the cross-cluster synchronization effect is achieved.
[0016] Glossary:
[0017] Message queue: a kind of asynchronous communication middleware. It can be understood as a post office. The sender delivers the message to the post office, and then the post office helps us to send it to the specific message receiver (consumer). We don't need to care about the specific sending process and time, and it won't interfere with our other things.
[0018] Cross-cluster synchronization: refers to the synchronization of message data between two independently deployed message queue clusters. It is generally used in the scenario of remote dual-active, and is used to support message queue dual-write.
[0019] Transaction message: refers to the simultaneous success or failure of the production end message sending event and the local transaction event. The transaction message mainly includes two stages: normal transaction sending and submission, and transaction information compensation process.
[0020] Embodiment one
[0021] As shown in Figure 1 , the present application provides a transaction message cross-cluster synchronization method, which comprises:
[0022] In the traditional scheme of transaction message cross-cluster synchronization, as shown in Figure 2 , the transaction message is divided into committed transactions, rolled-back transactions and timed-out transactions.
[0023] When the transaction message belongs to the committed transaction, it is divided into a prepare preparation stage and a commit stage. When preparing, a pre-processing message is stored in the half message queue. When the message producer performs commit, a processed message indicating that the transaction is complete is written to the half message processing queue.
[0024] When the transaction message belongs to a transaction that is rolled back, it is divided into a prepare preparation phase and a rollback phase. When preparing, a pre-processing message is stored in a half-message queue. When executing a transaction rollback, a transaction end message is written in the half-message processing queue to indicate that the transaction is complete.
[0025] When the transaction message belongs to a transaction that is rolled back, it is divided into a prepare preparation phase and a rollback phase. When preparing, a pre-processing message is stored in a half-message queue. When executing a transaction rollback, a transaction end message is written in the half-message processing queue to indicate that the transaction is complete.
[0026] The above is the execution principle of transaction messages within two clusters.
[0027] Further, as shown in Figure 3 The traditional two-cluster synchronization process is as follows: the target cluster half-message processing queue synchronizes the actual message queue and the half-processing message queue of the source cluster, resulting in a state conflict.
[0028] When the target data center receives the first synchronization data from the source data center, the first synchronization data source queue is obtained;
[0029] 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;
[0030] 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;
[0031] 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.
[0032] In a preferred embodiment, an additional transaction message queue is configured in the target data center. 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.
[0033] 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. Avoiding the data of the first half-message queue or the first half-message processing queue, which causes a state conflict in the execution of the actual message queue.
[0034] 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 first synchronization data source queue refers to the source queue of the first synchronization data in the source data center.
[0035] Further, it also includes:
[0036] When the pre-processing message is generated, the source data center is put into the preparation stage, the pre-processing message is stored into the first half message queue;
[0037] When the pre-processing message is executed by the producer to complete the submission, a submission transaction instruction is generated, the actual message is stored into the first actual message queue, and a processing completion identifier of the pre-processing message is generated and added into the first half message processing queue.
[0038] In a preferred embodiment, in the source data center, when the transaction message belongs to the committed transaction, it is divided into a prepare preparation stage and a commit submission stage, a pre-processing message is stored into the first half message queue when the prepare is performed, and when the message producer performs the commit submission, a processing completed message indicating that the transaction is completed is written into the first half message processing queue, and the submitted actual message is stored into the first actual message queue.
[0039] Further, it also includes:
[0040] When the pre-processing message is executed to complete the submission, a submission timeout identifier is generated and added into the first half message processing queue.
[0041] In a preferred embodiment, in the source data center, when the transaction message belongs to the committed transaction, a submission timeout identifier representing the transaction message submission timeout is generated and added into the first half message processing queue, and the subsequent synchronization to the additional transaction message processing queue of the target data center is avoided. When the additional transaction message processing queue needs to be processed, it is called separately.
[0042] Further, it also includes:
[0043] When the pre-processing message is rolled back, a transaction end identifier of the pre-processing message is generated and added into the first half message processing queue.
[0044] In a preferred embodiment, in the source data center, when the transaction message belongs to the committed transaction, a transaction end identifier of the pre-processing message is generated and added into the first half message processing queue. The subsequent synchronization to the additional transaction message processing queue of the target data center is avoided. When the additional transaction message processing queue needs to be processed, it is called separately.
[0045] Further, it also includes:
[0046] When receiving the transaction recovery instruction, reading the unprocessed transaction from the additional transaction message queue;
[0047] Further, traversing the unprocessed transaction for recovery processing, comprising:
[0048] When the unprocessed transaction has a commit timeout identifier, recovering the unprocessed transaction in the first half message queue.
[0049] Traversing the unprocessed transaction for recovery processing.
[0050] In a preferred embodiment, the transaction recovery instruction refers to a control command that needs to recover the timeout transaction. When the user issues, read the unprocessed transaction from the additional transaction message queue; the unprocessed transaction has a transaction end identifier or a processing complete identifier or an unprocessed identifier or a commit timeout identifier. When having a commit timeout identifier, recovering the unprocessed transaction in the first half message queue, executing the transaction, and avoiding transaction omission.
[0051] In summary, the embodiments of the present application have at least the following technical effects:
[0052] The embodiments of the present application provide a transaction message cross-cluster synchronization method and system, which are used to solve the technical problem that three different transaction states will cause state conflicts in two clusters, resulting in poor cross-cluster synchronization effect in the prior art. By configuring an additional transaction message queue in the target data center, the secondary transaction data of the source data center is stored. The state conflict problem of different transactions is effectively avoided, and the technical effect of improving the cross-cluster synchronization effect is achieved.
[0053] Embodiment two
[0054] Based on the same inventive concept as the transaction message cross-cluster synchronization method in the foregoing embodiments, as shown in Figure 4 The present application provides a transaction message cross-cluster synchronization system, comprising:
[0055] The first processing unit 100 is used to obtain the first synchronization data source queue when the target data center receives the first synchronization data of the source data center;
[0056] The second processing unit 200 is used to add the first synchronization data into the 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;
[0057] The third processing unit 300 is used to synchronize the first synchronization data and add it into the second actual message queue when the first synchronization data source queue belongs to the first actual message queue.
[0058] 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.
[0059] Further, the system further comprises:
[0060] A fourth processing unit is configured to, when a pre-processing message is generated, put the source data center into a preparation stage, and store the pre-processing message into the first half message queue.
[0061] A fifth processing unit is configured to, when the pre-processing message is submitted by a producer, generate a submission transaction instruction, store an actual message into the first actual message queue, and generate a processing completion identifier of the pre-processing message and add the processing completion identifier into the first half message processing queue.
[0062] Further, the system further comprises:
[0063] A sixth processing unit is configured to, when the pre-processing message is submitted with a timeout, generate a submission timeout identifier and add the submission timeout identifier into the first half message processing queue.
[0064] Further, the system further comprises:
[0065] A seventh processing unit is configured to, when the pre-processing message is rolled back, generate a transaction end identifier of the pre-processing message and add the transaction end identifier into the first half message processing queue.
[0066] Further, the system further comprises:
[0067] An eighth processing unit is configured to, when a transaction recovery instruction is received, read an unprocessed transaction from the additional transaction message queue.
[0068] The unprocessed transaction is iterated to perform recovery processing.
[0069] Further, the system further comprises:
[0070] A ninth processing unit is configured to, when the unprocessed transaction has a submission timeout identifier, recover the unprocessed transaction in the first half message queue.
[0071] The specification and drawings are merely exemplary of the present application and are intended to cover any and all modifications, variations, combinations or equivalents that fall within the scope of the present application. Obviously, many modifications and variations of the present application are possible in light of the above teachings. It is, therefore, to be understood that within the scope of the application herein, the application can be practiced otherwise than as specifically described. Thus, any and all modifications, variations or equivalents of the present application fall within the scope of the below claims.
Claims
1. A transaction message cross-cluster synchronization method, characterized in that, The method comprises the following steps: When the target data center receives the first synchronization data of the source data center, a first synchronization data source queue is obtained; When the first synchronization data source queue belongs to a first half message queue or a first half message processing queue, the first synchronization data is added to an additional transaction message queue, which is configured in the target data center; When the first synchronization data source queue belongs to a first actual message queue, the first synchronization data is synchronized and added to a 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; When a preprocessing message is generated, the source data center is placed in a preparation stage, and the preprocessing message is stored in the first half message queue; When the preprocessing message is executed by a producer to complete the submission, a submission transaction instruction is generated, an actual message is stored in the first actual message queue, and a processing completion identifier of the preprocessing message is generated and added to the first half message processing queue; When the preprocessing message is executed to submit a timeout, a submission timeout identifier is generated and added to the first half message processing queue; When the preprocessing message is rolled back, a transaction end identifier of the preprocessing message is generated and added to the first half message processing queue.
2. The method of claim 1, wherein, The method further comprises the following steps: When a transaction recovery instruction is received, an unprocessed transaction is read from the additional transaction message queue; The unprocessed transaction is iterated for recovery processing.
3. The method of claim 2, wherein, The iteration of the unprocessed transaction for recovery processing comprises the following steps: When the unprocessed transaction has a submission timeout identifier, the unprocessed transaction is recovered in the first half message queue.
4. A transaction message cross-cluster synchronization system, characterized in that, The method comprises the following steps: A first processing unit is configured to obtain a first synchronization data source queue when a target data center receives first synchronization data of a source data center; A second processing unit is configured 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, the additional transaction message queue being configured in the target data center; A third processing unit is 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 a 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; A fourth processing unit is configured to place the source data center in a preparation stage and store a preprocessing message in the first half message queue when the preprocessing message is generated; A fifth processing unit is configured to generate a submission transaction instruction, store an actual message in the first actual message queue, and generate a processing completion identifier of the preprocessing message and add the processing completion identifier to the first half message processing queue when the preprocessing message is executed by a producer to complete the submission. A sixth processing unit is configured to generate a commit timeout identifier and add the commit timeout identifier into the first half message processing queue when the pre-processing message is executed with a commit timeout; A seventh processing unit is configured to generate a transaction end identifier of the pre-processing message and add the transaction end identifier into the first half message processing queue when the pre-processing message is rolled back.
Citation Information
Patent Citations
Cross-cluster transaction message synchronization method and system
WO2024183431A1