Database-based data synchronization method and device, medium, equipment and product

By executing DDL-type target statements in the database, writing data synchronization sites to the log file, and finding and using these sites when the breakpoint is continued, the problem of site failure during master-slave database switching is solved, ensuring the data Consistency and integrity, suitable for all MySQL versions.

CN119415598AActive Publication Date: 2025-02-11BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411535621.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-11
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

In the master-slave database switching scenario, physical sites based on binary file names and offsets are invalid. Lower versions of MySQL do not support logical sites based on GTID/GTIDSet, resulting in data synchronization sites that cannot be effectively recorded and restored.

Method used

By executing a target statement of the Data Definition Language (DDL) type with the current data synchronization site in the database, the current data synchronization site is written to the database log file, and when the data breakpoint continues, it is transferred from the log file. Find the target data synchronization site in the site and perform data synchronization based on this site.

Benefits of technology

It realizes effective recording and recovery of data synchronization sites in the master-slave database switching scenario, ensuring data consistency and integrity, and is suitable for various versions of MySQL databases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119415598A_ABST
    Figure CN119415598A_ABST
Patent Text Reader

Abstract

The invention relates to a data synchronization method and device based on a database, a medium, equipment and a product, in particular to the technical field of data transmission, and the method comprises the steps that a target statement which carries a current data synchronization site and belongs to a data definition language type is executed in the database; according to the method, the current data synchronization site is written into the log file of the database through the target statement, the target data synchronization site is searched in the log file of the database during data breakpoint resuming, and then data synchronization is performed based on the target data synchronization site, so that a data fence effect can be achieved; the data synchronization site is prevented from losing efficacy in the scene of switching the master database and the slave database, so that the consistency and the integrity of the data can be guaranteed in the data synchronization process in the scene of switching the master database and the slave database. Moreover, the point burying of the data synchronization site is carried out through the target statement belonging to the data definition language, and various versions of MySQL databases can also be supported.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of data transmission, and in particular, to a method, device, medium, equipment and product for data synchronization based on a database. Background Art

[0002] During the data synchronization process, the currently synchronized location information needs to be continuously recorded. When data synchronization is interrupted due to network problems, system failures, or other reasons, the system needs to be able to detect this and save the current location information. After the interruption problem is resolved, the system will use the previously saved location information to resume data synchronization. Therefore, the recording of location information is crucial for breakpoint resuming.

[0003] In the related art, the sites used by MySQL (a relational database management system) include physical sites based on binary file names and offsets and logical sites based on GTID / GTIDSet. However, in the scenario of master-slave switching, since the physical locations of the master database and the slave database are different, when the master-slave switching is performed, the physical sites based on binary file names and offsets will become invalid. Although the logical sites based on GTID / GTIDSet can solve the problem of site failure in master-slave switching, lower versions of MySQL do not support the use of logical sites based on GTID / GTIDSet. Therefore, there is an urgent need to provide a new data synchronization method that can adapt to various versions of MySQL and can solve the problem of site failure in master-slave switching. Summary of the invention

[0004] This summary is provided to introduce concepts in a brief form that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.

[0005] In a first aspect, the present disclosure provides a data synchronization method based on a database, comprising: Executing a target statement carrying a current data synchronization point in a database, so as to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; When data is resumed from a breakpoint, a target data synchronization point is searched in the log file of the database, and the target data synchronization point is the current data synchronization point recorded when the data synchronization was interrupted last time; Data synchronization is performed based on the target data synchronization site.

[0006] In a second aspect, the present disclosure provides a data synchronization device based on a database, comprising: an execution module, configured to execute a target statement carrying a current data synchronization point in a database, so as to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; A search module is configured to search for a target data synchronization point in the log file of the database when data is resumed after a breakpoint, wherein the target data synchronization point is the current data synchronization point recorded when data synchronization was interrupted last time; The synchronization module is configured to perform data synchronization based on the target data synchronization site.

[0007] In a third aspect, the present disclosure provides a computer-readable medium having a computer program stored thereon, which, when executed by a processing device, implements the steps of the method described in the first aspect.

