Database synchronization method and device based on bidirectional transaction ID number, and electronic equipment

By adopting a database synchronization method based on two-way transaction ID number in the multi-main database synchronization scenario, the problem of loopback synchronization is solved, and synchronization efficiency and consistency are improved.

CN120144669APending Publication Date: 2025-06-13INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510219734.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-26
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

In the multi-main database synchronization scenario, existing database synchronization strategies are prone to loopback synchronization, wasting network bandwidth and computing resources, and affecting system stability and performance.

Method used

The database synchronization method based on the two-way transaction ID number is adopted. By monitoring the main database of the target park, the transaction ID number and IP address are obtained, the transaction message data is generated, and the transaction message data is checked in the two-way transaction number cache. If it does not exist, it is sent to the message queue of another campus. Other parks obtain transaction ID numbers and IP addresses based on transaction message data, convert them into transaction instructions, execute and generate two-way transaction ID numbers, and save them to the two-way transaction number cache.

Benefits of technology

It effectively prevents duplicate synchronization between databases, avoids the problem of data loopback synchronization between multiple master databases, and improves the efficiency and consistency of database synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144669A_ABST
    Figure CN120144669A_ABST
Patent Text Reader

Abstract

The invention discloses a database synchronization method and device based on a bidirectional transaction ID number and electronic equipment, and relates to the technical field of cloud computing or other related fields, and the method comprises the steps: monitoring a main database of a target park, obtaining a transaction number and a main database address under the condition that the main database is monitored to successfully execute a transaction instruction, and storing the transaction number and the address of the main database; and when the transaction message data does not exist in the bidirectional transaction number cache of the target park, the transaction message data is sent to message queues of other parks, the transaction number and address of the target park are obtained by the other parks, and the transaction message data is converted into a transaction instruction and executed. And obtaining transaction numbers and addresses of other parks, generating bidirectional transaction numbers based on the transaction numbers and addresses of the other parks and the target park, and storing the bidirectional transaction numbers to bidirectional transaction number caches of the other parks. According to the method and the device, the technical problem that a loopback synchronization phenomenon exists when multiple main databases synchronize data in related technologies is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of cloud computing technology or other related fields. Specifically, it relates to a database synchronization method, device, and electronic device based on a two-way transaction ID number. Background Art

[0002] In the current environment of cloud computing and big data processing, with the development of automation technology, the deployment of cloud computing facilities, and the application of micro-server architectures, multi-campus deployment has become a common architecture choice. In multi-campus deployment, in order to achieve fast response of each application system, each campus usually needs to deploy an independent database service. In order to enable each campus's application system to run independently and ensure the response speed and high availability of data access, the databases deployed in each campus are usually set as master databases, that is, primary databases. This multi-primary database architecture can effectively support the independent operation of each application system within the local campus and ensure timely access and processing of data.

[0003] In the related art, there are significant problems in the existing multi-primary database synchronization strategies in achieving data consistency, especially in avoiding loop synchronization problems and improving synchronization efficiency. The existing database synchronization strategies usually adopt a master-slave synchronization mechanism, that is, data synchronization between a single primary database and multiple slave databases. However, in the multi-primary database synchronization scenario, each database is a primary database. If the master-slave synchronization mechanism is directly adopted, it will cause loop synchronization of data among multiple primary databases, that is, database A synchronizes data to database B, and database B synchronizes the same data back to database A. This loop synchronization phenomenon not only wastes network bandwidth and computing resources but also leads to data inconsistency, affecting the overall stability and performance of the system. In addition, the existing multi-primary database synchronization strategies frequently query the database to confirm the data status and synchronization progress, imposing an additional burden on the database performance. Especially in a high-concurrency environment, it will significantly reduce the synchronization efficiency and response speed of the database.

[0004] In view of the above problems, no effective solution has been proposed yet. Summary of the Invention

[0005] Embodiments of the present invention provide a database synchronization method, device, and electronic device based on a two-way transaction ID number, so as to at least solve the technical problem of loop synchronization when multi-primary databases synchronize data in the related art.

[0006] To achieve the above object, according to one aspect of the present application, a database synchronization method based on a two-way transaction ID number is provided, including: monitoring the master database of the target park, and when it is monitored that the master database successfully executes a transaction instruction initiated by an external application, obtaining the transaction ID number and the IP address of the master database, and generating transaction message data based on the transaction ID number and the IP address, where the master database is a database independently deployed and independently operated in each park; when there is no transaction message data in the two-way transaction number cache of the target park, sending the transaction message data to the message queue of other parks, where other parks refer to the database deployment parks other than the target park, and other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into a transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of other parks, generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks.

[0007] Optionally, the step of obtaining the IP address and the transaction ID number of the master database includes: obtaining the log file of the master database, parsing the log file to obtain the change data of the master database; parsing the change data to obtain the IP address and the transaction ID number of the master database.

[0008] Optionally, when there is transaction message data in the two-way transaction number cache of the target park, it further includes: deleting the two-way transaction ID number corresponding to the transaction message data in the two-way transaction number cache of the target park.

[0009] Optionally, the step of determining whether there is transaction message data in the two-way transaction number cache of the target park includes: traversing the two-way transaction ID numbers stored in the two-way transaction number cache of the target park based on the transaction message data; when the traversal result indicates that the two-way transaction ID number contains the transaction message data, determining that there is transaction message data in the two-way transaction number cache of the target park; when the traversal result indicates that all two-way transaction ID numbers do not contain the transaction message data, determining that there is no transaction message data in the two-way transaction number cache of the target park.

[0010] Optionally, the step of generating a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park includes: concatenating the transaction ID number and the IP address of other parks to obtain the total ID number of other parks; concatenating the transaction ID number and the IP address of the target park to obtain the total ID number of the target park; concatenating the total ID number of other parks with the total ID number of the target park to obtain the two-way transaction ID number.

