Heterogeneous database data synchronization method, device, medium and electronic device

By dynamically allocating incremental data in heterogeneous database systems to multiple write threads and writing them to the target database in parallel, the problem of low incremental data synchronization performance in heterogeneous database systems is solved, and the data loading performance is significantly improved.

CN111984729BActive Publication Date: 2024-09-13CETC JINCANG (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010820904.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-08-14
Publication Date
2024-09-13
Estimated Expiration
2040-08-14

AI Technical Summary

Technical Problem

In a heterogeneous database system environment, how to improve the data warehousing and loading performance of the target database during incremental data synchronization is an urgent problem that needs to be solved.

Method used

By reading data and instruction information from the incremental data file transmitted from the source database, it is determined based on the preset configuration file whether the data involves the association table in the target database. If not, the data is allocated to multiple writing threads to achieve Write to the target database in parallel, dynamically allocate data from unrelated tables to multiple warehousing channels, and write to the target database in parallel.

Benefits of technology

This greatly improves the data writing efficiency of the target database, saves data processing time, and significantly improves the incremental data synchronization performance in a heterogeneous database system environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111984729B
    Figure CN111984729B
Patent Text Reader

Abstract

The present disclosure relates to the field of database technology, and specifically to a heterogeneous database data synchronization method, a heterogeneous database data synchronization device, a computer-readable storage medium, and an electronic device, wherein the method comprises: reading data and indication information from an incremental data file transmitted from a source database; the indication information includes table information indicating that the data is to be written; determining whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information; when it is determined that the data does not involve the association relationship table, allocating the data to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to each of the multiple data read write the data to the target database in parallel. The implementation scheme of the present disclosure can improve the data warehousing and loading performance of the target database when synchronizing data in a heterogeneous database system environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present disclosure relate to the field of database technology, and in particular to a heterogeneous database data synchronization method, a heterogeneous database data synchronization device, and a computer-readable storage medium and an electronic device for implementing the heterogeneous database data synchronization method. Background Art

[0002] With the continuous development of computer network technology, database synchronization technology, as a method to maintain data consistency between various database nodes, has become a key technology to ensure system performance and improve system reliability.

[0003] For heterogeneous database systems, data synchronization tools can be used to synchronize data, which can usually include three stages: the first stage is to initialize the loading of existing data to obtain the basic point for data synchronization; the second stage is to synchronize incremental data based on the synchronization basic point established by the initial data loading; the third stage is to regularly compare and verify the data of the source database and the target database for data synchronization to confirm that no data is lost during the data synchronization process. In the second stage of incremental data synchronization, the main performance indicators considered include maximum delay and maximum throughput. Among them, the maximum delay refers to the interval after the source database adds new data to be transmitted to the target database. The maximum throughput refers to how long it takes for the synchronization software tool to synchronize the accumulated source database data to the target database after a large number of log files are pre-accumulated on the source database side.

[0004] In order to improve data synchronization performance, these two performance indicators can be optimized, for example, the parsing speed of incremental data on the source database side can be increased, the data transmission speed can be increased, and the data loading speed of the target database can be increased. However, when synchronizing incremental data in a heterogeneous database system environment, how to improve the data loading performance of the target database is an urgent problem to be solved. Summary of the invention

[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a heterogeneous database data synchronization method, a heterogeneous database data synchronization device, and a computer-readable storage medium and an electronic device for implementing the heterogeneous database data synchronization method.

[0006] In a first aspect, an embodiment of the present disclosure provides a method for synchronizing data in a heterogeneous database, including:

[0007] Reading data and indication information from the incremental data file transmitted from the source database; the indication information includes table information indicating the data to be written;

[0008] Determine whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information;

[0009] When it is determined that the data does not involve the association relationship table, the data is distributed to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the multiple data read respectively write the data into the target database in parallel.

[0010] In some embodiments of the present disclosure, the preset configuration file is pre-set with a correspondence between table information of different tables in the target database and corresponding write thread identifiers;

[0011] The allocating the data to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information comprises:

[0012] Determine a write thread identifier corresponding to the data based on the table information to which the data is to be written in the indication information and the corresponding relationship;

[0013] Based on the write thread identifier corresponding to the data, the data is distributed to a designated write thread indicated by the write thread identifier corresponding to the data.

[0014] In some embodiments of the present disclosure, the preset configuration file further includes a preset data allocation strategy, which indicates allocating data among multiple writing threads based on a preset polling algorithm;

[0015] The allocating the data to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information comprises:

[0016] Based on the table information to which the data is to be written in the indication information and the corresponding relationship, determining whether the table to which the data is to be written is a first preset data table; the first preset data table is at least one table involved in the corresponding relationship;

[0017] When it is determined that the first preset data table is not present, allocating the data to a designated writing thread among a plurality of writing threads based on the preset data allocation strategy;

[0018] When it is determined that it is the first preset data table, the data is distributed to a designated writing thread among multiple writing threads based on the corresponding relationship and the indication information.

[0019] In some embodiments of the present disclosure, the preset configuration file further includes table information of an association relationship table; and determining whether the data involves an association relationship table in a target database based on the preset configuration file and the indication information includes:

[0020] Obtaining table information of the association relationship table in the preset configuration file;

[0021] Determine whether the table information of the association relationship table is the same as the table information to which the data in the indication information is to be written;

[0022] When it is determined that they are the same, the data relates to an association relationship table in the target database;

[0023] When it is determined that they are different, the data does not involve the association relationship table in the target database.

[0024] In some embodiments of the present disclosure, the preset configuration file further includes a consistency protection strategy, which includes a data allocation rule and a serial execution order when operating the association relationship table; the method further includes:

[0025] When it is determined that the data involves the association relationship table, determining whether all writing threads have finished writing the data;

[0026] When it is determined that all writing threads have finished writing data, the data is distributed to a designated writing thread among the multiple writing threads based on the data distribution rule in the consistency protection strategy;

[0027] Based on the serial execution order in the consistency protection strategy, the designated writing threads corresponding to the data are executed serially to write the data into the association relationship table in the target database.

[0028] In some embodiments of the present disclosure, the data allocation rule includes an allocation rule based on a preset polling algorithm; and / or the table information includes a table name and / or a unique identifier of a table.

[0029] In some embodiments of the present disclosure, before reading data and indication information from the incremental data file transmitted from the source database, the method further includes:

[0030] Initialize and start a read thread and multiple write threads on the target database side;

[0031] Corresponding cache queues are configured for the multiple writing threads respectively, and the multiple writing threads are connected to the target database; wherein the data allocated to each designated writing thread enters the corresponding cache queue.

[0032] In some embodiments of the present disclosure, it further includes:

[0033] The incremental data files transmitted to the target database are stored sequentially in units of transactions;

[0034] The step of reading multiple data from the incremental data file transmitted from the source database includes:

[0035] The reading thread sequentially reads the sequentially stored incremental data files in series to read data.

[0036] In some embodiments of the present disclosure, it further includes:

[0037] The read thread inserts stop instruction data into the cache queue of each of the write threads, and exits the read thread;

[0038] Each of the writing threads exits the writing thread when receiving the stop instruction data, and the data synchronization ends when all threads stop running.

[0039] In a second aspect, an embodiment of the present disclosure provides a heterogeneous database data synchronization device, including:

[0040] A data reading module, used to read data and indication information from an incremental data file transmitted from a source database; the indication information includes table information indicating the data to be written;

[0041] A relationship determination module, used to determine whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information;

[0042] The data processing module is used to determine that the data does not involve the association relationship table, and to distribute the data to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the multiple data read respectively write the data into the target database in parallel.

[0043] In a third aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the heterogeneous database data synchronization method described in any embodiment of the first aspect above.

[0044] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, including:

[0045] Processor; and

[0046] A memory, configured to store executable instructions of the processor;

[0047] Among them, the processor is configured to execute the steps of the heterogeneous database data synchronization method described in any embodiment of the first aspect by executing the executable instructions.

[0048] Compared with the prior art, the technical solution provided by the embodiments of the present disclosure has the following advantages:

[0049] In an embodiment of the present disclosure, data and indication information are first read from an incremental data file transmitted from a source database, the indication information including table information indicating the data to be written; then, based on a preset configuration file and the indication information, it is determined whether the data involves an association relationship table in a target database; when it is determined that the data does not involve the association relationship table, the data is then allocated to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to each of the multiple data read write the data to the target database in parallel. In this way, the essence of the scheme of this embodiment can dynamically allocate incremental data to be written into multiple unrelated target database tables to multiple designated writing threads, i.e., multiple warehousing channels, and then the data can be written into the target database in parallel, which greatly improves the data writing efficiency of the target database and saves data processing time, thereby greatly improving the data warehousing loading performance of the target database when synchronizing incremental data in a heterogeneous database system environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0052] Figure 1 This is a flow chart of a method for synchronizing data in heterogeneous databases according to an embodiment of the present disclosure;

[0053] Figure 2 This is a flow chart of another heterogeneous database data synchronization method according to an embodiment of the present disclosure;

[0054] Figure 3 This is a schematic diagram of an exemplary heterogeneous database system architecture in an embodiment of the present disclosure;

[0055] Figure 4 A schematic diagram of a data synchronization scenario of heterogeneous databases according to an embodiment of the present disclosure;

[0056] Figure 5 A schematic diagram of a heterogeneous database data synchronization device in an embodiment of the present disclosure;

[0057] Figure 6 A schematic diagram of an electronic device for implementing a heterogeneous database data synchronization method in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0058] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.

