A method and apparatus for data synchronization between dual-active systems

By encapsulating the operation tasks of the active-active system with data primary keys, timestamps, and operation source markers, the execution order and address of the target are determined, thus solving the real-time and consistency problems of data synchronization between active-active systems and achieving efficient bidirectional or unidirectional data synchronization.

CN115563220BActive Publication Date: 2026-04-14AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-26
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

Existing methods for data synchronization between active-active systems suffer from poor real-time performance, are limited to one-way synchronization, and are prone to data synchronization disorder.

Method used

By acquiring the operation task information of the dual-active system, the task is encapsulated based on the data primary key, timestamp, and operation source tag, and the target execution order and operation address are determined to achieve bidirectional or unidirectional data synchronization.

Benefits of technology

It enables real-time bidirectional data synchronization between active-active systems, avoiding synchronization chaos, reducing costs, and ensuring data consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115563220B_ABST
    Figure CN115563220B_ABST
Patent Text Reader

Abstract

The application discloses a method and device for synchronizing data between dual-active systems. The application obtains a first task and a second task from a first system and a second system of the dual-active systems respectively, and determines a current target synchronization operation task based on time series, operation source marks and data primary keys, and a target operation address and an operation object of the target synchronization operation task, thereby avoiding execution confusion of the dual-active systems in a synchronization process, and enabling the target operation address to explicitly indicate whether the target synchronization operation task is one-way synchronization execution or two-way synchronization execution, so that data between the dual-active systems can be one-way synchronized and two-way synchronized, and real-time performance of the current target synchronization operation task is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and more specifically, to a method and apparatus for data synchronization between active-active systems. Background Technology

[0002] When two systems simultaneously provide the same service while their databases operate independently, their databases will undergo different changes due to the different operations performed by each system. To ensure that both systems can provide the same service, real-time data synchronization between their databases is necessary to maintain data consistency at all times.

[0003] Based on current technology, message queues are typically used to synchronize data between two databases in an active-active system. This involves updating one database, retrieving the updated data or data operation record, and then updating the other database via a message queue. However, since active-active systems provide services simultaneously, there's a possibility that both systems might modify the same data at the same time. In such cases, synchronization fails, causing problems. While there are other methods for synchronizing data between two databases in an active-active system, these methods still suffer from high implementation barriers, poor real-time performance, high costs, and one-way synchronization issues. Summary of the Invention

[0004] In view of this, this application provides a data synchronization method and apparatus between active-active systems to solve the problems of poor real-time data synchronization, limitation to unidirectional data synchronization, and easy data synchronization disorder when synchronizing the same data in existing active-active system data synchronization methods.

[0005] To achieve the above objectives, the following solution is proposed:

[0006] A method for data synchronization between active-active systems, wherein the active-active systems include a first system and a second system, comprising:

[0007] The first system and the second system respectively acquire the first task and the second task that perform operations on the first target database and the second target database corresponding to the first system and the second system;

[0008] Based on the data primary key, timestamp, and operation source flag corresponding to the first task and the second task, the first task and the second task are encapsulated to obtain a set of operation tasks to be synchronized.

[0009] Based on the timestamp corresponding to each task in the set of tasks to be synchronized, the target execution order of each task to be synchronized is determined to obtain the target synchronization task.

[0010] The target operation address of the target synchronization operation task is determined based on the data primary key, operation source tag, and the set of operation tasks to be synchronized of the target synchronization operation task.

[0011] Based on the target operation address of the target synchronization operation task, the target synchronization operation task is executed on the corresponding data primary key.

[0012] Preferably, the step of obtaining the first task and the second task respectively, which involve the first system and the second system performing operations on the first target database and the second target database corresponding to the first system and the second system, includes:

[0013] Obtain operation information from the first system and the second system respectively targeting the first target database and the second target database, wherein the operation information includes first operation information and second operation information;

[0014] The target operation information is obtained from the operation information, and the target operation information is the operation information that changes data in the target database.

[0015] Based on the operation information, a first task corresponding to the first system and a second task corresponding to the second system are determined.

[0016] Preferably, determining the target operation address of the target synchronization operation task based on the data primary key, operation source tag, and the set of tasks to be synchronized includes:

[0017] Determine whether there exists a synchronized operation task in the set of synchronized operation tasks that has the same data primary key as the target synchronized operation task but a different operation source tag;

[0018] If they exist, then the target synchronization operation task is determined to have the first system and the second system as the target operation addresses;

[0019] If it does not exist, then in response to the existence of a data primary key with the same data primary key as the target synchronization operation task, the target synchronization operation task is determined to use the first system and the second system as the target operation address;