[0011] Optionally, after the transaction message data is sent to the message queue of the target park in other parks, it includes: the target park obtains the transaction message data, obtains the transaction ID number and IP address of other parks based on the transaction message data; converts the transaction message data into a transaction instruction, the target park executes the transaction instruction, and obtains the transaction ID number and IP address of the target park, and generates a two-way transaction ID number based on the transaction ID numbers and IP addresses of the target park and other parks, and saves the two-way transaction ID number to the two-way transaction number cache of the target park.

[0012] Optionally, after the transaction instruction is successfully executed in the main database, it further includes: the data in the main database changes, and the changed data is saved to a log file, where the changed data includes: the data before the change, the data after the change, the transaction instruction, the transaction ID number, and the IP address of the main database, and there is a unique correspondence between the changed data and the transaction ID number.

[0013] According to another aspect of the embodiments of the present invention, there is also provided a database synchronization device based on a two-way transaction ID number, including: a monitoring unit, configured to monitor the main database of the target park, and when it is monitored that the main database successfully executes a transaction instruction initiated by an external application, obtain the transaction ID number and the IP address of the main database, and generate transaction message data based on the transaction ID number and the IP address, where the main database is a database independently deployed and independently operated in each park; a sending unit, configured to send the transaction message data to the message queue of other parks when there is no transaction message data in the two-way transaction number cache of the target park, and a generating unit, where other parks refer to the database deployment parks other than the target park, and is configured to obtain the transaction ID number and IP address of the target park based on the transaction message data by other parks, convert the transaction message data into a transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of other parks, generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks.

[0014] Optionally, the monitoring unit includes: an obtaining module, configured to obtain the log file of the main database, parse the log file, and obtain the changed data of the main database; a parsing module, configured to parse the changed data to obtain the IP address and transaction ID number of the main database.

[0015] Optionally, the sending unit includes: a deleting module, configured to delete the two-way transaction ID number corresponding to the transaction message data in the two-way transaction number cache of the target park when there is transaction message data in the two-way transaction number cache of the target park.

[0016] Optionally, the sending unit further includes: a traversing module, configured to traverse the two-way transaction ID numbers stored in the two-way transaction number cache of the target park based on the transaction message data when determining whether there is transaction message data in the two-way transaction number cache of the target park; a first determination module, configured to determine that there is transaction message data in the two-way transaction number cache of the target park when the traversal result indicates that the two-way transaction ID number includes the transaction message data; a second determination module, configured to determine that there is no transaction message data in the two-way transaction number cache of the target park when the traversal result indicates that all two-way transaction ID numbers do not include the transaction message data.

[0017] Optionally, the generating unit includes: a first splicing module, configured to splice the transaction ID number and the IP address of another park into a string to obtain the total ID number of another park when generating a two-way transaction ID number based on the transaction ID numbers and IP addresses of another park and the target park; a second splicing module, configured to splice the transaction ID number and the IP address of the target park into a string to obtain the total ID number of the target park; a third splicing module, configured to splice the total ID number of another park and the total ID number of the target park to obtain the two-way transaction ID number.

[0018] Optionally, the sending unit further includes: an execution module, configured to, after another park sends transaction message data to the message queue of the target park, the target park obtains the transaction message data, and obtains the transaction ID number and the IP address of another park based on the transaction message data; a first saving module, configured to convert the transaction message data into a transaction instruction, the target park executes the transaction instruction, and obtains the transaction ID number and the IP address of the target park, generates a two-way transaction ID number based on the transaction ID numbers and IP addresses of the target park and another park, and saves the two-way transaction ID number to the two-way transaction number cache of the target park.

[0019] Optionally, the monitoring unit further includes: a second saving module, configured to, after the main database successfully executes the transaction instruction and the data in the main database changes, save the changed data to a log file, where the changed data includes: the data before the change, the data after the change, the transaction instruction, the transaction ID number, and the IP address of the main database, and there is a unique correspondence between the changed data and the transaction ID number.

[0020] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, and when the computer program runs, it controls the device where the computer-readable storage medium is located to execute the database synchronization method based on the two-way transaction ID number according to any one of the above.

[0021] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including one or more processors and a memory, where the memory is used to store one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the database synchronization method based on the two-way transaction ID number as described in any one of the above.

[0022] According to another aspect of the embodiments of the present invention, there is also provided a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the steps of the database synchronization method based on the two-way transaction ID number as described in any one of the above.

[0023] In the present disclosure, by monitoring the master database of the target park, when it is monitored that the master database successfully executes a transaction instruction initiated by an external application, the transaction ID number and the IP address of the master database are obtained, and transaction message data is generated based on the transaction ID number and the IP address. When the transaction message data does not exist in the two-way transaction number cache of the target park, the transaction message data is sent to the message queue of other parks. In this process, before sending the transaction message data, the target park will first check in the two-way transaction ID number cache of the target park whether there is already a two-way transaction ID number containing the transaction message data. If not, it indicates that the transaction message data has not been synchronized by other parks, so the transaction message data is sent, thereby effectively preventing duplicate synchronization between databases and avoiding the problem of loop synchronization of data between multiple master databases.

[0024] At the same time, other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into a transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of other parks, and then generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks. By generating and saving the two-way transaction ID number in a timely manner, it is ensured that each transaction instruction is only executed once in the master databases of each park, thereby solving the technical problem of loop synchronization phenomenon when multiple master databases synchronize data in the related art. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The schematic embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation to the present invention. In the drawings:

[0026] Figure 1 It shows a hardware structure block diagram of a computer terminal (or mobile device) for implementing the database synchronization method based on the two-way transaction ID number;

[0027] Figure 2 It is a flowchart of an optional database synchronization method based on a two-way transaction ID number according to an embodiment of the present invention;

[0028] Figure 3 It is a data synchronization flowchart of an optional database synchronization method based on a two-way transaction ID number according to an embodiment of the present invention;

[0029] Figure 4 It is a schematic diagram of an optional database synchronization device based on a two-way transaction ID number according to an embodiment of the present invention;

[0030] Figure 5 It is a structural block diagram of an electronic device according to an embodiment of the present application. Detailed implementation manners