[0059] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.

[0060] When synchronizing incremental data in a heterogeneous database system environment, for example, in an environment where log files are used to synchronize incremental data in heterogeneous databases, the upper-layer application will not perform data manipulation language DML (Data Manipulation Language) operations on multiple tables in the target database at the same time in a short period of time, such as inserting, deleting, and modifying data in the table. Based on this feature, in the present embodiment, the incremental data to be written into multiple unrelated target database tables can be dynamically allocated to different storage channels to be written into the target database in parallel, so as to minimize the impact on the normal operation of the target database, thereby greatly improving the data storage loading performance of the target database when synchronizing incremental data in a heterogeneous database system environment.

[0061] Figure 1 A flow chart of a heterogeneous database data synchronization method provided by the present disclosure embodiment, referring to Figure 1 As shown in , the data synchronization method may include the following steps:

[0062] Step S102: Read data and indication information from the incremental data file transmitted from the source database. The indication information includes table information indicating the data to be written.

[0063] Step S104: determining whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information.

[0064] Step S106: When it is determined that the data does not involve the association relationship table, the data is distributed to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the multiple data read respectively write the data into the target database in parallel.

[0065] The above-mentioned heterogeneous database data synchronization method of the disclosed embodiment can dynamically allocate the incremental data to be written into multiple unrelated target database tables to multiple designated writing threads, i.e., multiple storage channels. Multiple unrelated target database tables, i.e., multiple data read, do not involve association relationship tables, have no business association relationship, and the writing of each data does not affect the business relationship of each other. Data can be written into the target database in parallel through multiple storage channels, which can minimize the impact on the normal operation of the target database, thereby greatly improving the data writing efficiency of the target database and saving data processing time, thereby greatly improving the data storage loading performance of the target database when synchronizing incremental data in a heterogeneous database system environment.