[0008] In a fourth aspect, the present disclosure provides an electronic device, including: a storage device having a computer program stored thereon; A processing device is used to execute the computer program in the storage device to implement the steps of the method described in the first aspect.

[0009] In a fifth aspect, the present disclosure provides a computer program product, including a computer program, which implements the steps of the method described in the first aspect when executed by a processor.

[0010] Based on the above technical solution, by executing a target statement of a data definition language type that carries the current data synchronization site in the database, the current data synchronization site is written into the database log file through the target statement, and when the data is resumed from a breakpoint, the target data synchronization site is found in the database log file, and then data synchronization is performed based on the target data synchronization site, which can play the role of a data fence and prevent the data synchronization site from failing in the scenario of master-slave database switching, so that in the scenario of master-slave database switching, the consistency and integrity of the data can be guaranteed during the data synchronization process. Moreover, by embedding the data synchronization site through a target statement of a data definition language, various versions of MySQL databases can also be supported.

[0011] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and the originals and elements are not necessarily drawn to scale. In the drawings: Figure 1 The diagram is a flow chart of a database-based data synchronization method according to some embodiments.

[0013] Figure 2 yes Figure 1 A detailed flow chart of step 120 is shown.

[0014] Figure 3 It is a schematic diagram of the structure of a database-based data synchronization device according to some embodiments.

[0015] Figure 4 is a schematic diagram of the structure of an electronic device according to some embodiments. DETAILED DESCRIPTION

[0016] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0017] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0018] The term "including" and its variations used herein are open inclusions, i.e., "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". The relevant definitions of other terms will be given in the following description.

[0019] It should be noted that the concepts such as "first" and "second" mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0020] It should be noted that the modifications of "one" and "plurality" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".

[0021] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.

[0022] Figure 1 FIG. 1 is a flowchart of a method for synchronizing data based on a database according to some embodiments. Figure 1 As shown, the embodiment of the present disclosure provides a method for data synchronization based on a database, which can be executed by an electronic device, and specifically by a data synchronization device based on a database, which can be implemented by software and / or hardware and configured in the electronic device. It should be understood that the electronic device can be a server. Figure 1 As shown, the method may include the following steps.

[0023] In step 110, a target statement carrying the current data synchronization point is executed in the database to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type.

[0024] Here, the database can be a source database, which refers to the database at the starting point of the data. The source database is the database where the original data is located. The data is read from the source database and copied or synchronized to another database (target database). The data synchronization point refers to the mark that records the current synchronization status during the data synchronization process. The data synchronization point can be composed of the synchronization timestamp or the log position of the data change (such as the binlog (binary log) file name and offset). The current data synchronization point refers to the real-time point information of the current data synchronization during the data synchronization process.

[0025] The target statement is a Data Definition Language (DDL) statement. DDL statements are a type of Structured Query Language (SQL). DDL statements are used to define and manage the structure of a database and are generally used to create, modify, and delete database objects, such as databases, tables, views, indexes, triggers, and stored procedures.

[0026] During the data synchronization process, the target statement carrying the current data synchronization point is executed in the database regularly through the Data Transmission Service (DTS), and the target statement is recorded in the database log file, thereby recording the current data synchronization point carried by the target statement in the log file. The log file can be a binary log (binlog) file.

[0027] It is worth noting that due to the MTS (Multi-Threaded Slave) mechanism of master-slave replication, DML (Data Manipulation Language) statements are not strictly sequenced between master and slave databases. For example, insert1, insert2, and insert3 are executed sequentially in the source database. Since there is no conflict between the three statements insert1, insert2, and insert3, the execution order on the slave database may be insert3, insert2, and insert1. Therefore, the DML statements of the master and slave databases are not sequenced. Therefore, if the DML statement is used to bury the current data synchronization point in the log file, the data synchronization point will become invalid in the scenario of switching between the master and slave databases.