[0020] If it does not exist, then in response to the fact that the marker does not have a data primary key that is the same as the data primary key of the target synchronization operation task, the target synchronization operation task is determined to use the operation source marker that is opposite to the operation source marker as the target operation address.

[0021] Preferably, after determining that the target synchronization operation task uses the first system and the second system as target operation addresses if they exist, the method further includes:

[0022] The primary key of the target synchronization operation task is stored in the tagger.

[0023] Preferably, after determining that the target synchronization operation task uses the first system and the second system as target operation addresses in response to the existence of a data primary key with the same data primary key as the target synchronization operation task if the primary key does not exist, the method further includes:

[0024] Remove the primary key of the target synchronization operation task from the marker.

[0025] Preferably, if a synchronization task with the same primary key and the same operation source tag as the target synchronization task is obtained, then determining the target synchronization task with the corresponding operation source tag as the target operation address includes:

[0026] If the operation source of the target synchronization operation task is marked as the first system, then the target operation address corresponding to the target synchronization operation task is the second system;

[0027] If the operation source of the target synchronization operation task is marked as the second system, then the target operation address corresponding to the target synchronization operation task is the first system.

[0028] Preferably, executing the corresponding target synchronization operation task based on the target operation address of the target synchronization operation task includes:

[0029] Obtain a data information database, wherein the data information database includes operation permission information for the target data;

[0030] Obtain data information corresponding to the target synchronization operation task from the information database;

[0031] Based on the data information and the target operation address, execute the target synchronization operation task.

[0032] Preferably, before acquiring the data information database, the method further includes:

[0033] Obtain the operation permission information for each piece of data in the target data, wherein the operation permission information includes the data's public key, private key, account password, and account name;

[0034] The operation permission information is combined with each piece of data to obtain a data information database.

[0035] Preferably, after executing the target synchronization operation task on the corresponding data primary key based on the target operation address of the target synchronization operation task, the method further includes:

[0036] Based on the target execution order, the tasks to be synchronized after the target synchronization task order are determined as the second target synchronization task, and the second target synchronization task is executed until each task to be synchronized in the set of tasks to be synchronized is completed.

[0037] A data synchronization device between active-active systems, the active-active system comprising a first system and a second system, comprising:

[0038] The task acquisition unit is used to acquire, respectively, the first task and the second task of the first system and the second system operating on the first target database and the second target database corresponding to the first system and the second system;

[0039] The task encapsulation unit is used to encapsulate the first task and the second task based on the data primary key, time stamp and operation source stamp corresponding to the first task and the second task to obtain a set of operation tasks to be synchronized;

[0040] The task sorting unit is used to determine the target execution order of each task to be synchronized based on the timestamp corresponding to each task in the set of tasks to be synchronized, so as to obtain the target synchronization task.

[0041] The address marking unit is used to determine the target operation address of the target synchronization operation task based on the data primary key of the target synchronization operation task, the operation source mark, and the set of operation tasks to be synchronized.

[0042] The task execution unit is used to execute the target synchronization operation task on the corresponding data primary key based on the target operation address of the target synchronization operation task.

[0043] As can be seen from the above technical solutions, the data synchronization method and apparatus between active-active systems provided in this application can respectively obtain the task sets of the two systems in the active-active system that operate on two independent target databases that need to be synchronized. Based on the data primary key, time, and task source of each task in the task set, the execution order and execution address of each task are determined, and each task is executed according to the execution address and execution order. By operating on the target data in the active-active system, data synchronization between the two systems is achieved. Furthermore, this application embodiment achieves real-time bidirectional synchronization of data between the active-active system by acquiring tasks in real time and operating on tasks based on time order and task execution address. It also eliminates the need to add a new system outside the active-active system to complete the synchronization task, thus saving costs while achieving real-time bidirectional synchronization. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0045] Figure 1 This is an optional system architecture diagram for implementing a data synchronization method between active-active systems, as provided in an embodiment of this application.

[0046] Figure 2 This is an optional signaling flowchart for a method of data synchronization between active-active systems provided in an embodiment of this application;

[0047] Figure 3 This is a schematic diagram of an optional structure for a data synchronization device between active-active systems provided in an embodiment of this application. Detailed Implementation

[0048] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0049] Figure 1 A schematic diagram of the system architecture of a data synchronization method between active-active systems according to one embodiment of this application is shown. See also Figure 1 The system architecture may include: a first system 10, a second system 20, and a synchronization terminal 30. The first system 10 and the second system 20 each have their own independent database. The first system 10 corresponds to a first target database, and the second system 20 corresponds to a second target database. The first system 10 and the second system 20 are two application systems that run in parallel, are simultaneously active, and provide the same services to the outside world; that is, they are a dual-active system. The first system and the second system can be dual-active systems distributed on different devices, or they can be two independent electronic devices connected via a network to achieve data synchronization.