[0066] In some embodiments of the present disclosure, the source database and the target database are at least part of a heterogeneous database system, and the incremental data file can be transmitted by the source-side data synchronization software on the source database side to the target-side synchronization software on the target database side through a network such as a local area network or a wide area network. Table information may include, but is not limited to, a table name and / or a unique identifier of a table. In this embodiment, the table information may be a table name such as TABLE1, that is, the table information may indicate that the data X1 read, for example, is to be written to a table TABLE1 in the target database. This is not limited in this embodiment and is determined by specific business needs.

[0067] In some embodiments of the present disclosure, before reading data and indication information from the incremental data file transmitted from the source database in step S102, the following steps may also be included:

[0068] Step a): Initialize and start a reading thread and multiple writing threads on the target database side. The reading thread can read data and indication information from the incremental data file.

[0069] Step b): respectively configure corresponding cache queues for the multiple writing threads, and connect the multiple writing threads to the target database. The data assigned to each designated writing thread enters the corresponding cache queue. In this embodiment, based on multiple writing threads and corresponding cache queues, data is loaded in a multi-channel parallel warehousing manner on the target database side, which can improve the data warehousing and loading performance of the target database.

[0070] Optionally, based on the above embodiments, in some embodiments of the present disclosure, the following step c) may be further included: the incremental data files transmitted to the target database are sequentially stored in units of transactions. Accordingly, in step S102, reading multiple data from the incremental data files may specifically include: the reading thread sequentially reads the incremental data files stored sequentially in series to read the data.

[0071] Optionally, in some embodiments of the present disclosure, the preset configuration file may be pre-set with the correspondence between the table information of different tables in the target database and the corresponding write thread identifiers. Exemplarily, multiple write threads are distinguished by different write thread identifiers, and the preset configuration file may pre-configure, for example, the correspondence between table TABLE1, table TABLE2, table TABLE3, table TABLE4, table TABLE5, table TABLE6 and the corresponding write thread identifier 1, write thread identifier 2, write thread identifier 3, write thread identifier 4, write thread identifier 5 and write thread identifier 6. The correspondence shown in Table 1 is only a simple example and is not limited to this in the present embodiment.

[0072] Table 1

[0073] Table information (table name) Write thread ID TABLE 1 1 TABLE 2 2 TABLE 3 3 TABLE 4 4 TABLE 5 5 TABLE 6 6

[0074] Correspondingly, in step S106, allocating data to a specified writing thread among multiple writing threads based on the preset configuration file and the instruction information specifically includes the following steps:

[0075] Based on the table information and the corresponding relationship of the data to be written in the indication information, the write thread identifier corresponding to the data is determined.

[0076] Based on the write thread identifier corresponding to the data, the data is distributed to the designated write thread indicated by the write thread identifier corresponding to the data.

