Data synchronization method, device and computer-readable storage medium for distributed system
By obtaining the working status and exception timestamp of the service engine in the distributed system, the data in the distributed system is automatically synchronized, and the problems of low data synchronization efficiency and data loss in the existing technology are solved, and efficient and reliable data synchronization is achieved.
Patent Information
- Application Number
- CN202110056333.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-15
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2041-01-15
AI Technical Summary
The prior art is inefficient when synchronizing data in distributed systems and easily leads to data loss, affecting the operating reliability and stability of the system.
By obtaining the working status of each service engine in each replica group in the distributed system, setting an exception timestamp, and querying the original data to be synchronized from the original database based on this timestamp to perform data synchronization.
It realizes the efficiency and reliability of data synchronization in distributed systems, avoiding the inefficiency and data loss caused by manual adjustment.
Smart Images

Figure CN112711641B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of distributed system control technology, and in particular to a data synchronization method, device and computer-readable storage medium for a distributed system. Background Art
[0002] The same original data in a distributed system usually has multiple backup data, and different backup data can be stored on different nodes. If a node fails and the backup data stored on it is inconsistent with the original data, it will greatly affect the reliability and stability of the distributed system. In order to make the backup data on each node consistent with the original data, the current method is to migrate the node data by manual adjustment after the node failure is restored. However, when large quantities of data need to be migrated, it not only takes a long time, causing the distributed system to fail to operate normally, but also easily leads to data loss, thereby reducing the reliability and stability of the distributed system. Summary of the invention
[0003] In order to overcome the above-mentioned defects, the present invention is proposed to provide a distributed system data synchronization method, device and computer-readable storage medium that solves or at least partially solves the technical problem of how to efficiently and reliably synchronize data in a distributed system.
[0004] In a first aspect, a data synchronization method for a distributed system is provided, the method comprising:
[0005] Get the working status of each service engine in each replica group in the distributed system;
[0006] According to the working status of each of the service engines, obtaining the service engine to be synchronized;
[0007] Obtaining the exception timestamp of each of the service engines to be synchronized;
[0008] Querying the original data to be synchronized of each of the service engines to be synchronized from a preset original database according to the abnormal timestamp;
[0009] Performing data synchronization on each of the to-be-synchronized service engines according to the to-be-synchronized original data;
[0010] The replica data stored in each replica group is different, the replica data stored in each service engine in the same replica group is the same, and the abnormal timestamp indicates the time when the abnormality occurs in the service engine.
[0011] In a technical solution of the above data synchronization method, the step of “querying the original data to be synchronized of each service engine to be synchronized from a preset original database according to the abnormal timestamp” specifically includes:
[0012] Determine whether the abnormal timestamp is time zero;
[0013] If so, the original data stored in the preset original database within the query period formed from time zero to the current time is obtained, and the original data is used as the original data to be synchronized;
[0014] If not, obtaining the query start time t according to the abnormal timestamp, obtaining the original data stored in the preset original database within the query period formed from the query start time t to the current time, and using the original data as the original data to be synchronized;
[0015] The query start time t=t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents a preset first time variable and Δt1≥0.
[0016] In a technical solution of the above data synchronization method, each of the service engines includes one or more replica databases, and each replica database in the same service engine stores different replica data;
[0017] The step of “synchronizing data for each of the service engines to be synchronized according to the original data to be synchronized” specifically includes:
[0018] Obtaining replica data of each replica database in each of the service engines to be synchronized;
[0019] Perform synchronization data comparison based on the original data to be synchronized and the replica data of each replica database;
[0020] Acquire the replica database to be synchronized and the corresponding data to be synchronized in each of the to-be-synchronized service engines according to the result of the synchronization data comparison, wherein the data to be synchronized includes data to be added to the replica database and / or data to be deleted from the replica database;
[0021] According to the data to be synchronized, data adding and / or data deleting operations are performed on each of the replica databases to be synchronized, so as to complete the data synchronization of the service engines to be synchronized.
[0022] In a technical solution of the above data synchronization method, after the step of "completing the data synchronization of the service engine to be synchronized", the method further includes:
[0023] Obtaining the data synchronization completion time t2 of each service engine to be synchronized;
[0024] Acquire the original data stored in the preset original database within the query period [t2-Δt2, t2+Δt2], and use the original data as the original data to be verified, wherein Δt2 represents a preset second time variable and Δt2>0;
[0025] Data verification is performed on each service engine that has completed data synchronization according to the original data to be verified.
[0026] In a technical solution of the above data synchronization method, the step of "performing data verification on each service engine that has completed data synchronization according to the original data to be verified" specifically includes:
[0027] Performing verification data comparison based on the original data to be verified and the replica data of each replica database that has completed data synchronization in the service engine;
[0028] Acquire a replica database to be adjusted and corresponding data to be adjusted according to the result of the comparison of the verification data, wherein the data to be adjusted includes data to be added to the replica database and / or data to be deleted from the replica database;
[0029] According to the data to be adjusted, data adding and / or data deleting operations are performed on each of the replica databases to be adjusted to complete data verification.
[0030] In a technical solution of the above data synchronization method, the method further includes:
[0031] A state data table is used to store the real-time working state of each of the service engines and the database state of each of the replica databases, wherein the database state includes a data deletion state and a data addition state;
[0032] And / or, the method further comprises:
[0033] Determine whether a call failure or restart of the service engine is detected; if so, adjust the working state of the service engine from the valid state to the waiting state; if not, maintain the working state of the service engine as the valid state;
[0034] After data synchronization is performed on the to-be-synchronized service engine, adjusting the working state of the to-be-synchronized service engine from a to-be-synchronized state to a temporary storage state;
[0035] After data verification is performed on the service engine that has completed data synchronization, the working state of the service engine is adjusted from a temporary storage state to a valid state.
[0036] In a technical solution of the above data synchronization method, the method further includes:
[0037] In response to the received service engine call fault information, obtaining the fault time when the service engine call fault occurs in the service engine call fault information, and setting an abnormal timestamp for the corresponding service engine according to the fault time;
[0038] And / or, the method further comprises:
[0039] Regularly detect whether each of the service engines is restarted;
[0040] When a service engine is detected to be restarted, obtaining a medium type of a storage medium storing copy data in the service engine;
[0041] If the medium type is a temporary storage medium, the abnormal timestamp of the service engine is set according to the zero time; if the medium type is a non-temporary storage medium, the restart time when the service engine is restarted is obtained, and the abnormal timestamp of the service engine is set according to the restart time.
[0042] In a second aspect, a data synchronization device for a distributed system is provided, the device comprising:
[0043] A service engine status acquisition module, which is configured to acquire the working status of each service engine in each replica group in the distributed system;
[0044] A to-be-synchronized service engine acquisition module, configured to acquire a to-be-synchronized service engine according to the working status of each of the service engines;
[0045] An abnormal timestamp acquisition module, configured to acquire the abnormal timestamp of each of the to-be-synchronized service engines;
[0046] A module for acquiring original data to be synchronized, configured to query the original data to be synchronized of each service engine to be synchronized from a preset original database according to the abnormal timestamp;
[0047] A data synchronization module, configured to perform data synchronization on each of the to-be-synchronized service engines according to the to-be-synchronized original data;
[0048] The replica data stored in each replica group is different, the replica data stored in each service engine in the same replica group is the same, and the abnormal timestamp indicates the time when the abnormality occurs in the service engine.
[0049] In a technical solution of the above data synchronization device, the module for acquiring the original data to be synchronized is further configured to perform the following operations:
[0050] Determine whether the abnormal timestamp is time zero;
[0051] If so, the original data stored in the preset original database within the query period formed from time zero to the current time is obtained, and the original data is used as the original data to be synchronized;
[0052] If not, obtaining the query start time t according to the abnormal timestamp, obtaining the original data stored in the preset original database within the query period formed from the query start time t to the current time, and using the original data as the original data to be synchronized;
[0053] The query start time t=t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents a preset first time variable and Δt1≥0.
[0054] In a technical solution of the above data synchronization device, each of the service engines includes one or more replica databases, and each replica database in the same service engine stores different replica data;
[0055] The data synchronization module includes a replica data acquisition submodule, a synchronization data acquisition submodule, a to-be-synchronized data acquisition submodule and a data synchronization submodule;
[0056] The replica data acquisition submodule is configured to acquire the replica data of each replica database in each of the to-be-synchronized service engines;
[0057] The synchronization data acquisition submodule is configured to perform synchronization data comparison according to the original data to be synchronized and the replica data of each replica database;
[0058] The to-be-synchronized data acquisition submodule is configured to acquire the replica database to be synchronized and the corresponding to-be-synchronized data in each of the to-be-synchronized service engines according to the result of the synchronization data comparison, wherein the to-be-synchronized data includes data to be added to the replica database and / or data to be deleted from the replica database;
[0059] The data synchronization submodule is configured to perform data addition and / or data deletion operations on each of the replica databases to be synchronized according to the data to be synchronized, so as to complete the data synchronization of the service engines to be synchronized.
[0060] In a technical solution of the above data synchronization device, the device further includes a data verification module, the data verification module includes a synchronization completion time acquisition submodule, a to-be-verified original data acquisition submodule and a data verification submodule;
[0061] The synchronization completion time acquisition submodule is configured to acquire the data synchronization completion time t2 of each service engine to be synchronized;
[0062] The to-be-verified original data acquisition submodule is configured to acquire original data stored in the preset original database within a query period [t2-Δt2, t2+Δt2], and use the original data as the to-be-verified original data, wherein Δt2 represents a preset second time variable and Δt2>0;
[0063] The data verification submodule is configured to perform data verification on each service engine that has completed data synchronization according to the original data to be verified.
[0064] In a technical solution of the above data synchronization device, the data verification submodule includes a verification data comparison unit, a to-be-verified data acquisition unit and a data verification unit;
[0065] The verification data comparison unit is configured to perform verification data comparison based on the original data to be verified and the replica data of each replica database that has completed data synchronization in the service engine;
[0066] The to-be-verified data acquisition unit is configured to acquire the to-be-adjusted replica database and the corresponding to-be-adjusted data according to the result of the verification data comparison, wherein the to-be-adjusted data includes data to be added to the replica database and / or data to be deleted from the replica database;
[0067] The data verification unit is configured to perform data addition and / or data deletion operations on each of the replica databases to be adjusted according to the data to be adjusted, so as to complete data verification.
[0068] In a technical solution of the above data synchronization device, the device further includes a state data table and / or a service engine state adjustment module, and the service engine state adjustment module includes a first state adjustment submodule, a second state adjustment submodule and a third state adjustment submodule;
[0069] The state data table is configured to store the real-time working state of each of the service engines and the database state of each of the replica databases, wherein the database state includes a data deletion state and a data addition state;
[0070] The first state adjustment submodule is configured to determine whether a call failure or restart of the service engine is detected; if so, adjust the working state of the service engine from the valid state to the waiting state; if not, maintain the working state of the service engine as the valid state;
[0071] The second state adjustment submodule is configured to adjust the working state of the to-be-synchronized service engine from the to-be-synchronized state to the temporary storage state after data synchronization is performed on the to-be-synchronized service engine;
[0072] The third state adjustment submodule is configured to adjust the working state of the service engine from the temporary storage state to the valid state after performing data verification on the service engine that has completed data synchronization.
[0073] In a technical solution of the above data synchronization device, the device further includes an abnormal timestamp setting module, and the abnormal timestamp setting module includes a first timestamp setting submodule and / or a second timestamp setting submodule;
[0074] The first timestamp setting submodule is configured to, in response to the received service engine call fault information, obtain the fault time when the service engine call fault occurs in the service engine call fault information, and set an abnormal timestamp for the corresponding service engine according to the fault time;
[0075] The second timestamp setting submodule is configured to perform the following operations:
[0076] Regularly detect whether each of the service engines is restarted;
[0077] When a service engine is detected to be restarted, obtaining a medium type of a storage medium storing copy data in the service engine;
[0078] If the medium type is a temporary storage medium, the abnormal timestamp of the service engine is set according to the zero time; if the medium type is a non-temporary storage medium, the restart time when the service engine is restarted is obtained, and the abnormal timestamp of the service engine is set according to the restart time.
[0079] According to a third aspect, a control device is provided, which includes a processor and a storage device, wherein the storage device is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the data synchronization method for a distributed system described in any one of the technical solutions of the data synchronization method for the above-mentioned distributed system.
[0080] In a fourth aspect, a computer-readable storage medium is provided, which stores a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the distributed system data synchronization method described in any one of the technical solutions of the above-mentioned distributed system data synchronization method.
[0081] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:
[0082] In the technical solution of the present invention, an exception timestamp (indicating the moment when the exception occurred in the service engine) can be set for the service engine when an exception occurs. According to the exception timestamp, the original data of the service engine from the occurrence of the exception to the restoration of normality can be locked. According to the comparison result of the original data and the copy data (backup data) stored in the service engine, it can be analyzed whether data synchronization of the service engine is required. If the copy data is consistent with the original data, data synchronization is not required; if the copy data is inconsistent with the original data, data synchronization is required. Specifically, the working status of each service engine in each copy group in the distributed system can be obtained first, and the service engine to be synchronized can be obtained according to the working status of each service engine. According to the exception timestamp of each service engine to be synchronized, the original data to be synchronized of each service engine to be synchronized can be queried from the preset original database, and finally, data synchronization is performed on each service engine to be synchronized according to the original data to be synchronized. Through the above method, the embodiment of the present invention can quickly locate the service engine to be synchronized that needs to be synchronized and determine the original data to be synchronized according to the working status of the service engine and the abnormal timestamp. According to the determined original data to be synchronized, each service engine to be synchronized can be accurately synchronized, which overcomes the defects of low efficiency and easy data loss caused by manual adjustment in the prior art. In addition, since each service engine in the distributed system is independent of each other, even if it is necessary to synchronize a large number of service engines to be synchronized, data synchronization can be performed on each service engine to be synchronized at the same time, thereby further improving the data synchronization efficiency of the distributed system. BRIEF DESCRIPTION OF THE DRAWINGS
[0083] The specific embodiments of the present invention are described below with reference to the accompanying drawings, in which:
[0084] Figure 1 is a flow chart of main steps of a data synchronization method for a distributed system according to an embodiment of the present invention;
[0085] Figure 2 is a flow chart of main steps of performing data synchronization on each service engine to be synchronized according to an embodiment of the present invention;
[0086] Figure 3 It is a flowchart of main steps of performing data verification on a service engine that completes data synchronization according to an embodiment of the present invention;
[0087] Figure 4 It is a main structural block diagram of a data synchronization device for a distributed system according to an embodiment of the present invention.
[0088] Figure 5 It is a schematic diagram of an application scenario of the present invention.
[0089] List of reference numerals:
[0090] 11: Service engine status acquisition module; 12: Service engine to be synchronized acquisition module; 13: Abnormal timestamp acquisition module; 14: Original data to be synchronized acquisition module; 15: Data synchronization module. DETAILED DESCRIPTION
[0091] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0092] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memories, and may also include software parts, such as program codes, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program codes, such as a magnetic disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, and the like. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B", and may include only A, only B, or A and B. The singular terms "one" and "the" may also include plural forms.
[0093] Here we first explain some terms involved in the present invention.
[0094] Engine refers to the supporting part of a computer program or a system, while Service Engine is service-oriented and can provide a set of internal components to support the service system. For example, a service engine can be a service engine for a face recognition system, which can provide a 1:N face recognition service (identifying a face image sample that matches the current face image from N face image samples).
[0095] A distributed system refers to a distributed service system composed of multiple service engines. In an embodiment of the present invention, the distributed system may include a preset original database and multiple replica groups, each replica group may include multiple service engines, and each service engine may include one or more replica databases. The original database stores all the original data to be used by the distributed system, and the replica database stores the replica data (backup data) of these original data. Further, in an embodiment of the present invention, the replica data stored in each replica group is different, and the replica data stored in each service engine in the same replica group is the same, that is, the number of service engines in the replica group determines the number of copies (number of backups) of the original data. If there are 2 service engines in the replica group, then each original data has two copies of data, and these two copies of data are stored in different service engines in the same replica group. When the amount of data is large, the replica data to be stored by each service engine can be split into multiple copies (each copy of the data is different), and each copy of the data is stored in different replica databases of the service engine. An example: replica group A includes service engine a1 and service engine a2, service engine a1 includes replica database a11 and replica database a12, service engine a2 includes replica database a21 and replica database a22, and the backup data to be stored by replica group A is the facial images of all teachers and students in school α and school β in a certain area. Then two identical facial images of teachers and students of school α can be stored in replica database a11 and replica database a21 respectively, and two identical facial images of teachers and students of school β can be stored in replica database a12 and replica database a22 respectively.
[0096] It should be noted that the service engines in the same replica group can be set on the same server or on different servers. Similarly, the service engines in different replica groups can be set on different servers or on the same server.
[0097] The same original data in a distributed system usually has multiple backup data, and different backup data may be stored on different nodes. If a node fails and the backup data stored there is inconsistent with the original data, it will greatly affect the reliability and stability of the distributed system. At present, the traditional data synchronization method of distributed systems mainly uses manual adjustment to migrate node data after the node failure is recovered, so that the backup data on different nodes are consistent. However, when large quantities of data need to be migrated, it not only takes a long time to make the distributed system unable to operate normally, but also easily leads to data loss, thereby reducing the reliability and stability of the distributed system.
[0098] In an embodiment of the present invention, an abnormal timestamp (indicating the moment when the abnormality occurs in the service engine) can be set for the service engine when an abnormality occurs. According to the abnormal timestamp, the original data of the service engine from the occurrence of the abnormality to the restoration of normality can be locked. According to the comparison result of the original data and the copy data (backup data) stored in the service engine, it can be analyzed whether it is necessary to synchronize the data of the service engine. If the copy data is consistent with the original data, data synchronization is not required; if the copy data is inconsistent with the original data, data synchronization is required. Specifically, the working status of each service engine in each copy group in the distributed system can be obtained first, and the service engine to be synchronized can be obtained according to the working status of each service engine. According to the abnormal timestamp of each service engine to be synchronized, the original data to be synchronized of each service engine to be synchronized can be queried from the preset original database, and finally, according to the original data to be synchronized, each service engine to be synchronized can be synchronized. Among them, the preset original database can be a database set on a background server in the distributed system, and the background server can communicate with each service engine. Through the above method, the embodiment of the present invention can quickly locate the service engine to be synchronized that needs to be synchronized and determine the original data to be synchronized according to the working status of the service engine and the abnormal timestamp. According to the determined original data to be synchronized, each service engine to be synchronized can be accurately synchronized, which overcomes the defects of low efficiency and easy data loss caused by manual adjustment in the prior art. In addition, since each service engine in the distributed system is independent of each other, even if it is necessary to synchronize a large number of service engines to be synchronized, data synchronization can be performed on each service engine to be synchronized at the same time, thereby further improving the data synchronization efficiency of the distributed system.
[0099] See attached Figure 5 In an example of an application scenario of the present invention, the distributed system is a system for performing face recognition on images of teachers and students of school A and school B. The system may include a middleware server and two replica groups ( Figure 5The middleware server is provided with an original database, which stores all images of teachers and students of school A and school B (original data). The original data in the original database is divided into two parts according to the classification of the branch schools, and the images of teachers and students of school A are stored in copy group 1, and the images of teachers and students of school B are stored in copy group 2. At the same time, two identical images of teachers and students of school A are stored in the face recognition service engine 11 and face recognition service engine 12 in copy group 1, and two identical images of teachers and students of school B are stored in the face recognition service engine 21 and face recognition service engine 22 in copy group 2. In actual application, if it is detected that the face recognition service engine 11 is restarted after power failure, an abnormal timestamp is set for the face recognition service engine 11 according to the restart time and the working state of the face recognition service engine 11 is adjusted to the state to be synchronized. According to the working status of the face recognition service engine 11, it is judged as a service engine to be synchronized, and then the original data to be synchronized is obtained from the original database of the middleware server according to the abnormal timestamp of the face recognition service engine 11. The face recognition service engine 11 is synchronized according to the obtained original data to be synchronized. After the data synchronization is completed and the data verification is qualified, the working status of the face recognition service engine 11 is adjusted to a valid status so that it can provide face recognition services normally.
[0100] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart showing the main steps of a data synchronization method for a distributed system according to an embodiment of the present invention. Figure 1 As shown, the data synchronization method of the distributed system in the embodiment of the present invention mainly includes the following steps:
[0101] Step S101: Obtain the working status of each service engine in each replica group in the distributed system, wherein the replica data stored in each replica group is different, and the replica data stored in each service engine in the same replica group is the same.
[0102] The working status of the service engine may include the valid status, the pending synchronization status and the temporary storage status. The valid status indicates that the service engine can provide related services normally; the pending synchronization status indicates that the service engine needs to be synchronized with data and the service engine cannot provide related services normally; the temporary storage status indicates that the data synchronization of the service engine has been completed and the service engine can provide related services normally after the data verification is confirmed to be correct.
[0103] In order to accurately and quickly obtain the working status of each service engine, in one implementation of this embodiment, a status data table can be used to store the real-time working status of each service engine, and the service engine to be synchronized can be quickly obtained by querying the status data table. Further, in this implementation, the working status type of the service engine can be adjusted in real time according to the running status of the service engine. Specifically, the working status type of the service engine can be adjusted according to the following steps: determine whether a call failure or restart of the service engine is detected; if so, adjust the working status of the service engine from the valid state to the state to be synchronized; if not, maintain the working status of the service engine as the valid state. After the service engine to be synchronized is synchronized, the working status of the service engine to be synchronized is adjusted from the state to be synchronized to the temporary state. After the service engine that has completed data synchronization is verified, the working status of the service engine is adjusted from the temporary state to the valid state. Further, in one implementation, in addition to enabling the status data table to store the real-time working status of each service engine, the database status of each replica database can also be stored to facilitate accurate acquisition of the data operations being performed by each replica database. The database status includes but is not limited to: data deletion status and data addition status.
[0104] Step S102: Obtain the abnormal timestamp of each service engine to be synchronized.
[0105] The exception timestamp indicates the time when the exception occurs in the service engine.
[0106] In one implementation of an embodiment of the present invention, different exception timestamp setting methods can be used to set an exception timestamp for each service engine where an exception occurs according to different exception types, wherein the exception types include but are not limited to: service engine call failure and service engine restart, etc. A service engine call failure refers to a failure of a service engine call due to problems such as an inability to communicate normally with the service engine, and a service engine restart refers to a restart of a service engine due to problems such as power outages, or a control of a service engine restart when data synchronization of the corresponding service engine is required due to the addition of data in the original database. The following describes the exception timestamp setting methods for the two exception types, service engine call failure and service engine restart.
[0107] 1. Service engine call failure
[0108] In this embodiment, in response to the received service engine call fault information, the fault time when the service engine call fault occurs in the service engine call fault information can be obtained, and an abnormal timestamp can be set for the corresponding service engine according to the fault time, that is, the abnormal timestamp can be set to the fault time. An example: if it is detected that the service engine 1 has a call fault at 13:00, an abnormal timestamp of "13:00" is set for the service engine 1.
[0109] 2. Service Engine Restart
[0110] In this embodiment, it is possible to periodically detect whether each service engine has restarted; when a service engine restart is detected, the media type of the storage medium storing the copy data in the service engine is obtained; if the media type is a temporary storage medium, the abnormal timestamp of the service engine is set according to the zero time; if the media type is a non-temporary storage medium, the restart time when the service engine restarts is obtained, and the abnormal timestamp of the service engine is set according to the restart time.
[0111] Temporary storage media refers to storage media whose stored data will be completely cleared after the service engine is restarted; non-temporary storage media refers to storage media that is not affected by the restart of the service engine and whose stored data will not be cleared regardless of whether the service engine is restarted or not.
[0112] An example: If it is detected that service engine 1 restarts at 13:00 and the storage medium is a temporary storage medium, an abnormal timestamp of "00:00" is set for service engine 1. If it is detected that service engine 1 restarts at 13:00 and the storage medium is a non-temporary storage medium, an abnormal timestamp of "13:00" is set for service engine 1.
[0113] Step S103: Obtain the exception timestamp of each service engine to be synchronized.
[0114] Step S104: querying the original data to be synchronized of each service engine to be synchronized from a preset original database according to the abnormal timestamp.
[0115] If the abnormal timestamp is zero, it indicates that the duplicate data in the service engine may have been completely cleared, so it is necessary to obtain all the original data in the original database for data synchronization. If the abnormal timestamp is not zero, it indicates that only a part of the data in the service engine is inconsistent with the data in the original database. At this time, only the original data from the time when the abnormality occurs to the time when the data returns to normal can be obtained for data synchronization. Specifically, in one implementation of this embodiment, the original data to be synchronized can be obtained according to the following steps 11-13:
[0116] Step 11: Determine whether the abnormal timestamp is time zero; if so, go to step 12; if not, go to step 13.
[0117] Step 12: Acquire the original data stored in the preset original database within the query period formed from time zero to the current time, and use the original data as the original data to be synchronized, that is, all the original data in the original database are used as the original data to be synchronized.
[0118] Step 13: Obtain the query start time t according to the abnormal timestamp, obtain the original data stored in the preset original database within the query period formed from the query start time t to the current time, and use the original data as the original data to be synchronized. Among them, the query start time t = t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents the preset first time variable and Δt1≥0. By setting Δt1≥0, the original data from the abnormal timestamp to the current time can be obtained, and the original data from a certain time before the abnormal timestamp to the current time can also be obtained. Through the above steps 11 to 13, the original data to be used for data synchronization can be quickly and accurately obtained according to the abnormal timestamp.
[0119] Step S105: synchronize data for each service engine to be synchronized according to the original data to be synchronized.
[0120] In this embodiment, a data comparison can be performed between the original data to be synchronized and the copy data stored in the service engine, and the synchronization operation (adding data and / or deleting data) to be performed can be determined based on the data comparison result to ensure that the copy data in the service engine is consistent with the corresponding original data, thereby completing data synchronization.
[0121] According to the above-mentioned explanation of the terminology of the distributed system, in the embodiment of the present invention, each service engine may include one or more replica databases, and the replica data stored in each replica database of the same service engine is different. Therefore, when synchronizing data on the service engine, it is necessary to determine whether data synchronization is required for each replica database, filter out the replica databases to be synchronized, and only synchronize data on the replica databases to be synchronized, thereby further improving the synchronization efficiency of data synchronization. Specifically, refer to the attached Figure 2 In one implementation of this embodiment, the Figure 2 Steps S201 to S204 shown are to perform data synchronization on the synchronization service engine:
[0122] Step S201: Acquire the replica data of each replica database in each service engine to be synchronized.
[0123] Step S202: performing synchronization data comparison based on the original data to be synchronized and the replica data of each replica database.
[0124] Step S203: Obtain the replica database to be synchronized and the corresponding data to be synchronized in each service engine to be synchronized according to the result of the synchronization data comparison.
[0125] If the replica data in the replica database is the same as the original data to be synchronized, it indicates that there is no need to synchronize the replica database; if the replica data in the replica database is different from the original data to be synchronized, it indicates that the replica database needs to be synchronized, and this replica database is the replica database to be synchronized. At the same time, according to the result of the synchronization data comparison, it can be determined which data to be synchronized specifically includes. In this embodiment, the data to be synchronized may include data to be added to the replica database and / or data to be deleted from the replica database.
[0126] An example: If the original data to be synchronized includes data [d1, d2, d3, d5, d6], and the replica data stored in a replica database is [d1, d2, d3, d4], then it can be determined that the data to be synchronized of this replica database includes: adding data d5 and d6, and deleting data d4.
[0127] Step S204: performing data addition and / or data deletion operations on each replica database to be synchronized according to the data to be synchronized, so as to complete the data synchronization of the service engine to be synchronized.
[0128] The method described in steps S201 to S204 is used to synchronize data for each service engine to be synchronized, so that data synchronization can be performed on a large number of service engines to be synchronized at the same time, thereby significantly improving the data synchronization efficiency of the distributed system.
[0129] In order to avoid the situation where some data is not synchronized due to abnormal data deletion and data addition operations, after the synchronization service engine completes the data synchronization, the synchronized data can be verified to see if it is consistent with the original data, that is, to verify the accuracy of data synchronization. Figure 3 In one implementation of this embodiment, after completing the data synchronization of the service engine to be synchronized (step S105), the Figure 3 Steps S301 to S303 shown are used to perform data verification.
[0130] Step S301: Obtain the data synchronization completion time t2 of each service engine to be synchronized. In this embodiment, if multiple replica databases in the service engine to be synchronized need to be synchronized, the data synchronization completion time t2 of the service engine to be synchronized can be set by the time when the last replica database completes data synchronization.
[0131] Step S302: obtaining the original data stored in the preset original database within the query period [t2-Δt2, t2+Δt2], and using the original data as the original data to be verified, wherein Δt2 represents the preset second time variable and Δt2>0. It should be noted that, in this embodiment, those skilled in the art can flexibly set the value of Δt2, as long as a period of time formed by the two moments before and after the data synchronization completion moment t2 can be obtained.
[0132] Step S303: performing data verification on each service engine that has completed data synchronization according to the original data to be verified.
[0133] In this embodiment, data verification can be performed on each service engine that has completed data synchronization according to the following steps 21 to 23.
[0134] Step 21: Verify data comparison based on the original data to be verified and the copy data of each replica database that has completed data synchronization in the service engine (the "replica database that has performed data synchronization in the "replica database that has completed data synchronization").
[0135] Step 22: Obtain the replica database to be adjusted and the corresponding data to be adjusted according to the result of the verification data comparison, wherein the data to be adjusted includes data to be added to the replica database and / or data to be deleted from the replica database.
[0136] An example: If the original data to be verified includes data [d1, d2, d3, d5, d6], and the copy data stored in a replica database that has completed data synchronization is [d1, d2, d3, d4], then it can be determined that the data to be adjusted in this replica database includes: adding data d5 and d6, and deleting data d4.
[0137] Step 23: Perform data addition and / or data deletion operations on each replica database to be adjusted according to the data to be adjusted to complete data verification.
[0138] For each service engine that has completed data synchronization, the method described in steps 21 to 23 above is used to perform data verification, which can simultaneously perform data verification on a large number of service engines, thereby improving not only the data synchronization efficiency of the distributed system, but also the data synchronization accuracy of the distributed system.
[0139] According to the description of the above data synchronization method embodiment, the embodiment of the present invention can quickly locate the service engine to be synchronized that needs to be synchronized and determine the original data to be synchronized according to the working status of the service engine and the abnormal timestamp. According to the determined original data to be synchronized, each service engine to be synchronized can be accurately synchronized, which overcomes the defects of low efficiency and easy data loss caused by manual adjustment of data synchronization in the prior art. In addition, since each service engine in the distributed system is independent of each other, even when it is necessary to synchronize a large number of service engines to be synchronized, data synchronization can be performed on each service engine to be synchronized at the same time, thereby further improving the data synchronization efficiency of the distributed system. Furthermore, the data synchronization method described in the above data synchronization method embodiment can be sampled regularly to synchronize the distributed system. For example, the data synchronization method described in the above data synchronization method embodiment is executed on the distributed system once every 7 days to ensure the consistency of the replica data and the original data in the distributed system.
[0140] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.
[0141] Furthermore, the present invention also provides a data synchronization device for a distributed system.
[0142] See attached Figure 4 , Figure 4 FIG. 1 is a main structural block diagram of a data synchronization device for a distributed system according to an embodiment of the present invention. Figure 4 As shown, the data synchronization device of the distributed system in the embodiment of the present invention mainly includes a service engine status acquisition module 11, a service engine to be synchronized acquisition module 12, an abnormal timestamp acquisition module 13, an original data to be synchronized acquisition module 14 and a data synchronization module 15. In some embodiments, one or more of the service engine status acquisition module 11, the service engine to be synchronized acquisition module 12, the abnormal timestamp acquisition module 13, the original data to be synchronized acquisition module 14 and the data synchronization module 15 can be combined into one module. In some embodiments,
[0143] The service engine status acquisition module 11 can be configured to acquire the working status of each service engine in each replica group in the distributed system; the service engine to be synchronized acquisition module 12 can be configured to acquire the service engine to be synchronized according to the working status of each service engine; the abnormal timestamp acquisition module 13 can be configured to acquire the abnormal timestamp of each service engine to be synchronized; the original data to be synchronized acquisition module 14 can be configured to query the original data to be synchronized of each service engine to be synchronized from the preset original database according to the abnormal timestamp; the data synchronization module 15 can be configured to perform data synchronization on each service engine to be synchronized according to the original data to be synchronized; wherein, the replica data stored in each replica group is different, and the replica data stored in each service engine in the same replica group is the same, and the abnormal timestamp indicates the time when the service engine has an abnormality. In one embodiment, the description of the specific implementation function can be referred to the description of steps S101-step S105.
[0144] In one embodiment, the module 14 for acquiring the original data to be synchronized can be further configured to perform the following operations: determine whether the abnormal timestamp is the zero time; if so, obtain the original data stored in the preset original database within the query period formed from the zero time to the current time, and use the original data as the original data to be synchronized; if not, obtain the query start time t according to the abnormal timestamp, obtain the original data stored in the preset original database within the query period formed from the query start time t to the current time, and use the original data as the original data to be synchronized; wherein, the query start time t = t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents the preset first time variable and Δt1 ≥ 0. In one embodiment, the description of the specific implementation function can be referred to the description of step S104.
[0145] In one embodiment, each service engine may include one or more replica databases, and the replica data stored in each replica database in the same service engine is different; the data synchronization module 15 may include a replica data acquisition submodule, a synchronization data acquisition submodule, a data acquisition submodule for synchronization, and a data synchronization submodule. The replica data acquisition submodule may be configured to acquire the replica data of each replica database in each service engine to be synchronized; the synchronization data acquisition submodule may be configured to perform synchronization data comparison based on the original data to be synchronized and the replica data of each replica database; the data acquisition submodule for synchronization may be configured to acquire the replica database to be synchronized and the corresponding data to be synchronized in each service engine to be synchronized according to the result of the synchronization data comparison, wherein the data to be synchronized may include data to be added to the replica database and / or data to be deleted from the replica database; the data synchronization submodule may be configured to perform data addition and / or data deletion operations on each replica database to be synchronized according to the data to be synchronized, so as to complete the data synchronization of the service engine to be synchronized. In one embodiment, the description of the specific implementation functions can be referred to the description of steps S201-step S204.
[0146] In one embodiment, Figure 4 The data synchronization device shown may also include a data verification module, which may include a synchronization completion time acquisition submodule, a to-be-verified original data acquisition submodule, and a data verification submodule. The synchronization completion time acquisition submodule may be configured to acquire the data synchronization completion time t2 of each to-be-synchronized service engine; the to-be-verified original data acquisition submodule may be configured to acquire the original data stored in the preset original database within the query period [t2-Δt2, t2+Δt2], and use the original data as the to-be-verified original data, wherein Δt2 represents the preset second time variable and Δt2>0; the data verification submodule may be configured to perform data verification on each service engine that has completed data synchronization according to the to-be-verified original data. In one embodiment, the description of the specific implementation functions may refer to steps S301-S303.
[0147] In one embodiment, the data verification submodule may include a verification data comparison unit, a data acquisition unit to be verified, and a data verification unit. The verification data comparison unit may be configured to perform verification data comparison based on the original data to be verified and the replica data of each replica database that has completed data synchronization in the service engine; the data acquisition unit to be verified may be configured to obtain the replica database to be adjusted and the corresponding data to be adjusted based on the result of the verification data comparison, wherein the data to be adjusted may include data to be added to the replica database and / or data to be deleted from the replica database; the data verification unit may be configured to perform data addition and / or data deletion operations on each replica database to be adjusted based on the data to be adjusted to complete data verification. In one embodiment, the description of the specific implementation function can be found in step S303.
[0148] In one embodiment, Figure 4 The data synchronization device shown may also include a state data table and a service engine state adjustment module, and the service engine state adjustment module may include a first state adjustment submodule, a second state adjustment submodule, and a third state adjustment submodule. The state data table may be configured to store the real-time working state of each service engine and the database state of each replica database, wherein the database state includes a data deletion state and a data addition state; the first state adjustment submodule may be configured to determine whether a call failure or a restart of the service engine is detected; if so, the working state of the service engine is adjusted from a valid state to a state to be synchronized; if not, the working state of the service engine is maintained as a valid state; the second state adjustment submodule may be configured to adjust the working state of the service engine to be synchronized from a state to be synchronized to a temporary state after data synchronization is performed on the service engine to be synchronized; the third state adjustment submodule may be configured to adjust the working state of the service engine from a temporary state to a valid state after data verification is performed on the service engine that has completed data synchronization. In one embodiment, the description of the specific implementation function can be referred to the description of step S101.
[0149] In one embodiment, Figure 4The data synchronization device shown may also include an abnormal timestamp setting module, and the abnormal timestamp setting module may include a first timestamp setting submodule and / or a second timestamp setting submodule. The first timestamp setting submodule may be configured to respond to the received service engine call fault information, obtain the fault time when the service engine call fault occurs in the service engine call fault information, and set the abnormal timestamp for the corresponding service engine according to the fault time. The second timestamp setting submodule may be configured to perform the following operations: regularly detect whether each service engine has restarted; when a service engine is detected to have restarted, obtain the medium type of the storage medium storing the copy data in the service engine; if the medium type is a temporary storage medium, set the abnormal timestamp of the service engine according to the zero time; if the medium type is a non-temporary storage medium, obtain the restart time when the service engine restarts, and set the abnormal timestamp of the service engine according to the restart time. In one embodiment, the description of the specific implementation function can be found in step S102.
[0150] The data synchronization device of the above distributed system is used to execute Figure 1-3 The data synchronization method embodiment of the distributed system shown in the figure has similar technical principles, technical problems solved and technical effects produced. Technical personnel in this technical field can clearly understand that for the convenience and conciseness of description, the specific working process and related instructions of the data synchronization device of the distributed system can refer to the contents described in the embodiment of the data synchronization method of the distributed system, which will not be repeated here.
[0151] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of each of the above method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0152] Furthermore, the present invention also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present invention, the computer-readable storage medium can be configured to store a program for executing the data synchronization method of the distributed system of the above-mentioned method embodiment, and the program can be loaded and run by the processor to implement the data synchronization method of the above-mentioned distributed system. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The computer-readable storage medium can be a storage device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present invention is a non-temporary computer-readable storage medium.
[0153] Furthermore, the present invention also provides a control device. In an embodiment of a control device according to the present invention, the control device includes a processor and a storage device, the storage device can be configured to store a program for executing a data synchronization method for a distributed system of the above method embodiment, and the processor can be configured to execute the program in the storage device, which includes but is not limited to a program for executing a data synchronization method for a distributed system of the above method embodiment. For ease of explanation, only the parts related to the embodiment of the present invention are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present invention. The control device can be a control device device formed by various electronic devices.
[0154] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the system of the present invention, the physical devices corresponding to these modules can be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.
[0155] Those skilled in the art will appreciate that the modules in the system may be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.
[0156] So far, the technical solution of the present invention has been described in conjunction with an embodiment shown in the accompanying drawings, but it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A data synchronization method for a distributed system, characterized in that: The method comprises: Obtaining the working status of each service engine in each replica group in the distributed system, wherein the working status includes a valid status and a to-be-synchronized status; According to the working status of each of the service engines, obtaining the service engine to be synchronized; Obtaining the exception timestamp of each of the service engines to be synchronized; Querying the original data to be synchronized of each of the service engines to be synchronized from a preset original database according to the abnormal timestamp; Performing data synchronization on each of the to-be-synchronized service engines according to the to-be-synchronized original data; The replica data stored in each replica group is different, the replica data stored in each service engine in the same replica group is the same, and the abnormal timestamp indicates the time when the abnormality occurs in the service engine; The querying of the original data to be synchronized of each of the service engines to be synchronized from a preset original database according to the abnormal timestamp includes: Determine whether the abnormal timestamp is time zero; If so, the original data stored in the preset original database within the query period formed from time zero to the current time is obtained, and the original data is used as the original data to be synchronized; If not, obtaining the query start time t according to the abnormal timestamp, obtaining the original data stored in the preset original database within the query period formed from the query start time t to the current time, and using the original data as the original data to be synchronized; The query start time t=t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents a preset first time variable and Δt1≥0.
2. The data synchronization method of a distributed system according to claim 1, characterized in that: Each of the service engines includes one or more replica databases, and each replica database in the same service engine stores different replica data; The step of "synchronizing data for each of the service engines to be synchronized according to the original data to be synchronized" specifically includes: Obtaining replica data of each replica database in each of the service engines to be synchronized; Perform synchronization data comparison based on the original data to be synchronized and the replica data of each replica database; Acquire the replica database to be synchronized and the corresponding data to be synchronized in each of the to-be-synchronized service engines according to the result of the synchronization data comparison, wherein the data to be synchronized includes data to be added to the replica database and / or data to be deleted from the replica database; According to the data to be synchronized, data adding and / or data deleting operations are performed on each of the replica databases to be synchronized, so as to complete the data synchronization of the service engines to be synchronized.
3. The data synchronization method of a distributed system according to claim 2, characterized in that: After the step of "completing data synchronization of the service engine to be synchronized", the method further includes: Obtaining the data synchronization completion time t2 of each service engine to be synchronized; Acquire the original data stored in the preset original database within the query period [t2-Δt2, t2+Δt2], and use the original data as the original data to be verified, wherein Δt2 represents a preset second time variable and Δt2>0; Data verification is performed on each service engine that has completed data synchronization according to the original data to be verified.
4. The data synchronization method of a distributed system according to claim 3, characterized in that: The step of "performing data verification on each service engine that has completed data synchronization according to the original data to be verified" specifically includes: Performing verification data comparison based on the original data to be verified and the replica data of each replica database that has completed data synchronization in the service engine; Acquire a replica database to be adjusted and corresponding data to be adjusted according to the result of the comparison of the verification data, wherein the data to be adjusted includes data to be added to the replica database and / or data to be deleted from the replica database; According to the data to be adjusted, data adding and / or data deleting operations are performed on each of the replica databases to be adjusted to complete data verification.
5. The data synchronization method of a distributed system according to claim 4, characterized in that: The method further comprises: A state data table is used to store the real-time working state of each of the service engines and the database state of each of the replica databases, wherein the database state includes a data deletion state and a data addition state; and / or, The method further comprises: Determine whether a call failure or restart of the service engine is detected; if so, adjust the working state of the service engine from the valid state to the waiting state; if not, maintain the working state of the service engine as the valid state; After data synchronization is performed on the to-be-synchronized service engine, adjusting the working state of the to-be-synchronized service engine from a to-be-synchronized state to a temporary storage state; After data verification is performed on the service engine that has completed data synchronization, the working state of the service engine is adjusted from a temporary storage state to a valid state.
6. The data synchronization method of a distributed system according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to the received service engine call fault information, obtaining the fault time when the service engine call fault occurs in the service engine call fault information, and setting an abnormal timestamp for the corresponding service engine according to the fault time; and / or, The method further comprises: Regularly detect whether each of the service engines is restarted; When a service engine is detected to be restarted, obtaining a medium type of a storage medium storing copy data in the service engine; If the medium type is a temporary storage medium, the abnormal timestamp of the service engine is set according to the zero time; if the medium type is a non-temporary storage medium, the restart time when the service engine is restarted is obtained, and the abnormal timestamp of the service engine is set according to the restart time.
7. A data synchronization device for a distributed system, characterized in that: The device comprises: A service engine status acquisition module, which is configured to acquire the working status of each service engine in each replica group in the distributed system, wherein the working status includes a valid status and a to-be-synchronized status; A to-be-synchronized service engine acquisition module, configured to acquire a to-be-synchronized service engine according to the working status of each of the service engines; An abnormal timestamp acquisition module, configured to acquire the abnormal timestamp of each of the to-be-synchronized service engines; A module for acquiring original data to be synchronized, configured to query the original data to be synchronized of each service engine to be synchronized from a preset original database according to the abnormal timestamp; A data synchronization module, configured to perform data synchronization on each of the to-be-synchronized service engines according to the to-be-synchronized original data; The replica data stored in each replica group is different, the replica data stored in each service engine in the same replica group is the same, and the abnormal timestamp indicates the time when the abnormality occurs in the service engine; The module for acquiring the original data to be synchronized is further configured to perform the following operations: Determine whether the abnormal timestamp is time zero; If so, the original data stored in the preset original database within the query period formed from time zero to the current time is obtained, and the original data is used as the original data to be synchronized; If not, obtaining the query start time t according to the abnormal timestamp, obtaining the original data stored in the preset original database within the query period formed from the query start time t to the current time, and using the original data as the original data to be synchronized; The query start time t=t1-Δt1, t1 represents the abnormal timestamp, Δt1 represents a preset first time variable and Δt1≥0.
8. The data synchronization device for a distributed system according to claim 7, characterized in that: Each of the service engines includes one or more replica databases, and each replica database in the same service engine stores different replica data; The data synchronization module includes a replica data acquisition submodule, a synchronization data acquisition submodule, a to-be-synchronized data acquisition submodule and a data synchronization submodule; The replica data acquisition submodule is configured to acquire the replica data of each replica database in each of the to-be-synchronized service engines; The synchronization data acquisition submodule is configured to perform synchronization data comparison according to the original data to be synchronized and the replica data of each replica database; The to-be-synchronized data acquisition submodule is configured to acquire the replica database to be synchronized and the corresponding to-be-synchronized data in each of the to-be-synchronized service engines according to the result of the synchronization data comparison, wherein the to-be-synchronized data includes data to be added to the replica database and / or data to be deleted from the replica database; The data synchronization submodule is configured to perform data addition and / or data deletion operations on each replica database to be synchronized according to the data to be synchronized, so as to complete the data synchronization of the service engine to be synchronized.
9. The data synchronization device for a distributed system according to claim 8, characterized in that: The device also includes a data verification module, which includes a synchronization completion time acquisition submodule, a to-be-verified original data acquisition submodule and a data verification submodule; The synchronization completion time acquisition submodule is configured to acquire the data synchronization completion time t2 of each service engine to be synchronized; The to-be-verified original data acquisition submodule is configured to acquire original data stored in the preset original database within a query period [t2-Δt2, t2+Δt2], and use the original data as the to-be-verified original data, wherein Δt2 represents a preset second time variable and Δt2>0; The data verification submodule is configured to perform data verification on each service engine that has completed data synchronization according to the original data to be verified.
10. The data synchronization device for a distributed system according to claim 9, characterized in that: The data verification submodule includes a verification data comparison unit, a to-be-verified data acquisition unit and a data verification unit; The verification data comparison unit is configured to perform verification data comparison based on the original data to be verified and the replica data of each replica database that has completed data synchronization in the service engine; The to-be-verified data acquisition unit is configured to acquire the to-be-adjusted replica database and the corresponding to-be-adjusted data according to the result of the verification data comparison, wherein the to-be-adjusted data includes data to be added to the replica database and / or data to be deleted from the replica database; The data verification unit is configured to perform data addition and / or data deletion operations on each of the replica databases to be adjusted according to the data to be adjusted, so as to complete data verification.
11. The data synchronization device for a distributed system according to claim 10, characterized in that: The device further comprises a state data table and / or a service engine state adjustment module, wherein the service engine state adjustment module comprises a first state adjustment submodule, a second state adjustment submodule and a third state adjustment submodule; The state data table is configured to store the real-time working state of each of the service engines and the database state of each of the replica databases, wherein the database state includes a data deletion state and a data addition state; The first state adjustment submodule is configured to determine whether a call failure or restart of the service engine is detected; if so, adjust the working state of the service engine from the valid state to the waiting state; if not, maintain the working state of the service engine as the valid state; The second state adjustment submodule is configured to adjust the working state of the to-be-synchronized service engine from the to-be-synchronized state to the temporary storage state after data synchronization is performed on the to-be-synchronized service engine; The third state adjustment submodule is configured to adjust the working state of the service engine from the temporary storage state to the valid state after performing data verification on the service engine that has completed data synchronization.
12. The data synchronization device for a distributed system according to any one of claims 7 to 11, characterized in that: The device further comprises an abnormal timestamp setting module, wherein the abnormal timestamp setting module comprises a first timestamp setting submodule and / or a second timestamp setting submodule; The first timestamp setting submodule is configured to, in response to the received service engine call fault information, obtain the fault time when the service engine call fault occurs in the service engine call fault information, and set an abnormal timestamp for the corresponding service engine according to the fault time; The second timestamp setting submodule is configured to perform the following operations: Regularly detect whether each of the service engines is restarted; When a service engine is detected to be restarted, obtaining a medium type of a storage medium storing copy data in the service engine; If the medium type is a temporary storage medium, setting the abnormal timestamp of the service engine according to the zero time; If the medium type is a non-temporary storage medium, a restart time when the service engine is restarted is obtained, and an abnormal timestamp of the service engine is set according to the restart time.
13. A control device, comprising a processor and a storage device, wherein the storage device is suitable for storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by the processor to execute the data synchronization method of a distributed system according to any one of claims 1 to 6.
14. A computer-readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the data synchronization method for a distributed system according to any one of claims 1 to 6.
Citation Information
Patent Citations
System and method to enable deduplication engine to sustain operational continuity
US10282256B1
Distributing database differences corresponding to database change events made to a database table located on a server computer
US5999947A