[0028] In the disclosed embodiment, the current data synchronization position is written into the log file through the target statement of the data definition language type. Since the DDL statement has a checkpoint mechanism, the DDL statement will not be out of order. In the scenario where the master database fails over to the slave database for data synchronization, the slave database will wait for the transaction before the DDL statement to be executed, and then execute the DDL statement. After the DDL statement is executed, the statement after the DDL statement will be released. Therefore, writing the current data synchronization position into the log file through the target statement of the data definition language type can play the role of a data fence to ensure that in the scenario of switching between the master and slave databases, the consistency and integrity of the data can be guaranteed during the data synchronization process.

[0029] In addition, since DDL statements are a type of SQL statement, all versions of MySQL databases can use the target statements provided in the embodiments of the present disclosure to record data synchronization points. For example, MySQL databases of versions 5.5 and earlier can use the database-based data synchronization method provided in the embodiments of the present disclosure to record data synchronization points to support breakpoint-resume transmission in master-slave switching scenarios.

[0030] It is worth noting that the data synchronization point in the embodiment of the present disclosure is a logical point, wherein the logical point refers to a point defined based on the logical order of data changes.

[0031] In step 120, when data is resumed from a breakpoint, a target data synchronization point is searched in the log file of the database, and the target data synchronization point is the current data synchronization point recorded when the data synchronization was interrupted last time.

[0032] Here, data breakpoint resume means that during the data synchronization process, if the transmission is interrupted due to network problems or other reasons, the unfinished data can be continued from the interrupted point without restarting the entire transmission process. Through the above step 110, during the data synchronization process, the current data synchronization point can be continuously recorded in the log file of the database. When data synchronization is interrupted due to network problems, system failures or other reasons, the current data synchronization point corresponding to the interruption time will also be recorded in the log file.

[0033] After the problem causing the data synchronization interruption is resolved, data is resumed through the data transmission service. When data is resumed, the target data synchronization position is read from the log file of the database through the data transmission service. The target data synchronization position is the current data synchronization position recorded at the last data synchronization interruption. Exemplarily, the target data synchronization position can be understood as the last data synchronization position recorded in the log file.

[0034] In some embodiments, the target statement may be found in the log file of the database, and then the target data synchronization position may be determined based on the found target statement.

[0035] In step 130, data synchronization is performed based on the target data synchronization site.

[0036] Here, data synchronization can be performed based on the target data synchronization site through the data transmission service. The target data synchronization site includes the binlig file name and offset of the last interrupted data synchronization. When performing data breakpoint resumption, the data is re-read and synchronized to the target database starting from the binlig file and offset of the last interruption.

[0037] Therefore, by executing a target statement of a data definition language type that carries the current data synchronization site in the database, the current data synchronization site is written into the database log file through the target statement, and when the data is resumed from a breakpoint, the target data synchronization site is found in the database log file, and then data synchronization is performed based on the target data synchronization site, which can play the role of a data fence and prevent the data synchronization site from failing in the scenario of master-slave database switching, so that in the scenario of master-slave database switching, the consistency and integrity of the data can be guaranteed during the data synchronization process. Moreover, by embedding the data synchronization site through a target statement of a data definition language, various versions of MySQL databases can also be supported.

[0038] In some feasible implementations, the target statement includes the current data synchronization site and the target table name, the table corresponding to the target table name does not belong to the database, and the target statement is used to instruct to delete the corresponding table based on the target table name.

[0039] Exemplarily, the target statement may be DROP TABLE IF EXISTS. It should be understood that DROP TABLE IF EXISTS is a statement in SQL used to delete a table in a database. DROP TABLE IF EXISTS is generally followed by table_name to indicate the name of the table to be deleted. Therefore, the current data synchronization site and the target table name may be carried in the position of table_name.

[0040] For example, the target sentence could be: DROP TABLE IF EXISTS ${NOT_EXISTS_TABLE_PREFIX}_${DATA}.

[0041] Among them, NOT_EXISTS_TABLE_PREFIX indicates the name of the target table that does not belong to the database, and DATA indicates the current data synchronization point.