[0077] Specifically, as an example, for example, if the indication information indicates that data X1 is to be written into table TABLE1 in the target database, based on the above correspondence relationship of the example, it can be determined by looking up the table that the write thread identifier corresponding to TABLE1 is 1, so that data X1 can be distributed to the cache queue of the designated write thread indicated by write thread identifier 1. For another example, if the indication information indicates that data X2, X3, and X4 are all to be written into table TABLE2 in the target database, based on the correspondence relationship, it can be determined by looking up the table that the corresponding subsequent operations of writing data X2, X3, and X4 are all executed by the designated thread indicated by write thread identifier 2, that is, data X2, X3, and X4 can be distributed to the cache queue of the designated write thread indicated by write thread identifier 2.

[0078] The reading thread can read multiple data in the incremental data file and repeat the above allocation process. At the same time, the designated writing threads corresponding to each data obtain data from their respective cache queues and encapsulate them into SQL statements for execution in the target database to be written in parallel to the target database. In this way, the incremental data to be written into multiple unrelated target database tables can be dynamically allocated to multiple designated writing threads, that is, multiple storage channels. The data can be written into the target database in parallel through multiple storage channels, which can minimize the impact on the normal operation of the target database, thereby greatly improving the data writing efficiency of the target database and saving data processing time, thereby greatly improving the data storage loading performance of the target database when synchronizing incremental data in a heterogeneous database system environment.

[0079] In this embodiment, the operations such as write operations for different tables in the target database can be preset through the preset configuration file. The tables that need to be configured with the corresponding designated write threads can be set according to the needs of the upper layer application. The preset configuration file can be pre-configured or updated, etc., and can be configured or updated according to the application scenario. In this way, the functions are enriched when synchronizing heterogeneous databases, and different scenarios can be applied, with better applicability.

[0080] Optionally, based on any of the above embodiments, in other embodiments of the present disclosure, the preset configuration file may further include a preset data allocation strategy, which indicates that data is allocated between multiple write threads based on a preset polling algorithm. Exemplarily, the preset polling algorithm may be a Round-robin algorithm, but is not limited thereto. Accordingly, allocating data to a specified write thread among multiple write threads based on the preset configuration file and the indication information may specifically include the following steps:

[0081] Step i): Based on the table information of the data to be written in the indication information and the corresponding relationship, determine whether the table to be written is a first preset data table; the first preset data table is at least one table involved in the corresponding relationship.

[0082] For example, if the corresponding relationship shown in Table 2 involves Table 1, Table 2, Table 3, Table 4, Table 5, and Table 6, these tables may be first preset data tables. If the table information indicating that data X5 is to be written to is Table 7 in the indication information, it can be determined that Table 7 is not the first preset data table specified above.

[0083] Step ii): when it is determined that the data table is not the first preset data table, the data is allocated to a designated writing thread among a plurality of writing threads based on the preset data allocation strategy.

[0084] Exemplarily, since table TABLE7 is not the first preset data table specified above, then for operations on table TABLE7, i.e., other tables, the preset configuration file may be configured with a corresponding preset data allocation strategy, such as a dynamic allocation strategy based on a Round-robin algorithm, etc. Therefore, when it is determined that table TABLE7 is not the first preset data table specified above, the data X5 is allocated to a specified write thread among multiple write threads based on a dynamic allocation strategy, such as a Round-robin algorithm.

[0085] Step iii): when it is determined that it is the first preset data table, the data is distributed to a designated writing thread among a plurality of writing threads based on the corresponding relationship and the indication information.

[0086] Exemplarily, it is determined that Table TABLE7 is the first preset data table specified above, that is, the correspondence relationship can also be pre-configured with a write thread identifier 7 corresponding to Table TABLE7. At this time, the above-mentioned correspondence relationship and indication information can be returned to allocate data X5 to the cache queue of the specified write thread indicated by the write thread identifier 7 among multiple write threads. The specific process can refer to the specific allocation process of the above-mentioned data such as X1, X2, X3 and X4, which will not be repeated here.

[0087] Optionally, based on any of the above embodiments, in some embodiments of the present disclosure, the preset configuration file may further include table information of an association table. An association table represents at least two tables with business dependencies or associations. For example, data X6 involves association tables TABLE8 and TABLE9, indicating that data X6 needs to be written into tables TABLE8 and TABLE9 in the target database in sequence according to, for example, business dependencies. Of course, this is not limited to this. In this embodiment, the preset configuration file may set table information of the association table such as table names TABLE8 and TABLE9. Accordingly, in step S104, determining whether the data involves an association table in the target database based on the preset configuration file and the indication information may specifically include the following steps:

[0088] Obtain table information of the association relationship table in the preset configuration file.

[0089] Determine whether the table information of the association table is the same as the table information to be written into the data in the indication information; if they are the same, the data involves the association table in the target database; if they are different, the data does not involve the association table in the target database.

[0090] Specifically, as an example, the table information of the association table in the preset configuration file can be obtained, such as table TABLE8 and table TABLE9. If the table information to be written by the data X6 indicated by the indication information includes the associated table TABLE8 and table TABLE9, it can be determined that the two table information are the same, that is, the data X6 indicated by the indication information is to be written into the associated table TABLE8 and table TABLE9.