[0050] The synchronization terminal 30 can be a shared synchronization system within the first system and the second system. The synchronization terminal interacts with the first system 10 and the second system 20 through intra-system data. After receiving data information from the first system and the second system, the synchronization terminal can independently achieve data synchronization between the two active systems. In this embodiment, the synchronization terminal 30 receives operation task information from the first system 10 and the second system 20 regarding data in their respective target databases. This operation task information includes a first operation task corresponding to the first system 10 and a second operation task corresponding to the second system. Subsequently, the operation task information is processed to obtain target operation addresses corresponding to different tasks, and the corresponding operation tasks are executed based on these target operation addresses.

[0051] Based on this, the synchronization terminal 30 acquires the operation task information of the first system 10 and the second system 20 in real time. Since it can distinguish the operation source of the operation task, it can achieve unidirectional synchronization. When the operation task to be synchronized originates from either system in the dual-active system, it only needs to be unidirectionally synchronized to the database of the other system. It can also achieve bidirectional synchronization. When the operation task to be synchronized can be identified by two operation sources, it needs to be bidirectionally synchronized to both system databases. Furthermore, based on this, real-time data synchronization is achieved simultaneously with data synchronization.

[0052] based on Figure 1 The system architecture diagram, Figure 2 This application provides an embodiment of an optional signaling flowchart for implementing a data synchronization method between active-active systems. (See attached diagram.) Figure 2 The process may include:

[0053] In step S110, the synchronization terminal 30 obtains the first task and the second task of the first system and the second system respectively for operating on the target data.

[0054] The first system and the second system respectively acquire the first task and the second task that perform operations on the first target database and the second target database corresponding to the first system and the second system. Since the first system and the second system are active-active systems, the first target database corresponding to the first system and the second target database corresponding to the second system need to be synchronized.

[0055] The synchronization terminal 30 can obtain the first and second tasks performed by the first and second systems on the target database through various means. For example, it can monitor data changes in the target databases corresponding to the two systems in real time to obtain the operation tasks being performed in the two target databases; or the two systems can proactively send the operation tasks to be executed to the synchronization terminal 30 before execution. Furthermore, after obtaining the operation tasks from the two systems, it can directly determine whether the operation task belongs to the first task corresponding to the first system or the second task corresponding to the second system based on the operation location of the task.

[0056] In step S120, the synchronization terminal 30 encapsulates the first task and the second task to obtain a set of tasks to be synchronized.

[0057] Based on the data primary key, timestamp, and operation source flag corresponding to the first and second tasks, the first and second tasks are encapsulated to obtain a set of operation tasks to be synchronized. This step specifically locates the first and second tasks, enabling the aforementioned operation tasks to clearly determine how to execute them subsequently.

[0058] The first and second tasks include various types of information in their operation information, such as operation time, command initiation information, execution information, execution target data, etc. For the synchronization end to perform data synchronization tasks, some operation information is not very relevant. It is also necessary to select the data synchronization-related information from the operation information and encapsulate it together with the operation tasks so that the synchronization end can easily locate different operation tasks.

[0059] The primary key represents the target data that the first and second tasks specifically operate on in the first and second target databases, respectively. The timestamp is used to accurately record the specific execution time of the corresponding operation task. The operation source tag is used to determine which system in the dual-active system the operation originates from, thus identifying the target database for the operation. By encapsulating the primary key, timestamp, and operation source tag of the operation task, the "execution object," "execution time," and "execution address" of the corresponding operation task can be clearly defined, preventing synchronization chaos during subsequent execution of synchronous tasks.

[0060] The target data directly manipulated by the first and second tasks in the first and second target databases are defined as the data primary key. The operation times of the first and second tasks are defined as the timestamps of the first and second tasks. The first system that generated the first task is defined as the operation source marker of the first task; the second system that generated the second task is defined as the operation source marker of the second task. The data primary key, the timestamp, and the operation source marker are combined with the corresponding first and second tasks to obtain a set of tasks to be synchronized.

[0061] In this embodiment of the application, the information necessary for the first and second tasks to complete data synchronization may include a data primary key, a timestamp, and an operation source marker. There are many ways to mark and encapsulate the first and second tasks based on the aforementioned necessary information. Preferably, the corresponding data primary key, timestamp, and operation source marker can be combined into a title, which serves as the name of the task encapsulation. Each task is encapsulated accordingly, resulting in a set of tasks to be synchronized. The synchronization end can determine a specific task to be synchronized from the set of tasks to be synchronized based on the encapsulation name of the task to be synchronized.

[0062] In step S130, the synchronization terminal 30 determines the target synchronization operation task based on the set of operation tasks to be synchronized.

