Search

CN-122019062-A - Transaction synchronization method, electronic equipment and storage medium

CN122019062ACN 122019062 ACN122019062 ACN 122019062ACN-122019062-A

Abstract

The application discloses a transaction synchronization method, electronic equipment and a storage medium, wherein the method comprises the steps of storing a transaction event written into a first system into a sending table, wherein the sending table is a database table for storing an event to be synchronized, and the transaction event is generated based on a local transaction in the first system; and in response to successful pushing, updating the state of the transaction event in the sending table. By the scheme, the strong consistency of transaction data among heterogeneous systems can be improved.

Inventors

  • WANG YOULANG
  • WANG RULEI
  • ZHU LINHAO
  • YU PENGZHAN
  • YE QINGHAN
  • ZHAO YABO
  • LIU YU
  • WANG FEICHENG
  • YANG BIAN
  • ZHANG ZHE

Assignees

  • 浙江大华技术股份有限公司

Dates

Publication Date
20260512
Application Date
20251205

Claims (10)

  1. 1. A method of transaction synchronization, comprising: Storing a transaction event written into a first system into a sending table, wherein the sending table is a database table for storing an event to be synchronized, and the transaction event is generated based on a local transaction in the first system; Pushing the transaction events meeting the preset state requirements in the sending table to a second system in batches; and in response to successful pushing, updating the state of the transaction event in the sending table.
  2. 2. The method of claim 1, wherein the predetermined state requirement is that the state of the transaction event is a state to be synchronized, and the pushing the transaction event meeting the predetermined state requirement in the sending table to the second system in batch includes: acquiring the number of events of the events to be synchronized in the sending table, wherein the events to be synchronized are transaction events of the state to be synchronized; And in response to the event number meeting the preset number requirement, pushing the events to be synchronized to the second system in batches.
  3. 3. The method of claim 2, wherein the preset number of requirements includes the number of events being less than a first preset value or the number of events being greater than a second preset value, wherein the pushing the batch of events to be synchronized into the second system in response to the number of events meeting the preset number of requirements comprises: in response to the number of events being smaller than the first preset value, taking the first number of events to be synchronized as a batch, pushing the events to be synchronized in the sending table to the second system in batches, or And in response to the event number being greater than the second preset value, taking a second number of events to be synchronized as a batch, and pushing the events to be synchronized in the sending table to the second system in batches, wherein the second preset value is greater than the first preset value, and the second number is greater than the first number.
  4. 4. The method of claim 1, wherein after saving the transaction event written to the first system in the send table, comprising: Responding to the successful storage of the local transaction to a service table and the successful storage of the corresponding transaction event to the sending table, generating a transaction identifier of the local transaction, and storing the corresponding transaction event to the transaction identifier, wherein the service table is a database table storing the transaction event in the first system; after pushing the transaction event meeting the preset state requirement in the sending table to the second system in batches, the method comprises the following steps: and responding to the transaction in the second system meeting the version updating requirement, updating the corresponding transaction event in the second system by utilizing the pushed transaction event, and taking the transaction identifier as the version number of the updated transaction event.
  5. 5. The method of claim 1, wherein the information of the transaction event in the send table includes a service table name, a service table primary key value, an operation type, a data content, a transaction identification, a status, and a creation time of the local transaction write.
  6. 6. The method according to claim 1, wherein the method further comprises: responding to the pushing failure, and after waiting for the current interval duration, pushing the corresponding transaction event to the second system again, wherein the current interval duration is the product of the preset interval duration and the number of times of re-pushing; And repeating the step of responding to the pushing failure and waiting for the current interval duration, and then pushing the corresponding transaction event to the second system again until the current interval duration is equal to or greater than a preset time threshold value, stopping pushing the corresponding transaction event to the second system, and setting the state of the corresponding transaction event in the sending table as a failure state.
  7. 7. The method according to claim 1, wherein the method further comprises: acquiring creation time data of a transaction event with a state to be synchronized in the sending table; And deleting the transaction event with the creation time data being greater than or equal to a preset creation time threshold value, and carrying out corresponding prompt.
  8. 8. The method of claim 1, wherein prior to pushing the transaction event meeting a preset state requirement in the send table to a second system in batches, comprising: and locking the transaction event meeting the preset state requirement in the sending table.
  9. 9. An electronic device comprising a memory and a processor coupled to each other, the processor configured to execute program instructions stored in the memory to implement the transaction synchronization method of any of claims 1-8.
  10. 10. A computer readable storage medium having stored thereon program instructions, which when executed by a processor implement the transaction synchronization method of any of claims 1 to 8.