[0091] Optionally, based on the above embodiments, in some embodiments of the present disclosure, the preset configuration file may further include a consistency protection strategy, which may include but is not limited to data allocation rules and serial execution order when operating on association relationship tables. For example, when operations involving associated tables TABLE8 and TABLE9 are involved, the consistency protection strategy may be activated, and the preset configuration file may pre-set data allocation rules and serial execution order when operating on tables TABLE8 and TABLE9. Exemplarily, in some embodiments of the present disclosure, the data allocation rules may include but are not limited to allocation rules based on preset polling algorithms, such as allocation rules based on Round-robin algorithms. The serial execution order, for example, operates on table TABLE8 first and then on table TABLE9, but is not limited to this, and may be specifically configured according to business relationships, etc. Accordingly, in combination with Figure 2 As shown in , in some embodiments of the present disclosure, the method may further include the following steps:

[0092] Step S102: Read data and indication information from the incremental data file transmitted from the source database. The indication information includes table information indicating the data to be written.

[0093] Step S104: determining whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information.

[0094] It can be understood that, regarding step S102 and step S104, reference may be made to the description in the aforementioned embodiment, and no further details will be given here.

[0095] Step S201: when it is determined that the data involves the association relationship table, it is determined whether all writing threads have finished writing the data.

[0096] Exemplary, for example, it is determined that data X6 involves association table TABLE8 and table TABLE9. At this time, it is determined whether all current writing threads have finished writing data, for example, the cache queues corresponding to multiple writing threads are continuously polled. When the cache queues of all writing threads become empty, it is determined that all writing threads have finished writing data. When the cache queue of at least one writing thread is not empty, it is determined that all writing threads have not finished writing data. That is, when operating on these specific association tables such as table TABLE8 and table TABLE9, it is necessary to wait until the previous transaction operation is completed, such as after all writing threads have finished writing data, before starting to execute operations on table TABLE8 and table TABLE9.

[0097] Step S202: when it is determined that all writing threads have finished writing data, the data is distributed to a designated writing thread among the multiple writing threads based on the data distribution rule in the consistency protection strategy.

[0098] Exemplarily, when it is determined that all writing threads have finished writing data, the data X6 is distributed to a cache queue corresponding to a designated writing thread among the multiple writing threads based on, for example, a Round-robin algorithm.

[0099] Step S203: Based on the serial execution order in the consistency protection strategy, the designated writing thread corresponding to the data is executed serially to write the data into the association relationship table in the target database.

[0100] For example, after data X6 is allocated, the corresponding designated writing thread obtains data from the cache queue, writes it into table TABLE8 first, and then writes it into table TABLE9. At the same time, the cache queue of the designated writing thread can be continuously queried. When the cache queue is empty, that is, data X6 has been written into the target database, the multi-channel parallel data distribution working mode before encountering the specific data X6 can be restored.

[0101] The embodiment of the present disclosure proposes a consistency protection strategy, that is, the concept of a strong consistency block, which allows the consistency protection strategy mode to be activated when operating on certain association relationship tables: that is, when certain specific data needs to be operated on these specific tables, it is necessary to wait for the previous transaction operation to be completed, and then serialize the DML for these tables. After completing the DML for these tables, it can be restored to the multi-channel parallel warehousing synchronization form in the above embodiment, so as to greatly improve the data warehousing and loading performance of the target database end during the database synchronization process.

[0102] When the entire data synchronization needs to be stopped, in order to reduce the impact on the system, based on any of the above embodiments, some embodiments of the present disclosure may further include the following steps:

[0103] The read thread inserts stop instruction data into the cache queue of each of the write threads, and exits the read thread.

[0104] Each of the writing threads exits the writing thread when receiving the stop instruction data, and the data synchronization ends when all threads stop running.

[0105] Exemplarily, the read thread can insert an empty data with the instruction STOP into the cache queue of each write thread and exit its own thread; when each write thread receives the empty data with the instruction STOP, it also exits its own thread; when all threads are stopped, the entire system stops. In this embodiment, when data synchronization needs to be stopped, all threads are not immediately forcibly closed, but the read thread inserts the stop instruction data into the cache queue of each write thread and then exits its own thread, and each write thread exits the write thread when it receives the stop instruction data. This method can reduce the impact on the database system, avoid the occurrence of some unknown faults or errors, and improve system reliability.

[0106] Combined with reference Figure 3 and Figure 4 As shown in , in a specific application scenario, the heterogeneous database data synchronization method can be executed by a target-side synchronization program and can include the following steps:

[0107] Step 1): Initialize a read thread and N write threads on the target database side, establish cache queues corresponding to the N write threads respectively, and connect the N write threads to the target database.

[0108] Step 2): The reading thread synchronizes the data from the source software such as Figure 3 The source-side synchronization program shown continuously reads data from the incremental data file transmitted from the source database, and based on a preset configuration file, allocates different data records to cache queues corresponding to different or non-identical write threads.