[0042] It is worth noting that the table corresponding to the target table name does not belong to the database means that the table corresponding to the target table name does not exist in the database. The target table name included in the target statement may refer to the entire target table name or a prefix of the target table name.

[0043] Accordingly, in step 110, the target statement may be executed in the database to delete the table corresponding to the target table name.

[0044] Here, when executing the target statement, since the table corresponding to the target table name does not exist in the database, the database will not report an error, but silently ignore the deletion operation of the target statement. Therefore, the target statement can be recorded in the log file. Moreover, through the target statement used to delete the table in the database, the user will not perceive the operation of deleting a table corresponding to a non-existent target table name. Therefore, the user is not aware of the writing of the current data synchronization position into the log file through the target statement.

[0045] Thus, through the above target statement, the data synchronization point can be written into the log file of the database. Moreover, the action of writing the data synchronization point into the log file is not noticeable to the user, which can avoid causing interference to the user and improve the user experience.

[0046] In some practicable implementations, the target statement may include a current data synchronization site and a specified table name, and the target statement is used to instruct to create a corresponding table based on the specified table name.

[0047] Exemplarily, the target statement may be CREATE TABLE IF NOT EXISTS. It should be understood that CREATE TABLE IF NOT EXISTS is a statement in SQL used to create a new table in a database. CREATE TABLE IFNOT EXISTS is generally followed by table_name to indicate the name of the table to be created through table_name. Therefore, the current data synchronization point and the specified table name may be carried in the position of table_name.

[0048] The specified table name may refer to a table name defined by a user specifically for recording data synchronization sites. For example, the target statement may be: CREATE TABLE IF NOT EXISTS ${TABLE_A}_${DATA}, where TABLE_A is the specified table name and DATA indicates the current data synchronization site.

[0049] It is worth noting that the specified table name in each executed target statement may be different. The specified table name included in the target statement may refer to the entire specified table name or a prefix of the specified table name.

[0050] Accordingly, in step 110, the target statement may be executed in the database, and a table corresponding to the specified table name may be created in the database.

[0051] Here, when executing the target statement in the database, if the specified table name does not exist, a table corresponding to the specified table name is created in the database. Therefore, the target statement can be recorded in the log file.

[0052] It should be understood that, compared with DROP TABLE IF EXISTS, CREATE TABLE IF NOT EXISTS requires creating a table in the database. Therefore, the operation of CREATE TABLE IF NOT EXISTS is actually noticeable to the user, while DROP TABLE IF EXISTS is not noticeable to the user.

[0053] It is worth noting that in the embodiment of the present disclosure, the current data synchronization point can be an increasing sequence number. Of course, the current data synchronization point can also be a timestamp. In actual application scenarios, the data synchronization point can be defined according to actual conditions, but it must be ensured that the data synchronization point has a partial order relationship.

[0054] Therefore, through the above target statement, the data synchronization location can be written into the log file of the database by creating a table in the database.

[0055] In some feasible implementations, in step 110, the current data synchronization point in the data synchronization process can be periodically obtained, and based on the preset table name and the current data synchronization point, a target statement is constructed and executed in the database to write the target statement into the log file of the database.

[0056] Here, during the data synchronization process, the current data synchronization position in the data synchronization process can be periodically obtained through the data transmission service, so as to record the current data position through the target statement. The interval time of each cycle can be set according to the actual situation.

[0057] The preset table name may be the target table name or the specified table name described in the above embodiment. The target statement may be constructed by carrying the preset table name and the current data synchronization point in DROP TABLE IF EXISTS or CREATE TABLE IF NOT EXISTS.

[0058] Then, the target statement is executed in the database through the data transmission service. It should be noted that the executed target statement will be recorded in the log file of the database, so that the data synchronization site carried in the target statement is written into the log file of the database.

[0059] For example, the preset table name and the current data synchronization point can be written into the corresponding DDL statement to construct a target statement, wherein the target statement can be DROP TABLE IF EXISTS or CREATE TABLE IF NOT EXISTS in the above embodiment.