[0063] The synchronization terminal 30 determines the target execution order of each task based on the timestamp corresponding to each task in the set of tasks to be synchronized, thus obtaining the target synchronization task. It sorts the tasks by time according to their timestamps to obtain the target execution order, thereby processing the tasks in the correct order and preventing situations where the processing order of the tasks is disordered, leading to situations where the target operation data cannot be found.

[0064] For example, consider a set of tasks to be synchronized, containing tasks A and B. Both tasks originate from the first system and operate on data M in the first target database. Task A's timestamp is 8:00, and task B's is 8:01. Following the timestamp order, during synchronization of the target database, task A should be executed first, followed by task B. Executing task A operates on data M to obtain data N. Executing task B then operates on data M, which is essentially operating on data N to obtain data L. If the synchronization is not performed in chronological order, tasks B might operate on data M to obtain data P, and then task A would operate on data M, which is essentially operating on data P to obtain data Q. Therefore, different execution orders result in different final task outcomes and will not yield the correct data.

[0065] In step S140, the synchronization terminal 30 determines the corresponding target operation address based on the data primary key and operation source marker corresponding to the target synchronization operation task.

[0066] Specifically, the synchronization terminal 30 determines the target operation address of the target synchronization operation task based on the operation source marker of the target synchronization operation task and the set of operation tasks to be synchronized.

[0067] Understandably, the primary key is the target data in the target database where the target synchronization operation task performs its operation; that is, the target operation object. The operation source tag is used to record which system and target database the corresponding synchronization operation task originates from within the dual-active system. The set of tasks to be synchronized contains all tasks to be synchronized at the current moment. The primary key and operation source tag of the target synchronization operation task are compared and matched with the primary key and operation source tag of each task to be synchronized in the set. If a matching task is found, it can be determined whether the target synchronization operation task should perform synchronization operations on one system or on two systems.

[0068] In step S150, the synchronization terminal 30 executes the target synchronization operation task on the corresponding data primary key according to the target operation address.

[0069] Specifically, based on the target operation address of the target synchronization operation task, the target synchronization operation task is executed on the corresponding data primary key.

[0070] Based on the above steps S110~S140, the specific "execution object" (i.e., the corresponding data primary key), "execution time" (i.e., the target execution order obtained according to the time stamp), and "execution address" (i.e., the target operation address) are determined for the target synchronization operation task. It is determined whether the target synchronization operation task only needs to be synchronized to a single system or whether the synchronization is performed on two systems.

[0071] The data synchronization method between active-active systems provided in this application collects tasks from the active-active system through a synchronization terminal. Based on the time series, task source, and data primary key, it determines the current target synchronization operation task, as well as the target operation address and operation object of the target synchronization operation task. This avoids execution chaos in the active-active system during the synchronization process and can also clarify whether the target synchronization operation task is executed unidirectionally or bidirectionally through the target operation address. This enables data between the active-active systems to achieve both unidirectional and bidirectional synchronization, while also ensuring the real-time performance of the currently executing target synchronization operation task.

[0072] Next, this application embodiment will further introduce the data synchronization scheme between active-active systems from the perspective of the synchronization terminal 30.

[0073] The preceding text has described how the synchronization terminal 30 obtains the first task and the second task of the first system and the second system respectively to perform operations on the first target database and the second target database corresponding to the first system and the second system. This embodiment describes in detail the process of the synchronization terminal 30 obtaining the first task and the second task.

[0074] The synchronization terminal 30 can acquire operation information from the first system and the second system for their respective target databases. It then retrieves target operation information from this operation information; this target operation information is information capable of modifying data in the target database. Based on this operation information, it determines a first task corresponding to the first system and a second task corresponding to the second system.

[0075] The operation information can include specific operations performed on data in the target database, such as inserting, deleting, reading, and updating data. It can also include which specific data in the target database these operations are based on. Combining the specific data in the records with the corresponding operations yields the operation information.

[0076] This application embodiment synchronizes operations that actually modify data in the target database. Therefore, the aforementioned operation information needs further filtering to remove operations that do not actually change the data, such as read operations like acquiring or retrieving data. Ultimately, write operations that actually modify, delete, or insert data are identified as the target operation information. The target operation information is then mapped to the first and second systems to obtain the first task and the second task.

[0077] Furthermore, the first and second tasks obtained above are both operation tasks that ultimately achieve the synchronization of the dual-active system. When the first and second tasks are determined as operation tasks to be synchronized, the first and second tasks need to be encapsulated based on the data primary key, time stamp and operation source stamp to obtain the set of operation tasks to be synchronized.