[0109] The following Table 2 is a simple example of a preset configuration file, but the present embodiment is not limited thereto.

[0110] Table 2

[0111]

[0112] In the example of the preset configuration file, operations on table TABLE1 are fixedly distributed to the cache queue corresponding to write thread 0; operations on table TABLE2 are fixedly distributed to the cache queue corresponding to write thread 1; operations on TABLE3, TABLE4, and TABLE5 are fixedly distributed to the cache queue corresponding to write thread 2. For other tables, i.e. tables marked with *, the Round-robin algorithm (marker parameter -1) is used for polling distribution. For operations on association tables, i.e. important (critical) tables TABLE6 and TABLE7, the strong consistency block mode, i.e. consistency protection strategy mode, is used.

[0113] Step 3): The writing threads are responsible for obtaining incremental data records from their respective cache queues, encapsulating them into SQL statements, and executing them in the target database to write data in parallel.

[0114] When a reader thread reads incremental data with a distribution strategy configured as -1 from an incremental data file, it uses the Round-robin algorithm to distribute it among N writer threads.

[0115] When the reader thread reads an incremental data configured as critical from the incremental data file, it continuously polls the cache queues of N writer threads. When the cache queues of all writer threads become empty, the reader thread puts the current critical incremental data into the cache queue corresponding to the writer thread determined by the algorithm according to the Round-robin algorithm, and continuously queries the cache queue of the writer thread. When the cache queue is empty, that is, the data has been written to the target database, it resumes to the parallel distribution working mode before encountering the critical incremental data.

[0116] When the entire system needs to stop, the read thread inserts an empty data with the instruction STOP into the cache queue of each write thread and exits its own thread; when each write thread receives the empty data with the instruction STOP, it also exits its own thread; when all threads stop, the entire system stops.

[0117] This embodiment uses the fact that the upper-layer application will not perform DML operations on multiple tables at the same time in a short period of time, and dynamically allocates the incremental data of multiple unrelated database tables to different storage channels and writes them into the database in parallel, so as to achieve the purpose of accelerating the performance of loading data into the target database. At the same time, this embodiment also proposes concepts such as preset configuration files and strong consistency blocks, allowing end users to configure them according to actual application scenarios, with good applicability and scalability.

[0118] It should be noted that, although the steps of the method in the present disclosure are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step for execution, and / or one step may be decomposed into multiple steps for execution, etc. In addition, it is also easy to understand that these steps may be, for example, executed synchronously or asynchronously in multiple modules / processes / threads.

[0119] Based on the same concept, the present disclosure also provides a heterogeneous database data synchronization device, referring to Figure 5 As shown in , the heterogeneous database data synchronization device 50 may include:

[0120] The data reading module 501 is used to read data and indication information from the incremental data file transmitted from the source database; the indication information includes table information indicating the data to be written.

[0121] The relationship determination module 502 is used to determine whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information.

[0122] The data processing module 503 is used to determine that the data does not involve the association relationship table, and then distribute the data to a designated writing thread among multiple writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the multiple data read respectively write the data into the target database in parallel.

[0123] Optionally, in some embodiments of the present disclosure, the preset configuration file may be pre-set with a correspondence between table information of different tables in the target database and corresponding write thread identifiers. The data processing module 503 distributes the data to a specified write thread among multiple write threads based on the preset configuration file and the indication information, which may specifically include: determining the write thread identifier corresponding to the data based on the table information to be written by the data in the indication information and the correspondence; and distributing the data to the specified write thread indicated by the write thread identifier corresponding to the data based on the write thread identifier corresponding to the data.

[0124] Optionally, in some embodiments of the present disclosure, the preset configuration file may further include a preset data allocation strategy, which may indicate that data is allocated between multiple write threads based on a preset polling algorithm. The data processing module 503 allocates the data to a specified write thread among the multiple write threads based on the preset configuration file and the indication information, which may specifically include:

[0125] Based on the table information to which the data is to be written in the indication information and the corresponding relationship, determining whether the table to which the data is to be written is a first preset data table; the first preset data table is at least one table involved in the corresponding relationship;

[0126] When it is determined that the first preset data table is not present, allocating the data to a designated writing thread among a plurality of writing threads based on the preset data allocation strategy;

[0127] When it is determined that it is the first preset data table, the data is distributed to a designated writing thread among multiple writing threads based on the corresponding relationship and the indication information.

[0128] Optionally, in some embodiments of the present disclosure, the preset configuration file may also include table information of an association relationship table. The relationship determination module 502 determines whether the data involves an association relationship table in the target database based on the preset configuration file and the indication information, which may specifically include:

[0129] Obtaining table information of the association relationship table in the preset configuration file;

[0130] Determine whether the table information of the association relationship table is the same as the table information to which the data in the indication information is to be written;