[0060] It should be understood that during data synchronization, the data transmission service periodically obtains the current data synchronization point, constructs a target statement based on the current data synchronization point and a preset table name, and then executes the target statement in the database.

[0061] Therefore, through the above implementation, the target statement can be executed periodically, and the data synchronization point in the data synchronization process can be written into the log file.

[0062] Figure 2 yes Figure 1 Detailed flow chart of step 120 is shown. Figure 2 As shown, in some possible implementations, step 120 includes the following steps.

[0063] In step 121, each log file of the database is scanned to obtain the first data synchronization position recorded in each log file.

[0064] Here, in the above implementation, the data transmission service executes the target statement regularly and writes the data synchronization point into the log file of the database. When resuming the data transmission, the data transmission service scans each log file of the database to obtain the first data synchronization point recorded in each log file.

[0065] It should be noted that the data synchronization point has a partial order relationship. For example, the data synchronization point can be an increasing sequence number or a timestamp. Therefore, by scanning the first data synchronization point recorded in each log file, the log file where the target data synchronization point is located can be determined through the first data synchronization point recorded in each log file.

[0066] In some embodiments, the target statement also includes a preset table name. Accordingly, based on the preset table name, the first target statement recorded in each log file can be found in each log file of the database, and the first data synchronization point recorded in each log file can be determined based on the data synchronization point carried in the found target statement.

[0067] The preset table name may be the target table name described in the above embodiment or a specified table name.

[0068] In the disclosed embodiment, the data synchronization site is recorded in the target statement of the log file. Therefore, the target statement for recording the data synchronization site can be found in each log file of the database by using the preset table name. Due to the partial order relationship of the data synchronization site, the first target statement found in the log file records the first data synchronization site recorded in the log file.

[0069] After the target statement is found in each log file, the data synchronization point carried in the first target statement found in each log file may be used to determine the first data synchronization point recorded in the log file.

[0070] It should be understood that, through the preset table name, the target statement for recording the data synchronization site can be quickly found in the log file.

[0071] In step 122, a target log file is determined from among the log files according to the order corresponding to each first data synchronization point.

[0072] Here, since the data synchronization sites have a partial order relationship, the target log file can be determined from each log file according to the order corresponding to each first data synchronization site. The target log file is the log file where the target data synchronization site for breakpoint resume is located.

[0073] Exemplarily, the log file corresponding to the first data synchronization point with the largest sequence may be determined as the target log file.

[0074] For example, assuming that the first data synchronization positions scanned are 1, 11, 21, and 31, respectively, the log file where the data synchronization position corresponding to 31 is located is the target log file.

[0075] In step 123, a target data synchronization site is determined among the data synchronization sites according to the order of the data synchronization sites recorded in the target log file.

[0076] Here, all target statements can be found from the target log file based on the preset table name, and the data synchronization locations recorded in the target log file can be determined according to all the target statements.

[0077] Exemplarily, since the data synchronization sites have a partial order relationship, the data synchronization site with the largest order among the data synchronization sites recorded in the target log file is determined as the target data synchronization site.

[0078] Therefore, through the above implementation, the target data synchronization site can be determined by scanning the first data synchronization site recorded in the log file, without scanning all sites of the log file, which can not only improve the scanning speed but also save computing resources.

[0079] In some feasible implementations, in step 110, the first target statement recorded in each log file can be found in each log file of the database based on a preset table name, and then the target data synchronization point can be determined based on the data synchronization point carried in the found target statement.

[0080] Here, the preset table name can be matched with each statement recorded in the log file, so as to find the first target statement recorded in each log file in each log file.

[0081] Due to the partial order relationship of the data synchronization sites, the first target statement found in the log file is the first data synchronization site recorded in the log file.

[0082] At this time, the target log file can be determined from each log file based on the order corresponding to each first data synchronization point, and then the target data synchronization point can be determined from each data synchronization point according to the order of each data synchronization point recorded in the target log file.

[0083] Therefore, through the above implementation, the target data synchronization position can be quickly and accurately determined in the log file by searching for the preset table name.