[0078] After completing the task encapsulation and obtaining the set of tasks to be synchronized, it is necessary to sort them based on the timestamp of each task in the set. This order determines the execution order of the tasks. Therefore, the synchronization tasks with earlier timestamps should be prioritized and executed as early as possible. After obtaining the final target execution order, the synchronization task corresponding to the earliest timestamp is determined as the target synchronization task for this data synchronization.

[0079] After obtaining the target synchronization operation task, it is necessary to determine the target operation address of the target synchronization operation task based on the data primary key, operation source tag, and the set of operation tasks to be synchronized. This embodiment will describe in detail the process of determining the target operation address of the target synchronization operation task.

[0080] Determine whether there exists a synchronized operation task in the set of synchronized operation tasks that has the same data primary key as the target synchronized operation task but a different operation source tag;

[0081] If they exist, then the target synchronization operation task is determined to have the first system and the second system as the target operation addresses;

[0082] If it does not exist, then in response to the existence of a data primary key with the same data primary key system as the target synchronization operation task, the target synchronization operation task is determined to use the first system and the second system as the target operation address;

[0083] If it does not exist, then in response to the fact that the marker does not have a data primary key that is the same as the data primary key of the target synchronization operation task, the target synchronization operation task is determined to be the target operation address marked by the corresponding operation source.

[0084] It is understandable that the matched synchronization task has the same primary key as the target synchronization task, but the operation source marker is different. The synchronization task and the target synchronization task come from two systems of the dual-active system. The target databases are different, but the primary key of the data to be executed is the same. This proves that the two systems are operating on the same execution object at the same time. In order to achieve data synchronization, it is necessary to execute the operation on both systems at the same time.

[0085] For example, target synchronization task A is an operation from the first system on the first target database, modifying a certain data to X. A matching operation task B is found, whereby the second system modifies the same data to Y in the second target database. This means the data in the first target database has been modified to X, and the data in the second target database has been modified to Y. To ensure eventual consistency between the first and second target databases, tasks A and B need to be executed sequentially on both databases. Therefore, task A should target both the first and second systems as its operation addresses.

[0086] If no matching data primary key but different operation source marker is found in the set of tasks to be synchronized, it is necessary to again determine from the marker whether a data primary key with the same data primary key as the target synchronization task exists. The marker records the data primary key that needs to be synchronized to both systems in the dual-active system, indicating that the target synchronization task needs to be synchronized to both the first and second systems. If no matching task is found in the set of tasks to be synchronized, but the same data primary key is found only in the marker, it indicates that the target synchronization task is the last synchronization task corresponding to the data primary key with the target operation address being the first and second systems.

[0087] In addition, if only the data primary key of the target synchronization operation task is matched, but the operation source tag is also the same, it proves that the two tasks are the same task and the operation is only performed on one of the dual-active systems. If data synchronization of the dual-active system is to be achieved, the other system of the dual-active system also needs to perform the operation task.

[0088] Specifically, when the operation source of the target synchronization operation task is marked as the first system, the target operation address corresponding to the target synchronization operation task is the second system; if the operation source of the target synchronization operation task is marked as the second system, the target operation address corresponding to the target synchronization operation task is the first system.

[0089] Based on the above analysis, we can determine whether the target synchronization operation task needs to be executed simultaneously on two target databases corresponding to the two systems, or only on one of the active-active systems. The target synchronization operation task can be determined based on the following two conditions: Condition 1: The target synchronization operation task can match a target synchronization operation task in the set of tasks to be synchronized with the same primary key but different operation source markers; Condition 2: The marker stores a primary key identical to that of the target synchronization operation task. The target synchronization operation task needs to satisfy at least one of these two conditions to determine that the corresponding target operation address is the first system and the second system, i.e., bidirectional synchronization; if neither condition is satisfied, the target operation address corresponding to the target synchronization operation task can be determined to be one of the active-active systems, i.e., unidirectional synchronization.

[0090] For example, consider three tasks: A, B, and C. These tasks occur sequentially in the order A, B, C. All three tasks share the same primary key. The operation source identifier for tasks A and C is the first target database of the first system, while the operation source identifier for task B is the second target database of the second system.

[0091] When task A is a target synchronization operation task, task B with the same data primary key but different operation source markers can be matched in the set of tasks to be synchronized. However, the data primary key has not yet been marked in the marker, so only condition one is satisfied, indicating that task A is the first task that needs to achieve bidirectional synchronization with the first system and the second system at the same time. The target operation address of task A is determined to be the first system and the second system, and the data primary key of task A is stored in the marker.

[0092] When task B is a target synchronization operation task, task C with the same data primary key but different operation source markers can be matched in the set of tasks to be synchronized. The markers have already recorded the same data primary key. Therefore, task B satisfies both conditions one and two, indicating that task B is neither the first nor the last task that needs to achieve bidirectional synchronization with the first and second systems.