[0131] When it is determined that they are the same, the data relates to an association relationship table in the target database;

[0132] When it is determined that they are different, the data does not involve the association relationship table in the target database.

[0133] Optionally, in some embodiments of the present disclosure, the preset configuration file may further include a consistency protection strategy, which may include data allocation rules and serial execution order when operating on the association table; the data synchronization device may further include a consistency protection module, which is used to: when it is determined that the data involves the association table, determine whether all writing threads have finished writing the data; when it is determined that all writing threads have finished writing the data, allocate the data to a specified writing thread among multiple writing threads based on the data allocation rules in the consistency protection strategy; based on the serial execution order in the consistency protection strategy, execute the specified writing thread corresponding to the data serially to write the data into the association table in the target database.

[0134] Optionally, in some embodiments of the present disclosure, the data allocation rule may include an allocation rule based on a preset polling algorithm. In some embodiments of the present disclosure, the table information may include but is not limited to a table name and / or a unique identifier of a table.

[0135] Optionally, in some embodiments of the present disclosure, a thread initialization module may also be included, which is used to initialize and start a reading thread and multiple writing threads on the target database side before reading data and indication information from the incremental data file received from the target database; configure corresponding cache queues for the multiple writing threads respectively, and connect the multiple writing threads to the target database; wherein the data allocated to each designated writing thread enters the corresponding cache queue.

[0136] Optionally, in some embodiments of the present disclosure, a file storage module may be further included to sequentially store the incremental data files transmitted to the target database in units of transactions. The data reading module 501 is also used to enable the reading thread to sequentially read the incremental data files stored sequentially in series to read data.

[0137] Optionally, in some embodiments of the present disclosure, an end synchronization module may also be included, which is used to enable the read thread to insert stop instruction data into the cache queue of each of the write threads and exit the read thread; each of the write threads exits the write thread when receiving the stop instruction data, and data synchronization is ended when all threads stop running.

[0138] Regarding the device in the above embodiment, the specific manner in which each module performs operations and the corresponding technical effects brought about have been described in detail in the embodiment of the method, and will not be elaborated here.

[0139] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiment of the present disclosure, the features and functions of two or more modules or units described above can be concretized in one module or unit. Conversely, the features and functions of a module or unit described above can be further divided into multiple modules or units for concretization. The components displayed as modules or units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed scheme. Those of ordinary skill in the art can understand and implement it without paying creative work.

[0140] The embodiments of the present disclosure further provide a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the heterogeneous database data synchronization method described in any of the above embodiments are implemented.

[0141] Exemplarily, the readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0142] The computer readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by an instruction execution system, an apparatus, or a device or used in combination with it. The program code contained on the readable storage medium may be transmitted with any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0143] The present disclosure also provides an electronic device, including a processor and a memory, wherein the memory is used to store executable instructions of the processor, wherein the processor is configured to execute the steps of the heterogeneous database data synchronization method described in any of the above embodiments by executing the executable instructions.

[0144] Refer to the following Figure 6 The electronic device 600 according to this embodiment of the present invention is described. Figure 6 The electronic device 600 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0145] like Figure 6 As shown, the electronic device 600 is in the form of a general computing device. The components of the electronic device 600 may include, but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.

[0146] The storage unit stores program codes, which can be executed by the processing unit 610, so that the processing unit 610 executes the steps of various exemplary embodiments of the present invention described in the above heterogeneous database data synchronization method section of this specification. For example, the processing unit 610 can execute the following steps: Figure 1 The steps of the method shown in .

[0147] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202 , and may further include a read-only memory unit (ROM) 6203 .

[0148] The storage unit 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205, such program modules 6205 including but not limited to: an operating system, one or more application programs, other program modules and program data, each of which or some combination may include the implementation of a network environment.

[0149] Bus 630 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.

[0150] The electronic device 600 may also communicate with one or more external devices 700 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 600, and / or communicate with any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 via a bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0151] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above-mentioned heterogeneous database data synchronization method according to the implementation of the present disclosure.

[0152] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0153] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for synchronizing data in heterogeneous databases, characterized in that: include: Read data and instruction information from the incremental data file transferred from the source database; The indication information includes table information indicating the data to be written; Determine whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information; When it is determined that the data does not involve the association relationship table, the data is distributed to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the plurality of data read respectively write the data into the target database in parallel; The preset configuration file includes table information of an association table and a consistency protection strategy; the association table represents at least two tables having a business dependency or association relationship, and the consistency protection strategy includes a data allocation rule and a serial execution order when operating the association table; The method further comprises: when determining that the data involves the association relationship table, determining whether all writing threads have finished writing the data; When it is determined that all writing threads have finished writing data, the data is distributed to a designated writing thread among the multiple writing threads based on the data distribution rule in the consistency protection strategy; Based on the serial execution order in the consistency protection strategy, the designated write thread corresponding to the data is executed serially to write the data into the association relationship table in the target database; The preset configuration file is pre-set with a correspondence between table information of different tables in the target database and corresponding write thread identifiers; the preset configuration file also includes a preset data allocation strategy, which indicates that data is allocated among multiple write threads based on a preset polling algorithm; The allocating the data to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information comprises: Based on the table information to which the data is to be written in the indication information and the corresponding relationship, determining whether the table to which the data is to be written is a first preset data table; the first preset data table is at least one table involved in the corresponding relationship; When it is determined that the first preset data table is not present, allocating the data to a designated writing thread among a plurality of writing threads based on the preset data allocation strategy; When it is determined that it is the first preset data table, the data is distributed to a designated writing thread among multiple writing threads based on the corresponding relationship and the indication information.