[0031] In order to enable those skilled in the art to better understand the solution of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present invention described here can be implemented in an order other than those illustrated or described here. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device including a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0033] It should be noted that the database synchronization method and its device based on a two-way transaction ID number in the present disclosure can be used in the field of cloud computing technology when implementing database synchronization based on a two-way transaction ID number, and can also be used in any field other than the field of cloud computing technology when implementing database synchronization based on a two-way transaction ID number. The application field of the database synchronization method and its device based on a two-way transaction ID number in the present disclosure is not limited.

[0034] It should be noted that the information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) collected in this disclosure are information and data authorized by the user or fully authorized by all parties. Moreover, the processing of relevant data, such as collection, storage, use, processing, transmission, provision, disclosure, and application, complies with relevant laws, regulations, and standards in the relevant regions, adopts necessary confidentiality measures, does not violate public order and good customs, and provides corresponding operation entrances for users to choose to authorize or reject. For example, there is an interface between this system and relevant users or institutions. Before obtaining relevant information, a request for acquisition needs to be sent to the aforementioned users or institutions through the interface, and after receiving the consent information feedback from the aforementioned users or institutions, the relevant information is obtained.

[0035] It should be noted that in this disclosure, when collecting customer information, analyzing customer information, a corresponding operation entrance is provided for users to choose to agree or reject the automated decision-making result; if the user chooses to reject, the expert decision-making process will be entered.

[0036] The following embodiments of the present invention can be applied to various systems / applications / devices for database synchronization based on two-way transaction ID numbers. In the present invention, before sending transaction message data, the target park will first check whether there is already a two-way transaction ID number containing the transaction message data in the two-way transaction ID number cache of the target park. If not, it indicates that the transaction message data has not been synchronized by other parks yet. Therefore, the transaction message data is sent. At the same time, other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into a transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of other parks, and then generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks. By generating and saving the two-way transaction ID number in a timely manner, it is ensured that each transaction instruction is only executed once in the main databases of each park, thereby effectively preventing duplicate synchronization between databases and avoiding the problem of loop synchronization of data between multiple main databases.

[0037] The present invention will be described in detail below in conjunction with each embodiment.

[0038] Embodiment 1

[0039] According to an embodiment of the present invention, an embodiment of a database synchronization method based on a two-way transaction ID number is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. And although the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than here.

[0040] The embodiment of the database synchronization method based on the bidirectional transaction ID number provided in the first embodiment of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 The following shows a hardware block diagram of a computer terminal (or mobile device) for implementing the database synchronization method based on the bidirectional transaction ID number. As Figure 1 shown, the computer terminal 10 (or mobile device) may include one or more ( Figure 1 illustrated as 102a, 102b,..., 102n herein) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU (Microcontroller Unit) or a field programmable gate array FPGA (Field Programmable Gate Array)), a memory 104 for storing data, and a transmission device 106 for communication functions. In addition, it may further include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports in the BUS bus), a network interface, a power supply, and / or a camera. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only illustrative and does not limit the structure of the above electronic device. For example, the computer terminal 10 may further include more or fewer components than Figure 1 shown herein, or have a different configuration from Figure 1 shown herein.

[0041] It should be noted that the above one or more processors 102 and / or other data processing circuits are generally referred to as "data processing circuits" herein. The data processing circuit may be embodied in software, hardware, firmware or any combination thereof, in whole or in part. In addition, the data processing circuit may be a single independent processing module, or be incorporated in whole or in part into any one of the other elements in the computer terminal 10 (or mobile device). As involved in the embodiments of the present application, the data processing circuit is a kind of processor control (such as the selection of a variable resistor terminal path connected to an interface).

[0042] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the database synchronization method based on the two-way transaction ID number in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, implements the above-mentioned database synchronization method based on the two-way transaction ID number. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely disposed relative to the processor 102, and these remote memories can be connected to the computer terminal 10 through a network. Examples of the above-mentioned network include but are not limited to the Internet, enterprise intranet, local area network, mobile communication network, and combinations thereof.

[0043] The transmission device 106 is used to receive or send data via a network. Specific examples of the above-mentioned network may include a wireless network provided by a communication provider of the computer terminal 10. In one instance, the transmission device 106 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station and thus can communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0044] The display can be, for example, a touch-screen liquid crystal display (Liquid Crystal Display, LCD for short), and this liquid crystal display enables a user to interact with the user interface of the computer terminal 10 (or mobile device).

[0045] Under the above operating environment, the present application provides a Figure 2 database synchronization method based on the two-way transaction ID number as shown. Figure 2 is a flowchart of an optional database synchronization method based on the two-way transaction ID number according to an embodiment of the present invention, as Figure 2 shown, and the method includes the following steps:

[0046] Step S201: Monitor the master database of the target park. When it is monitored that the master database successfully executes a transaction instruction initiated by an external application, obtain the transaction ID number and the IP address of the master database, and generate transaction message data based on the transaction ID number and the IP address, where the master database is a database independently deployed and independently operated in each park.

[0047] In the embodiments of the present invention, the main databases of each park are closely monitored. The main databases of each park are database entities that are independently deployed and operate independently, carrying the read and write requirements of local application systems for data. The main database of each park is like an independent node for data processing, responsible for processing data changes within the park, and at the same time maintaining close contact with the main databases of other parks through a data synchronization mechanism to achieve the consistency of global data.

[0048] When the main database of a certain park receives and successfully executes a transaction instruction initiated by an external application system, the data synchronization process is started in the embodiments of the present invention. First, it should be noted that in the embodiments of the present invention, the park that has received and successfully executed the transaction instruction is called the target park, and the parks other than the target park are called other parks.

[0049] At the beginning of the data synchronization process, after the target park successfully executes the transaction instruction, the data in the main database of the target park will change, generating changed data. Among them, the changed data includes the data before the change, the data after the change, the executed transaction instruction, the transaction ID number, and the IP address of the main database. Among them, the transaction ID number is an identifier generated by the main database after successfully executing the transaction instruction, and there is a unique correspondence between the transaction ID number and the changed data, which can ensure the uniqueness and traceability of the changed data.