Description

Transaction synchronization method, electronic equipment and storage medium Technical Field The present application relates to the field of heterogeneous system synchronization, and in particular, to a transaction synchronization method, an electronic device, and a storage medium. Background In practical application, in the dual-write mode, transaction data is written to two heterogeneous systems, namely a relational database (Greenplum, GP for short) and a search engine (ES for short), at the same time, which faces a serious challenge of guaranteeing data consistency. Moreover, the lack of a unified transaction coordination mechanism is difficult to ensure the atomicity of cross-system operation, and the problem of transaction data consistency is particularly prominent in a high concurrency scene. In order to solve the problem of transaction data consistency in the dual-write mode, a technical scheme capable of avoiding the complexity of distributed transactions and guaranteeing the strong consistency and the near real-time synchronization of the transaction data is urgently needed in the industry. Disclosure of Invention The application provides at least a transaction synchronization method, electronic equipment and a storage medium, which can promote the strong consistency of transaction data among heterogeneous systems. The first aspect of the application provides a transaction synchronization method, which comprises the steps of storing transaction events written into a first system into a sending table, wherein the sending table is a database table for storing events to be synchronized, the transaction events are generated based on local transactions in the first system, pushing the transaction events meeting preset state requirements in the sending table into a second system in batches, and updating the state of the transaction events in the sending table in response to successful pushing. The method comprises the steps of obtaining the number of events of the events to be synchronized in a sending table, wherein the events to be synchronized are the events to be synchronized, and pushing the events to be synchronized to a second system in batches in response to the number of the events meeting the preset number requirement. The preset number requirement comprises that the number of the events is smaller than a first preset value or the number of the events is larger than a second preset value, and the batch pushing of the events to be synchronized into the second system is performed in response to the fact that the number of the events meets the preset number requirement, wherein the batch pushing of the events to be synchronized into the second system comprises that the first number of the events to be synchronized is used as a batch in response to the fact that the number of the events is smaller than the first preset value, or the batch pushing of the events to be synchronized into the second system is performed in response to the fact that the number of the events is larger than the second preset value, the second number of the events to be synchronized in the sending table is used as a batch in response to the fact that the number of the events is larger than the second preset value, and the second number of the events to be synchronized is larger than the first number. After the transaction event written into the first system is saved into the sending table, the method comprises the steps of responding to the fact that the local transaction is successfully saved into the service table and the corresponding transaction event is successfully saved into the sending table, generating a transaction identifier of the local transaction, and the corresponding transaction event is saved with the transaction identifier, wherein the service table is a database table for storing the transaction event in the first system, and pushing the transaction event meeting the preset state requirement in the sending table into the second system in batches. The information of the transaction event in the sending table comprises a business table name written by a local transaction, a business table main key value, an operation type, data content, a transaction identifier, a state and creation time. The method further comprises the steps of responding to the pushing failure, waiting for the current interval duration, pushing the corresponding transaction event to the second system again, wherein the current interval duration is the product of the preset interval duration and the number of times of re-pushing, repeatedly responding to the pushing failure, waiting for the current interval duration, pushing the corresponding transaction event to the second system again until the current interval duration is equal to or greater than a preset time threshold value, stopping pushing the corresponding transaction event to the second system, and setting the state of the corresponding transaction event in the sending table to be