Database bidirectional synchronization method, system, device, storage medium and program product
Patent Information
- Application Number
- CN202410263750.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-07
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2044-03-07
AI Technical Summary
传统的数据库双向同步方案中,从源库同步到目的库的数据,当源库的角色转变为目的库,目的库的角色转变为源库时,容易出现转变后的源库把之前同步过来的数据又重新同步到转变后的目的库中的问题,也即出现数据循环问题
[0009] In this embodiment, full synchronization between databases is performed sequentially via the forward synchronization link and the reverse synchronization link. When synchronizing the database via the reverse synchronization link, the reverse synchronization object information is filtered based on the forward synchronization object information. This ensures that the full data synchronized from the first database instance to the second database instance via the forward synchronization link will not be resynchronized from the second database instance to the first database instance via the reverse synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the bidirectional database synchronization performance in terms of full synchronization.
Smart Images

Figure CN120610996B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of database technology, and in particular to a database bidirectional synchronization method, system, device, storage medium, and program product. Background Technology
[0002] In various application scenarios such as multi-site active-active deployment and cross-site disaster recovery, bidirectional synchronization between two databases is required. This means either database can act as the source database, and the other as the destination database. Data synchronization between the source and destination databases ensures data consistency, thereby guaranteeing database reliability and availability. In traditional bidirectional database synchronization schemes, when the source database becomes the destination database and vice versa, a data loop problem can occur: the previously synchronized data is resynchronized from the source database to the destination database. Therefore, it is necessary to propose a better bidirectional database synchronization scheme. Summary of the Invention
[0003] This application provides a database bidirectional synchronization method, system, device, storage medium, and program product in several aspects, to propose a better database bidirectional synchronization scheme.
[0004] This application provides a database bidirectional synchronization method, comprising: establishing a forward synchronization link between a first database instance and a second database instance, wherein the first database instance is a first source database instance and the second database instance is a first destination database instance; the forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier; initiating and executing a forward full synchronization task based on the forward synchronization object information, wherein the forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object, wherein the first source object is the object corresponding to the first source object identifier and the first destination object is the object corresponding to the first destination object identifier; and establishing a reverse synchronization link between the first database instance and the second database instance, wherein the second database instance is a second source database instance. For example, the first database instance is the second destination database instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source database instance and the second destination object identifier of the second destination database instance corresponding to the second source object identifier. The reverse synchronization object information is filtered according to the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier. According to the remaining reverse synchronization object information, a reverse full synchronization task is started and executed. The reverse full synchronization task is used to perform full synchronization between the remaining second source objects and their corresponding remaining second destination objects. The remaining second source objects are the objects corresponding to the remaining second source object identifiers, and the remaining second destination objects are the objects corresponding to the remaining second destination object identifiers.
[0005] This application embodiment also provides a database bidirectional synchronization system, including: a client, a data transmission service, a first database instance, and a second database instance; the client is used to respond to user configuration operations, obtain and send link configuration information to the data transmission service, the link configuration information including forward synchronization object information of the forward synchronization link and reverse synchronization object information of the reverse synchronization link, the forward synchronization object information of the forward synchronization link including: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier, the reverse synchronization object information of the reverse synchronization link including: at least one second source object identifier of the second source database instance and a second destination object identifier of the second destination database instance corresponding to the second source object identifier; the data transmission service is used to establish a forward synchronization link between the first database instance and the second database instance, the first database instance being the first source database instance and the second database instance being the first destination database instance, the forward synchronization object information of the forward synchronization link including: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier; and, based on the forward synchronization object information, initiate and execute a forward full synchronization. The task consists of several steps: a forward full synchronization task to perform full synchronization between a first source object and its corresponding first destination object; a reverse synchronization link to establish a first database instance and a second database instance; a reverse synchronization link to obtain the remaining reverse synchronization object information, which includes at least one second source object identifier of the second source instance and a second destination object identifier corresponding to the second source object identifier of the second destination instance; filtering the reverse synchronization object information based on the forward synchronization object information to obtain the remaining reverse synchronization object information, which includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier; and finally, starting the reverse full synchronization task to perform full synchronization between the remaining second source objects and their corresponding remaining second destination objects, where the remaining second source objects are the objects corresponding to the remaining second source object identifiers and the remaining second destination objects are the objects corresponding to the remaining second destination object identifiers.
[0006] This application also provides an electronic device, including: a memory and a processor; the memory for storing a computer program; and the processor coupled to the memory for executing the computer program to perform steps in a database bidirectional synchronization method.
[0007] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, enables the processor to implement the steps in the database bidirectional synchronization method.
[0008] This application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, enable the processor to implement the steps in the database bidirectional synchronization method.
[0009] In this embodiment, full synchronization between databases is performed sequentially via the forward synchronization link and the reverse synchronization link. When synchronizing the database via the reverse synchronization link, the reverse synchronization object information is filtered based on the forward synchronization object information. This ensures that the full data synchronized from the first database instance to the second database instance via the forward synchronization link will not be resynchronized from the second database instance to the first database instance via the reverse synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the bidirectional database synchronization performance in terms of full synchronization. Attached Figure Description
[0010] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0011] Figure 1 A flowchart illustrating a database bidirectional synchronization method provided in this application embodiment;
[0012] Figure 2 A flowchart illustrating another database bidirectional synchronization method provided in this application embodiment;
[0013] Figure 3 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0014] Figure 4 This application provides a schematic diagram of the structure of a bidirectional database synchronization system.
[0015] Figure 5 This is a schematic diagram of the structure of a database bidirectional synchronization device provided in an embodiment of this application;
[0016] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0017] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0018] In the embodiments of this application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the access relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone, where A and B can be singular or plural. In the textual description of this application, the character " / " generally indicates that the preceding and following associated objects have an "or" relationship. Furthermore, in the embodiments of this application, "first," "second," "third," etc., are only used to distinguish the content of different objects and have no other special meaning.
[0019] In various application scenarios such as multi-site active-active deployment and cross-site disaster recovery, bidirectional synchronization between two databases is required. This means either database can act as the source database, and the other as the destination database. Data synchronization between the source and destination databases ensures data consistency, thereby guaranteeing database reliability and availability. In traditional bidirectional database synchronization schemes, when the source database becomes the destination database and vice versa, a data loop problem can occur: the previously synchronized data is resynchronized from the source database to the destination database. Therefore, it is necessary to propose a better bidirectional database synchronization scheme.
[0020] Therefore, this application provides a database bidirectional synchronization method, system, device, storage medium, and program product. In this embodiment, full synchronization between databases is performed sequentially through a forward synchronization link and a reverse synchronization link. When synchronizing the database through the reverse synchronization link, the reverse synchronization object information is filtered based on the forward synchronization object information. This ensures that the full data synchronized from the first database instance to the second database instance through the forward synchronization link will not be resynchronized from the second database instance to the first database instance through the reverse synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the performance of bidirectional database synchronization in the full synchronization dimension. Further optionally, in the incremental synchronization phase, since system table change statements indicate that the incremental data of the source objects in the source database instance originates from database synchronization, the decision to initiate the incremental synchronization task is made by checking whether the newly added database update events in the binlog file include system table change statements. Therefore, incremental data synchronized from one database instance to another through a single synchronization link will not be resynchronized from one database instance to the same database instance through another synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the performance of bidirectional database synchronization in the incremental synchronization dimension.
[0021] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.
[0022] Figure 1 A flowchart illustrating a bidirectional database synchronization method provided in an embodiment of this application. See also... Figure 1 The method may include the following steps:
[0023] 101. Establish a forward synchronization link between the first database instance and the second database instance. The first database instance is the first source database instance, and the second database instance is the first destination database instance. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier.
[0024] Specifically, the first database instance and the second database instance are two different database instances. A database instance typically includes multiple databases, and each database typically includes multiple database tables. Database tables are usually two-dimensional data structures, consisting of columns and rows. In practical applications, the objects of a database instance include, but are not limited to, databases, database tables, or columns. If the object of a database instance is a database, the object identifier is the database name (also called the database name); if the object of a database instance is a database table, the object identifier is defined by the database name of the database containing the table and the table name within the database; if the object of a database instance is a column, the object identifier is defined by the database name of the database containing the table, the table name within the database, and the column name within the database table.
[0025] In this embodiment, either the first database instance or the second database instance can serve as the source database instance, and the other can serve as the destination database instance. The data synchronization direction is from the source database instance to the destination database instance. The granularity of the synchronization object includes, but is not limited to, databases, database tables, or columns. When the granularity of the synchronization object is a database, data in the database on the source database instance can be synchronized to the corresponding database on the destination database instance. When the granularity of the synchronization object is a database table, table data in the database table on the source database instance can be synchronized to the database table in the database on the destination database instance. When the granularity of the synchronization object is a column, column data in the database table on the database table on the source database instance can be synchronized to the database table in the database on the destination database instance.
[0026] When configuring synchronization object information, the required information varies depending on the granularity of the synchronization object. Synchronization object information defines the database, table, and column information required for database synchronization. It needs to include both the object identifier to be synchronized in the source database instance and the object identifier in the destination database instance that has a mapping relationship with the object identifier to be synchronized.
[0027] For example, when the granularity of the synchronization object is a database, the configured synchronization object information includes, but is not limited to: the name of the database to be synchronized in the source database instance, and the name of the database in the destination database instance that has a mapping relationship with the name of the database to be synchronized. Here, the name of the database to be synchronized in the source database instance is the object identifier to be synchronized in the source database instance; the name of the database in the destination database instance that has a mapping relationship with the name of the database to be synchronized is the object identifier in the destination database instance that has a mapping relationship with the object identifier to be synchronized.
[0028] For example, when the granularity of the synchronization object is a database table, the configured synchronization object information includes, but is not limited to: the name of the database to be synchronized in the source database instance, the name of the database in the destination database instance that has a mapping relationship with the name of the database to be synchronized (which can be called the mapping database name), the name of the table to be synchronized in the source database instance, and the name of the table in the destination database instance that has a mapping relationship with the name of the database to be synchronized (which can be called the mapping table name). Here, the name of the database to be synchronized in the source database instance and the name of the table to be synchronized in the source database instance define the object identifier to be synchronized in the source database instance; the mapping database name and the mapping table name in the destination database instance define the object identifier that has a mapping relationship with the object identifier to be synchronized in the destination database instance.
[0029] For example, when the granularity of the synchronization object is at the column level, the configured synchronization object information includes, but is not limited to: the name of the library to be synchronized in the source library instance, the name of the library in the destination library instance that has a mapping relationship with the name of the library to be synchronized (which can be called the mapped library name), the name of the table to be synchronized in the source library instance, the name of the table in the destination library instance that has a mapping relationship with the name of the library to be synchronized (which can be called the mapped table name), the name of the column to be synchronized in the table to be synchronized, and the name of the column to be synchronized in the destination library instance that has a mapping relationship with the name of the column to be synchronized in the table to be synchronized (which can be called the mapped column name). Here, the name of the library to be synchronized in the source library instance, the name of the table to be synchronized in the source library instance, and the name of the column to be synchronized in the table to be synchronized define the object identifier to be synchronized in the source library instance; the name of the mapped library, the name of the mapped table, and the name of the mapped column in the destination library instance define the object identifier that has a mapping relationship with the object identifier to be synchronized in the destination library instance.
[0030] In this embodiment, a forward synchronization link is established between the first database instance and the second database instance. The data synchronization direction of the forward synchronization link is from the first database instance to the second database instance, that is, the first database instance is the source database instance, and the second database instance is the destination database instance. For ease of understanding and distinction, the source database instance on the forward synchronization link is referred to as the first source database instance, and the destination database instance on the forward synchronization link is referred to as the first destination database instance.
[0031] In practical applications, the entity executing the database bidirectional synchronization method (e.g., a database bidirectional synchronization device or data transmission service) can connect to the first database instance based on the connection information of the first database instance, and connect to the second database instance based on the connection information of the second database instance, in order to establish a forward synchronization link.
[0032] For any database instance in the first or second database instance, the connection information required to connect to the database instance depends on the situation. The connection information of the database instance includes, but is not limited to: the database instance's account and password information, the database instance name (or database instance identifier), the Internet Protocol (IP) address, domain name, port number, etc. of the host where the database instance is located.
[0033] In this embodiment, the user can configure the synchronization object information of the forward synchronization link as needed. For ease of distinction and understanding, the synchronization object information of the forward synchronization link is referred to as forward synchronization object information. The forward synchronization object information includes, but is not limited to, at least one first source object identifier of the first source library instance and a first destination object identifier of the first destination library instance corresponding to the first source object identifier. The first source object identifier is also the object identifier of the synchronization object of the first source library instance, and the first source object identifier includes, but is not limited to, the object identifier of a database, the object identifier of a database table, or the object identifier of a column; the first destination object identifier is also the object identifier in the first destination library instance that has a mapping relationship with the first source object identifier.
[0034] 102. Based on the forward synchronization object information, start the forward full synchronization task. The forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object.
[0035] Specifically, the first source object is the object identified by the first source object identifier, and the first destination object is the object identified by the first destination object identifier. During the full synchronization phase, all data in the first source object needs to be synchronized to the first destination object; the full data refers to all the current data in the first source object.
[0036] For example, if the granularity of the synchronization object is a database, then all data in each database table on the database to be synchronized will be synchronized to the database with the mapping relationship. As another example, if the granularity of the synchronization object is a database table, then all data in the database table to be synchronized will be synchronized to the database table with the mapping relationship. As yet another example, if the granularity of the synchronization object is a column, then all data in the columns that need to be synchronized in the database table to be synchronized will be synchronized to the corresponding columns in the database table with the mapping relationship.
[0037] In practical applications, there are no restrictions on the full synchronization method. For example, there's trigger-based full synchronization, plugin-based full synchronization, and message queue-based full synchronization.
[0038] Optionally, to improve the performance of full synchronization, step 102 is implemented as follows: construct a query statement for the first source object based on the first source object identifier, and execute the query statement for the first source object in the database where the first source object is located to obtain the full data in the first source object; construct an insert statement for the first destination object based on the full data in the first source object and the first destination object identifier corresponding to the first source object identifier, and execute the insert statement for the first destination object in the database where the first destination object is located to insert the full data in the first source object into the first destination object.
[0039] It is worth noting that first using a query statement to retrieve all the data in the source object to be synchronized, and then using an insert statement to insert all the data in the source object to be synchronized into the database where the target object is located, can effectively ensure that all the data in the source database is synchronized to the target database, thus improving the performance of full synchronization.
[0040] Specifically, regardless of whether the granularity of the synchronization object is a database, a database table, or a column, the constructed query statements are database table query statements, and the constructed insert statements are statements that insert data into the database table. Database table query statements are database operation statements used to query data in a database table, and include, but are not limited to, the SELECT statement. Insert statements are database operation statements used to insert data into a database table, and include, but are not limited to, the INSERT statement. If the granularity of the synchronization object is a database, for each database table to be synchronized, a query statement retrieving all data in the database table and the corresponding insert statement are constructed. If the granularity of the synchronization object is a database table, a query statement retrieving all data in the database table and the corresponding insert statement are constructed. If the granularity of the synchronization object is a column, a query statement retrieving all data in the database column of the database table and the corresponding insert statement are constructed.
[0041] For example, suppose the first source object identifiers include database1 (the name of the database to be synchronized) and table1 (the name of the table to be synchronized), and the first destination object identifiers include database2 (the name of the mapped database) and table2 (the name of the mapped table). The query statement for the first source object is "select from table1". Executing "select from table1" in database1 retrieves all the data from table1 in database1. The insert statement for the first destination object is "INSERT INTO table2 VALUES (value1, value2, ...)," where value1, value2, ..., are the column data from each column of table1. Executing "INSERT INTO table2 VALUES (value1, value2, ...)" in database2 synchronizes all the data from table1 in database1 into table2 in database2.
[0042] 103. Establish a reverse synchronization link between the first database instance and the second database instance, where the second database instance is the second source database instance and the first database instance is the second destination database instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source database instance and a second destination object identifier of the second destination database instance corresponding to the second source object identifier.
[0043] The second source object is the object with the identifier of the second source object, and the second destination object is the object with the identifier of the second destination object.
[0044] In practical applications, the second database instance is the second source database instance, and the first database instance is the second destination database instance. The execution entity of the database bidirectional synchronization method (e.g., a database bidirectional synchronization device or data transmission service) can connect to the first database instance based on the connection information of the first database instance, and connect to the second database instance based on the connection information of the second database instance, in order to establish a reverse synchronization link.
[0045] In this embodiment, the user can configure the synchronization object information of the reverse synchronization link as needed. For ease of distinction and understanding, the synchronization object information of the reverse synchronization link is referred to as reverse synchronization object information. The reverse synchronization object information includes, but is not limited to: at least one second source object identifier of the second source library instance and a second destination object identifier of the second destination library instance corresponding to the second source object identifier. The second source object identifier is also the object identifier of the synchronization object of the second source library instance, and may include, for example, but is not limited to: the object identifier of the database, the object identifier of the database table, or the object identifier of the column; the second destination object identifier is also the object identifier in the second destination library instance that has a mapping relationship with the second source object identifier.
[0046] 104. Filter the reverse synchronization object information based on the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier.
[0047] In this embodiment, when filtering the reverse synchronization object information based on the forward synchronization object information, the second source object identifiers in at least one of the second source object identifiers in the reverse synchronization object information that are identical to the first destination object identifier in the forward synchronization object information are deleted. The remaining second source object identifiers are then used as the residual second source object identifiers. Of course, during the filtering process, the second destination object identifiers in the reverse synchronization object information that have a mapping relationship with the deleted second source object identifiers are also deleted. Thus, the residual reverse synchronization object information obtained after filtering includes at least one residual second source object identifier and a residual second destination object identifier corresponding to the residual second source object identifier. The residual second source object is the object corresponding to the residual second source object identifier, and the residual second destination object is the object corresponding to the residual second destination object identifier.
[0048] In this embodiment, when synchronizing the database via the reverse synchronization link, the reverse synchronization object information is filtered based on the forward synchronization object information. In this way, the full amount of data synchronized from the first database instance to the second database instance via the forward synchronization link will not be resynchronized from the second database instance to the first database instance via the reverse synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization and prevents the database from experiencing data bloat.
[0049] 105. Based on the remaining reverse synchronization object information, start the reverse full synchronization task. The reverse full synchronization task is used to perform full synchronization between the remaining second source object and its corresponding remaining second destination object.
[0050] In practical applications, a reverse full synchronization task can be started after the forward full synchronization task has been completed. For example, the timestamp of the completion of the forward full synchronization task can be recorded, and the reverse full synchronization task can be started after the timestamp of the completion of the forward full synchronization task.
[0051] In practical applications, there are no restrictions on the full synchronization method. Optionally, to improve the performance of full synchronization, step 105 is implemented as follows: construct a query statement for the remaining second source object based on the remaining second source object identifier, and execute the query statement for the remaining second source object in the database where the remaining second source object resides to obtain the full data in the remaining second source object; construct an insert statement for the remaining second destination object based on the full data in the remaining second source object and the remaining second destination object identifier corresponding to the remaining second source object identifier, and execute the insert statement for the remaining second destination object in the database where the remaining second destination object resides to insert the full data in the remaining second source object into the remaining second destination object.
[0052] It is worth noting that first using a query statement to retrieve all the data in the remaining source objects to be synchronized, and then using an insert statement to insert all the data in the remaining source objects to be synchronized into the database where the remaining destination objects are located, can effectively ensure that all the data in the source database is synchronized to the destination database, thus improving the performance of full synchronization.
[0053] The database bidirectional synchronization method provided in this application performs full synchronization between databases sequentially through a forward synchronization link and a reverse synchronization link. When synchronizing the database through the reverse synchronization link, the reverse synchronization object information is filtered based on the forward synchronization object information. This ensures that the full data synchronized from the first database instance to the second database instance via the forward synchronization link will not be resynchronized from the second database instance to the first database instance via the reverse synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the performance of bidirectional database synchronization in terms of full synchronization.
[0054] After a full synchronization task is initiated, over time, the database tables in the source instance may experience changes such as new data additions, deletions, or updates, resulting in incremental data. Incremental data includes, but is not limited to, newly added, deleted, or updated data. When changes occur in the database tables of the source instance, these changes are synchronized to the database tables of the destination instance; in other words, incremental synchronization occurs between the source and destination instances.
[0055] In this embodiment, after initiating the full synchronization task, the incremental synchronization task can be initiated at any time without restriction. The incremental synchronization task includes a forward incremental synchronization task with data synchronization direction from the first database instance to the second database instance, and may also include a reverse incremental synchronization task with data synchronization direction from the second database instance to the first database instance. For example, the start timestamp of the forward full synchronization task can be recorded, and the forward incremental synchronization task can be initiated at any time after the start timestamp of the forward full synchronization task. Similarly, the start timestamp of the reverse full synchronization task can be recorded, and the reverse incremental synchronization task can be initiated at any time after the start timestamp of the reverse full synchronization task. As another example, the start timestamp of the reverse full synchronization task can be recorded, and both the forward and reverse incremental synchronization tasks can be initiated at any time after the start timestamp of the reverse full synchronization task. Furthermore, the completion timestamp of the forward full synchronization task can be recorded, and the forward incremental synchronization task can be initiated at any time after the completion timestamp of the forward full synchronization task. Record the timestamp of the completion of the reverse full synchronization task. The reverse incremental synchronization task can be started at any time after the timestamp of the completion of the reverse full synchronization task, but it is not limited to the example above.
[0056] The following section introduces a two-way database synchronization scheme from the perspective of incremental synchronization. Figure 2 A flowchart illustrating another database bidirectional synchronization method provided in this application embodiment. After initiating the forward full synchronization task or the reverse full synchronization task, see [link to flowchart]. Figure 2 The method may include the following steps:
[0057] 201. In response to the fulfillment of preset trigger conditions, check whether a new first database update event has been added to the binary log (binlog) file of the source database instance.
[0058] Specifically, a binlog file is a binary file that records database modification statements that update the database. These statements include, but are not limited to: INSERT statements (for inserting data into a database table), DELETE statements (for deleting data from a database table), and UPDATE statements (for updating data in a database table). INSERT, DELETE, and UPDATE statements are all Structured Query Language (SQL) statements.
[0059] In practical applications, binlog files record data in an event-based manner, recording one or more database update events. After each database transaction is executed in the database, a new database update event corresponding to that transaction is added to the binlog file of the database instance. A database transaction is a complete unit of operation consisting of related operations, including multiple database operations. These operations are either all executed or none are executed; it is an indivisible unit of work.
[0060] In this embodiment, the source library instance can be the first source library instance on the forward synchronization link, and the destination library instance corresponding to the source library instance is the first destination library instance on the forward synchronization link; the source library instance can also be the second source library instance on the reverse synchronization link, and the destination library instance corresponding to the source library instance is the second destination library instance on the reverse synchronization link.
[0061] In this embodiment, after starting the full synchronization task on the forward synchronization link, an incremental synchronization task can be started on the forward synchronization link; or, after starting the full synchronization task on the reverse synchronization link, an incremental synchronization task can be started on the reverse synchronization link.
[0062] During the incremental synchronization phase, the presence of newly added database update events in the binlog file can confirm whether the incremental synchronization task has been initiated. In practical applications, when preset trigger conditions are met, it can be checked whether a new first database update event has been added to the source database instance's binlog file. The first database update event is the currently detected new database update event in the source database instance's binlog file. If no first database update event is detected, it means that the source database instance has not performed any database change operations in the most recent time period, and step 201 continues. If a first database update event is detected, it means that the source database instance has performed database change operations in the most recent time period, and step 202 continues.
[0063] In this embodiment, the preset trigger condition refers to a pre-defined condition used to detect whether a new database update event has been added to the binlog file. The preset trigger condition can be flexibly set, and includes, but is not limited to, periodic detection conditions, timed detection conditions, or critical event trigger conditions. A periodic detection condition means that detection is performed every other detection period; a timed detection condition means that detection is performed when the current time reaches a specified time; and a critical event trigger condition means that detection is performed when a critical event occurs. Critical events can be flexibly set as needed, and include, but are not limited to, situations where the database table to be synchronized is of high importance, or where there is a need for incremental updates to the database table to be synchronized, or where data migration of the database table to be synchronized is required, etc.
[0064] 202. If a first database update event is detected, then parse the first database update event.
[0065] 203. Determine whether the first system table change statement is parsed from the first database update event, where the first system table change statement is used to indicate that the incremental data of the third source object in the source database instance comes from database synchronization; if the determination result is yes, then proceed to step 204; if the determination result is no, then proceed to step 205.
[0066] In this embodiment, for ease of distinction and understanding, the source object in the source database instance is referred to as the third source object, and the corresponding target object in the destination database instance is referred to as the third destination object. When database change operations such as adding, deleting, or updating data are performed on the third source object, the binlog file of the source database instance records the database change operation information of the third source object in the form of events, that is, a database update event related to the third source object is added to the binlog file of the source database instance.
[0067] In this embodiment, the first database update event is parsed according to the binlog event parsing method to obtain the event parsing result of the first database update event. Based on the event parsing result of the first database update event, it is determined whether the first system table modification statement can be parsed from the first database update event.
[0068] In this embodiment, the first system table modification statement refers to the system table modification statement recorded in the first database update event. A system table modification statement is a database modification operation statement that modifies a system table. A system table is a database table distinct from function tables; the data in a system table is unrelated to the application system. Database tables synchronized via forward or reverse synchronization links are function tables, and the data in function tables is typically application data related to the application system. For ease of understanding and distinction, the database tables in the source database instance are referred to as source function tables, and the database tables in the destination database instance are referred to as destination function tables. Data in the source function tables is typically written by the application system, while data in the destination function tables is typically synchronized from the source function tables.
[0069] In this embodiment, the system table can perform database change operations if the following conditions are met: the target function table needs to be incrementally synchronized with the source function table. This ensures that the feasibility of starting the incremental synchronization task can be confirmed by the database update events added to the binlog file.
[0070] In this embodiment, within the most recent time period of the current time, due to the application system's access, a database change operation is performed on the source function table associated with the third source object in the source database instance. This causes the source function table associated with the third source object in the source database instance to generate incremental data within the most recent time period of the current time. At this time, a new database transaction is initiated. The new database transaction includes change statements (which can be called function table change statements) that modify the target function table associated with the third target object and change statements (which can be called system table change statements) that modify the system table. A new database transaction is executed in the target database instance where the third target object resides. In this way, the same database change operation is performed on the target function table associated with the third target object in the target database where the third target object resides, so that the target function table associated with the third target object generates the same incremental data as the source function table associated with the third source object, thereby achieving incremental synchronization between the third source object in the source database instance and the corresponding third target object in the target database instance; at the same time, arbitrary database change operations are performed on the system table corresponding to the target function table associated with the third target object. When a new database transaction is completed, the corresponding database change events are recorded in the binlog file of the destination database instance. These recorded database change events include statements modifying function tables and system tables. Thus, when the destination database instance changes its role to the source database instance, if a new database change event including a system table change statement is detected in the source database instance's binlog file, it indicates that the incremental data generated by the source function table associated with the third source object in the source database instance within the most recent time period originated from database synchronization, and not from incremental data generated by application system access and database change operations.
[0071] In this embodiment, a number of system tables can be flexibly created in the target library where the third target object resides, as needed. For example, 32 or more system tables can be created. For any target function table among all target function tables in the target library, a portion of system tables are selected from multiple system tables and assigned to that target function table. Furthermore, based on the table name of the target function table and the table names of the system tables to which the target function table is assigned, the association between the table names of the target function table and the table names of the system tables is established and stored.
[0072] Further optionally, to distribute the pressure on system tables and improve incremental synchronization performance, at least one system table is created in the target library where the third target object resides, each system table having an initial table name; the target function tables in the target library are labeled, and the labels of the system tables corresponding to the target function tables are determined based on the labels of the target function tables and the number of system tables; for the system tables corresponding to the target function tables, the system table label is added to the end of the initial table name of the system table to obtain the table name of the system table corresponding to the target function table; based on the table names of the target function tables and their corresponding system table names, the association between the table names of the target function tables and the table names of the system tables is established and stored.
[0073] For ease of understanding and distinction, the destination database refers to the database within the destination database instance that participates in the synchronization task, and correspondingly, the source database refers to the database within the source database instance that participates in the synchronization task. In practical applications, the forward synchronization object information based on the forward synchronization link can determine the number and names of the destination function tables included in the destination database of the first destination database instance on the forward synchronization link; similarly, the reverse synchronization object information based on the reverse synchronization link can determine the number and names of the destination function tables included in the destination database of the second destination database instance on the reverse synchronization link. For any destination database in either the first or second destination database instance, all destination function tables in the destination database are sequentially labeled, with different destination function tables having different labels, and each destination function table's label is unique. For any destination function table among all destination function tables in the destination database, a subset of system tables is selected from all system tables and assigned to that destination function table; that is, the destination function table is associated with at least one system table.
[0074] In this embodiment, after determining the label of the target function table and its associated system table, the label of the system table corresponding to the target function table is determined based on the label of the target function table and the number of system tables. For example, the label of the system table corresponding to the target function table is obtained by performing a modulo operation on the label of the target function table and the number of system tables. Another example is by performing a subtraction operation on the label of the target function table and the number of system tables. Yet another example is by performing an addition operation on the label of the target function table and the number of system tables, but these examples are not limited to the above.
[0075] For the system table corresponding to the target function table, a system table number is appended to the end of the initial table name to obtain the table name of the system table corresponding to the target function table. For example, if the target function table number is 100 and the number of system tables is 32, the remainder when 100 is divided by 32 is 4. Therefore, the system table number corresponding to the target function table is 4. If the initial table name of the system table corresponding to the target function table is dts_trx4unit_mark, the table name after appending the number is dts_trx4unit_mark_4.
[0076] In this embodiment, when the first system table change statement is parsed from the first database update event, it indicates that the incremental data of the third source object in the source database instance comes from database synchronization, and is not the incremental data generated by the application system's access to perform database change operations such as adding, deleting, or updating data on the third source object in the source database instance. At this time, step 204 is executed.
[0077] In this embodiment, if the first system table change statement is not parsed from the first database update event, but the first function table change statement associated with the third source object is parsed from the first database update event, it indicates that the source function table associated with the third source object in the source database instance has generated incremental data due to the database change operation performed by the application system in the most recent time period. At this time, it is necessary to start the incremental synchronization task between the third source object in the source database instance and the corresponding third destination object in the destination database instance, that is, to execute step 205 and its subsequent steps.
[0078] In this embodiment, if the first system table change statement is not parsed from the first database update event, and other function table change statements unrelated to the third source object are parsed from the first database update event, it means that the source function table associated with other objects in the source database instance that do not belong to the synchronization object has generated incremental data due to the database change operation performed by the application system in the most recent time period of the current time. At this time, step 204 can also be executed.
[0079] 204. Discard the first database update event to prevent incremental synchronization tasks between the third source object in the source database instance and the corresponding third destination object in the destination database instance.
[0080] 205. If the first function table change statement associated with the third source object is parsed from the first database update event, construct the second function table change statement and the second system table change statement. The second function table change statement is used to execute the incremental synchronization task between the third source object and its corresponding third destination object, and the second system table change statement is used to change the first system table corresponding to the first destination function table associated with the third destination object.
[0081] Specifically, when constructing the second function table change statement, the first function table change statement associated with the third source object is used as a reference. The corresponding synchronization object information is queried based on the object identifier of the third source object to obtain the object identifier of the third destination object. Based on the object identifier of the third destination object, a second function table change statement with the same change operation as the first function table change statement is constructed. In other words, the change operation of the first function table change statement on the third source object is the same as the change operation of the second function table change statement on the third destination object. Therefore, the second function table change statement enables incremental synchronization between the third source object and its corresponding third destination object.
[0082] It is worth noting that when querying the corresponding synchronization object information based on the object identifier of the third source object, if incremental synchronization is performed based on the forward synchronization link, the queried synchronization object information is the forward synchronization object information of the forward synchronization link. If incremental synchronization is performed based on the reverse synchronization link, the queried synchronization object information is the reverse synchronization object information of the reverse synchronization link.
[0083] For example, the table name of the source function table associated with the third source object is user-a; the table name of the destination function table associated with the third destination object is user-b; the first function table modification statement is INSERT INTO user-a col1VALUES(123), executing the first function table modification statement can insert data 123 into the column named col1 of the source function table user-a associated with the third source object; the second function table modification statement is INSERT INTO user-b col1VALUES(123), executing the second function table modification statement can insert data 123 into the column named col1 of the destination function table user-b associated with the third destination object.
[0084] For example, the source function table associated with the third source object is named user-a; the destination function table associated with the third destination object is named user-b; the first function table modification statement is DELETE from user-a where id=123, executing the first function table modification statement will delete the data with id=123 in the source function table user-a associated with the third source object; the second function table modification statement is DELETE from user-b where id=123, executing the second function table modification statement will delete the data with id=123 in the destination function table user-b associated with the third destination object.
[0085] For example, the source function table associated with the third source object is named user-a; the destination function table associated with the third destination object is named user-b; the first function table modification statement is UPDATE user-a set age=20where name=Tom, executing the first function table modification statement will change the age of the person named Tom in the source function table user-a associated with the third source object to 20; the second function table modification statement is UPDATE user-b set age=20wherename=Tom, executing the second function table modification statement will change the age of the person named Tom in the destination function table user-b associated with the third destination object to 20.
[0086] In this embodiment, in addition to constructing the second function table change statement, it is also necessary to construct the second system table change statement. The second system table change statement is used to change the first system table corresponding to the first purpose function table associated with the third purpose object.
[0087] In practical applications, when constructing a second system table change statement, the table name of the first system table associated with the first target function table is determined based on the table name of the first target function table and the relationship between the table names of the target function table and the system table. The second system table change statement is then created based on the table name of the first system table. It is understandable that finding the relationship accurately determines the first system table corresponding to the first target function table.
[0088] It is worth noting that when creating a second system table modification statement based on the table name of the first system table, the table name of the first system table is used as the table name in the database table modification statement. This allows for the creation of any type of database table modification statement, i.e., a second system table modification statement. Second system table modification statements include, but are not limited to, data insertion statements, data deletion statements, or data update statements. For example, if the table name of the first system table is dts_trx4unit_mark_4, the second system table modification statement could be, for example, UPDATE dts_trx4unit_mark_4where col1; or, for example, DELETE from dts_trx4unit_mark_4where id=123; or, for example, INSERT INTO dts_trx4unit_mark_4col1 VALUES(0).
[0089] Alternatively, to reduce the probability of database data bloat, when creating a second system table modification statement based on the table name of the first system table, if the first system table is being modified for the first time, an INSERT statement of type 2 should be created; otherwise, if the first system table is not being modified for the first time, an UPDATE statement of type 2 should be created. This means that, except for the initial insertion of a record into the system table, all other database modification operations on system tables update the existing data. This ensures that each system table contains only one row of data, preventing data bloat.
[0090] 206. Execute the second system table modification statement and the second function table modification statement in the target database instance where the third target object is located, and add a second database update event to the binlog file of the target database instance. The second database update event is used to record the second system table modification statement and the second function table modification statement.
[0091] In this embodiment, a second system table modification statement is executed to complete the incremental synchronization task between the third source object and its corresponding third destination object; the second system table modification statement is also executed to modify the first system table corresponding to the first destination function table associated with the third destination object. After the second system table modification statement and the second function table modification statement are executed, a second database update event is added to the binlog file of the destination database instance. The second database update event records the second system table modification statement and the second function table modification statement. Recording the second system table modification statement in the second database update event can provide support for subsequent confirmation that the incremental synchronization task between the third source object and its corresponding third destination object does not need to be executed.
[0092] Further optionally, to improve incremental synchronization performance, a new database transaction can be created based on the second system table change statement and the second function table change statement. The new database transaction includes the second system table change statement and the second function table change statement. The new database transaction is executed in the target database instance where the third target object is located. After the new database transaction is completed, a second database update event corresponding to the new database transaction is added to the binlog file of the target database instance.
[0093] In this embodiment, the recording order of the second system table modification statement and the second function table modification statement in the second database update event is not restricted. Further optionally, to improve incremental synchronization performance, the first database modification statement recorded in the second database update event is a second system table modification statement. Correspondingly, the method for determining whether the first system table modification statement is parsed from the first database update event is as follows: determine whether the first database modification statement in the event parsing result of the first database update event is a first system table modification statement.
[0094] Understandably, the second database update event records the second system table change statement as the first database change statement. In this way, during the incremental synchronization phase, it is only necessary to determine whether the first database change statement recorded in the database update event is a system table change statement, without having to iterate through each database change statement recorded in the database update event to determine whether it is a system table change statement. This saves computing resources and improves the performance of incremental synchronization.
[0095] The database bidirectional synchronization method provided in this application, during the incremental synchronization phase, determines whether to initiate the incremental synchronization task by checking whether the newly added database update events in the binlog file include system table change statements, since system table change statements indicate that incremental data of source objects in the source database instance originates from database synchronization. Therefore, incremental data synchronized from one database instance to another through a single synchronization link will not be resynchronized from one database instance to the same instance through another synchronization link. This avoids the data loop synchronization problem in bidirectional database synchronization, prevents data bloat in the database, and effectively improves the performance of bidirectional database synchronization in the incremental synchronization dimension.
[0096] To better understand the technical solutions of the embodiments of this application, the following is combined with... Figure 3 The application scenario diagram shown illustrates a specific scenario implementation.
[0097] See Figure 3 Specifically, a first database instance is used as the first source database instance, and a second database instance is used as the first destination database instance. A connection is established between the first and second database instances based on their connection information, thus establishing a forward synchronization link. Next, based on the forward synchronization object information of the forward synchronization link, a forward full synchronization task is initiated, that is, a full synchronization from the first database instance to the second database instance is initiated. The first database instance is the first source database on the forward synchronization link, and the second database instance is the first destination database on the forward synchronization link.
[0098] Using the second database instance as the second source database instance and the first database instance as the second destination database instance, a reverse synchronization link is established between the first and second database instances based on their connection information. Next, the reverse synchronization object information is filtered based on the forward synchronization object information to obtain the remaining reverse synchronization object information. Based on this remaining information, a full reverse synchronization task is initiated, thus completing the full synchronization from the second database instance to the first database instance. The second database is the second source database on the reverse synchronization link, and the first database is the second destination database on the reverse synchronization link.
[0099] In practical applications, after starting a forward full synchronization task or a reverse full synchronization task, incremental synchronization needs to be performed between the source database instance and the destination database instance over time. There is no restriction on the triggering time of incremental synchronization; it can be during the execution of the full synchronization task or after the full synchronization task is completed.
[0100] During the incremental synchronization phase, whether incremental synchronization is needed is determined by checking whether the newly added database update events in the binlog file include system table change statements that modify system tables.
[0101] For the forward synchronization link, it checks whether new database update events have been added to the binlog file of the first database. If a new database update event is detected in the binlog file, and the database update event does not include system table modification statements, then the incremental data of the first source function table in the first database is synchronized to the corresponding first destination function table in the second database via the forward synchronization link. If a new database update event is detected in the binlog file, and the database update event includes system table modification statements, then it is confirmed that the incremental data of the first source function table in the first database does not need to be synchronized to the corresponding first destination function table in the second database. See also Figure 3The binlog file of the first database records multiple database update events, including database update event 1, database update event 2, and database update event 3. Database update event 3 is the currently detected new database update event. The event information for database update event 3 is, for example, "Event Begin Insert 123 Event End". Event Begin indicates the start of the event, Event End indicates the end of the event, and Insert 123 indicates that data 123 was recently written to the first source function table in the first database. Since the application system wrote data 123 to the first source function table in the first database, database update event 3 does not include system table change statements and needs to be synchronized forward. That is, the incremental data 123 in the first source function table of the first database is synchronized to the corresponding first destination function table in the second database through the forward synchronization link.
[0102] During the process of writing the forward-synchronized "123" to the second database, it is also necessary to modify the system table in the second database. After inserting the forward-synchronized "123" into the corresponding first destination function table in the second database and modifying the system table of the first destination function table, a new database update event is added to the binlog file of the database instance where the second database resides. See also Figure 3 The binlog file of the second database records multiple database update events, including database update event 1, database update event 2, and database update event 3. Database update event 3 is the currently newly added database update event. The event information for database update event 3 is, for example, "Event BeginUpdate Symstem Table Insert 123Event End". Here, "Update Symstem Table" indicates that the system table is being updated.
[0103] When the application system writes 456 to the second database, a new database update event 4 is added to the binlog file of the second database. The event information of database update event 4 is, for example, "Event Begin Insert 456Event End".
[0104] For the reverse synchronization link, it checks whether a new database update event has been added to the binlog file of the database instance where the second database resides. If a new database update event is detected in the binlog file, and the database update event does not include system table modification statements, then the incremental data of the second source function table in the second database is synchronized to the corresponding second destination function table in the first database via the reverse synchronization link. If a new database update event is detected in the binlog file, and the database update event includes system table modification statements, then it is confirmed that the incremental data of the second source function table in the second database does not need to be synchronized to the corresponding second destination function table in the first database. For example, when a new database update event of database update event 3 is detected in the binlog file of the second database, database update event 3 includes UpdateSystem Table, indicating that the 123 written in the second database was synchronized from the first database, and there is no need to resynchronize it back to the first database. Database update event 3 is discarded, that is, there is no need to perform incremental synchronization operation based on database update event 3.
[0105] For example, when a new database update event, database update event 4, is detected in the binlog file of the second database, and database update event 3 does not include Update Symstem Table, it indicates that the data 456 written in the second database was written by an external application system and needs to be synchronized to the first database. In this case, reverse synchronization of 456 is performed, that is, the incremental data 456 of the second source function table in the second database is synchronized to the corresponding second destination function table in the first database via the reverse synchronization link.
[0106] Figure 4 This is a schematic diagram of a bidirectional database synchronization system provided in an embodiment of this application. See also... Figure 4 This bidirectional database synchronization system may include: a client 10, a data transmission service 20, a first database instance 30, and a second database instance 40; among them, the data transmission service (DTS) 20 has emerged with the continuous development of database technology. DTS can support data interaction between data sources such as relational databases or non-relational databases, and provide various services such as data synchronization, migration, subscription, integration, and processing.
[0107] In this embodiment, the client 10 is used to respond to the user's configuration operation, obtain and send link configuration information to the data transmission service 20. The link configuration information includes forward synchronization object information of the forward synchronization link and reverse synchronization object information of the reverse synchronization link. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source library instance and a first destination object identifier of the first destination library instance corresponding to the first source object identifier. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source library instance and a second destination object identifier of the second destination library instance corresponding to the second source object identifier.
[0108] In practical applications, users configure link configuration information through client 10. This link configuration information includes, but is not limited to, the synchronization object information for the forward synchronization link and the synchronization object information for the reverse synchronization link. For example, the link configuration information may also include connection information for the database instance, which may include, but is not limited to: the database instance's account and password information, the database instance name (or database instance identifier), the IP address (Internet Protocol) of the host where the database instance resides, the domain name, the port number, etc.
[0109] In this embodiment, the data transmission service 20 is used to establish a forward synchronization link between a first database instance 30 and a second database instance 40. The first database instance 30 is a first source database instance, and the second database instance 40 is a first destination database instance. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier. Based on the forward synchronization object information, a forward full synchronization task is initiated and executed. The forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object. The first source object is the object corresponding to the first source object identifier, and the first destination object is the object corresponding to the first destination object identifier. A reverse synchronization link is established between the first database instance 30 and the second database instance 40. The second database instance 40 is the first source database instance. In the two source database instances, the first database instance 30 is the second destination database instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source database instance and the second destination object identifier of the second destination database instance corresponding to the second source object identifier. The reverse synchronization object information is filtered according to the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier. Based on the remaining reverse synchronization object information, a reverse full synchronization task is started and executed. The reverse full synchronization task is used to perform full synchronization between the remaining second source objects and their corresponding remaining second destination objects. The remaining second source objects are the objects corresponding to the remaining second source object identifiers, and the remaining second destination objects are the objects corresponding to the remaining second destination object identifiers.
[0110] Optionally, when the data transmission service 20 initiates and executes the forward full synchronization task based on the forward synchronization object information, it can be used to: construct a query statement for the first source object based on the first source object identifier, and execute the query statement for the first source object in the database where the first source object is located to obtain the full data in the first source object; construct an insert statement for the first destination object based on the full data in the first source object and the first destination object identifier corresponding to the first source object identifier, and execute the insert statement for the first destination object in the database where the first destination object is located to insert the full data in the first source object into the first destination object.
[0111] Optionally, when the data transmission service 20 starts executing the reverse full synchronization task based on the remaining reverse synchronization object information, it can be used to: construct a query statement for the remaining second source object based on the remaining second source object identifier, and execute the query statement for the remaining second source object in the database where the remaining second source object is located, so as to obtain the full data in the remaining second source object;
[0112] Based on the full data in the remaining second source object and the remaining second destination object identifier corresponding to the remaining second source object identifier, construct an insert statement for the remaining second destination object, and execute the insert statement for the remaining second destination object in the database where the remaining second destination object is located, so as to insert the full data in the remaining second source object into the remaining second destination object.
[0113] Optionally, after initiating the full synchronization task, the data transmission service 20 is further configured to: in response to the fulfillment of a preset trigger condition, detect whether a first database update event has been added to the binary log (binlog) file of the source database instance; if a first database update event is detected, parse the first database update event; if a first system table change statement is parsed from the first database update event, discard the first database update event to prevent the execution of the incremental synchronization task between the third source object in the source database instance and the corresponding third destination object in the destination database instance, wherein the first system table change statement indicates that the incremental data of the third source object in the source database instance originates from database synchronization.
[0114] Optionally, the data transmission service 20 is further configured to: if a first system table change statement is not parsed from the first database update event, and a first function table change statement associated with a third source object is parsed from the first database update event, construct a second function table change statement and a second system table change statement, wherein the second function table change statement is used to perform incremental synchronization between the third source object and its corresponding third destination object, the change operation of the first function table change statement on the third source object is the same as the change operation of the second function table change statement on the third destination object, and the second system table change statement is used to change the first system table corresponding to the first destination function table associated with the third destination object; execute the second system table change statement and the second function table change statement in the destination database instance where the third destination object is located, and add a second database update event to the binlog file of the destination database instance, the second database update event being used to record the second system table change statement and the second function table change statement.
[0115] Optionally, the first database change statement in the second database update event record is a second system table change statement;
[0116] Accordingly, when the data transmission service 20 determines whether the first system table change statement is parsed from the first database update event, it can be used to: determine whether the first database change statement in the event parsing result of the first database update event is a first system table change statement.
[0117] Optionally, when the data transmission service 20 constructs the second system table change statement, it can be used to: determine the table name of the first system table associated with the first destination function table based on the table name of the first destination function table and the association relationship between the table name of the destination function table and the table name of the system table; and create the second system table change statement based on the table name of the first system table.
[0118] Optionally, when the data transmission service 20 creates a second system table modification statement based on the table name of the first system table, it can be used as follows: if the first system table needs to be modified for the first time, a second system table modification statement of type INSERT statement is created based on the table name of the first system table; if the first system table needs to be modified for the first time, a second system table modification statement of type UPDATE statement is created based on the table name of the first system table.
[0119] Optionally, before determining the table name of the first system table associated with the first destination function table, the data transmission service 20 is further configured to: create at least one system table in the destination library where the third destination object is located, each system table having an initial table name; label the destination function tables in the destination library, and determine the label of the system table corresponding to the destination function table based on the label of the destination function table and the number of system tables; for the system table corresponding to the destination function table, add the system table label to the end of the initial table name of the system table to obtain the table name of the system table corresponding to the destination function table; and establish and store the association relationship between the table name of the destination function table and the table name of the system table based on the table name of the destination function table and the table name of the system table.
[0120] Optionally, when the data transmission service 20 determines the system table number corresponding to the destination function table based on the destination function table number and the number of system tables, it may include at least one of the following: performing a modulo operation on the destination function table number and the number of system tables to obtain the system table number corresponding to the destination function table; performing a subtraction operation on the destination function table number and the number of system tables to obtain the system table number corresponding to the destination function table; or performing an addition operation on the destination function table number and the number of system tables to obtain the system table number corresponding to the destination function table.
[0121] For the implementation principles and technical effects of the database bidirectional synchronization system, please refer to the relevant descriptions in the foregoing method embodiments, which will not be repeated here.
[0122] Figure 5 This is a schematic diagram illustrating the structure of a bidirectional database synchronization device provided in an embodiment of this application. The device can consist of software and / or hardware, and is generally configured in an electronic device. See also... Figure 5 The device may include:
[0123] The first establishment module 51 is used to establish a forward synchronization link between a first database instance and a second database instance. The first database instance is a first source database instance, and the second database instance is a first destination database instance. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier. The first source object is the object corresponding to the first source object identifier, and the first destination object is the object corresponding to the first destination object identifier.
[0124] The first full synchronization module 52 is used to start and execute a forward full synchronization task based on the forward synchronization object information. The forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object.
[0125] The second establishment module 53 is used to establish a reverse synchronization link between the first database instance and the second database instance. The second database instance is the second source database instance, and the first database instance is the second destination database instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source database instance and a second destination object identifier of the second destination database instance corresponding to the second source object identifier.
[0126] The second full synchronization module 54 is used to filter the reverse synchronization object information based on the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier. Based on the remaining reverse synchronization object information, the reverse full synchronization task is started and executed. The reverse full synchronization task is used to perform full synchronization between the remaining second source object and its corresponding remaining second destination object. The remaining second source object is the object corresponding to the remaining second source object identifier, and the remaining second destination object is the object corresponding to the remaining second destination object identifier.
[0127] Optionally, when performing full synchronization, the first full synchronization module 52 can be used to: construct a query statement for the first source object based on the first source object identifier, and execute the query statement for the first source object in the database where the first source object is located to obtain the full data in the first source object; construct an insert statement for the first destination object based on the full data in the first source object and the first destination object identifier corresponding to the first source object identifier, and execute the insert statement for the first destination object in the database where the first destination object is located to insert the full data in the first source object into the first destination object.
[0128] Optionally, when the second full synchronization module 54 performs full synchronization, it can be used to: initiate and execute a reverse full synchronization task based on the remaining reverse synchronization object information, including: constructing a query statement for the remaining second source object based on the remaining second source object identifier, and executing the query statement for the remaining second source object in the database where the remaining second source object is located to obtain the full data in the remaining second source object; constructing an insert statement for the remaining second destination object based on the full data in the remaining second source object and the remaining second destination object identifier corresponding to the remaining second source object identifier, and executing the insert statement for the remaining second destination object in the database where the remaining second destination object is located to insert the full data in the remaining second source object into the remaining second destination object.
[0129] Further optionally, the above-mentioned device also includes:
[0130] Detection module 55 is used to detect whether a first database update event has been added to the binary log (binlog) file of the source database instance in response to the fulfillment of preset trigger conditions;
[0131] Parsing module 56 is used to parse the first database update event if the first database update event is detected;
[0132] The discard module 57 is used to discard the first database update event when the first system table change statement is parsed from the first database update event, so as to prevent the execution of the incremental synchronization task between the third source object in the source database instance and the corresponding third destination object in the destination database instance. The first system table change statement is used to indicate that the incremental data of the third source object in the source database instance comes from database synchronization.
[0133] Further optionally, the incremental synchronization module 58 is used to construct a second function table change statement and a second system table change statement if a first function table change statement associated with a third source object is parsed from the first database update event, provided that no first system table change statement is parsed from the first database update event. The second function table change statement is used for incremental synchronization between the third source object and its corresponding third destination object. The change operation of the first function table change statement on the third source object is the same as the change operation of the second function table change statement on the third destination object. The second system table change statement is used to change the first system table corresponding to the first destination function table associated with the third destination object. The second system table change statement and the second function table change statement are executed in the destination database instance where the third destination object resides, and a second database update event is added to the binlog file of the destination database instance. The second database update event is used to record the second system table change statement and the second function table change statement.
[0134] Further optionally, the first database change statement in the second database update event record is a second system table change statement;
[0135] The first database change statement in the event resolution result of the first database update event is the first system table change statement.
[0136] Further optionally, when the incremental synchronization module 58 constructs the second system table change statement, it can be used to: determine the table name of the first system table associated with the first target function table based on the table name of the first target function table and the association relationship between the table name of the target function table and the table name of the system table; and create the second system table change statement based on the table name of the first system table.
[0137] Optionally, when the incremental synchronization module 58 creates a second system table change statement based on the table name of the first system table, it can be used as follows: if the first system table needs to be changed for the first time, then create a second system table change statement of type insert statement based on the table name of the first system table; if the first system table needs to be changed for the first time, then create a second system table change statement of type update statement based on the table name of the first system table.
[0138] Optionally, the above apparatus further includes: an association establishment module 59, configured to create at least one system table in the target library where the third target object is located, each system table having an initial table name; to label the target function tables in the target library, and to determine the label of the system table corresponding to the target function table based on the label of the target function table and the number of system tables; to add the system table label to the end of the initial table name of the system table corresponding to the target function table to obtain the table name of the system table corresponding to the target function table; and to establish and store the association between the table name of the target function table and the table name of the system table based on the table name of the target function table and the table name of the corresponding system table.
[0139] Further optionally, when determining the system table number corresponding to the target function table based on the target function table number and the number of system tables, the association relationship establishment module 59 can be used to: perform a modulo operation on the target function table number and the number of system tables to obtain the system table number corresponding to the target function table; and / or, perform a subtraction operation on the target function table number and the number of system tables to obtain the system table number corresponding to the target function table; and / or, perform an addition operation on the target function table number and the number of system tables to obtain the system table number corresponding to the target function table.
[0140] Figure 5 The apparatus shown can perform the aforementioned method embodiments, and its implementation principle and technical effects will not be repeated here. Regarding the embodiments described above... Figure 5The specific ways in which each module and unit of the device performs operations have been described in detail in the embodiments of the method, and will not be elaborated here.
[0141] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6 As shown, the electronic device includes: a memory 61 and a processor 62;
[0142] Memory 61 is used to store computer programs and can be configured to store various other data to support operation on the computing platform. Examples of this data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc.
[0143] The memory 61 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0144] Processor 62, coupled to memory 61, is used to execute computer programs in memory 61 for use in steps of a database bidirectional synchronization method.
[0145] Optional, such as Figure 6 As shown, the electronic device also includes other components such as a communication component 63, a display 64, a power supply component 65, and an audio component 66. Figure 6 The diagram only shows some components and does not mean that the electronic device includes only these components. Figure 6 The components shown. Additionally... Figure 6The components within the dashed box are optional, not mandatory, and their specific requirements depend on the product form of the electronic device. The electronic device in this embodiment can be a desktop computer, laptop computer, smartphone, or IoT (Internet of Things) device, or a server-side device such as a conventional server, cloud server, or server array. If the electronic device in this embodiment is a desktop computer, laptop computer, or smartphone, it may include... Figure 6 The components within the dashed box; if the electronic device in this embodiment is implemented as a conventional server, cloud server, or server array, etc., it may be omitted. Figure 6 The component within the dashed box.
[0146] For a detailed description of the implementation process of each action by the processor, please refer to the relevant descriptions in the foregoing method embodiments or device embodiments, which will not be repeated here.
[0147] Accordingly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed, can implement the steps that can be performed by an electronic device in the above method embodiments.
[0148] Accordingly, this application also provides a computer program product, including a computer program / instructions, which, when executed by a processor, enables the processor to perform the steps that can be executed by an electronic device in the above method embodiments.
[0149] The aforementioned communication components are configured to facilitate wired or wireless communication between the device containing the communication components and other devices. The device containing the communication components can access wireless networks based on communication standards, such as WiFi (Wireless Fidelity), 2G (2nd Generation), 3G (3rd Generation), 4G (4th Generation) / LTE (long Term Evolution), 5G (5th Generation), or combinations thereof. In one exemplary embodiment, the communication components receive broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication components also include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra Wide Band (UWB), Bluetooth, and other technologies.
[0150] The aforementioned display includes a screen, which may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a Touch Panel, the screen can be implemented as a touchscreen to receive input signals from the user. The Touch Panel includes one or more touch sensors to sense touches, swipes, and gestures on the Touch Panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also the duration and pressure associated with the touch or swipe operation.
[0151] The aforementioned power supply components provide power to various components within the device in which they reside. These power supply components may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device in which they reside.
[0152] The aforementioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) configured to receive external audio signals when the device containing the audio component is in an operating mode, such as call mode, recording mode, or voice recognition mode. The received audio signals can be further stored in memory or transmitted via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0153] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0154] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0155] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0156] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0157] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.
[0158] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0159] Computer-readable media, including both permanent and non-permanent, removable and non-removable media, can store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change RAM (PRAM), static random-access memory (SRAM), dynamic random-access memory (DRAM), other types of random-access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device. As defined in this article, computer-readable media do not include transient media, such as modulated data signals and carrier waves.
[0160] It should also be noted that 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 process, method, article, or apparatus. Unless otherwise specified, 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 that element.
[0161] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.
Claims
1. A method for bidirectional database synchronization, characterized in that, include: A forward synchronization link is established between a first database instance and a second database instance, wherein the first database instance is a first source database instance and the second database instance is a first destination database instance. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier. Based on the forward synchronization object information, a forward full synchronization task is initiated and executed. The forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object. The first source object is the object corresponding to the first source object identifier, and the first destination object is the object corresponding to the first destination object identifier. A reverse synchronization link is established between the first database instance and the second database instance, where the second database instance is the second source database instance and the first database instance is the second destination database instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source database instance and a second destination object identifier of the second destination database instance corresponding to the second source object identifier. The reverse synchronization object information is filtered based on the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier. Based on the remaining reverse synchronization object information, a reverse full synchronization task is initiated. The reverse full synchronization task is used to perform full synchronization between the remaining second source object and its corresponding remaining second destination object. The remaining second source object is the object corresponding to the remaining second source object identifier, and the remaining second destination object is the object corresponding to the remaining second destination object identifier.
2. The method according to claim 1, characterized in that, Based on the aforementioned forward synchronization object information, initiate and execute a forward full synchronization task, including: A query statement for the first source object is constructed based on the first source object identifier, and the query statement for the first source object is executed in the database where the first source object is located to obtain the full data in the first source object. Based on the full data in the first source object and the first destination object identifier corresponding to the first source object identifier, an insert statement for the first destination object is constructed, and the insert statement for the first destination object is executed in the database where the first destination object is located, so as to insert the full data in the first source object into the first destination object.
3. The method according to claim 1, characterized in that, Based on the remaining reverse synchronization object information, initiate the execution of a reverse full synchronization task, including: A query statement for the remaining second source object is constructed based on the identifier of the remaining second source object, and the query statement for the remaining second source object is executed in the database where the remaining second source object is located to obtain the full data in the remaining second source object; Based on the full data in the remaining second source object and the remaining second destination object identifier corresponding to the remaining second source object identifier, an insert statement for the remaining second destination object is constructed, and the insert statement for the remaining second destination object is executed in the database where the remaining second destination object is located, so as to insert the full data in the remaining second source object into the remaining second destination object.
4. The method according to any one of claims 1 to 3, characterized in that, After initiating the forward full synchronization task or the reverse full synchronization task, the following steps are also included: In response to the fulfillment of preset triggering conditions, check whether a new first database update event has been added to the binary log (binlog) file of the source database instance; If a first database update event is detected, then the first database update event is parsed; If a first system table change statement is parsed from the first database update event, the first database update event is discarded to prevent the execution of incremental synchronization tasks between the third source object in the source database instance and the corresponding third destination object in the destination database instance. The first system table change statement is used to indicate that the incremental data of the third source object in the source database instance comes from database synchronization.
5. The method according to claim 4, characterized in that, Also includes: If no first system table change statement is parsed from the first database update event, and a first function table change statement associated with the third source object is parsed from the first database update event, then a second function table change statement and a second system table change statement are constructed. The second function table change statement is used to perform incremental synchronization between the third source object and its corresponding third destination object. The change operation of the first function table change statement on the third source object is the same as the change operation of the second function table change statement on the third destination object. The second system table change statement is used to change the first system table corresponding to the first destination function table associated with the third destination object. Execute the second system table modification statement and the second function table modification statement in the target library instance where the third target object is located, and add a second database update event to the binlog file of the target library instance. The second database update event is used to record the second system table modification statement and the second function table modification statement.
6. The method according to claim 5, characterized in that, The first database change statement in the second database update event record is the second system table change statement; the first database change statement in the event parsing result of the first database update event is the first system table change statement.
7. The method according to claim 5, characterized in that, Construct the second system table change statement, including: Based on the table name of the first purpose function table and the association between the table name of the purpose function table and the table name of the system table, determine the table name of the first system table associated with the first purpose function table. Create a change statement for the second system table based on the table name of the first system table.
8. The method according to claim 7, characterized in that, Create a change statement for the second system table based on the table name of the first system table, including: If the first system table needs to be modified for the first time, then create a second system table modification statement of type INSERT based on the table name of the first system table; If this is not the first time the first system table needs to be modified, then create a second system table modification statement of type update statement based on the table name of the first system table.
9. The method according to claim 7, characterized in that, Before determining the table name of the first system table associated with the first purpose function table, the process also includes: Create at least one system table in the target library where the third target object is located, and each system table has an initial table name; The target function tables in the target library are labeled, and the label of the system table corresponding to the target function table is determined according to the label of the target function table and the number of system tables; For the system table corresponding to the target function table, add the system table's label to the end of the initial table name of the system table to obtain the table name of the system table corresponding to the target function table. Based on the table name of the target function table and the table name of the corresponding system table, establish and store the association between the table name of the target function table and the table name of the system table.
10. The method according to claim 9, characterized in that, Based on the index of the target function table and the number of system tables, determine the index of the system table corresponding to the target function table, including at least one of the following: The number of the system table corresponding to the target function table is obtained by performing a modulo operation on the number of the target function table and the number of the system table. Subtract the number of the target function table from the number of the system tables to obtain the number of the system table corresponding to the target function table; The label of the target function table and the number of the system tables are added together to obtain the label of the system table corresponding to the target function table.
11. A bidirectional database synchronization system, characterized in that, include: Client, data transmission service, first database instance, and second database instance; The client is used to respond to the user's configuration operation, obtain and send link configuration information to the data transmission service. The link configuration information includes forward synchronization object information of the forward synchronization link and reverse synchronization object information of the reverse synchronization link. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source library instance and a first destination object identifier of the first destination library instance corresponding to the first source object identifier. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source library instance and a second destination object identifier of the second destination library instance corresponding to the second source object identifier. The data transmission service is used to establish a forward synchronization link between a first database instance and a second database instance, where the first database instance is a first source database instance and the second database instance is a first destination database instance. The forward synchronization object information of the forward synchronization link includes: at least one first source object identifier of the first source database instance and a first destination object identifier of the first destination database instance corresponding to the first source object identifier. Based on the forward synchronization object information, a forward full synchronization task is initiated and executed. The forward full synchronization task is used to perform full synchronization between the first source object and its corresponding first destination object, where the first source object is the object corresponding to the first source object identifier and the first destination object is the object corresponding to the first destination object identifier. A reverse synchronization link is established between the first database instance and the second database instance, where the second database instance is a second source database instance and the first database instance is a second source database instance. The instance is a second destination library instance. The reverse synchronization object information of the reverse synchronization link includes: at least one second source object identifier of the second source library instance and a second destination object identifier of the second destination library instance corresponding to the second source object identifier. The reverse synchronization object information is filtered according to the forward synchronization object information to obtain the remaining reverse synchronization object information. The remaining reverse synchronization object information includes at least one remaining second source object identifier and a remaining second destination object identifier corresponding to the remaining second source object identifier. According to the remaining reverse synchronization object information, a reverse full synchronization task is started. The reverse full synchronization task is used to perform full synchronization between the remaining second source object and its corresponding remaining second destination object. The remaining second source object is the object corresponding to the remaining second source object identifier, and the remaining second destination object is the object corresponding to the remaining second destination object identifier.
12. The system according to claim 11, characterized in that, The data transmission service is also used to: detect whether a first database update event has been added to the binary log (binlog) file of the source database instance in response to the fulfillment of a preset trigger condition; If a first database update event is detected, then the first database update event is parsed; If a first system table change statement is parsed from the first database update event, the first database update event is discarded to prevent the execution of incremental synchronization tasks between the third source object in the source database instance and the corresponding third destination object in the destination database instance. The first system table change statement indicates that the incremental data of the third source object in the source database instance comes from database synchronization.
13. The system according to claim 12, characterized in that, The data transmission service is also used for: If the first system table change statement is not parsed from the first database update event, and if the first function table change statement associated with the third source object is parsed from the first database update event, a second function table change statement and a second system table change statement are constructed. The second function table change statement is used to perform incremental synchronization between the third source object and its corresponding third destination object. The change operation of the first function table change statement on the third source object is the same as the change operation of the second function table change statement on the third destination object. The second system table change statement is used to change the first system table corresponding to the first destination function table associated with the third destination object. Execute the second system table modification statement and the second function table modification statement in the target library instance where the third target object is located, and add a second database update event to the binlog file of the target library instance. The second database update event is used to record the second system table modification statement and the second function table modification statement.
14. An electronic device, characterized in that, include: Memory and processor; The memory is used to store computer programs; The processor is coupled to the memory for executing the computer program to perform the steps of the method according to any one of claims 1-10.
15. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it causes the processor to perform the steps of the method according to any one of claims 1-10.
16. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-10.
Citation Information
Patent Citations
Bidirectional synchronization method and device for heterogeneous database based on token table
CN115145944A
Data migration tool and corresponding computer equipment and storage medium
CN115543958A