[0093] When task C is the target synchronization operation task, no task with the same data primary key but different operation sources can be matched in the set of tasks to be synchronized. However, the data primary key of C exists in the marker, thus only condition two is satisfied, indicating that task C is the last task that needs to achieve bidirectional synchronization with the first and second systems. After task C is executed, the synchronization end will clear the corresponding data primary key in the marker, so it will not affect subsequent operations on that data.

[0094] Furthermore, after obtaining the target operation address corresponding to the target synchronization operation task, the target synchronization operation task is executed on the corresponding data primary key based on the target operation address. However, since different data in a database generally have different access, allocation, and operation permissions, the process of executing the target synchronization operation task also includes:

[0095] A data information database is obtained, which includes operation permission information of the target database; permission information corresponding to the target synchronization operation task is obtained according to the data information database; based on the corresponding permission information and the target operation address, the target synchronization operation task is executed on the data primary key corresponding to the target synchronization operation task to complete data synchronization between the active-active systems.

[0096] Understandably, a typical database server may run multiple project databases simultaneously. Some projects have fixed, unmodifiable data, allowing only read operations like querying and retrieval. Other projects require only the database administrator to modify the data, while still others require authorization from users with specific permissions before they can operate on the database. Therefore, when the synchronization endpoint 30 needs to modify data in the target database, it retrieves the corresponding permission information for the primary key of the target synchronization task. Only after obtaining authorization can it execute the target synchronization operation on the primary key, completing data synchronization between the active-active systems.

[0097] Furthermore, the data information repository has different permission information for different database systems. Therefore, different data information repositories need to be pre-made for different databases. The data information repository will collect the permission information of the corresponding database so that the synchronization terminal 30 can obtain the operation permissions for the corresponding data. This application embodiment will provide an preferred process for creating the data information repository.

[0098] Obtain the operation permission information corresponding to each data primary key in the target database. The operation permission information may include the public and private keys of the data primary key, account name, account password, and other operation permission information. Combine the operation permission information with the corresponding data primary key to obtain the data information database.

[0099] Specifically, the operation permission information is not limited to the public and private keys, username, and password mentioned above, but may also include database login permissions, viewing permissions, and so on.

[0100] Furthermore, after obtaining the operation permission for the data primary key of the target synchronization operation task at the synchronization end 30, the target synchronization operation task is executed to achieve data synchronization between the active-active systems. However, there are other pending synchronization operation tasks in the target synchronization operation task set. Based on the target execution order described above, the first pending synchronization operation task after the target synchronization operation task order is determined as the second target synchronization operation task, and the second target synchronization operation task is executed until each pending synchronization operation task in the pending synchronization operation task set is completed.

[0101] Below is a practical application scenario example of the data synchronization method between active-active systems based on the embodiments of this application. Bank service halls typically have multiple self-service banking devices, including self-service card issuing machines. These machines issue cards instantly through user self-operation. When a bank hall has multiple self-service card issuing machines, it is necessary to achieve data interoperability between them, that is, to synchronize data between two self-service card issuing machines to prevent the same user from opening accounts repeatedly on different self-service card issuing machines.

[0102] Suppose there are two self-service card issuing machines, machine A and machine B. When user Li Ming successfully applies for a card at machine A and receives the card, machine A adds Li Ming's account opening information to its user database. The data synchronization system between machines A and B detects this addition to machine A's database and compares the data with all the data collected from both machines. If only machine A adds Li Ming's account opening information, the synchronization system will simultaneously execute the same operation on machine B's user database, thus synchronizing the data between the two machines.

[0103] When user Li Ming goes to self-service card issuing machine B again to open an account and issue a card, the user database of self-service card issuing machine B will remind user Li Ming that he has already opened an account because the database already contains user Li Ming's account opening information, thus avoiding duplicate account opening.

[0104] The data synchronization device between active-active systems provided in the embodiments of this application is described below. The data synchronization device between active-active systems described below and the data synchronization method between active-active systems described above can be referred to in correspondence.

[0105] First, combined Figure 3 The data synchronization device between active and passive systems applied to the synchronization terminal 30 is described, such as... Figure 3 As shown, the data synchronization device between the dual-active systems may include:

[0106] The task acquisition unit 100 is used to acquire, respectively, the first task and the second task of the first system and the second system performing operations on the first target database and the second target database corresponding to the first system and the second system;

[0107] The task encapsulation unit 200 is used to encapsulate the first task and the second task based on the data primary key, time stamp and operation source stamp corresponding to the first task and the second task to obtain a set of operation tasks to be synchronized;

[0108] The task sorting unit 300 is used to determine the target execution order of each task to be synchronized based on the time stamp corresponding to each task to be synchronized in the set of tasks to be synchronized, so as to obtain the target synchronization task.