[0050] After the target park successfully executes the transaction instruction and generates the changed data, the embodiments of the present invention obtain the transaction ID number and the main database IP address of the target park from the changed data, and then generate transaction message data based on the transaction ID number and the main database IP address. This generation process is actually an encapsulation of the transaction information, and the encapsulated content includes the transaction ID number and the main database IP address. By generating the transaction message data, the data can be accurately sent from one park to another park without causing information loss or confusion.

[0051] It should be noted that the monitoring and data capture mechanism in the embodiments of the present invention is triggered immediately after the transaction instruction is successfully executed, which means that the data change of the main database can be quickly captured and propagated within the park cluster, thereby significantly shortening the time delay of data synchronization and improving the real-time performance of database synchronization.

[0052] Step S202, when there is no transaction message data in the two-way transaction number cache of the target park, send the transaction message data to the message queue of other parks.

[0053] After generating the transaction message data, the target park will first check whether the transaction message data already exists in the local two-way transaction number cache. Each park includes a two-way transaction number cache, which is used to store two-way transaction ID numbers, that is, to store the transaction ID numbers and IP addresses that have been successfully synchronized between two parks.

[0054] If the combination of the transaction ID number and the IP address in the transaction message data does not exist in the two-way transaction number cache, it means that the current transaction message data has not completed the complete synchronization process among multiple parks, that is, the transaction instructions corresponding to the transaction message data have not been successfully executed on the main databases of all parks. In this case, the transaction message data is regarded as new data that needs to be synchronized and will be sent to the message queues of other parks, waiting for further processing and execution. Through this checking mechanism, the repeated transmission and execution of data among parks are avoided, significantly improving the efficiency and accuracy of data synchronization.

[0055] Step S203, other parks refer to the database deployment parks other than the target park. Based on the transaction message data, other parks obtain the transaction ID number and IP address of the target park, convert the transaction message data into transaction instructions, execute the transaction instructions, obtain the transaction ID number and IP address of other parks, generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks.

[0056] When the transaction message data generated by the target park is confirmed as new messages that need to be synchronized, it sends the transaction message data to other parks, where other parks include all parks other than the target park. For each other park, after receiving the transaction message data, it will immediately convert the received transaction message data into specific transaction instructions, that is, the transaction instructions that have been successfully executed by the target park. By executing the transaction instructions, other parks complete the data synchronization with the target park.

[0057] Meanwhile, after receiving the transaction message data sent by the target park, the embodiment of the present invention will parse the transaction message data to obtain the transaction ID number id0 and the IP address ip0 of the target park. Other parks will then convert the transaction message data into a transaction instruction, and generate the transaction ID number id1 and the IP address ip1 of other parks by executing the transaction instruction. It should be noted that in this process, id0 and ip0 are the data sent by the target park, that is, the transaction message data sent by the target park contains id0 and ip0. Among them, id0 is the transaction ID number generated by the target park when executing the transaction message, and ip0 is the IP address of the main database of the target park. And id1 and ip1 are the data generated by other parks themselves, that is, other parks generate their own transaction ID number id1 by executing the same transaction instruction as the target park. id1 is different from id0, and ip1 is the IP address of the main database of other parks.

[0058] After obtaining the transaction ID numbers and IP addresses of other parks and the target park, a two-way transaction ID number is generated based on the transaction ID numbers and IP addresses of other parks and the target park. The generation of the two-way transaction ID number is to splice and combine the transaction ID number and IP address after the transaction instruction is executed in the target park with the new transaction ID number and IP address generated after the execution in other parks to form a unique identifier in the format of "id0+ip0:id1+ip1". Here, id0 and ip0 respectively represent the transaction ID number of the target park and its database IP address, while id1 and ip1 represent the transaction ID number generated by other parks after executing the transaction instruction and its database IP address.

[0059] The generated two-way transaction ID number will then be saved to the two-way transaction number cache of other parks. By saving the two-way transaction ID number, other parks can record the status of data synchronization with the target park, that is, it indicates that a certain transaction instruction has been successfully executed in this park, that is, this park has completed synchronization with the target park. Saving the two-way transaction ID number not only provides a key judgment basis for subsequent data synchronization in other rounds, but also further enhances the park's ability to track and manage the data synchronization status, effectively avoiding the problem of data loop synchronization.

[0060] Optionally, the steps of obtaining the IP address of the main database and the transaction ID number include: obtaining the log file of the main database, parsing the log file to obtain the change data of the main database; parsing the change data to obtain the IP address of the main database and the transaction ID number.

[0061] In step S201, when it is monitored that the master database has successfully executed the transaction instruction initiated by the external application, first, the log file of the master database will be obtained. The log file is usually a binary file that records all transaction change information executed on the master database, including data modification, insertion, and deletion operations, and is a real-time record of the database execution status. After obtaining the log file, it is parsed to obtain the changed data generated after the master database successfully executes the transaction instruction, and then the changed data is further parsed to obtain the IP address of the master database and the transaction ID number corresponding to the changed data, so as to ensure that data synchronization can be performed based on the transaction ID number and the master database IP address in the subsequent process.

[0062] Optionally, when there is transaction message data in the two-way transaction number cache of the target park, it further includes: deleting the two-way transaction ID number corresponding to the transaction message data in the two-way transaction number cache of the target park.

[0063] In step S202, after the transaction message data is generated in the target park, if there is transaction message data in the two-way transaction number cache of the target park, it means that the transaction information data has completed data synchronization. In this case, in order to avoid storing too many duplicate two-way transaction ID numbers in the cache, the embodiment of the present invention will delete the two-way transaction ID number corresponding to the current transaction message data in the two-way transaction number cache of the target park.

[0064] Optionally, the step of determining whether there is transaction message data in the two-way transaction number cache of the target park includes: traversing the two-way transaction ID numbers stored in the two-way transaction number cache of the target park based on the transaction message data; when the traversal result indicates that the two-way transaction ID number contains the transaction message data, it is determined that there is transaction message data in the two-way transaction number cache of the target park; when the traversal result indicates that all two-way transaction ID numbers do not contain the transaction message data, it is determined that there is no transaction message data in the two-way transaction number cache of the target park.

