Data synchronization methods, devices, and data synchronization platforms
By employing append mode and Apollo configuration value management for merged calculations in the target system, the problem of failed synchronization of multiple data records with the same primary key was solved, achieving efficient data synchronization between the target system and the source system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2026-03-06
AI Technical Summary
In existing technologies, the synchronization of multiple records with the same primary key fails, and the technology fails to effectively handle scenarios where multiple records with the same primary key exist in the same batch but some synchronization fails.
The append mode is used to add multiple data entries from the target data to be synchronized to the primary key data that is the same as the target primary key in the target system. Combined with Apollo configuration value management, the merge calculation is realized to update the target system data.
This solves the problem of failed synchronization of multiple data records with the same primary key, and achieves efficient data synchronization between the target system and the source system.
Smart Images

Figure CN119383194B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data synchronization technology, and more specifically, to a data synchronization method, apparatus, computer-readable storage medium, computer program product, and data synchronization platform. Background Technology
[0002] File-based data synchronization involves the source system organizing the data to be synchronized into files and sending them to the target system. The target system then parses the file content and stores the data in a database in a certain way.
[0003] Traditional file-based data synchronization completely overwrites the original data in the target system, without considering how to handle scenarios where multiple records of the same primary key exist in the same batch but some synchronization fails.
[0004] Existing patents based on file data synchronization methods have the following main shortcomings:
[0005] 1) Often only one synchronization mode is provided, namely the full coverage method, which only considers the case that there is only one record of the same primary key data in the source system, without considering how to achieve data synchronization in the scenario that there are multiple records in the source system and that cannot provide merging calculation;
[0006] 2) Regarding the handling of synchronization failures, it only mentions resending all records or resending upon failure, without detailing how to handle scenarios where multiple records with the same primary key exist in the same file (these records will be merged in the target system) but partial synchronization fails. Summary of the Invention
[0007] The main objective of this application is to provide a data synchronization method, apparatus, computer-readable storage medium, computer program product, and data synchronization platform to at least solve the problem of multiple data synchronization failures with the same primary key in the prior art.
[0008] To achieve the above objectives, according to one aspect of this application, a data synchronization method is provided, comprising: acquiring target data to be synchronized from a source system; and, when there are multiple records of data with the same target primary key in the target data to be synchronized, appending multiple records of data with the same target primary key in the target system to the data with the same primary key as the target primary key in the target system, thereby obtaining updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0009] Optionally, after achieving data synchronization between the target system and the source system, the method further includes: setting the configuration values of all data in the target system to the current Apollo configuration value of the target system, wherein the initial value of the Apollo configuration value is 0; if the target data to be synchronized in the source system is modified, obtaining the modified target data to be synchronized in the source system and controlling the Apollo configuration value of the target system to be incremented by 1; if the Apollo configuration value of the target system is greater than the configuration value of the current data in the target system, merging and calculating multiple data entries with the same target primary key in the modified target data to be synchronized to obtain one data entry with the target primary key, updating the data with the same primary key in the target system to one data entry with the target primary key, wherein the current data is the data with the same primary key in the target system.
[0010] Optionally, after achieving data synchronization between the target system and the source system, the method further includes: setting the configuration values of all data in the target system to the current Apollo configuration value of the target system, wherein the initial value of the Apollo configuration value is 0; obtaining new target data to be synchronized from the source system and controlling the Apollo configuration value of the target system to remain unchanged; and, when the Apollo configuration value of the target system is equal to the configuration value of the current data in the target system and there are multiple records of data with the same target primary key in the new target data to be synchronized, using the append mode to accumulate multiple records of data with the same target primary key in the new target data to be synchronized onto the data with the same primary key as the target primary key in the target system, thereby obtaining the updated data of the primary key in the target system and achieving data synchronization between the target system and the source system.
[0011] Optionally, after obtaining the target data to be synchronized from the source system, the method further includes: if there is only one record of the same primary key in the target data to be synchronized, using an overwrite mode to update the data of the primary key in the target system that is the same as the target primary key to the data of the primary key in the target data to be synchronized, thereby obtaining the updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0012] Optionally, after obtaining the target data to be synchronized from the source system, the method further includes: if there are multiple records of the same primary key in the target data to be synchronized and the source system supports merging calculation, controlling the source system to merge and calculate the multiple records of the same target primary key in the target data to be synchronized to obtain one record of the target primary key, and using an overwrite mode to update the data of the primary key in the target system that is the same as the target primary key to one record of the primary key in the target data to be synchronized, thereby obtaining the updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0013] Optionally, after achieving data synchronization between the target system and the source system, the method further includes: in the event that data synchronization between the target system and the source system fails, reacquiring the target data to be synchronized from the source system and performing data synchronization between the target system and the source system.
[0014] According to another aspect of this application, a data synchronization device is provided, comprising: a first acquisition unit, configured to acquire target data to be synchronized from a source system; and a first synchronization unit, configured to, when there are multiple data entries with the same target primary key in the target data to be synchronized, append multiple data entries with the same target primary key in the target system to the data with the same primary key as the target primary key in the target system, thereby obtaining updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0015] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0016] According to another aspect of this application, a computer program product is provided, comprising a computer program that, when executed by a processor, implements any of the methods described.
[0017] According to another aspect of this application, a data synchronization platform is provided, comprising: a source system, a target system, one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include methods for performing any one of the methods described.
[0018] By applying the technical solution of this application, in the above data synchronization method, when there are multiple records of data with the same target primary key in the target data to be synchronized, instead of directly updating the data with the same primary key as the target primary key in the target system using the overwrite mode of the prior art, it is necessary to merge and calculate the multiple records of data with the same target primary key. By using the append mode, the multiple records of data with the same target primary key in the target data to be synchronized are accumulated on the data with the same primary key as the target primary key in the target system, thereby realizing the data synchronization of multiple records of data with the same target primary key and solving the problem of failure in synchronizing multiple records of data with the same primary key in the prior art. Attached Figure Description
[0019] Figure 1 A hardware structure block diagram of a mobile terminal performing a data synchronization method according to an embodiment of this application is shown;
[0020] Figure 2 A flowchart illustrating a data synchronization method according to an embodiment of this application is shown;
[0021] Figure 3 A flowchart illustrating another data synchronization method provided according to an embodiment of this application is shown;
[0022] Figure 4 A structural block diagram of a data synchronization device provided according to an embodiment of this application is shown.
[0023] The above figures include the following reference numerals:
[0024] 102. Processor; 104. Memory; 106. Transmission device; 108. Input / output device. Detailed Implementation
[0025] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0026] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0028] For ease of description, the following explains some of the nouns or terms used in the embodiments of this application:
[0029] Data synchronization: refers to the operation of maintaining the consistency of a set of data with the same meaning between the source system and the target system.
[0030] Source system: The system that provides data files.
[0031] Target system: The system that receives the data file.
[0032] As described in the background section, synchronization of multiple data records with the same primary key fails in the prior art. To solve this technical problem, embodiments of this application provide a data synchronization method, apparatus, computer-readable storage medium, computer program product, and data synchronization platform.
[0033] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0034] The methods and embodiments provided in this application can be executed on a mobile terminal, computer terminal, or similar computing device. Taking running on a mobile terminal as an example, Figure 1 This is a hardware structure block diagram of a mobile terminal for a data synchronization method according to an embodiment of the present invention. Figure 1 As shown, a mobile terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.) and a memory 104 for storing data are also shown. The mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that... Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the mobile terminal described above. For example, the mobile terminal may also include components that are more... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown.
[0035] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the data synchronization method in this embodiment of the invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The transmission device 106 is used to receive or send data via a network. Specific examples of the aforementioned networks may include wireless networks provided by the mobile terminal's communication provider. In one example, the transmission device 106 includes a network interface controller (NIC), which can be connected to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0036] This embodiment provides a data synchronization method that runs on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0037] Figure 2 This is a flowchart of a data synchronization method according to an embodiment of this application. For example... Figure 2 As shown, the method includes the following steps:
[0038] Step S201: Obtain the target data to be synchronized from the source system;
[0039] Step S202: When there are multiple records of the same target primary key in the target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the target data to be synchronized to the data of the same primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0040] In the above data synchronization method, when there are multiple records of data with the same target primary key in the target data to be synchronized, instead of directly updating the data with the same primary key in the target system using the overwrite mode of the existing technology, it is necessary to merge and calculate the multiple records of data with the same target primary key. By using the append mode, the multiple records of data with the same target primary key in the target data to be synchronized are accumulated on the data with the same primary key in the target system. This can realize the data synchronization of multiple records with the same target primary key, and solve the problem of failure in synchronizing multiple records with the same primary key in the existing technology.
[0041] To achieve full retransmission, in one optional implementation, after achieving data synchronization between the target system and the source system, the method further includes:
[0042] Step S301: Set the configuration values of all data in the target system to the current Apollo configuration values of the target system. The initial value of the Apollo configuration values is 0.
[0043] Step S302: If the target data to be synchronized in the source system is corrected, obtain the modified target data to be synchronized in the source system and control the Apollo configuration value of the target system to be incremented by 1.
[0044] Step S303: If the Apollo configuration value of the target system is greater than the configuration value of the current data of the target system, multiple data records with the same target primary key in the modified target data to be synchronized are merged and calculated to obtain one data record with the target primary key. The data with the same primary key as the target primary key in the target system is updated to one data record with the target primary key. The current data is the data with the same primary key as the target primary key in the target system.
[0045] In the above implementation, the target system sets the Apollo configuration value, with an initial value of 0. Subsequently, for each full synchronization of the same file, that is, after the target data to be synchronized is modified and synchronized again, the Apollo configuration value of the target system will be incremented by 1. It is necessary to check the Apollo configuration value of the target system. If the Apollo configuration value of the target system is greater than the configuration value of the current data in the target system, it means that all data with this primary key in the file needs to be re-merged and recalculated, and the configuration value recorded in each data entry will be updated to the Apollo configuration value.
[0046] To achieve proper synchronization, in one optional implementation, after achieving data synchronization between the target system and the source system, the method further includes:
[0047] Step S401: Set the configuration values of all data of the target system to the current Apollo configuration value of the target system. The initial value of the Apollo configuration value is 0.
[0048] Step S402: Obtain new target data to be synchronized from the source system and keep the Apollo configuration value of the target system unchanged.
[0049] Step S403: When the Apollo configuration value of the target system is equal to the configuration value of the current data of the target system and there are multiple records of the same target primary key in the new target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the new target data to be synchronized to the primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0050] In the above implementation, if the new target data to be synchronized from the source system is obtained instead of the previous target data to be synchronized being fully retransmitted, then there is no need to increment the Apollo configuration value by 1, i.e., it remains unchanged. If the Apollo configuration value of the target system is equal to the configuration value of the current data in the target system, then the data value in the file is directly added to the data in the target system.
[0051] To achieve synchronization, in one optional implementation, after acquiring the target data to be synchronized from the source system, the method further includes:
[0052] Step S501: If there is only one record of the same primary key in the target data to be synchronized, the data of the primary key in the target system that is the same as the target primary key is updated to the data of the primary key in the target data to be synchronized, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0053] In the above implementation, there is only one record of the same primary key in the target data to be synchronized, so there is no need to perform merging calculations. The primary key in the target system that is the same as the target primary key can be directly updated using the overwrite mode.
[0054] To achieve synchronization, in one optional implementation, after acquiring the target data to be synchronized from the source system, the method further includes:
[0055] Step S601: When there are multiple records of the same primary key in the target data to be synchronized and the source system supports merging calculation, the source system is controlled to merge and calculate the multiple records of the same target primary key in the target data to be synchronized, to obtain one record of the target primary key. The data of the primary key in the target system that is the same as the target primary key is updated to one record of the primary key in the target data to be synchronized, in the overwrite mode, to obtain the updated data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system.
[0056] In the above implementation, there are multiple records of the same primary key in the target data to be synchronized, which need to be merged and calculated. The source system supports merging and calculation, and the source system can perform merging and calculation to obtain one record of the target primary key. Then, the data of the same primary key in the target system can be directly updated using the overwrite mode.
[0057] To enable retransmission in case of failure, in an optional implementation, after achieving data synchronization between the target system and the source system, the method further includes:
[0058] Step S701: If the data synchronization between the target system and the source system fails, the target data to be synchronized from the source system is reacquired, and the data synchronization between the target system and the source system is performed.
[0059] In the above implementation, some data synchronization may fail due to system reasons during the synchronization process. Therefore, during the synchronization process, the target system needs to record the synchronization status of each piece of data and return it to the source system. If the data synchronization between the target system and the source system fails, it means that the synchronization was not successful. It is necessary to re-acquire the target data to be synchronized from the source system and perform data synchronization between the target system and the source system until the synchronization is successful.
[0060] It should be noted that if the target system does not have data with the same primary key as the target primary key, it can be created directly during synchronization.
[0061] To enable those skilled in the art to better understand the technical solution of this application, the implementation process of the data synchronization method of this application will be described in detail below with reference to specific embodiments.
[0062] This embodiment relates to a specific data synchronization method, such as... Figure 3 As shown, it includes the following steps:
[0063] To implement a shared primary key, the source system may have multiple records with the same primary key, while the target system can only retain one record for the same primary key. Therefore, during data synchronization, the target system needs to calculate the cases where multiple records exist and ultimately merge them into a single record.
[0064] (II) The overall processing flow consists of the following three steps:
[0065] 1) Set the Apollo configuration value for the target system: The initial value is 0, and the configuration value will be incremented by 1 every time the same file is fully synchronized.
[0066] 2) The source system extracts the data to be synchronized and produces a file (it is necessary to ensure that data with the same primary key in this system is in the same synchronization file). There are two possible data configurations in the file:
[0067] i. If the source system has the ability to merge data with the same primary key into a single data entry or if there is only one data entry with the same primary key, mark this data entry as an overwrite mode;
[0068] ii. If the source system cannot merge data with the same primary key, mark all data under that primary key as append mode;
[0069] 3) The target system receives and parses the synchronization file:
[0070] i. When the data is in overwrite mode, query the data in this system based on the primary key. If it does not exist, create it based on the data in the file. If it exists, update it with the data in the file.
[0071] ii. When the data is in append mode, query the data in this system based on the primary key:
[0072] If it exists, the configuration value of Apollo needs to be checked. If the configuration value is greater than the configuration value of the current data in the target system, it means that all data with this primary key in the file needs to be re-merged and recalculated, and the configuration value recorded in each data entry is updated to the configuration value of Apollo. If the configuration value is equal to the configuration value of the current data in the target system, the data value in the file is directly added to the data in the target system.
[0073] If it does not exist, it will be created based on the data in the file;
[0074] During the synchronization process, some data may fail to synchronize due to system issues. Therefore, the target system needs to record the synchronization status of each piece of data and return it to the source system. After receiving the synchronization feedback, the source system can resend the data in two ways: a full resend or a resend for failed attempts. If the source system chooses a full resend, it needs to notify the target system before resending. The target system must then increment its Apollo configuration value by 1 before proceeding with subsequent synchronization operations.
[0075] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0076] This application also provides a data synchronization device. It should be noted that the data synchronization device of this application can be used to execute the data synchronization method provided in this application. This device is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0077] The data synchronization device provided in the embodiments of this application will be described below.
[0078] Figure 4 This is a structural block diagram of a data synchronization device according to an embodiment of this application. Figure 4 As shown, the device includes:
[0079] The first acquisition unit 10 is used to acquire the target data to be synchronized from the source system;
[0080] The first synchronization unit 20 is used to, when there are multiple records of the same target primary key in the target data to be synchronized, add multiple records of the same target primary key in the target system to the primary key in the target system using an append mode, thereby obtaining the updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0081] In the aforementioned data synchronization device, when there are multiple records of data with the same target primary key in the target data to be synchronized, instead of directly updating the data with the same primary key in the target system using the overwrite mode of the existing technology, it is necessary to merge and calculate the multiple records of data with the same target primary key. By using the append mode, the multiple records of data with the same target primary key in the target data to be synchronized are accumulated on the data with the same primary key in the target system, thereby realizing the data synchronization of multiple records with the same target primary key and solving the problem of synchronization failure of multiple records with the same primary key in the existing technology.
[0082] To achieve full retransmission, in one optional implementation, the above-mentioned device further includes:
[0083] The first setting unit is used to set the configuration value of all data of the target system to the current Apollo configuration value of the target system after the data synchronization between the target system and the source system is achieved. The initial value of the Apollo configuration value is 0.
[0084] The second acquisition unit is used to acquire the modified target data to be synchronized in the source system when the target data to be synchronized in the source system is corrected, and to control the Apollo configuration value of the target system to be incremented by 1.
[0085] The second synchronization unit is used to merge and calculate multiple data entries with the same target primary key in the modified target data to be synchronized when the Apollo configuration value of the target system is greater than the configuration value of the current data of the target system, to obtain one data entry with the target primary key, and to update the data with the same primary key in the target system to one data entry with the target primary key. The current data is the data with the same primary key in the target system.
[0086] In the above implementation, the target system sets the Apollo configuration value, with an initial value of 0. Subsequently, for each full synchronization of the same file, that is, after the target data to be synchronized is modified and synchronized again, the Apollo configuration value of the target system will be incremented by 1. It is necessary to check the Apollo configuration value of the target system. If the Apollo configuration value of the target system is greater than the configuration value of the current data in the target system, it means that all data with this primary key in the file needs to be re-merged and recalculated, and the configuration value recorded in each data entry will be updated to the Apollo configuration value.
[0087] To achieve proper synchronization, in one optional implementation, the above-mentioned device further includes:
[0088] The second setting unit is used to set the configuration value of all data of the target system to the current Apollo configuration value of the target system after the data synchronization between the target system and the source system is achieved. The initial value of the Apollo configuration value is 0.
[0089] The third acquisition unit is used to acquire new target data to be synchronized from the source system and control the Apollo configuration value of the target system to remain unchanged.
[0090] The third synchronization unit is used to append multiple records of the same target primary key in the new target data to be synchronized to the data with the same target primary key in the target system when the Apollo configuration value of the target system is equal to the configuration value of the current data of the target system and there are multiple records of the same target primary key in the new target data to be synchronized, in the above append mode, so as to obtain the updated data of the primary key in the target system and realize the data synchronization between the target system and the source system.
[0091] In the above implementation, if the new target data to be synchronized from the source system is obtained instead of the previous target data to be synchronized being fully retransmitted, then there is no need to increment the Apollo configuration value by 1, i.e., it remains unchanged. If the Apollo configuration value of the target system is equal to the configuration value of the current data in the target system, then the data value in the file is directly added to the data in the target system.
[0092] To achieve synchronization, in one optional implementation, the above-mentioned device further includes:
[0093] The fourth synchronization unit is used to update the primary key data in the target system with the primary key data in the target system after obtaining the target data to be synchronized from the source system, in the case that there is only one data with the same primary key in the target data to be synchronized, by using the overwrite mode, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0094] In the above implementation, there is only one record of the same primary key in the target data to be synchronized, so there is no need to perform merging calculations. The primary key in the target system that is the same as the target primary key can be directly updated using the overwrite mode.
[0095] To achieve synchronization, in one optional implementation, the above-mentioned device further includes:
[0096] The fifth synchronization unit is used to, after acquiring the target data to be synchronized from the source system, and when there are multiple records of the same primary key in the target data to be synchronized and the source system supports merging calculations, control the source system to merge and calculate the multiple records of the same target primary key in the target data to be synchronized, obtain one record of the target primary key, and update the record of the primary key in the target system with the record of the primary key in the target data to be synchronized using an overwrite mode, thereby obtaining the updated data of the primary key in the target system and realizing data synchronization between the target system and the source system.
[0097] In the above implementation, there are multiple records of the same primary key in the target data to be synchronized, which need to be merged and calculated. The source system supports merging and calculation, and the source system can perform merging and calculation to obtain one record of the target primary key. Then, the data of the same primary key in the target system can be directly updated using the overwrite mode.
[0098] The aforementioned data synchronization device includes a processor and a memory. The first acquisition unit and the first synchronization unit, among others, are stored as program units in the memory. The processor executes these program units stored in the memory to achieve their respective functions. All of the aforementioned modules reside in the same processor; alternatively, the modules may be located in different processors in any combination.
[0099] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured, and adjusting kernel parameters can resolve the problem of synchronization failures for multiple data entries with the same primary key in existing technologies.
[0100] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0101] This invention provides a computer-readable storage medium including a stored program, wherein the program, when running, controls the device containing the computer-readable storage medium to execute the data synchronization method.
[0102] Specifically, data synchronization methods include:
[0103] Step S201: Obtain the target data to be synchronized from the source system;
[0104] Step S202: When there are multiple records of the same target primary key in the target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the target data to be synchronized to the data of the same primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0105] This invention provides a processor for running a program, wherein the program executes the data synchronization method described above.
[0106] Specifically, data synchronization methods include:
[0107] Step S201: Obtain the target data to be synchronized from the source system;
[0108] Step S202: When there are multiple records of the same target primary key in the target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the target data to be synchronized to the data of the same primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0109] This invention provides a data synchronization platform, which includes a source system, a target system, a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps:
[0110] Step S201: Obtain the target data to be synchronized from the source system;
[0111] Step S202: When there are multiple records of the same target primary key in the target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the target data to be synchronized to the data of the same primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0112] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program having at least the following method steps:
[0113] Step S201: Obtain the target data to be synchronized from the source system;
[0114] Step S202: When there are multiple records of the same target primary key in the target data to be synchronized, the append mode is used to add multiple records of the same target primary key in the target data to be synchronized to the data of the same primary key in the target system, thereby obtaining the updated data of the primary key in the target system and realizing the data synchronization between the target system and the source system.
[0115] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0116] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0117] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0118] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0119] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0120] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0121] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0122] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0123] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0124] As can be seen from the above description, the embodiments of this application achieve the following technical effects:
[0125] 1) In the data synchronization device of this application, when there are multiple records of data with the same target primary key in the target data to be synchronized, instead of directly updating the data with the same primary key as the target primary key in the target system using the overwrite mode of the prior art, it is necessary to merge and calculate the multiple records of data with the same target primary key. By using the append mode, the multiple records of data with the same target primary key in the target data to be synchronized are accumulated on the data with the same primary key as the target primary key in the target system, so as to realize the data synchronization of multiple records of data with the same target primary key, and solve the problem of failure of synchronization of multiple records of the same primary key in the prior art.
[0126] 2) In the data synchronization device of this application, when there are multiple records of data with the same target primary key in the target data to be synchronized, instead of directly updating the data with the same primary key as the target primary key in the target system using the overwrite mode of the prior art, it is necessary to merge and calculate the multiple records of data with the same target primary key. By using the append mode, the multiple records of data with the same target primary key in the target data to be synchronized are accumulated on the data with the same primary key as the target primary key in the target system, so as to realize the data synchronization of multiple records of data with the same target primary key, and solve the problem of failure of synchronization of multiple records of the same primary key in the prior art.
[0127] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method of data synchronization, the method comprising: The method comprises: obtaining target data to be synchronized of a source system; in the case where there are multiple pieces of data of the same target primary key in the target data to be synchronized, accumulating the multiple pieces of data of the same target primary key in the target data to be synchronized on the data of the same primary key in the target system in an append mode to obtain update data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system, after realizing data synchronization between the target system and the source system, the method further comprises: setting configuration values of all data of the target system to the current Apollo configuration value of the target system, and the initial value of the Apollo configuration value is 0; in the case where the target data to be synchronized of the source system is modified, obtaining the modified target data to be synchronized of the source system, and controlling the Apollo configuration value of the target system to be incremented by 1; in the case where the Apollo configuration value of the target system is greater than the configuration value of the current data of the target system, performing combined calculation on the multiple pieces of data of the same target primary key in the modified target data to be synchronized to obtain one piece of data of the target primary key, and updating the data of the same primary key as the target primary key in the target system to the one piece of data of the target primary key, wherein the current data is the data of the same primary key as the target primary key in the target system; after realizing data synchronization between the target system and the source system, the method further comprises: setting configuration values of all data of the target system to the current Apollo configuration value of the target system, and the initial value of the Apollo configuration value is 0; obtaining new target data to be synchronized of the source system, and controlling the Apollo configuration value of the target system to remain unchanged; in the case where the Apollo configuration value of the target system is equal to the configuration value of the current data of the target system and there are multiple pieces of data of the same target primary key in the new target data to be synchronized, accumulating the multiple pieces of data of the same target primary key in the new target data to be synchronized on the data of the same primary key as the target primary key in the target system in the append mode to obtain update data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system.
2. The method of claim 1, wherein, after obtaining the target data to be synchronized of the source system, the method further comprises: in the case where there is only one piece of data of the same primary key in the target data to be synchronized, updating the data of the same primary key as the target primary key in the target system to the data of the primary key in the target data to be synchronized in an overwrite mode to obtain update data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system.
3. The method of claim 1, wherein, after obtaining the target data to be synchronized of the source system, the method further comprises: In the case that there are multiple pieces of data of the same primary key in the target data to be synchronized and the source system supports merge calculation, the source system is controlled to perform merge calculation on the multiple pieces of data of the same target primary key in the target data to be synchronized, to obtain one piece of data of the target primary key, and the data of the same primary key in the target system is updated to the one piece of data of the primary key in the target data to be synchronized in a cover mode, to obtain the update data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system.
4. The method of claim 1, wherein, After realizing data synchronization between the target system and the source system, the method further comprises: In the case that data synchronization between the target system and the source system fails, the target data to be synchronized of the source system is re-acquired, and data synchronization between the target system and the source system is performed.
5. A data synchronization apparatus, characterized by comprising: Comprise: A first acquisition unit is configured to acquire target data to be synchronized of a source system; In the case that there are multiple pieces of data of the same target primary key in the target data to be synchronized, a first synchronization unit is configured to accumulate the multiple pieces of data of the same target primary key in the target data to be synchronized on the data of the same primary key in the target system in an append mode, to obtain update data of the primary key in the target system, thereby realizing data synchronization between the target system and the source system, A first setting unit is configured to, after realizing data synchronization between the target system and the source system, set configuration values of all data of the target system to current Apollo configuration values of the target system, and the initial value of the Apollo configuration values is 0; A second acquisition unit is configured to, in the case that the target data to be synchronized of the source system is modified, acquire the target data to be synchronized of the source system after modification, and control the Apollo configuration value of the target system to be incremented by 1; A second synchronization unit is configured to, in the case that the Apollo configuration value of the target system is greater than the configuration value of current data of the target system, perform merge calculation on the multiple pieces of data of the same target primary key in the target data to be synchronized after modification, to obtain one piece of data of the target primary key, and update the data of the same primary key in the target system to the one piece of data of the target primary key, wherein the current data is the data of the same primary key in the target system, A second setting unit is configured to, after realizing data synchronization between the target system and the source system, set configuration values of all data of the target system to current Apollo configuration values of the target system, and the initial value of the Apollo configuration values is 0; and a third acquisition unit is configured to acquire new target data to be synchronized of the source system, and control the Apollo configuration value of the target system to remain unchanged. The third synchronization unit is configured to, in a case where the Apollo configuration value of the target system is equal to the configuration value of the current data of the target system and there are multiple pieces of data of the same target primary key in the new target data to be synchronized, accumulate the multiple pieces of data of the same target primary key in the new target data to be synchronized on the data of the same primary key in the target system in the append mode, to obtain updated data of the primary key in the target system, and realize data synchronization between the target system and the source system.
6. A computer readable storage medium characterized by, The computer readable storage medium comprises a stored program, wherein the program, when executed, controls a device in which the computer readable storage medium is located to perform the method of any one of claims 1 to 4.
7. A computer program product comprising a computer program, characterized in that, The computer program, when executed by a processor, implements the method of any one of claims 1 to 4.
8. A data synchronization platform, characterized by, The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4. The computer program, when executed by a processor, implements the method of any one of claims 1 to 4.
Citation Information
Patent Citations
Data importing method and device
CN114490855A
Data migration tool and corresponding computer equipment and storage medium
CN115543958A