[0109] Address marking unit 400 is used to determine the target operation address of the target synchronization operation task based on the data primary key of the target synchronization operation task, the operation source mark and the set of operation tasks to be synchronized;

[0110] The task execution unit 500 is used to execute the target synchronization operation task on the corresponding data primary key based on the target operation address of the target synchronization operation task.

[0111] Optionally, the task acquisition unit 100 includes:

[0112] An operation information acquisition subunit is used to acquire operation information of the first system and the second system for the same target database, respectively. The operation information includes first operation information and second operation information.

[0113] A target operation information acquisition subunit is used to obtain target operation information from the operation information, wherein the target operation information is operation information that changes data in the target database.

[0114] The task determination subunit is used to determine, based on the operation information, a first task corresponding to the first system and a second task corresponding to the second system.

[0115] Optionally, the address marking unit includes:

[0116] The task matching subunit determines in the set of tasks to be synchronized whether there is a task to be synchronized that has the same data primary key as the target synchronization task but a different operation source tag.

[0117] If it exists, then jump to the first sub-unit of the bidirectional address tag, which is used to determine that the target synchronization operation task takes the first system and the second system as the target operation address;

[0118] If it does not exist, then jump to the second sub-unit of the bidirectional address tag, which is used to determine that the target synchronization operation task takes the first system and the second system as the target operation address in response to the existence of a data primary key with the same data primary key as the target synchronization operation task.

[0119] If it does not exist, then jump to the one-way address marking subunit, which is used to determine that the target synchronization operation task is marked with the corresponding operation source as the target operation address in response to the fact that the marker does not have the same data primary key as the data primary key of the target synchronization operation task.

[0120] Preferably, after the bidirectional address tag first subunit, the following is further included:

[0121] The tagger storage unit is used to store the primary key of the target synchronization operation task in the tagger.

[0122] Preferably, after the bidirectional address mark second subunit, the following is further included:

[0123] The marker deletion unit is used to delete the data primary key of the target synchronization operation task from the marker.

[0124] Preferably, the one-way address tag subunit includes:

[0125] The first subunit of the one-way address marking is used to respond that if the operation source marking of the target synchronization operation task is the first system, then the target operation address corresponding to the target synchronization operation task is the second system;

[0126] The second subunit of the one-way address marking is used to respond that if the operation source of the target synchronization operation task is marked as the second system, then the target operation address corresponding to the target synchronization operation task is the first system.

[0127] Preferably, the task execution unit 500 includes:

[0128] A data information database acquisition subunit is used to acquire a data information database, wherein the data information database includes operation permission information of the target data;

[0129] The permission information acquisition subunit is used to acquire data information corresponding to the target synchronization operation task based on the information database.

[0130] The task execution subunit is used to execute the target synchronization operation task based on the data information and the target operation address.

[0131] Preferably, before the data information database acquisition subunit, the method further includes:

[0132] An operation permission information acquisition unit is used to acquire the operation permission information of each piece of data in the target data. The operation permission information includes the data's public key, private key, account password, and account name.

[0133] The data information database creation unit is used to combine the operation permission information with each data item to obtain the data information database.

[0134] Preferably, after the task execution unit 500, the following is further included:

[0135] The sequential task execution unit is used to determine the tasks to be synchronized after the target synchronization task sequence as the second target synchronization task based on the target execution order, and execute the second target synchronization task until each task to be synchronized in the set of tasks to be synchronized is completed.

[0136] The data synchronization device between active-active systems provided in this application embodiment obtains corresponding task information from the first and second systems in the active-active system through a task acquisition unit. The task information is encapsulated based on specific operation information such as data primary key, time stamp, and operation source stamp. Based on this, the target synchronization operation task to be executed and the corresponding target operation address are determined. Then, the target synchronization operation task is executed according to the data primary key and target operation address corresponding to the target synchronization operation task, thereby completing the data synchronization between the active-active systems.

[0137] Based on this, data operations of the target database in any system within the dual-active system can be monitored in real time, and corresponding execution plans can be made according to the specific information of the data operations. This can achieve real-time data synchronization between the dual-active systems, and can also achieve both one-way and two-way data synchronization based on the operation tasks. Furthermore, the filtering scheme for the synchronization task execution can maintain the stability of system operation.