[0065] In step S202, the system starts to traverse the two-way transaction number cache of the target park based on the received transaction message data. The two-way transaction number cache stores all two-way transaction ID numbers that have completed cross-park synchronization, and its format is "id0+ip0:id1+ip1", where id0 and ip0 respectively represent the transaction ID number generated by the target park after executing the transaction instruction and its database IP address, while id1 and ip1 represent the transaction ID number generated by other parks after executing the transaction instruction and their database IP addresses.

[0066] The traversal operation checks each two-way transaction ID number stored in the two-way transaction number cache to find a record that matches the transaction ID number and IP address in the current transaction message data. If the result of the traversal indicates that the two-way transaction ID number contains the transaction ID number and IP address in the transaction message data, it is determined that the transaction message data exists in the two-way transaction number cache of the target park, which means that the transaction message data has been successfully synchronized by other parks and there is no need to synchronize it again, thus avoiding the generation of loop synchronization and ensuring the unidirectionality and efficiency of data synchronization.

[0067] On the contrary, if the result of the traversal shows that all two-way transaction ID numbers do not contain the transaction ID number and IP address in the transaction message data, that is, no matching cache record is found, it is determined that the transaction message data does not exist in the two-way transaction number cache of the target park, which indicates that the transaction message data has not been synchronized to other parks yet. Therefore, it needs to be sent as new transaction message data to the message queue of other parks for further processing and execution by other parks to ensure the full synchronization of data across multiple parks.

[0068] Optionally, the step of generating a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park includes: concatenating the transaction ID number and IP address of other parks to obtain the total ID number of other parks; concatenating the transaction ID number and IP address of the target park to obtain the total ID number of the target park; concatenating the total ID number of other parks with the total ID number of the target park to obtain the two-way transaction ID number.

[0069] In step S203, when generating the two-way transaction ID number, first concatenate the transaction ID number id1 and IP address ip1 of other parks to obtain the total ID number of other parks "id1+ip1", then concatenate the transaction ID number id0 and IP address ip0 of the target park to obtain the total ID number of the target park "id0+ip1", and finally concatenate the total ID number of other parks "id1+ip1" with the total ID number of the target park "id0+ip1" to obtain the two-way transaction ID number "id0+ip0:id1+ip1", and save this two-way transaction ID number to the two-way transaction number cache.

[0070] Optionally, after other parks send the transaction message data to the message queue of the target park, it includes: the target park obtains the transaction message data, and obtains the transaction ID number and IP address of other parks based on the transaction message data; converts the transaction message data into a transaction instruction, the target park executes the transaction instruction, and obtains the transaction ID number and IP address of the target park, generates a two-way transaction ID number based on the transaction ID numbers and IP addresses of the target park and other parks, and saves the two-way transaction ID number to the two-way transaction number cache of the target park.

[0071] It should be noted that after the target park successfully executes a transaction instruction, it will generate transaction message data and send it to other parks. Other parks will implement data synchronization based on this transaction message data. Similarly, after a certain other park successfully executes a transaction instruction, it will also generate transaction message data and send it to other parks except this other park, including the target park. After receiving the transaction message data, the target park executes the data synchronization process, including obtaining the transaction ID number and IP address of other parks based on the received transaction message data, then converting the transaction message data into a transaction instruction, executing this transaction instruction, obtaining the transaction ID number and IP address generated by the target park itself, and finally generating a two-way transaction ID number based on the transaction ID numbers and IP addresses of the target park and other parks, and saving the two-way transaction ID number to the two-way transaction number cache of the target park.

[0072] Optionally, after the main database successfully executes a transaction instruction, it further includes: the data in the main database changes, and the changed data is saved to a log file, where the changed data includes: the data before the change, the data after the change, the transaction instruction, the transaction ID number, and the IP address of the main database, and there is a unique correspondence between the changed data and the transaction ID number.

[0073] It should be noted that after the main database of the park successfully executes a transaction instruction, the data in the main database will change, and at the same time, the changed data is saved to the log file of the main database. Among them, the changed data recorded in the log file includes the data before the change, the data after the change, the executed transaction instruction, the transaction ID number, and the IP address of the main database. Among them, the transaction ID number is an identifier generated by the main database after successfully executing the transaction instruction, and there is a unique correspondence between the transaction ID number and the changed data. Therefore, after the target park and other parks perform data synchronization and execute the same transaction instruction, different transaction ID numbers will be generated.

[0074] Figure 3 It is a data synchronization flowchart of an optional database synchronization method based on a two-way transaction ID number according to an embodiment of the present invention, as Figure 3As shown in the figure, the monitoring module of Park A is responsible for monitoring the main database of Park A. When it monitors that the main database of Park A has successfully executed the transaction instruction initiated by an external application, the monitoring module of Park A obtains and parses the log file to obtain the transaction ID number after Park A executes the transaction instruction and the IP address of the main database of Park A. The monitoring module of Park A pushes the transaction ID number and the IP address to the filter module of Park A. The filter module of Park A generates transaction message data based on the transaction ID number and the IP address, and determines whether there is such transaction message data in the two-way transaction ID number cache of Park A. If it exists, the transaction message data is discarded, and the corresponding two-way transaction ID number in the two-way transaction ID number cache of Park A is deleted. If it does not exist, the transaction message data is sent to the message queue of Park B. The synchronous data module of Park B consumes the transaction message data in the message queue of Park B. By parsing the transaction message data, it obtains the transaction ID number id0 and the IP address ip0 of Park A. Then, by converting the transaction message data into a transaction instruction, Park B executes the transaction instruction to generate the transaction ID number id1 and the IP address ip1 of Park B. Finally, a two-way transaction ID number is generated based on the transaction ID numbers and IP addresses of Park A and Park B, and the two-way transaction ID number is saved to the two-way transaction ID number cache of Park B, where the two-way transaction ID number cache is located in the filter module. After the monitoring module of Park B monitors that the main database of Park B has successfully executed the transaction instruction initiated by an external application, the same data synchronization process is executed.