2. The data synchronization method according to claim 1, characterized in that: The allocating the data to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information comprises: Determine a write thread identifier corresponding to the data based on the table information to which the data is to be written in the indication information and the corresponding relationship; Based on the write thread identifier corresponding to the data, the data is distributed to a designated write thread indicated by the write thread identifier corresponding to the data.

3. The data synchronization method according to any one of claims 1 to 2, characterized in that: The determining, based on the preset configuration file and the indication information, whether the data involves an association relationship table in a target database includes: Obtaining table information of the association relationship table in the preset configuration file; Determine whether the table information of the association relationship table is the same as the table information to which the data in the indication information is to be written; When it is determined that they are the same, the data relates to an association relationship table in the target database; When it is determined that they are different, the data does not involve the association relationship table in the target database.

4. The data synchronization method according to claim 1, characterized in that: The data allocation rule includes an allocation rule based on a preset polling algorithm; and / or the table information includes a table name and / or a unique identifier of a table.

5. The data synchronization method according to claim 1, characterized in that: Before reading the data and indication information from the incremental data file transmitted from the source database, the method further includes: Initialize and start a read thread and multiple write threads on the target database side; Corresponding cache queues are configured for the multiple writing threads respectively, and the multiple writing threads are connected to the target database; wherein the data allocated to each designated writing thread enters the corresponding cache queue.

6. The data synchronization method according to claim 5, characterized in that: Also includes: The incremental data files transmitted to the target database are stored sequentially in units of transactions; The step of reading multiple data from the incremental data file transmitted from the source database includes: The reading thread sequentially reads the sequentially stored incremental data files in series to read data.

7. The data synchronization method according to claim 5, characterized in that: Also includes: The read thread inserts stop instruction data into the cache queue of each of the write threads, and exits the read thread; Each of the writing threads exits the writing thread when receiving the stop instruction data, and the data synchronization ends when all threads stop running.

8. A heterogeneous database data synchronization device, characterized in that: include: A data reading module is used to read data and indication information from the incremental data file transmitted from the source database; The indication information includes table information indicating the data to be written; A relationship determination module, used to determine whether the data involves an association relationship table in a target database based on a preset configuration file and the indication information; a data processing module, configured to, when determining that the data does not involve the association relationship table, distribute the data to a designated writing thread among a plurality of writing threads based on the preset configuration file and the indication information, so that the designated writing threads corresponding to the plurality of data read respectively write the data into the target database in parallel; The preset configuration file includes table information of an association table and a consistency protection strategy; the association table represents at least two tables having a business dependency or association relationship, and the consistency protection strategy includes a data allocation rule and a serial execution order when operating the association table; The data synchronization device includes a consistency protection module, which is used to: determine whether all writing threads have finished writing data when it is determined that the data involves the association relationship table; when it is determined that all writing threads have finished writing data, distribute the data to a designated writing thread among multiple writing threads based on the data distribution rule in the consistency protection strategy; and make the designated writing thread corresponding to the data execute serially based on the serial execution order in the consistency protection strategy, so as to write the data into the association relationship table in the target database; The preset configuration file is pre-set with a correspondence between table information of different tables in the target database and corresponding write thread identifiers; the preset configuration file also includes a preset data allocation strategy, which indicates that data is allocated among multiple write threads based on a preset polling algorithm; The data processing module is used to determine whether the table to be written by the data is a first preset data table based on the table information to be written by the data in the indication information and the corresponding relationship; the first preset data table is at least one table involved in the corresponding relationship; When it is determined that the first preset data table is not present, allocating the data to a designated writing thread among a plurality of writing threads based on the preset data allocation strategy; When it is determined that it is the first preset data table, the data is distributed to a designated writing thread among multiple writing threads based on the corresponding relationship and the indication information.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the heterogeneous database data synchronization method described in any one of claims 1 to 7 are implemented.

10. An electronic device, characterized in that: include: processor; as well as A memory, configured to store executable instructions of the processor; Wherein, the processor is configured to execute the steps of the heterogeneous database data synchronization method according to any one of claims 1 to 7 by executing the executable instructions.