Data synchronization method and device, equipment, storage medium and program product
By determining the query time period in the distributed system and using message queues to assist synchronization, the problem of omissions in data synchronization is solved, the synchronization effect is improved, and internal consumption and bandwidth loss are reduced.
Patent Information
- Application Number
- CN202310257501.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-09
- Publication Date
- 2024-09-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
There are data omissions during data synchronization in existing distributed systems, resulting in poor synchronization effects.
By determining the query time period, it is ensured that the synchronized data has been stored in the first device without omissions, and message queues are used to assist data synchronization to reduce the synchronization of duplicate data.
It improves the effect of data synchronization, reduces device internal consumption and bandwidth loss, and ensures data integrity.
Smart Images

Figure CN118626554A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data synchronization method, apparatus, device, storage medium and program product. Background Art
[0002] A distributed system is a system composed of a group of computer nodes that communicate through a network and coordinate work to complete a common task. Distributed storage data is a very critical part of a distributed system, and the data storage process generally involves data synchronization issues.
[0003] Currently, when synchronizing data in a distributed system, the query range is generally set in advance by more than ten minutes, and then the business field is used to query the relevant business data in the business system, and the queried data is transmitted to other subsequent systems to achieve data synchronization.
[0004] However, when the above technology is used for data synchronization, there are still omissions in the synchronized data, which leads to poor data synchronization effect. Summary of the invention
[0005] Based on this, it is necessary to provide a data synchronization method, device, equipment, storage medium and program product that can reduce data omissions in data synchronization and improve data synchronization effects in response to the above technical problems.
[0006] In a first aspect, the present application provides a data synchronization method, the method comprising:
[0007] Determine the corresponding query time period according to the data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0008] Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0009] The target data in the target data set is synchronized to the second device.
[0010] In this embodiment, since the data query time period can be limited to before the latest data is received each time, it can be ensured that the data matching the query time period has been stored and not missed, so there will be no missed data in the synchronized data, thereby improving the synchronization effect.
[0011] In one embodiment, the data synchronization information further includes a deadline of a previous data synchronization of the first device, and the determining of the corresponding query time period according to the data synchronization information of the first device includes:
[0012] The start time is determined according to the deadline of the previous data synchronization, and the end time is determined according to the acquisition time of the latest data;
[0013] Get the query time period based on the start time and end time.
[0014] In this embodiment, the start time is determined by the deadline of the previous data synchronization and the end time is determined according to the acquisition time of the latest data, and then the query time period is obtained. This ensures that the data queried and synchronized each time is data that has been stored in the first device without omissions, and at the same time, too much duplicate data will not be synchronized. This can reduce device internal consumption, reduce bandwidth loss, and thus improve data synchronization effects.
[0015] In one embodiment, obtaining the query time period based on the start time and the end time includes:
[0016] The start time and the time range between the start time and the end time are taken together as the query time period.
[0017] In this embodiment, the query time period is set to be a left-open and right-closed time period, that is, a time period including the start time, so that the data at the end of the last synchronization can be included, thereby avoiding data omissions during the data synchronization process.
[0018] In one embodiment, the method further comprises:
[0019] Obtain the target storage time corresponding to the target data in the target data set;
[0020] Determine a maximum target storage time according to the target storage time;
[0021] The maximum target storage time is determined as the deadline for this data synchronization.
[0022] In this embodiment, by obtaining the target storage time of the target data and determining the maximum target storage time, and then using the maximum target storage time as the deadline for this data synchronization, data duplication in the data synchronization process can be minimized as much as possible, system internal friction and bandwidth loss can be reduced, and the data synchronization effect can be improved.
[0023] In one embodiment, the acquisition time of the latest data is less than the storage time of the latest data.
[0024] In this embodiment, the acquisition time of the latest data is shorter than the storage time of the latest data, so that the situation where the stored data is not received can be avoided, that is, the problem of data omission can be avoided.
[0025] In one embodiment, synchronizing the target data in the target data set to the second device includes:
[0026] Send the target data in the target data set to the message queue;
[0027] The target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
[0028] In this embodiment, the target data in the target data set is sent to the message queue so that the second device can consume the target data from the message queue and store the target data in the second device. The message queue is used to assist in data synchronization, which can further ensure the data integrity during the data synchronization process.
[0029] In a second aspect, the present application further provides a data synchronization device, the device comprising:
[0030] A time period determination module, used to determine a corresponding query time period according to data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0031] A matching module, configured to determine, based on the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0032] The synchronization module is used to synchronize the target data in the target data set to the second device.
[0033] In a third aspect, the present application further provides a device, the device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the following steps when executing the computer program:
[0034] Determine the corresponding query time period according to the data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0035] Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0036] The target data in the target data set is synchronized to the second device.
[0037] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0038] Determine the corresponding query time period according to the data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0039] Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0040] The target data in the target data set is synchronized to the second device.
[0041] In a fifth aspect, the present application further provides a computer program product, the computer program product comprising a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0042] Determine the corresponding query time period according to the data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0043] Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0044] The target data in the target data set is synchronized to the second device.
[0045] The above-mentioned data synchronization method, device, equipment, storage medium and program product determine the corresponding query time period through the data synchronization information of the first device, and determine the target data set composed of the target data whose storage time matches the query time period according to the storage time of the data stored in the first device, and then synchronize the target data to the second device; wherein the data synchronization information includes the acquisition time of the latest data acquired by the first device, and the data acquired before the latest data has been stored in the first device. In this method, since the query time period of the data can be limited to the time before the latest data is received each time, it can be ensured that the data matching the query time period has been stored and not missed, so that there will be no missed data in the synchronized data, thereby improving the synchronization effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 An application environment diagram of a data synchronization method in an embodiment;
[0047] Figure 2 A schematic diagram of a flow chart of a data synchronization method in an embodiment;
[0048] Figure 3is a flowchart of a data synchronization method in another embodiment;
[0049] Figure 4 is a flowchart of a data synchronization method in another embodiment;
[0050] Figure 5 This is an example diagram of the overall architecture of a data synchronization method in another embodiment;
[0051] Figure 6 This is an example diagram of executing the scheduled task 1 in the data synchronization method in another embodiment;
[0052] Figure 7 This is an example diagram of executing the scheduled task 2 in the data synchronization method in another embodiment;
[0053] Figure 8 is a structural block diagram of a data synchronization device in an embodiment;
[0054] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] The following is a description of the terms used in this application:
[0057] Atomicity: All operations included in a transaction are either completed or not completed, and will not end at any stage in the middle. Even if an error occurs during the execution of a transaction, it will be rolled back to the state before the transaction started, as if the transaction had never been executed, that is, the operations in the transaction are indivisible.
[0058] The data synchronization method provided in the embodiment of the present application can be applied to Figure 1In the data synchronization system shown. Among them, data synchronization mainly synchronizes the data in the first device 102 to the second device 104. In the specific synchronization process, the first device 102 can obtain data through a third-party device, and store the data after processing. At the same time, the first device 102 can communicate with the synchronization device 106, and read the data to be synchronized from the first device 102 through the synchronization device 106, and then synchronize the data to be synchronized to the second device 102. In addition, the first device 102, the second device 104 and the synchronization device 106 can all be computer devices, and the computer device can be a terminal or a server. For example, the first device 102 can be a server, the second device 104 can be a terminal, the synchronization device 106 can be a sub-device in the first device 102, and so on.
[0059] In one embodiment, Figure 2 As shown, a data synchronization method is provided, which is applied to Figure 1 Taking the synchronization device in as an example, the method may include the following steps:
[0060] S202, determining a corresponding query time period according to data synchronization information of the first device; the above data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device.
[0061] In this step, the first device may be a business system that needs to process business data. Generally, in order to reduce the pressure on the business system to process data, most of the business data can be processed by a third-party device. After the third-party device completes the processing, the first device may actively send a business request to the third-party device to obtain the data processed by the third-party device. Of course, if the third-party device supports the push function, the third-party device can push the data to the first device after completing the data processing. In short, the first device can obtain data from the third-party device.
[0062] The first device needs to ensure the atomicity of the acquired data in the process of acquiring data from the third-party device, that is, the acquired data is generally in batches and the data in the batches have completed the entire data processing process. Each time the first device acquires a batch of data, it can record the time when the batch of data is acquired (for example, it can be recorded as sys_time, and the acquisition time indicates that the data processing operation has been completed), and then the batch of data will be put into storage, that is, stored (also called persistence operation), and the time when the storage starts will be recorded as the storage time of the batch of data (for example, it can be recorded as persistence_time). Generally speaking, the first device first acquires a batch of data and then stores it, so the time when the data is acquired is naturally earlier than (or less than) the storage time of the data, that is, as an optional embodiment, the acquisition time of the latest data is less than the storage time of the latest data, so that the situation where the stored data is not received can be avoided, that is, the problem of data omission can be avoided.
[0063] In addition, the first device can continuously obtain the data processed by the third-party device and synchronize it, that is, it can continuously obtain multiple batches of data and synchronize them, but the first device generally obtains the next batch of data and stores it and records the storage time after storing the acquired batch of data and obtaining the storage time. Here, the storage time of different batches of data is generally: the storage time of the current batch of data must be greater than the storage time of the previous batch of data, that is, the storage time of the current batch of data cannot be less than the previous value, so as to prevent the rollback during data storage, resulting in the problem of repeated data storage. Generally, even if the data processed by the third-party device in the current batch is omitted, the omitted data will be processed and obtained by the first device when the next batch of data is processed, and stored by the first device, and the omitted data will also be marked with the storage time according to the time when it is actually stored by the first device. In other words, the storage time of the data in the first device will continue to grow, and the storage time of each batch of data is between it and the acquisition time of the next batch of data. For example, the first batch of data is acquired at sys_time1 and stored at persistence_time1, and the second batch of data is acquired at sys_time2, then persistence_time1 is between [sys_time1, sys_time2].
[0064] Based on the above description, it can be known that in the process of the first device continuously acquiring data from a third-party device and synchronizing, the data acquired before each acquisition of new data has been stored. Assuming that the currently acquired data is recorded as the latest data here, the acquisition time of the current latest data can be recorded here, and the acquisition time of the latest data can be used as the data synchronization information of the first device during the data synchronization process. Afterwards, the first device can determine the query time period corresponding to the data to be synchronized based on the acquisition time of the latest data. For example, the query time period can be set to the acquisition time of the latest data as the end of the query, that is, the data before the acquisition time of the latest data can be queried subsequently.
[0065] S204: Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period.
[0066] In this step, after the query time period is determined as described above, since the data acquired in the first device before the latest data is acquired has been stored, and the storage time of the stored data has also been recorded, the storage time of the stored data in the first device can be matched with the query time period as described above to obtain the matching storage time, and then the data corresponding to the matching storage time can be obtained and recorded as target data. These target data can be combined to obtain the target data set.
[0067] For the above storage time matching process, for example, the data storage time may fall within the query time period to determine that it matches the query time period. For the above query time period, the acquisition time of the latest data may be set as the end of the query, so here the storage time may be before the acquisition time of the latest data to determine that it matches.
[0068] S206: Synchronize the target data in the target data set to the second device.
[0069] In this step, after determining the target data set in the first device, the target data in the target data set are all data that have not been synchronized, so the target data can be synchronized to the second device. For the synchronization method, for example, the above-mentioned synchronization device can read the target data from the first device and then send the target data to the second device; or the synchronization device can read the target data from the first device, and then the second device actively reads the target data; of course, other methods are also possible; in short, the data in the first device and the second device can be consistent, so that the data synchronization of the first device and the second device is achieved.
[0070] In addition, it should be noted that the data synchronization process completed by the above synchronization device can be a scheduled task, that is, the data in the first device can be synchronized to the second device on a regular basis to achieve continuity and consistency of business data.
[0071] In the above data synchronization method, the corresponding query time period is determined by the data synchronization information of the first device, and the target data set consisting of the target data whose storage time matches the query time period is determined according to the storage time of the data stored in the first device, and then the target data is synchronized to the second device; wherein the data synchronization information includes the acquisition time of the latest data acquired by the first device, and the data acquired before the latest data has been stored in the first device. In this method, since the query time period of the data can be limited to the time before the latest data is received each time, it can be ensured that the data matching the query time period has been stored and not missed, so that there will be no missed data in the synchronized data, thereby improving the synchronization effect.
[0072] The above embodiment mentioned that the data synchronization information of the first device may include the time for obtaining the latest data. Of course, the data synchronization information may also include other information, such as the deadline for the previous data synchronization of the first device. Then, how to set the query time period based on the data synchronization information is described in detail in the following embodiment.
[0073] In another embodiment, Figure 3 As shown, another data synchronization method is provided, and the above S202 may include the following steps:
[0074] S302, determining a start time according to a deadline of a previous data synchronization, and determining an end time according to a time when the latest data is acquired.
[0075] In this step, each time the synchronization device performs data synchronization, the deadline for completing the data synchronization may be recorded. The deadline may indicate that the data synchronization has been completed, that is, data stored before the deadline has been synchronized.
[0076] Before the synchronization device performs the current data synchronization, it can first obtain the deadline of the previous data synchronization recorded before, and determine the start time of the query time period by the deadline of the previous data synchronization. For example, the deadline of the previous data synchronization can be directly used as the start time, or the deadline of the previous data synchronization can be moved forward for some time as the start time, or other methods can be used. In short, the start time can be determined by the deadline of the previous data synchronization. In addition, assuming that the synchronization device has not performed data synchronization, that is, the deadline of the previous data synchronization is empty, the current time can be used as the start time.
[0077] After obtaining the latest data acquisition time, the latest data acquisition time can be directly used as the termination time, or the latest data acquisition time can be moved back some time as the termination time, or other methods can be used. In short, the termination time can be determined by the latest data acquisition time.
[0078] S304: Obtain a query time period based on the start time and the end time.
[0079] After obtaining the start time and the end time, as an optional embodiment, the start time and the time range between the start time and the end time are taken as the query time period. That is, the query time period is an interval that includes the start time but does not include the end time and is open on the left and closed on the right. Here, by setting the query time period to be a time period that is open on the left and closed on the right, that is, a time period that includes the start time, the data at the end of the last synchronization can be included, thereby avoiding data omissions during the data synchronization process.
[0080] For example, assuming that the start time is end_time and the end time is the latest sys_time, the query time period can be recorded as [end_time, latest sys_time).
[0081] In addition, it should be noted that, in the present embodiment, the synchronization delay of each data synchronization depends on the maximum value of the processing time of each batch of data of the first device and the time interval for the first device to synchronize the data to the second device, which is generally maintained at about 1 minute. It can be seen that the delay of data synchronization can be greatly reduced, and the real-time performance of data synchronization can be improved, thereby ensuring the coherence and consistency of business data between subsequent devices and improving user experience.
[0082] In this embodiment, the start time is determined by the deadline of the previous data synchronization and the end time is determined according to the acquisition time of the latest data, and then the query time period is obtained. This ensures that the data queried and synchronized each time is data that has been stored in the first device without omissions, and at the same time, too much duplicate data will not be synchronized. This can reduce device internal consumption, reduce bandwidth loss, and thus improve data synchronization effects.
[0083] In the above embodiment, it is mentioned that the deadline for synchronization of the batch of data U can be recorded each time data synchronization is completed. In the following embodiment, the synchronization process of the target data of this batch is taken as an example to explain in detail how to determine the deadline for synchronization of each batch of data.
[0084] In another embodiment, Figure 4 As shown, another data synchronization method is provided, and the above method may also include the following steps:
[0085] S402, obtaining a target storage time corresponding to the target data in the target data set.
[0086] In this step, as mentioned in S202 above, each time the first device acquires new data, it can record the time of acquisition, and then store or persist the data, and record the storage time. In this way, after the target data is queried, the storage time corresponding to the target data can also be obtained, which can be recorded as the target storage time.
[0087] S404: Determine a maximum target storage time according to the target storage times.
[0088] In this step, if the target data is one, then the target storage time is also one, and the target storage time can be directly used as the maximum target storage time.
[0089] If there are multiple target data, then there are also multiple target storage times. In this case, the multiple target storage times can be sorted from large to small or from small to large, and the largest target storage time can be obtained through the sorting result.
[0090] S405: Determine the maximum target storage time as the deadline for this data synchronization.
[0091] In this step, after obtaining the maximum target storage time, the maximum target storage time can be directly used as the deadline for this data synchronization. The maximum target storage time is selected here mainly because the storage time of data is gradually increasing. If the maximum storage time is selected, it can be said that this batch of data has been synchronized. If the maximum storage time is not selected, then the maximum target storage time of the synchronized data will fall into the query time period when the data is queried next time, and the corresponding data will be synchronized again in the next data synchronization process. In this way, the synchronized data will be repeated, which will increase the system internal consumption and bandwidth loss. This situation needs to be avoided. Therefore, the maximum target storage time is selected here as the deadline for this data synchronization.
[0092] In this embodiment, by obtaining the target storage time of the target data and determining the maximum target storage time, and then using the maximum target storage time as the deadline for this data synchronization, data duplication in the data synchronization process can be minimized as much as possible, system internal friction and bandwidth loss can be reduced, and the data synchronization effect can be improved.
[0093] The following embodiments illustrate the specific process of synchronizing the data in the first device to the second device mentioned above.
[0094] In another embodiment, another data synchronization method is provided, and the above S206 may include the following steps:
[0095] Step A: sending target data in the target data set to the message queue.
[0096] In this step, the synchronization device can obtain the target data from the first device and send the target data set to the message queue MQ. The target data is used to instruct the second device to consume the target data from the message queue and synchronize the target data to the second device.
[0097] That is to say, the second device can use a message queue MQ listener to monitor whether there is data in the message queue MQ. If there is data, the target data can be consumed from the message queue MQ. During the consumption process, the target data can be parsed or filtered to remove unnecessary data. After that, the parsed or filtered data can be stored or persisted. Then it can be determined whether the persistence is successful. If it is successful, it means that the data storage is successful, and the data consumption is ended. If not, it means that the data storage fails, and the data needs to be consumed again. For the message queue MQ here, the availability of data sending and consumption needs to be guaranteed during general use, and the idempotence of the data can be supported by the receiving end of the data.
[0098] Similar to the second device parsing and filtering the data in the process of consuming data, the first device can also parse and filter the data after obtaining the data from the third-party device, and store or persist the data after parsing and filtering to ensure the accuracy of the stored data.
[0099] In this embodiment, the target data in the target data set is sent to the message queue so that the second device can consume the target data from the message queue and store the target data in the second device. The message queue is used to assist in data synchronization, which can further ensure the data integrity during the data synchronization process.
[0100] In order to facilitate a detailed description of the technical solution of the embodiment of the present application, a detailed embodiment is given below. Based on the above embodiment, the method may include the following steps:
[0101] S1, determine the start time according to the end time of the previous data synchronization;
[0102] S2, determining the termination time according to the acquisition time of the latest data acquired by the first device; wherein the data acquired before the latest data has been stored in the first device, and the acquisition time of the latest data is less than the storage time of the latest data;
[0103] S3, taking the start time and the time range between the start time and the end time as the query time period;
[0104] S4, determining a target data set consisting of target data whose storage time matches the query time period according to the storage time corresponding to the data stored in the first device;
[0105] S5, sending the target data in the target data set to the message queue; wherein the target data is used to instruct the second device to consume the target data from the message queue, and synchronously store the target data in the second device;
[0106] S6, obtaining a target storage time corresponding to the target data in the target data set;
[0107] S7, determining a maximum target storage time according to the target storage time;
[0108] S8, determining the maximum target storage time as the deadline for this data synchronization.
[0109] For example, the first device is a business system, the second device is a business display system, the synchronization device can be a sub-device in the first device, and data synchronization is mainly to synchronize data in the business system to the business display system through the synchronization device. Figure 5 The overall architecture diagram of the synchronization process is shown in FIG. Among them, the business system can first initiate a business request to the third-party device, and then the third-party device returns the business request tag in real time (i.e., receives the business request), and then the business system can process internal data and then cache the business request tag.
[0110] The synchronous device can start two scheduled tasks when it is turned on. The first scheduled task is recorded as scheduled task 1. For a specific example diagram, see Figure 6 As shown. Scheduled task 1 mainly queries the third-party device for the processing status of business data (generally only queries the completed business data of the third-party device), and then returns the processing result of the business data (that is, obtains the processed data). After obtaining the data, the acquisition time is recorded. After that, the data can be parsed or filtered, and then the data can be stored or persisted in the database. At the same time, the storage time or storage time of the data can be recorded (that is, the current business processing time mark is recorded). After the data storage is completed, this scheduled task ends.
[0111] The second scheduled task can be recorded as scheduled task 2. For a specific example diagram, see Figure 7As shown. After the scheduled task 2 is started, the storage time of the business, the deadline of the previous data synchronization, and the acquisition time of the latest data can be queried from the scheduled task 1, and the query time period can be determined. After that, the target data within the query time period can be determined, and the target data can be converted and filtered; then the target data is sent to MQ, and it is determined whether the sending is successful. If the sending is successful, the success mark and the deadline of this synchronization are recorded. If the sending fails, the data is queried again. After the data is sent to MQ, this polling ends.
[0112] For the business display system, it can start the message queue MQ listener to monitor whether there is data in the message queue MQ. If there is data, the target data will be consumed from the message queue MQ. The target data can be parsed or filtered during the consumption process, and then the parsed or filtered data can be stored or persisted; then it can be judged whether the persistence is successful. If it is successful, it means that the data storage is successful, and this data consumption ends. Otherwise, it means that the data storage fails, and the data needs to be consumed again.
[0113] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0114] Based on the same inventive concept, the embodiment of the present application also provides a data synchronization device for implementing the data synchronization method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more data synchronization device embodiments provided below can refer to the limitations on the data synchronization method above, and will not be repeated here.
[0115] In one embodiment, Figure 8 As shown, a data synchronization device is provided, comprising: a time period determination module, a matching module and a synchronization module, wherein:
[0116] A time period determination module, used to determine a corresponding query time period according to data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device;
[0117] A matching module, configured to determine, based on the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period;
[0118] The synchronization module is used to synchronize the target data in the target data set to the second device.
[0119] Optionally, the acquisition time of the latest data is less than the storage time of the latest data.
[0120] In another embodiment, another data synchronization device is provided. Based on the above embodiment, the data synchronization information further includes the deadline of the previous data synchronization of the first device, and the time period determination module may include:
[0121] A start and end time determination unit, used to determine the start time according to the end time of the previous data synchronization, and determine the end time according to the acquisition time of the latest data;
[0122] The time period determination unit is used to obtain the query time period based on the start time and the end time.
[0123] Optionally, the time period determination unit is specifically configured to use the start time and the time range between the start time and the end time as the query time period.
[0124] In another embodiment, another data synchronization device is provided. Based on the above embodiment, the above device may further include:
[0125] A time acquisition unit, used to acquire a target storage time corresponding to target data in a target data set;
[0126] A maximum time determination unit, used for determining a maximum target storage time according to the target storage time;
[0127] The deadline determination unit is used to determine the maximum target storage time as the deadline for this data synchronization.
[0128] In another embodiment, another data synchronization device is provided. Based on the above embodiment, the synchronization module may include:
[0129] A sending unit, used for sending target data in a target data set to a message queue;
[0130] The target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
[0131] Each module in the above data synchronization device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0132] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store business data. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data synchronization method is implemented.
[0133] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0134] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0135] Determine a corresponding query time period according to data synchronization information of the first device; the above data synchronization information includes the acquisition time of the latest data acquired by the first device, and the data acquired before the latest data has been stored in the first device; according to the storage time corresponding to the data stored in the first device, determine a target data set composed of target data matching the storage time period; synchronize the target data in the target data set to the second device.
[0136] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0137] The start time is determined according to the deadline of the previous data synchronization, and the end time is determined according to the acquisition time of the latest data; and the query time period is obtained based on the start time and the end time.
[0138] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0139] The start time and the time range between the start time and the end time are taken together as the query time period.
[0140] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0141] Obtain the target storage time corresponding to the target data in the target data set; determine the maximum target storage time according to the target storage time; and determine the maximum target storage time as the deadline for this data synchronization.
[0142] In one embodiment, the acquisition time of the latest data is shorter than the storage time of the latest data.
[0143] In one embodiment, when the processor executes the computer program, the following steps are also implemented:
[0144] The target data in the target data set is sent to the message queue; wherein the target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
[0145] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0146] Determine a corresponding query time period according to data synchronization information of the first device; the above data synchronization information includes the acquisition time of the latest data acquired by the first device, and the data acquired before the latest data has been stored in the first device; according to the storage time corresponding to the data stored in the first device, determine a target data set composed of target data matching the storage time period; synchronize the target data in the target data set to the second device.
[0147] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0148] The start time is determined according to the deadline of the previous data synchronization, and the end time is determined according to the acquisition time of the latest data; and the query time period is obtained based on the start time and the end time.
[0149] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0150] The start time and the time range between the start time and the end time are taken together as the query time period.
[0151] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0152] Obtain the target storage time corresponding to the target data in the target data set; determine the maximum target storage time according to the target storage time; and determine the maximum target storage time as the deadline for this data synchronization.
[0153] In one embodiment, the acquisition time of the latest data is shorter than the storage time of the latest data.
[0154] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0155] The target data in the target data set is sent to the message queue; wherein the target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
[0156] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0157] Determine a corresponding query time period according to data synchronization information of the first device; the above data synchronization information includes the acquisition time of the latest data acquired by the first device, and the data acquired before the latest data has been stored in the first device; according to the storage time corresponding to the data stored in the first device, determine a target data set composed of target data matching the storage time period; synchronize the target data in the target data set to the second device.
[0158] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0159] The start time is determined according to the deadline of the previous data synchronization, and the end time is determined according to the acquisition time of the latest data; and the query time period is obtained based on the start time and the end time.
[0160] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0161] The start time and the time range between the start time and the end time are taken together as the query time period.
[0162] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0163] Obtain the target storage time corresponding to the target data in the target data set; determine the maximum target storage time according to the target storage time; and determine the maximum target storage time as the deadline for this data synchronization.
[0164] In one embodiment, the acquisition time of the latest data is shorter than the storage time of the latest data.
[0165] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0166] The target data in the target data set is sent to the message queue; wherein the target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
[0167] It should be noted that the data involved in this application (including but not limited to data used for analysis, data stored, data displayed, etc.) are all data fully authorized by all parties.
[0168] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0169] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0170] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data synchronization method, characterized in that: The method comprises: Determine a corresponding query time period according to data synchronization information of the first device; the data synchronization information includes the acquisition time when the first device acquires the latest data, and the data acquired before the latest data has been stored in the first device; Determine, according to the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period; The target data in the target data set is synchronized to the second device.
2. The method according to claim 1, characterized in that The data synchronization information also includes the deadline of the previous data synchronization of the first device, and the determining the corresponding query time period according to the data synchronization information of the first device includes: Determine the start time according to the deadline of the previous data synchronization, and determine the end time according to the acquisition time of the latest data; The query time period is obtained based on the start time and the end time.
3. The method according to claim 2, characterized in that The obtaining the query time period based on the start time and the end time includes: The start time and the time range between the start time and the end time are collectively used as the query time period.
4. The method according to claim 2, characterized in that: The method further comprises: Obtaining a target storage time corresponding to the target data in the target data set; Determine a maximum target storage time according to the target storage time; The maximum target storage time is determined as the deadline for this data synchronization.
5. The method according to any one of claims 1 to 3, characterized in that: The acquisition time of the latest data is shorter than the storage time of the latest data.
6. The method according to any one of claims 1 to 3, characterized in that: The synchronizing the target data in the target data set to the second device includes: Sending the target data in the target data set to a message queue; The target data is used to instruct the second device to consume the target data from the message queue and synchronously store the target data in the second device.
7. A data synchronization device, characterized in that: The device comprises: A time period determination module, configured to determine a corresponding query time period according to data synchronization information of a first device; the data synchronization information includes an acquisition time when the first device acquires the latest data, and data acquired before the latest data has been stored in the first device; A matching module, configured to determine, based on the storage time corresponding to the data stored in the first device, a target data set consisting of target data whose storage time matches the query time period; A synchronization module is used to synchronize the target data in the target data set to the second device.
8. A device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, 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.
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
Data synchronizing system and method
CN105095364A
Product data query method and device based on scheme indexes, equipment and medium
CN112579645A
Master-slave database synchronization method, device and system of time sequence database and medium
CN114398443A
Statistical method, device and equipment for high-performance operation moving trajectory and storage medium
CN114896125A
Resource allocation method of cluster, server and storage medium
CN115480911A