[0075] The steps provided by the above database synchronization method based on the two-way transaction ID number can monitor the main database of the target park. When it monitors that the main database has successfully executed the transaction instruction initiated by an external application, it obtains the transaction ID number and the IP address of the main database, and generates transaction message data based on the transaction ID number and the IP address. When there is no transaction message data in the two-way transaction ID number cache of the target park, the transaction message data is sent to the message queue of other parks. In this process, before sending the transaction message data, the target park will first check whether there is a two-way transaction ID number containing the transaction message data in the two-way transaction ID number cache of the target park. If it does not exist, it indicates that the transaction message data has not been synchronized by other parks, so the transaction message data is sent, thereby effectively preventing duplicate synchronization between databases and avoiding the problem of loop synchronization of data between multiple main databases.

[0076] Meanwhile, other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into transaction instructions, execute the transaction instructions, obtain the transaction ID number and IP address of other parks, and then generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks. By generating and saving the two-way transaction ID number in a timely manner, it is ensured that each transaction instruction is only executed once in the main databases of each park, thereby solving the technical problem of loop synchronization that exists when multiple main databases synchronize data in the related art.

[0077] Secondly, in the embodiments of the present invention, by monitoring the main database, change data is obtained from the log file of the main database, and then the transaction ID number and the IP address of the main database are obtained. There is no need to query the main database, which does not affect the running state of the main database. And when performing data synchronization, it is only necessary to query the two-way transaction number cache to determine whether data synchronization is required, significantly reducing the query times of the main database and effectively improving the efficiency of database synchronization.

[0078] The following is a detailed description in combination with another embodiment.

[0079] Embodiment 2

[0080] A database synchronization device based on a two-way transaction ID number provided in this embodiment includes multiple implementation units, and each implementation unit corresponds to each implementation step in Embodiment 1 above.

[0081] Figure 4 is a schematic diagram of an optional database synchronization device based on a two-way transaction ID number according to an embodiment of the present invention, as Figure 4 shown. The database synchronization device based on the two-way transaction ID number may include: a monitoring unit 41, a sending unit 42, and a generating unit 43.

[0082] Among them, the monitoring unit 41 is used to monitor the main database of the target park. When it is monitored that the main database successfully executes a transaction instruction initiated by an external application, the transaction ID number and the IP address of the main database are obtained, and transaction message data is generated based on the transaction ID number and the IP address. Here, the main database is a database independently deployed and independently operated in each park.

[0083] The sending unit 42 is used to send the transaction message data to the message queue of other parks when the transaction message data does not exist in the two-way transaction number cache of the target park.

[0084] A generating unit 43. Other parks refer to the database deployment parks other than the target park, which are used for other parks to obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into transaction instructions, execute the transaction instructions, obtain the transaction ID number and IP address of other parks, generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks.

[0085] The above database synchronization device based on the two-way transaction ID number can monitor the main database of the target park through the monitoring unit 41. When it is monitored that the main database has successfully executed the transaction instructions initiated by the external application, obtain the transaction ID number and the IP address of the main database, and generate transaction message data based on the transaction ID number and the IP address. When there is no transaction message data in the two-way transaction number cache of the target park, send the transaction message data to the message queue of other parks through the sending unit 42. In this process, before sending the transaction message data, the target park will first check whether there is already a two-way transaction ID number containing the transaction message data in the two-way transaction ID number cache of the target park. If not, it indicates that the transaction message data has not been synchronized by other parks, so the transaction message data is sent, thus effectively preventing duplicate synchronization between databases and avoiding the problem of loop synchronization of data between multiple main databases.

[0086] At the same time, in the generating unit 43, other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into transaction instructions, execute the transaction instructions, obtain the transaction ID number and IP address of other parks, then generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks. By generating and saving the two-way transaction ID number in a timely manner, it is ensured that each transaction instruction is only executed once in the main databases of each park, thus solving the technical problem of loop synchronization phenomenon existing in the synchronization of data by multiple main databases in the related technology.

[0087] Optionally, the monitoring unit 41 includes: an obtaining module, which is used to obtain the log file of the main database, parse the log file, and obtain the change data of the main database; a parsing module, which is used to parse the change data to obtain the IP address and transaction ID number of the main database.

[0088] Optionally, the sending unit 42 includes: a deleting module, which is used to delete the two-way transaction ID number corresponding to the transaction message data in the two-way transaction number cache of the target park when there is transaction message data in the two-way transaction number cache of the target park.

[0089] Optionally, the sending unit 42 further includes: a traversing module, configured to traverse the two-way transaction ID numbers stored in the two-way transaction number cache of the target park based on the transaction message data when determining whether there is transaction message data in the two-way transaction number cache of the target park; a first determination module, configured to determine that there is transaction message data in the two-way transaction number cache of the target park if the traversal result indicates that the two-way transaction ID number includes the transaction message data; a second determination module, configured to determine that there is no transaction message data in the two-way transaction number cache of the target park if the traversal result indicates that all two-way transaction ID numbers do not include the transaction message data.

[0090] Optionally, the generating unit 43 includes: a first splicing module, configured to splice the transaction ID number and the IP address of another park into a string to obtain the total ID number of another park when generating a two-way transaction ID number based on the transaction ID numbers and IP addresses of another park and the target park; a second splicing module, configured to splice the transaction ID number and the IP address of the target park into a string to obtain the total ID number of the target park; a third splicing module, configured to splice the total ID number of another park and the total ID number of the target park to obtain the two-way transaction ID number.

[0091] Optionally, the sending unit 42 further includes: an execution module, configured to, after another park sends transaction message data to the message queue of the target park, the target park obtains the transaction message data, and obtains the transaction ID number and the IP address of another park based on the transaction message data; a first saving module, configured to convert the transaction message data into a transaction instruction, the target park executes the transaction instruction, and obtains the transaction ID number and the IP address of the target park, generates a two-way transaction ID number based on the transaction ID numbers and IP addresses of the target park and another park, and saves the two-way transaction ID number to the two-way transaction number cache of the target park.