[0138] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0139] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0140] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for data synchronization between active-active systems, wherein the active-active system comprises a first system and a second system, characterized in that, include: The first task of the first system to perform operations on the first target database and the second task of the second system to perform operations on the second target database are respectively obtained. Based on the data primary key, timestamp, and operation source flag corresponding to the first task and the second task, the first task and the second task are encapsulated to obtain a set of operation tasks to be synchronized. Based on the timestamp corresponding to each task in the set of tasks to be synchronized, the target execution order of each task to be synchronized is determined to obtain the target synchronization task. The target operation address of the target synchronization operation task is determined based on the data primary key, operation source marker, and the set of tasks to be synchronized. This determination includes: determining whether a task with the same data primary key but a different operation source marker exists in the set of tasks to be synchronized; if so, determining that the target synchronization operation task uses the first system and the second system as its target operation addresses; if no such task exists, further determining whether a marker contains a data primary key identical to the data primary key of the target synchronization operation task; if the marker contains this data primary key, determining that the target synchronization operation task uses the first system and the second system as its target operation addresses; if the marker does not contain this data primary key, determining that the target synchronization operation task uses the corresponding operation source marker as its target operation address; wherein the marker stores the data primary key of the target synchronization operation task. Based on the target operation address of the target synchronization operation task, the target synchronization operation task is executed on the corresponding data primary key.

2. The method according to claim 1, characterized in that, The step of obtaining the first task of the first system performing operations on the first target database and the second task of the second system performing operations on the second target database includes: Obtain operation information from the first system and the second system respectively targeting the first target database and the second target database, wherein the operation information includes first operation information and second operation information; The target operation information is obtained from the operation information, and the target operation information is the operation information that changes data in the target database. Based on the operation information, a first task corresponding to the first system and a second task corresponding to the second system are determined.

3. The method according to claim 1, characterized in that, After the primary key of the data exists in the marker, and the target synchronization operation task is determined to have the first system and the second system as the target operation addresses, the following steps are also included: Remove the primary key of the target synchronization operation task from the marker.

4. The method according to claim 1, characterized in that, The step of determining the target synchronization operation task with the corresponding operation source marker as the target operation address includes: If the operation source of the target synchronization operation task is marked as the first system, then the target operation address corresponding to the target synchronization operation task is the second system; If the operation source of the target synchronization operation task is marked as the second system, then the target operation address corresponding to the target synchronization operation task is the first system.

5. The method according to claim 1, characterized in that, The step of executing the corresponding target synchronization operation task based on the target operation address of the target synchronization operation task includes: Obtain a data information database, wherein the data information database includes operation permission information for the target data; Obtain data information corresponding to the target synchronization operation task from the information database; Based on the data information and the target operation address, execute the target synchronization operation task.

6. The method according to claim 5, characterized in that, Before acquiring the data information database, the following is also included: Obtain the operation permission information for each piece of data in the target data, wherein the operation permission information includes the data's public key, private key, account password, and account name; The operation permission information is combined with each piece of data to obtain a data information database.

7. The method according to claim 1, characterized in that, After executing the target synchronization operation task on the corresponding data primary key based on the target operation address of the target synchronization operation task, the method further includes: Based on the target execution order, the tasks to be synchronized after the target synchronization task order are determined as the second target synchronization task, and the second target synchronization task is executed until each task to be synchronized in the set of tasks to be synchronized is completed.

8. A data synchronization device between two active-active systems, wherein the two active-active systems comprise a first system and a second system, characterized in that, include: The task acquisition unit is used to acquire the first task of the first system performing operations on the first target database, and the second task of the second system performing operations on the second target database, respectively. The task encapsulation unit is used to encapsulate the first task and the second task based on the data primary key, time stamp and operation source stamp corresponding to the first task and the second task to obtain a set of operation tasks to be synchronized; The task sorting unit is used to determine the target execution order of each task to be synchronized based on the timestamp corresponding to each task in the set of tasks to be synchronized, so as to obtain the target synchronization task. An address marking unit is used to determine the target operation address of the target synchronization operation task based on the data primary key, operation source mark, and the set of tasks to be synchronized. The determination of the target operation address based on the data primary key, operation source mark, and set of tasks to be synchronized includes: determining whether there exists a task in the set of tasks to be synchronized that has the same data primary key as the target synchronization operation task but a different operation source mark; if so, determining that the target synchronization operation task uses the first system and the second system as its target operation addresses; if there is no such task, further determining whether there exists a data primary key in the marker that has the same data primary key as the target synchronization operation task; if the marker contains the data primary key, determining that the target synchronization operation task uses the first system and the second system as its target operation addresses; if the marker does not contain the data primary key, determining that the target synchronization operation task uses the corresponding operation source mark as its target operation address; wherein the marker is used to store the data primary key of the target synchronization operation task. The task execution unit is used to execute the target synchronization operation task on the corresponding data primary key based on the target operation address of the target synchronization operation task.

Citation Information

Patent Citations

  • Cross-machine-room database synchronization equipment and method based on MariaDB

    CN104933127A

  • Active-active system and synchronization method

    CN114741416A