[0084] It is worth noting that the database-based data synchronization method provided by the embodiment of the present disclosure can not only provide a solution for recording logical sites for low-version MySQL databases by periodically executing target statements belonging to the data definition language type during the data synchronization process, but also support data breakpoint resumption in the scenario of master-slave database switching through the checkpoint mechanism of the DDL statement, so as to ensure that the consistency and integrity of the data can be guaranteed. In addition, the database-based data synchronization method provided by the embodiment of the present disclosure is also applicable to the master-slave replication scenario. In the scenario where the transaction identifier (ID) is not inherited, the data synchronization site can also be recorded based on the target statement of the data definition language type provided by the embodiment of the present disclosure. Moreover, when the target statement of the data definition language type is a DROP TABLE IF EXISTS statement, it is not noticeable to the user, which greatly improves the user experience.

[0085] Figure 3 FIG. 1 is a schematic diagram of a structure of a data synchronization device based on a database according to some embodiments. Figure 3 As shown, the embodiment of the present disclosure provides a data synchronization device 300 based on a database, and the data synchronization device 300 based on a database includes: An execution module 301 is configured to execute a target statement carrying a current data synchronization point in a database, so as to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; The search module 302 is configured to search for a target data synchronization point in the log file of the database when data is resumed after a breakpoint, wherein the target data synchronization point is the current data synchronization point recorded when data synchronization was interrupted last time; The synchronization module 303 is configured to perform data synchronization based on the target data synchronization point.

[0086] Optionally, the target statement includes a current data synchronization site and a target table name, the table corresponding to the target table name does not belong to the database, and the target statement is used to instruct to delete the corresponding table based on the target table name; The execution module 301 is specifically configured as follows: The target statement is executed in the database, and a table corresponding to the target table name is deleted.

[0087] Optionally, the target statement includes a current data synchronization site and a specified table name, and the target statement is used to instruct to create a corresponding table based on the specified table name; The execution module 301 is specifically configured as follows: The target statement is executed in the database, and a table corresponding to the specified table name is created in the database.

[0088] Optionally, the execution module 301 is specifically configured to: Periodically obtain the current data synchronization position during the data synchronization process; Constructing the target statement based on the preset table name and the current data synchronization position; The target statement is executed in the database to write the target statement into a log file of the database.

[0089] Optionally, the search module 302 is specifically configured to: Scan each log file of the database to obtain the first data synchronization point recorded in each log file; Determine a target log file from each of the log files according to the order corresponding to each of the first data synchronization sites; The target data synchronization site is determined among the data synchronization sites according to the order of the data synchronization sites recorded in the target log file.

[0090] Optionally, the target statement further includes a preset table name; the search module 302 is specifically configured to: The scanning of each log file of the database to obtain the first data synchronization position recorded in each log file includes: Based on the preset table name, searching each log file in the database for the first target statement recorded in each log file; The target data synchronization point is determined based on the data synchronization point carried in the target statement found.

[0091] The logic of the method executed by each functional module in the above-mentioned database-based data synchronization device 300 can refer to the part of the method related to the above-mentioned embodiment, and will not be repeated here.

[0092] Reference below Figure 4, which shows a schematic diagram of the structure of an electronic device 400 suitable for implementing the embodiment of the present disclosure. In the embodiment of the present disclosure, the electronic device may be a server, for example, the server may be a server where a database is located. Figure 4 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.

[0093] like Figure 4 As shown, the electronic device 400 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 401, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 402 or a program loaded from a storage device 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the electronic device 400 are also stored. The processing device 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0094] Typically, the following devices may be connected to the I / O interface 405: an input device 406 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 407 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 408 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 409. The communication device 409 may allow the electronic device 400 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 4 The electronic device 400 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.

[0095] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 409, or installed from the storage device 408, or installed from the ROM 402. When the computer program is executed by the processing device 401, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.

[0096] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-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 of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer 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 of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. 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. Computer readable signal media may also be any computer readable medium other than computer readable storage media that can send, propagate or synchronize programs for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be synchronized using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.