[0092] Optionally, the monitoring unit 41 further includes: a second saving module, configured to save the changed data to a log file after the main database successfully executes the transaction instruction and the data in the main database changes, where the changed data includes: the data before the change, the data after the change, the transaction instruction, the transaction ID number, and the IP address of the main database, and there is a unique correspondence between the changed data and the transaction ID number.

[0093] The above database synchronization device based on the two-way transaction ID number may further include a processor and a memory. The above monitoring unit 41, sending unit 42, generating unit 43, etc. are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.

[0094] The above-mentioned processor contains a kernel, which retrieves corresponding program units from the memory. One or more kernels can be set, and database synchronization is achieved based on the two-way transaction ID number by adjusting the kernel parameters.

[0095] The above-mentioned memory may include non-permanent memory in a computer-readable medium, in the form of random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM (flash random access memory), and the memory includes at least one memory chip.

[0096] Embodiment 3

[0097] An embodiment of the present application can provide an electronic device. Figure 5 It is a structural block diagram of an electronic device according to an embodiment of the present application. As Figure 5 shown, the electronic device may include: one or more ( Figure 5 only one is shown in the figure) processors 502, a memory 504, a storage controller, and a peripheral interface, wherein the peripheral interface is connected to a radio frequency module, an audio module, and a display.

[0098] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and devices in the embodiments of the present application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the above-mentioned methods are implemented. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memories. In some instances, the memory may further include a memory remotely set relative to the processor, and these remote memories can be connected to the terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an enterprise internal network, a local area network, a mobile communication network, and combinations thereof.

[0099] The processor can call the information and application programs stored in the memory through the transmission device to execute the following steps: monitor the main database of the target park, and when it is monitored that the main database successfully executes the transaction instruction initiated by the external application, obtain the transaction ID number and the IP address of the main database, and generate transaction message data based on the transaction ID number and the IP address, where the main database is a database independently deployed and independently operated in each park; when the transaction message data does not exist in the two-way transaction number cache of the target park, send the transaction message data to the message queue of other parks, where other parks refer to the database deployment parks other than the target park, and other parks obtain the transaction ID number and IP address of the target park based on the transaction message data, convert the transaction message data into a transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of other parks, generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks.

[0100] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: obtain the log file of the main database, parse the log file to obtain the change data of the main database; parse the change data to obtain the IP address and transaction ID number of the main database.

[0101] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: when the transaction message data exists in the two-way transaction number cache of the target park, delete the two-way transaction ID number corresponding to the transaction message data in the two-way transaction number cache of the target park.

[0102] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: based on the transaction message data, traverse the two-way transaction ID numbers stored in the two-way transaction number cache of the target park; when the traversal result indicates that the two-way transaction ID number contains the transaction message data, determine that the transaction message data exists in the two-way transaction number cache of the target park; when the traversal result indicates that all two-way transaction ID numbers do not contain the transaction message data, determine that the transaction message data does not exist in the two-way transaction number cache of the target park.

[0103] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: splice the transaction ID number and IP address of other parks into a string to obtain the total ID number of other parks; splice the transaction ID number and IP address of the target park into a string to obtain the total ID number of the target park; splice the total ID number of other parks with the total ID number of the target park to obtain the two-way transaction ID number.

[0104] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: obtain transaction message data from the target park, and obtain the transaction ID numbers and IP addresses of other parks based on the transaction message data; convert the transaction message data into transaction instructions, execute the transaction instructions by the target park, and obtain the transaction ID numbers and IP addresses of the target park. Based on the transaction ID numbers and IP addresses of the target park and other parks, generate a two-way transaction ID number, and save the two-way transaction ID number to the two-way transaction number cache of the target park.

[0105] The processor can also call the information and application programs stored in the memory through the transmission device to execute the following steps: when the data in the main database changes, save the changed data to the log file, where the changed data includes: the data before the change, the data after the change, the transaction instruction, the transaction ID number, and the IP address of the main database. There is a unique correspondence between the changed data and the transaction ID number.

[0106] By adopting the embodiment of the present application, a solution for a database synchronization method based on a two-way transaction ID number is provided. By monitoring the main database of the target park, when it is monitored that the main database successfully executes the transaction instruction initiated by the external application, obtain the transaction ID number and the IP address of the main database, and generate transaction message data based on the transaction ID number and the IP address. When the transaction message data does not exist in the two-way transaction number cache of the target park, send the transaction message data to the message queue of other parks, and then other parks obtain the transaction ID number and the IP address of the target park based on the transaction message data, convert the transaction message data into transaction instructions, execute the transaction instructions, obtain the transaction ID number and the IP address of other parks, and then generate a two-way transaction ID number based on the transaction ID numbers and IP addresses of other parks and the target park, and save the two-way transaction ID number to the two-way transaction number cache of other parks, thereby achieving the purpose of ensuring that each transaction instruction is only executed once in the main databases of each park and avoiding the problem of loop synchronization of data between multiple main databases. Furthermore, the technical problem of loop synchronization phenomenon existing when multiple main databases synchronize data in the related art is solved.

[0107] Those of ordinary skill in the art can understand that Figure 5 the structure shown is only for illustration, and the electronic device can also be a terminal device such as a smart phone, a tablet computer, a handheld computer, and a mobile Internet device (Mobi le I nternet Devices, MID), PAD, etc. Figure 5 It does not limit the structure of the above-mentioned electronic device. For example, the electronic device may further include more or fewer components (such as a network interface, a display device, etc.) than those shown in Figure 5 or have a different configuration from that shown in Figure 5 shown.

[0108] Those of ordinary skill in the art can understand that all or part of the steps in the above-described database synchronization methods based on two-way transaction ID numbers of the embodiments can be completed by a program instructing the relevant hardware of the terminal device. The program can be stored in a computer-readable storage medium, and the storage medium can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, etc.

[0109] Embodiment 4

[0110] An embodiment of the present application also provides a storage medium. Optionally, in this embodiment, the above storage medium can be used to save the program code executed by the database synchronization method based on the two-way transaction ID number provided in Embodiment 1 above.

[0111] On the other hand, according to an embodiment of the present invention, there is also provided a computer-readable storage medium. The computer-readable storage medium includes a stored computer program, wherein when the computer program runs, it controls the device where the computer-readable storage medium is located to execute the database synchronization method based on the two-way transaction ID number in any one of the above Embodiment 1.

[0112] Optionally, in this embodiment, the above storage medium can be located in any one of the computer terminals in a computer terminal group in a computer network, or in any one of the mobile terminals in a mobile terminal group.

[0113] The present application also provides a computer program product, including a computer program, and when the computer program is executed by a processor, it implements the steps of the database synchronization method based on the two-way transaction ID number in each embodiment of the present application.

[0114] The present application also provides a computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps of the database synchronization method based on the two-way transaction ID number in each embodiment of the present application.

[0115] The above serial numbers of the embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0116] In the above embodiments of the present invention, the descriptions of each embodiment have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0117] In several embodiments provided by this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only illustrative. For example, the division of the units can be a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections between each other can be through some interfaces. The indirect couplings or communication connections of units or modules can be in electrical or other forms.

[0118] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place or distributed to multiple units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0119] In addition, in each embodiment of the present invention, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units.

[0120] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in each embodiment of the present invention. The foregoing storage medium includes: USB flash drives, read-only memories (ROMs), random access memories (RAMs), mobile hard disks, magnetic disks, or optical discs and other various media that can store program codes.

[0121] The above is only the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle of the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.

Claims

1. A database synchronization method based on bidirectional transaction ID number, characterized in that: include: Monitor the master database of the target park, and when it is monitored that the master database successfully executes the transaction instruction initiated by the external application, obtain the transaction ID number and the IP address of the master database, and generate transaction message data based on the transaction ID number and the IP address, wherein the master database is a database independently deployed and operated by each park; If the transaction message data does not exist in the bidirectional transaction number cache of the target park, the transaction message data is sent to the message queue of another park. Among them, the other park refers to a database deployment park other than the target park, and the other park obtains the transaction ID number and IP address of the target park based on the transaction message data, converts the transaction message data into the transaction instruction, executes the transaction instruction, obtains the transaction ID number and IP address of the other park, generates a bidirectional transaction ID number based on the transaction ID number and IP address of the other park and the target park, and saves the bidirectional transaction ID number to the bidirectional transaction number cache of the other park.

2. The database synchronization method according to claim 1, characterized in that: The step of obtaining the IP address and transaction ID number of the primary database includes: Obtaining a log file of the primary database, parsing the log file, and obtaining change data of the primary database; The change data is parsed to obtain the IP address and transaction ID number of the primary database.

3. The database synchronization method according to claim 1, characterized in that: In the case where the transaction message data exists in the bidirectional transaction number cache of the target park, the method further includes: The bidirectional transaction ID number corresponding to the transaction message data in the bidirectional transaction number cache of the target park is deleted.

4. The database synchronization method according to claim 1, characterized in that: The step of determining whether the transaction message data exists in the bidirectional transaction number cache of the target park comprises: Based on the transaction message data, traverse the bidirectional transaction ID numbers stored in the bidirectional transaction number cache of the target park; When the traversal result indicates that the bidirectional transaction ID number includes the transaction message data, determining that the transaction message data exists in the bidirectional transaction number cache of the target park; When the traversal result indicates that all bidirectional transaction ID numbers do not include the transaction message data, it is determined that the transaction message data does not exist in the bidirectional transaction number cache of the target park.

5. The database synchronization method according to claim 1, characterized in that: The step of generating a bidirectional transaction ID number based on the transaction ID numbers and IP addresses of the other parks and the target park includes: Concatenate the transaction ID number and IP address of the other parks to obtain the total ID number of the other parks; Concatenate the transaction ID number and IP address of the target park to obtain the total ID number of the target park; The total ID number of the other parks is concatenated with the total ID number of the target park to obtain the bidirectional transaction ID number.

6. The database synchronization method according to claim 1, characterized in that: After the other park sends the transaction message data to the message queue of the target park, the method includes: Acquire transaction message data from the target park, and acquire transaction ID numbers and IP addresses of the other parks based on the transaction message data; The transaction message data is converted into a transaction instruction, which is executed by the target park, and the transaction ID number and IP address of the target park are obtained. Based on the transaction ID numbers and IP addresses of the target park and the other parks, a bidirectional transaction ID number is generated, and the bidirectional transaction ID number is saved in the bidirectional transaction number cache of the target park.

7. The database synchronization method according to claim 1, characterized in that: After the primary database successfully executes the transaction instruction, the method further includes: When the data in the master database changes, the changed data is saved in a log file, wherein the changed data includes: data before the change, data after the change, the transaction instruction, transaction ID number and the IP address of the master database, and there is a unique correspondence between the changed data and the transaction ID number.

8. A database synchronization device based on a bidirectional transaction ID number, characterized in that: include: A monitoring unit is used to monitor the master database of the target park, and when it is monitored that the master database successfully executes the transaction instruction initiated by the external application, obtain the transaction ID number and the IP address of the master database, and generate transaction message data based on the transaction ID number and the IP address, wherein the master database is a database independently deployed and operated in each park; a sending unit, configured to send the transaction message data to a message queue of another park if the transaction message data does not exist in the bidirectional transaction number cache of the target park; A generating unit, wherein the other park refers to a database deployment park other than the target park, and is used for the other park to obtain the transaction ID number and IP address of the target park based on the transaction message data, and convert the transaction message data into the transaction instruction, execute the transaction instruction, obtain the transaction ID number and IP address of the other park, generate a bidirectional transaction ID number based on the transaction ID number and IP address of the other park and the target park, and save the bidirectional transaction ID number to the bidirectional transaction number cache of the other park.

9. An electronic device, characterized in that: It includes one or more processors and a memory, wherein the memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the database synchronization method based on bidirectional transaction ID number as described in any one of claims 1 to 7.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the database synchronization method based on a bidirectional transaction ID number described in any one of claims 1 to 7 are implemented.