[0097] In some embodiments, the servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.

[0098] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.

[0099] The above-mentioned computer-readable medium carries one or more programs. When the above-mentioned one or more programs are executed by the electronic device, the electronic device: executes a target statement carrying a current data synchronization site in a database to write the current data synchronization site into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; when resuming data breakpoints, searches for a target data synchronization site in the log file of the database, wherein the target data synchronization site is the current data synchronization site recorded at the last data synchronization interruption; and performs data synchronization based on the target data synchronization site.

[0100] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages ​​or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0101] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0102] The modules involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a module does not, in some cases, limit the module itself.

[0103] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.

[0104] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer 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 of the foregoing.

[0105] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.

[0106] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.

[0107] Although the subject matter has been described in language specific to structural features and / or method logic actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims. Regarding the device in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.

Claims

1. A data synchronization method based on a database, characterized in that: include: Executing a target statement carrying a current data synchronization point in a database, so as to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; When data is resumed from a breakpoint, a target data synchronization position is searched in the log file of the database, and the target data synchronization position is the current data synchronization position recorded when the data synchronization was interrupted last time; Data synchronization is performed based on the target data synchronization site.

2. The method according to claim 1, characterized in that: The target statement includes a current data synchronization site and a target table name, the table corresponding to the target table name does not belong to the database, and the target statement is used to instruct to delete the corresponding table based on the target table name; The executing of the target statement carrying the current data synchronization site in the database includes: The target statement is executed in the database, and a table corresponding to the target table name is deleted.

3. The method according to claim 1, characterized in that The target statement includes a current data synchronization location and a specified table name, and the target statement is used to instruct to create a corresponding table based on the specified table name; The executing of the target statement carrying the current data synchronization site in the database includes: The target statement is executed in the database, and a table corresponding to the specified table name is created in the database.

4. The method according to claim 1, characterized in that: The executing of the target statement carrying the current data synchronization site in the database includes: Periodically obtain the current data synchronization position during the data synchronization process; Constructing the target statement based on the preset table name and the current data synchronization position; The target statement is executed in the database to write the target statement into a log file of the database.

5. The method according to any one of claims 1 to 4, characterized in that The step of searching the log file of the database to obtain the target data synchronization location includes: Scan each log file of the database to obtain the first data synchronization point recorded in each log file; Determine a target log file from each of the log files according to the order corresponding to each of the first data synchronization sites; The target data synchronization site is determined among the data synchronization sites according to the order of the data synchronization sites recorded in the target log file.

6. The method according to any one of claims 1 to 4, characterized in that The target statement also includes a preset table name; The step of searching the log file of the database to obtain the target data synchronization location includes: Based on the preset table name, searching each log file in the database for the first target statement recorded in each log file; The target data synchronization point is determined based on the data synchronization point carried in the target statement found.

7. A data synchronization device based on a database, characterized in that: include: an execution module, configured to execute a target statement carrying a current data synchronization point in a database, so as to write the current data synchronization point into a log file of the database through the target statement, wherein the target statement is a statement of a data definition language type; A search module is configured to search for a target data synchronization point in the log file of the database when data is resumed after a breakpoint, wherein the target data synchronization point is the current data synchronization point recorded when data synchronization was interrupted last time; The synchronization module is configured to perform data synchronization based on the target data synchronization site.

8. A computer readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processing device, the steps of the method according to any one of claims 1 to 6 are implemented.

9. An electronic device, characterized in that: include: a storage device having a computer program stored thereon; A processing device, configured to execute the computer program in the storage device to implement the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Synchronization of plural databases in a database replication system

    CA2397393A1

  • Call control based terminal-to-terminal breakpoint transmission method

    CN101064910A

  • Method and system for analyzing database incremental logs

    CN105205053A

  • Method and synchronization system for guaranteeing data consistency based on log analysis synchronization

    CN112307118A

  • Method and system for uninterrupted copying between heterogeneous databases

    CN116881354A