Data synchronization method, apparatus, device, storage medium, and program product
By dividing the difference interval in the master-slave dual-write mode and using the read-write lock mechanism, the problem of data non-synchronization between the master and slave ends is solved, achieving a fast, non-blocking fully synchronized state and ensuring data consistency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-26
- Publication Date
- 2026-04-07
AI Technical Summary
During incremental replication, the data on the master and slave ends fails to reach a fully synchronized state, resulting in data inconsistency. Existing technologies require suspending user-end write requests or increasing log overhead, making it difficult to achieve full synchronization under continuous write conditions.
When the master is in dual-write mode, the difference data is obtained and divided into multiple intervals. The data synchronization operation with read lock is performed, and the new data is written with write lock for the interval without read lock. The read-write lock mechanism is used to ensure data consistency, and write blocking is controlled by the granularity of the difference interval.
It enables the master and slave to quickly achieve a fully synchronized state without affecting the user's write requests, avoiding write blocking and additional overhead, and ensuring data consistency.
Smart Images

Figure CN116126234B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of remote replication technology, and in particular to a data synchronization method, apparatus, device, storage medium, and program product. Background Technology
[0002] To protect data from loss due to power outages, fires, or other reasons, data is typically backed up remotely. When backing up data, a snapshot is usually created on the master device, and the differences between the snapshot and the previous snapshot are copied to the slave device to achieve incremental replication and ensure high availability of data.
[0003] However, during incremental replication, the user end continuously writes data to the master's data volume. As a result, after one incremental replication, the master end still has more data than the slave end, causing the master and slave ends to never reach a state of complete synchronization. Summary of the Invention
[0004] Therefore, it is necessary to provide a data synchronization method, apparatus, device, storage medium, and program product that can enable the master and slave ends to achieve a complete synchronization state in order to address the above-mentioned technical problems.
[0005] In a first aspect, this application provides a data synchronization method, the method comprising:
[0006] When the master is in dual-write mode, the difference between the current data and the previous data in the master's data volume is obtained; new data written to the master in dual-write mode will be automatically synchronized to the slave.
[0007] The intervals containing the differential data are divided into multiple differential intervals;
[0008] Data synchronization operations with read locks are performed on each difference interval. During the data synchronization operation, if new data that needs to be written to a difference interval without read locks is received, a new data write operation with write locks is performed on the difference interval without read locks. The data synchronization operation is used to synchronize data between the master and slave ends.
[0009] In the technical solution of this application embodiment, when the master end is in dual-write mode, the difference data between the current data and the previous data in the master end's data volume is obtained. The interval where the difference data is located is divided into multiple difference intervals. A read-lock data synchronization operation is performed on each difference interval. During the data synchronization operation, if new data that needs to be written to a difference interval without a read lock is received, a write-lock new data write operation is performed on the difference interval without a read lock. The data synchronization operation is used to synchronize the data between the master end and the slave end. In dual-write mode, new data written to the master end is automatically synchronized to the slave end. This method synchronizes the data in the difference intervals to the slave end by adding read locks to the difference intervals. Upon receiving new data, if the new data is not within the difference interval, it is directly written to the master and slave ends. If the new data is within the difference interval but not within a difference interval that is not locked by a read lock, a write lock operation is performed on the difference interval to write the new data. If the new data is within the difference interval and is within a difference interval that is being processed, it is necessary to wait for the difference interval to be processed before writing the new data to the master and slave ends. After processing all difference intervals, the master and slave ends can achieve a fully synchronized state. Because the granularity of the difference interval is small, even if the new data needs to wait for the difference interval to be processed, the waiting time for the new data is short, and there is basically no write blocking problem. It can achieve uninterrupted construction of a fully synchronized state between the master and slave ends.
[0010] In one embodiment, a read-lock data synchronization operation is performed on each difference interval, including:
[0011] Obtain the order of data synchronization operations that perform read locks on each difference interval;
[0012] According to the operation sequence, data synchronization operations with read locks are performed sequentially on each difference interval.
[0013] In the technical solution of this application embodiment, the operation order of data synchronization operation of acquiring read locks for each difference interval can be obtained, and the data synchronization operation of acquiring read locks for each difference interval can be performed sequentially according to the operation order. This method avoids the concurrent blocking of data synchronization operation of difference interval and new data writing by acquiring read locks for each difference interval sequentially through the operation order of data synchronization operation of acquiring read locks for each difference interval.
[0014] In one embodiment, obtaining the order of operations for performing read lock acquisition on each difference interval includes:
[0015] Obtain the write probability of new data being written to each difference interval during the data synchronization operation;
[0016] Based on each write probability, determine the order of operations for performing read locks on each difference interval for data synchronization.
[0017] In the technical solution of this application embodiment, the operation order of data synchronization operations with read locks performed on each difference interval is obtained, and the data synchronization operations with read locks are performed on each difference interval in turn according to the operation order. The method determines the operation order of data synchronization operations with read locks performed on each difference interval based on the write probability of new data being written to each difference interval during the data synchronization operation, thereby achieving avoidance processing, ensuring as much as possible that the data synchronization operation and the new data writing operation in each difference interval do not collide, avoiding the blocking of new data writing, and improving the efficiency of data synchronization.
[0018] In one embodiment, a read-lock data synchronization operation is performed sequentially on each difference interval, including:
[0019] For any difference interval, acquire a read lock on the difference interval;
[0020] Retrieve the data from the difference range and copy the data from the difference range to the data volume on the slave end;
[0021] Receive the confirmation message from the slave that the data was successfully written, and release the read lock on the difference range.
[0022] In the technical solution of this application embodiment, for any difference interval, a read lock is acquired on the difference interval, the data in the difference interval is obtained, and the data in the difference interval is copied to the data volume of the slave end. Then, an acknowledgment message of successful data writing sent by the slave end is received, and the read lock on the difference interval is released. When performing data synchronization operations for each difference interval, this method uses the read lock method to prevent new data from being written to the difference interval, which would cause inconsistency between the master and slave ends, thereby ensuring data consistency between the master and slave ends.
[0023] In one embodiment, performing a new data write operation with a write lock on the non-read-locked difference interval includes:
[0024] Add a write lock to the difference interval that is not currently being read-locked;
[0025] Write the new data to the write-locked difference range and synchronously write the new data to the slave's data volume;
[0026] Receive a confirmation message from the slave end confirming the successful writing of new data, and release the write lock on the difference range that was previously locked.
[0027] In the technical solution of this application embodiment, a write lock is added to the difference interval that is not read-locked, and new data is written into the difference interval with the write lock. The new data is also synchronously written to the data volume of the slave end. Then, an acknowledgment message of successful new data writing is received from the slave end, and the write lock on the difference interval with the write lock is released. In this method, when the new data received by the master end is in the difference interval that is not read-locked, the new data is written after adding a write lock to the difference interval. This prevents the master end from copying the difference interval to the slave end during the process of writing new data in the difference interval, which would cause the data to be inconsistent between the master and slave ends, thus ensuring the data consistency between the master and slave ends.
[0028] In one embodiment, the method further includes:
[0029] When the master is not in dual-write mode, copy the data from the master's data volume to the slave's data volume;
[0030] Each time new data is received, the new data is written to the master's data volume, and an incremental replication operation is performed on the master's data volume based on the current data and the data from the previous moment.
[0031] In the technical solution of this application embodiment, when the master end is not in dual-write mode, the data in the master end's data volume is copied to the slave end's data volume. Each time new data is received, the new data is written to the master end's data volume, and an incremental copy operation is performed on the master end's data volume based on the current data and the previous data. This method ensures high data availability and data consistency between the master and slave ends by performing full copying and continuous incremental copying of the data in the master end's data volume. 。
[0032] In one embodiment, the method further includes:
[0033] In response to the mode adjustment command, the master end's write mode is adjusted to dual-write mode.
[0034] In the technical solution of this application embodiment, data synchronization between the master and slave ends is achieved by adjusting the write mode of the master end to the dual write mode.
[0035] In one embodiment, the conditions for triggering the mode adjustment command include at least one of the following:
[0036] The duration of the incremental copy operation is less than the preset duration threshold;
[0037] The amount of new data received is less than a preset threshold.
[0038] The number of incremental copies performed is greater than or equal to a preset threshold.
[0039] In the technical solution of this application embodiment, by setting preset conditions, it is determined whether to adjust the mode of the master end, thereby reducing the probability of concurrent collisions between writing new data operations and data synchronization operations.
[0040] Secondly, this application also provides a data synchronization device, which includes:
[0041] The acquisition module is used to acquire the difference between the current data and the previous data in the data volume of the master when the master is in dual-write mode; new data written to the master in dual-write mode will be automatically synchronized to the slave.
[0042] The partitioning module is used to divide the intervals containing the differential data, resulting in multiple differential intervals;
[0043] The execution module is used to perform read-lock data synchronization operations on each difference interval. During the data synchronization operation, if new data that needs to be written to the difference interval without read lock is received, a write-lock operation is performed on the difference interval without read lock to write the new data. The data synchronization operation is used to synchronize the data between the master and slave ends.
[0044] Thirdly, embodiments of this application provide a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of any of the methods provided in the first aspect of the embodiments described above.
[0045] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of any of the methods provided in the first aspect of the embodiments described above.
[0046] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the methods provided in the first aspect of the embodiments described above.
[0047] The aforementioned data synchronization method, apparatus, device, storage medium, and program product, when the master end is in dual-write mode, obtains the difference data between the current data and the previous data in the master end's data volume, divides the interval containing the difference data into multiple difference intervals, and performs a read-locked data synchronization operation on each difference interval. During the data synchronization operation, if new data that needs to be written to a difference interval without a read lock is received, a write-locked new data write operation is performed on the difference interval without a read lock. The data synchronization operation is used to synchronize data between the master end and the slave end. In dual-write mode, new data written to the master end is automatically synchronized to the slave end. In this method, data in the difference intervals are synchronized to the slave end by acquiring read locks in the difference intervals. Upon receiving new data, if the new data is not within a difference interval, it is directly written to both the master and slave ends. If the new data is within a difference interval but not acquired by a read lock, a write lock operation is performed on the difference interval to write the new data. If the new data is within a difference interval and is currently being processed, the processing of the difference interval must be completed before the new data is written to both the master and slave ends. After processing all difference intervals, the master and slave ends can achieve a fully synchronized state. Because the granularity of the difference intervals is small, even if new data needs to wait for the processing of the difference intervals to complete, the waiting time is short, and there is basically no write blocking problem. This method can achieve uninterrupted construction of a fully synchronized state between the master and slave ends. Attached Figure Description
[0048] Figure 1 This is a diagram illustrating the application environment of a data synchronization method in one embodiment;
[0049] Figure 2 This is a flowchart illustrating a data synchronization method in one embodiment;
[0050] Figure 3 This is a flowchart illustrating the data synchronization method in another embodiment;
[0051] Figure 4 This is a flowchart illustrating the data synchronization method in another embodiment;
[0052] Figure 5 This is a flowchart illustrating the data synchronization method in another embodiment;
[0053] Figure 6 This is a flowchart illustrating the data synchronization method in another embodiment;
[0054] Figure 7 This is a flowchart illustrating the data synchronization method in another embodiment;
[0055] Figure 8 This is a flowchart illustrating the data synchronization method in another embodiment;
[0056] Figure 9 This is a flowchart illustrating the data synchronization method in another embodiment;
[0057] Figure 10 This is a flowchart illustrating the data synchronization method in another embodiment;
[0058] Figure 11 This is a flowchart illustrating the data synchronization method in another embodiment;
[0059] Figure 12 This is a flowchart illustrating the data synchronization method in another embodiment;
[0060] Figure 13 This is a flowchart illustrating the data synchronization method in another embodiment;
[0061] Figure 14 This is a flowchart illustrating the data synchronization method in another embodiment;
[0062] Figure 15 This is a structural block diagram of a data synchronization device in one embodiment;
[0063] Figure 16 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0065] The data synchronization method provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown depicts a scenario where the master device communicates with both the user and slave devices via a network. The master, user, and slave devices can be, but are not limited to, various personal computers, laptops, smartphones, tablets, terminal devices, and servers.
[0066] With the rapid increase in information in the internet age, storage technology has become a key factor in enterprise infrastructure. Faced with the massive growth of data, data protection and disaster recovery are becoming increasingly important while ensuring efficient data utilization. Remote replication technology in disaster recovery centers can effectively protect the physical security of data by remotely backing it up, preventing data loss due to power outages, fires, or natural disasters. Remote replication in disaster recovery centers is mainly divided into asynchronous remote replication and synchronous remote replication.
[0067] This application uses synchronous remote replication as an example for explanation. Synchronous remote replication mainly refers to the local host (master) sending a write request to the remote host (slave) at the same time as writing data to the local storage device after receiving a write request from the upper-layer application (user). After receiving confirmation information from both the local storage device and the remote host that the write was successful, the local host then returns a write success message to the upper-layer application.
[0068] Synchronous remote replication offers a simple disaster recovery method, but its implementation requires consideration of the network conditions of the two data centers, replication efficiency, and the performance impact on the replication endpoint. If a natural disaster or human-caused accident occurs at one endpoint during replication, how to ensure that the data being transmitted is not lost and how to quickly restore the synchronous replication state are also crucial considerations. These delicate trade-offs are the core issues of distributed systems.
[0069] Furthermore, for remote replication, simply copying data from one end to the other is usually insufficient, because the client continuously writes new data to the master, and the data is constantly changing. These changing data must be carried over to the slave in a timely manner according to the replication strategy. Locking the master (making it writable) could be considered to ensure data consistency during replication, but this would violate the high availability design goal. Therefore, for the overall strategy of asynchronous replication, and in the initial stage of synchronous replication, snapshots are typically continuously created on the master. Data is copied each time based on the differences between the master snapshots. This ensures both high data availability and continuous incremental replication.
[0070] However, during incremental replication, the user end continues to write data to the master's data volume. This means that after one incremental replication, the master still has more data than the slave. Therefore, if only incremental replication is used, the replication state will never reach complete synchronization. A partially synchronized state refers to the state where the data on both the master and slave volumes are not fully synchronized. In this case, the data on both ends is inconsistent, and it is necessary to restore the state to full synchronization to maintain real-time synchronous remote replication.
[0071] The fully synchronized state refers to the state after the master and slave ends of the synchronous remote replication have completed initialization. During this stage, the reading and writing of data on both ends are consistent. The master end can only return to the user after both the master and slave ends have completed writing.
[0072] In one approach, the write rate of the user end can be limited. When the difference between the master and slave ends is small, the write request of the user end is suspended on the backend, and the incremental replication is completed quickly. At this time, the data of the master and slave ends are consistent, the replication state becomes fully synchronized, and the write request of the user end is allowed to pass.
[0073] In another approach, when the difference between the master and slave ends is small, the user's new write requests during an incremental replication can be recorded by logging. After the incremental replication, the write is changed to dual-end write, and the differences between the two ends of these records are copied to the slave end. This way, a fully synchronized state can eventually be achieved.
[0074] However, the first method requires suspending client-side write requests for a period of time before the master and slave are fully synchronized for the final incremental replication. If the suspension time is long, the client will clearly feel the write request blocking. The second method requires additional logging, increasing backend request overhead for a period of time, and also requires handling log-related operations. Furthermore, both methods can only be implemented when the difference between the master and slave is very small, and are dependent on the actual input / output (I / O) request volume of the client. If the client continuously makes write requests, it will be difficult to find an opportunity for the master and slave to reach a fully synchronized state.
[0075] Based on this, this application provides a data synchronization method, apparatus, device, storage medium, and program product that enables the master and slave ends to achieve a complete synchronization state.
[0076] Furthermore, the data synchronization method in this application does not affect the write requests of the user client, nor does it rely on the amount of I / O on the user client for state transitions.
[0077] The data synchronization method in this application will be described below with the master end as the execution subject.
[0078] In one embodiment, such as Figure 2 As shown, a data synchronization method is provided, including the following steps:
[0079] S201, when the master is in dual-write mode, obtain the difference data between the current data and the previous data in the master's data volume.
[0080] In dual-write mode, new data written to the master end will be automatically synchronized to the slave end, such as... Figure 3 As shown, Figure 3 The flowchart shows the process when the master is in dual-write mode. When the master receives a new data write request from the user, it writes the new data to the master's data volume and simultaneously writes the new data to the slave. Only after both the master and slave have successfully written the data will the master send a confirmation message to the user. Furthermore, when the master is in dual-write mode, it retrieves the difference between the current data and the previous data in the master's data volume.
[0081] When the master is in dual-write mode, obtain the difference data between the current data and the previous data in the master's data volume; where the previous time is the time after the last new data was written to the master; the difference data is the data that shows the difference between the current data in the master's data volume and the data in the master's data volume at the previous time.
[0082] After the master writes the new data it receives to its data volume, it creates a snapshot of the data volume as a backup. Therefore, the master stores snapshots of its data volume at various points in time.
[0083] Therefore, one way to obtain the difference between the current data and the previous data in the master's data volume is to compare the data in the master's data volume at the current moment with the snapshot created in the master's data volume at the previous moment to determine the difference.
[0084] Another way to obtain the difference between the current data and the previous data in the master's data volume is to compare the snapshot created in the master's data volume at the current time with the snapshot created in the master's data volume at the previous time to determine the difference.
[0085] A snapshot of a data volume refers to an available copy of the data volume, which includes an image of the data volume at a certain point in time (the point at which the copy begins). A snapshot can be a copy of the data represented by the data volume or a replica of the data volume.
[0086] S202 divides the intervals containing the differential data to obtain multiple differential intervals.
[0087] The master data volume is divided into multiple intervals, and the data in the data volume is stored in the intervals. Therefore, the interval where the difference data is located is called the difference interval, and there may be multiple difference intervals.
[0088] Optionally, after obtaining the intervals corresponding to the difference data, in order to reduce the granularity, the intervals corresponding to the difference data can be divided into multiple difference intervals.
[0089] One possible method is to divide the interval corresponding to any difference data into a preset number of intervals on average, and use the preset number of intervals as the preset number of difference intervals.
[0090] S203, perform read lock data synchronization operations on each difference interval respectively, and if new data that needs to be written to the difference interval without read lock is received during the data synchronization operation, perform write lock new data writing operation on the difference interval without read lock.
[0091] The data synchronization operation is used to synchronize data between the master and slave ends.
[0092] Based on the differences obtained above, a read lock is acquired for each difference interval to synchronize the data of each difference interval to the slave end. When performing the data synchronization operation on each difference interval, a read lock is acquired for the corresponding difference interval.
[0093] If, during data synchronization, new data is received that needs to be written to a difference interval without a read lock, a write lock operation is performed on the difference interval without a read lock to write the new data. That is, if a read lock is acquired on the difference interval during data synchronization, and the master receives new data in a difference interval without a read lock, then a write lock is acquired on the corresponding difference interval without a read lock, and the new data is written into that difference interval without a read lock. Since the master is in dual-write mode at this time, when the master receives new data, it acquires a write lock on the difference interval without a read lock corresponding to the new data and writes it into that difference interval. At the same time, the master will also synchronize the new data to the slave and write it into the corresponding data volume of the slave.
[0094] When the master performs a write operation on a difference range that is not locked by a read lock, it first acquires a write lock on the difference range, and then writes the new data to the data volume of the master and the data volume of the slave. When the data volume of the master and the data volume of the slave are finished writing the new data, the write lock on the difference range is released.
[0095] Optionally, if a read lock is acquired during a data synchronization operation in a certain difference interval, and the master receives new data within the difference interval with the read lock, the new data needs to wait until the data synchronization operation in the difference interval with the read lock is completed and the read lock is released before the new data is written to the master and slave.
[0096] If the master is performing a write operation on a differential interval that is not currently locked, and the master needs to perform a data synchronization operation on the differential interval that is locked, the master must wait for the write lock on the differential interval to be released before the data synchronization operation on the differential interval is performed.
[0097] It should be noted that both reading locks and writing locks on a difference interval are locks on the interval located on the data volume of the master end; if a read lock is added to a difference interval, new data cannot be written to the difference interval, and if a write lock is added to a difference interval, data in the difference interval cannot be read.
[0098] A range lock can lock a range of data. A range read-write lock divides the range lock into two parts: a read lock and a write lock. A read lock allows multiple requests to acquire it simultaneously because read operations are request-safe. A write lock, however, is a mutex lock, preventing multiple requests from acquiring it concurrently, and write and read operations are mutually exclusive. In summary, the characteristics of a read-write lock are: reads are not mutually exclusive, reads and writes are mutually exclusive, and writes and writes are mutually exclusive.
[0099] The above data synchronization method, when the master is in dual-write mode, obtains the difference data between the current data and the previous data in the master's data volume, divides the interval containing the difference data into multiple difference intervals, and performs a read-lock data synchronization operation on each difference interval. During the data synchronization operation, if new data that needs to be written to a difference interval without a read lock is received, a write-lock new data write operation is performed on the difference interval without a read lock. The data synchronization operation is used to synchronize the data between the master and slave. In dual-write mode, new data written to the master is automatically synchronized to the slave. In this method, data in the difference intervals are synchronized to the slave end by acquiring read locks in the difference intervals. Upon receiving new data, if the new data is not within a difference interval, it is directly written to both the master and slave ends. If the new data is within a difference interval but not acquired by a read lock, a write lock operation is performed on the difference interval to write the new data. If the new data is within a difference interval and is currently being processed, the processing of the difference interval must be completed before the new data is written to both the master and slave ends. After processing all difference intervals, the master and slave ends can achieve a fully synchronized state. Because the granularity of the difference intervals is small, even if new data needs to wait for the processing of the difference intervals to complete, the waiting time is short, and there is basically no write blocking problem. This method can achieve uninterrupted construction of a fully synchronized state between the master and slave ends.
[0100] In one embodiment, such as Figure 4 As shown, data synchronization operations with read locks are performed on each difference interval, including:
[0101] S401, obtain the operation sequence of data synchronization operations that perform read locks on each difference interval.
[0102] The master's data volume contains multiple intervals, and the master pre-stores the sequence number of each interval, which can be the order of operations for processing each interval.
[0103] Therefore, the corresponding data synchronization operation order for each differential interval is obtained from the operation order of each interval.
[0104] S402, according to the operation sequence, perform data synchronization operations by acquiring read locks on each difference interval in turn.
[0105] According to the operation sequence, data synchronization operations with read locks are performed sequentially on each difference interval. In one embodiment, such as... Figure 5 As shown, the data synchronization operation of acquiring read locks is performed sequentially on each difference interval, including the following steps:
[0106] S501: For any difference interval, add a read lock to the difference interval.
[0107] Before performing data synchronization operations on any difference interval, a read lock must first be acquired on that difference interval. Acquiring a read lock on the difference interval ensures that no new data is written during the synchronization operation, thus preventing data modifications within the difference interval and ensuring data consistency between the master and slave ends.
[0108] S502, retrieve the data in the difference range and copy the data in the difference range to the data volume of the slave end.
[0109] After acquiring a read lock on the difference interval, the data in that difference interval is read from the master's data volume and sent to the slave, where it is written to the slave's data volume. Once the slave has successfully written the data, it sends a confirmation message to the master confirming the successful data write.
[0110] S503 receives an acknowledgment message from the slave end confirming successful data write and releases the read lock on the difference interval.
[0111] After the master receives a confirmation message from the slave indicating that the data has been successfully written, it releases the read lock on the difference interval.
[0112] like Figure 6 As shown, Figure 6 The flowchart shows the data synchronization operation of acquiring read locks on the difference interval. First, a read lock is acquired on the difference interval. Then, the data of the difference interval is read from the data volume of the master end and written to the data volume of the slave end. A confirmation message of successful data writing is received from the slave end. Finally, the read lock is released. The data synchronization operation of acquiring read locks is performed on each difference interval in sequence until all difference intervals are processed. At this time, the data of the master and slave ends are completely consistent, and the master and slave ends reach a state of complete synchronization.
[0113] Understandably, when performing data synchronization operations in different intervals, read locks are used to prevent new data from being written to that interval, which could lead to inconsistencies between the master and slave ends, thus ensuring data consistency between the master and slave ends.
[0114] The aforementioned data synchronization method obtains the operation order of acquiring read locks for each difference interval, and performs read lock acquisition operations on each difference interval sequentially according to the operation order. This method avoids concurrent blocking when handling data synchronization operations in difference intervals and writing new data by sequentially performing read lock acquisition operations on each difference interval.
[0115] The following example illustrates how to obtain the data synchronization operation sequence for acquiring read locks in each difference interval. In one example, as shown... Figure 7 As shown, the operation sequence for obtaining data synchronization operations that acquire read locks on each difference interval includes the following steps:
[0116] S701, obtains the write probability of new data being written to each difference interval during the data synchronization operation.
[0117] The process of acquiring a read lock on the difference range, copying the data in the difference range after acquiring the read lock to the data volume on the slave end, and releasing the write lock after successful copying is also called the remote copy function.
[0118] Because a read lock is applied to the difference interval before processing, when the new data requested by the user is in the difference interval with the read lock, it needs to wait for the remote replication function to finish processing the current difference interval and release the read lock before it can be processed. In the end, both the master and slave ends have the latest data written by the user, and this difference interval keeps the data of the master and slave ends consistent.
[0119] It should be noted that since the read requests from the user end also use read locks, this concurrency scenario does not need to be handled, and the latest data can always be read. However, if the write request from the user end becomes concurrent with the processing of the remote replication function, it may be necessary to wait for an additional cycle of the remote replication function's processing of the difference range before it can be processed.
[0120] Therefore, when the remote copy function handles the difference interval, several factors need to be considered: (1) the difference interval is very small and the probability of concurrent collision is low; (2) the remote copy function can determine which interval the user terminal will write at a certain moment based on the trend of user terminal I / O feedback from the underlying layer, and thus perform avoidance processing (that is, if it is believed that the user terminal will write certain intervals at certain times, and the difference interval happens to have this interval, other difference intervals can be processed first, and this difference interval can be processed after this period of time).
[0121] Therefore, based on the trend of new data being written by the user end in the underlying feedback, the write probability of new data being written to each difference interval during the data synchronization operation is determined.
[0122] S702 determines the order of operations for performing read locks on data synchronization operations for each difference interval based on the write probability.
[0123] Based on the order of write probabilities from smallest to largest, the order of data synchronization operations that acquire read locks on each difference interval is determined. That is, the smaller the write probability, the earlier the data synchronization operation that acquires read locks on the difference interval is performed.
[0124] Accordingly, data synchronization operations with read locks are performed sequentially on each difference interval in order of increasing write probability.
[0125] The aforementioned data synchronization method obtains the write probability of new data being written to each difference interval during the data synchronization operation, and determines the operation order of performing read lock acquisition on each difference interval based on the write probability. This method, by determining the operation order of performing read lock acquisition on each difference interval based on the write probability of new data being written to each difference interval during the data synchronization operation, implements avoidance processing, ensuring that data synchronization operations in each difference interval do not collide with new data write operations as much as possible, avoiding blocking of new data writes, and improving the efficiency of data synchronization.
[0126] The above embodiments illustrate how to perform read-lock data synchronization operations on different difference intervals. The following embodiment illustrates how to perform write-lock new data writing operations on difference intervals without read locks. In one embodiment, as shown... Figure 8 As shown, performing a new data write operation with a write lock on a difference interval that is not currently locked by a read lock includes the following steps:
[0127] S801 adds a write lock to the difference interval that is not currently locked for reading.
[0128] Before performing a new data write operation on a differential interval that is not read-locked, a write lock must first be added to the differential interval that is read-locked. Adding a write lock to the differential interval ensures that no data synchronization operation is performed on the differential interval during the process of performing a new data write operation, thus ensuring data consistency between the master and slave ends.
[0129] S802 writes new data into the write-locked difference range and synchronously writes new data into the slave's data volume.
[0130] After acquiring a write lock on the difference interval, the new data is written to the difference interval of the master's data volume, and simultaneously written to the slave's data volume. After the new data is successfully written to the slave's data volume, the slave will send a confirmation message to the master confirming the successful write of the new data.
[0131] S803 receives an acknowledgment message from the slave end confirming successful writing of new data and releases the write lock on the difference range.
[0132] After the master receives a confirmation message from the slave indicating that the new data has been successfully written, it releases the write lock on the difference interval.
[0133] Optionally, after the master releases the write lock on the difference range, it will send a confirmation message to the user terminal confirming that the new data has been successfully written.
[0134] The aforementioned data synchronization method involves acquiring a write lock on the unlocked difference interval, writing new data into the write-locked difference interval, and synchronously writing the new data to the slave's data volume. Then, it receives an acknowledgment message from the slave confirming the successful write of the new data and releases the write lock on the difference interval. In this method, when the new data received by the master is within an unlocked difference interval, acquiring a write lock on that interval before writing the new data prevents the master from copying the difference interval to the slave during the writing process, thus ensuring data consistency between the master and slave.
[0135] In one embodiment, such as Figure 9 As shown, this embodiment includes the following steps:
[0136] S901, when the master is not in dual-write mode, copies the data in the master's data volume to the slave's data volume.
[0137] For the data volume on the master side, I / O requests are allowed to be made by the user client at any time. Before synchronous remote replication, the master side is not set to dual-write mode. Once the I / O request is completed on the master side, a write success result can be returned to the user client.
[0138] Synchronous remote replication refers to the process of copying local (master) production data to a remote (slave) location in a completely synchronized manner using replication software or smart hardware systems. Under this replication rule, the remote backup data and local data have strong real-time performance, and the remote data copy is completely synchronized with the local data in the event of a disaster.
[0139] Therefore, at the start of synchronous remote replication, such as Figure 10 As shown, when the master is in single-write mode, the master considers the new data to be successfully written when the master's data volume is successfully written. After receiving the new data write request from the user, the master writes the new data into the master's data volume and returns a confirmation message of successful write to the user. Then, a full copy is performed, that is, all the data in the master's data volume is copied to the slave's data volume.
[0140] Because the data in the master's data volume is constantly being written to by user clients during the replication process, and the data in the master's data volume is constantly changing, a snapshot is used as the replication source to ensure that the data is not modified during replication. Therefore, the method for replicating data from the master's data volume to the slave's data volume is as follows: create a snapshot of the current master's data volume, and then replicate the data corresponding to the snapshot to the corresponding data volume in the slave cluster.
[0141] S902: Each time new data is received, the new data is written to the master's data volume, and an incremental copy operation is performed on the master's data volume based on the current data and the previous data.
[0142] During the process of copying data from the master data volume to the slave data volume, new data from the user terminals is continuously written to the master data volume. Incremental replication can be used to compare the changes in the data in the master data volume and copy the differences to the slave to ensure data consistency between the master and slave.
[0143] Therefore, after the master receives new data and writes it to its data volume, it compares the data in the current data volume with the data in the data volume during the last full or incremental replication, and then performs an incremental replication operation on the master's data volume.
[0144] like Figure 11 As shown, a snapshot is created on the master's data volume at the current moment, and the current snapshot is compared with the snapshot created at the start of the last full / incremental replication. The difference data between the two snapshots is obtained, and the difference data is read and copied to the slave's data volume.
[0145] The aforementioned data synchronization method, when the master end is not in dual-write mode, copies data from the master end's data volume to the slave end's data volume. Each time new data is received, it is written to the master end's data volume. Based on the current data and the previous data in the master end's data volume, incremental replication is performed on the master end's data volume. This method, by performing full replication and continuous incremental replication of data in the master end's data volume, ensures high data availability and data consistency between the master and slave ends. 。
[0146] After several incremental copies, an evaluation can be performed to determine whether the mode of the master end should be adjusted. When the conditions for triggering the mode adjustment command are met, the write mode of the master end can be adjusted. In one embodiment, the embodiment includes: in response to the mode adjustment command, adjusting the write mode of the master end to dual-write mode.
[0147] The conditions for triggering the mode adjustment command include at least one of the following: the duration of the incremental copy operation is less than a preset duration threshold; the amount of new data received is less than a preset quantity threshold; or the number of incremental copies performed is greater than or equal to a preset number threshold.
[0148] The duration of an incremental replication operation is the time taken from the creation of a snapshot to the completion of the replication. This includes the time between creating a snapshot of the current master's data volume, comparing the current snapshot with the previously created snapshot to obtain the difference data, copying the difference data to the slave's data volume, and receiving a confirmation message from the slave confirming the successful writing of the difference data.
[0149] If at least one of the following conditions is met: the duration of the incremental copy operation is less than a preset duration threshold, the amount of new data received is less than a preset quantity threshold, or the number of incremental copies performed is greater than or equal to a preset number threshold, a mode adjustment command is triggered. In response to the mode adjustment command, the master end adjusts its write mode to dual-write mode.
[0150] It should be noted that the triggering condition for the mode adjustment command can also be other user configurations. For example, the mode adjustment command can be triggered at a preset time to adjust the write mode of the master end to dual-write mode at the preset time. The triggering condition for the mode adjustment command in this application embodiment is not limited in this application, and in practical applications, other triggering conditions are also possible.
[0151] Understandably, by evaluating whether to adjust the master-side mode, the probability of concurrent collisions between new data write operations and data synchronization operations is reduced.
[0152] Therefore, it is possible to assess when to stop incremental replication and switch to the process before full synchronization. We can choose a time when the difference in the difference data is relatively small. This way, the probability of concurrent collisions between writing new data operations and data synchronization operations will be very low. At the same time, even if a collision occurs, only the current request interval needs to wait for one more data sending and slave I / O cycle, which has a negligible impact on the overall user request performance.
[0153] The processing during the final incremental replication to the fully synchronized state ensures data consistency between the master and slave ends. This process is explained in detail here. Inconsistency scenarios only occur when there is dual writing on the master end, or when new data writing and data synchronization operations occur concurrently on the user end. In this case, read-write locks are used to ensure that inconsistency does not occur and that the final data is the data written to the user end.
[0154] In one embodiment, such as Figure 12 As shown, Figure 12 When new data received and data synchronization operations are in the same time interval, the data synchronization operation is processed first.
[0155] When new data is received from the client, the new data is in a certain difference range, and data synchronization is being performed in that range. A read lock has been acquired for this difference range. When a write lock is acquired for the difference range, the write lock acquisition fails, and the client must wait for the read lock to be released.
[0156] When performing a synchronization operation on a difference interval, a read lock is acquired on the difference interval, and data B in the data volume of the difference interval on the master end is read and sent to the slave end. The slave end writes B into the corresponding interval of the slave end's data volume, receives a confirmation message of successful write from the slave end, and releases the read lock on the difference interval. Then, a write lock is acquired on the difference interval, new data A is written to the difference interval of the master end's data volume, and A is sent to the slave end. The slave end writes A into the corresponding interval of the data volume and returns a confirmation message of successful write. The master end releases the write lock on the difference interval and returns a confirmation message of successful write of new data A to the user end.
[0157] In one embodiment, such as Figure 13 As shown, Figure 13 When new data is received and data synchronization operations are in the same interval, the new data is written first.
[0158] When performing a data synchronization operation in the difference interval, the master receives new data A sent by the user, and A is within the difference interval. When writing new data A, a write lock is acquired for the difference interval corresponding to the new data A. Therefore, acquiring a read lock for the difference interval before performing the data synchronization operation in the difference interval fails, and it is necessary to wait for the write lock of the difference interval to be released.
[0159] The master receives new data A from the user. Since data A is within the difference interval, it acquires a write lock on the difference interval corresponding to A. Then, it writes A into the difference interval of its data volume and sends A to the slave, writing it into the corresponding interval of the slave's data volume. The master receives a write success confirmation message from the slave, releases the write lock on the difference interval, and sends a write success confirmation message back to the user. Next, it acquires a read lock on the difference interval, reads the data (data A) from the difference interval in the master's data volume, sends A to the slave, writes it into the corresponding interval of the slave's data volume, receives a write success confirmation message from the slave, and releases the read lock on the difference interval.
[0160] In this application, the processing from the end of the last incremental replication to the state of full synchronization involves handling the concurrency issues with new data write requests from the user end by acquiring a range read lock, reading the corresponding range content of the master data volume, and sending it to the slave end each time a difference range is processed. Finally, after all difference processing is completed, a state of full synchronization is achieved.
[0161] As described above, when new data is written to the user end first, the data synchronization operation for this interval must wait for the new data to be written completely and the write lock to be released due to the mutual exclusion of read-write locks. At this time, when the data synchronization operation executes this interval, it reads the latest data just written by the user end and sends it to the slave end. Ultimately, both ends still display the latest data written by the user end, and this interval maintains data consistency between the two ends. Furthermore, it achieves the transition of the data volumes of the synchronous remote replication master and slave ends to a fully synchronized state without interruption. During the process of replicating the data volumes of the master and slave ends to a fully synchronized state, it does not affect new data write requests on the user end and does not rely on user I / O volume for state transition.
[0162] In one embodiment, such as Figure 14 As shown, this embodiment includes the following steps:
[0163] S1401: When the master is in single-write mode, create a snapshot of the master volume on the master and copy the data corresponding to the snapshot to the slave volume on the slave.
[0164] In the single-write mode, the master terminal performs a write operation on the master volume after receiving a write request from the user, and returns a confirmation message to the user terminal after the write is successful.
[0165] S1402, each time new data is received, a snapshot is created for the current primary volume, and the current snapshot is compared with the snapshot created for the previous primary volume to determine the difference data between the two snapshots, and the difference data is copied from the primary volume to the secondary volume.
[0166] S1403, when the preset conditions are met, the write mode of the master end is adjusted to dual write mode, the difference data between the current snapshot and the last created snapshot of the master end is obtained, and the difference range is obtained.
[0167] The preset conditions include: the time spent on the previous incremental replication was less than a preset threshold; or, the user request data on the user's end was less than a preset threshold during the previous incremental replication; or, the number of incremental replications reached a preset threshold.
[0168] Only after both the master and slave ends have successfully written the data will a confirmation message be sent to the user end to confirm the successful write.
[0169] S1404 divides the difference intervals to obtain multiple difference intervals.
[0170] S1405, for each difference interval, perform a data synchronization operation with a read lock on the difference interval; if write data that needs to be written to a difference interval without a read lock is received during the data synchronization operation, then perform a new data write operation with a write lock on the difference interval without a read lock to achieve data synchronization between the master and slave ends.
[0171] The data synchronization operation of performing read lock on the difference interval includes: acquiring a read lock on the difference interval of the main volume data, then reading the data of the difference interval from the main volume, and writing the data to the slave volume at the slave end;
[0172] The process of performing a write lock operation on a difference interval that is not read-locked includes: acquiring a write lock on the difference interval that is not read-locked, writing the new data to the difference interval of the primary volume and the corresponding difference interval of the secondary volume at the same time, and then releasing the write lock on the difference interval.
[0173] Once the difference intervals have been processed, it is determined that the data on the master and slave ends are completely consistent, and the master and slave ends are in a state of complete synchronization.
[0174] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0175] Based on the same inventive concept, this application also provides a data synchronization device for implementing the data synchronization method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations in one or more data synchronization device embodiments provided below can be found in the limitations of the data synchronization method described above, and will not be repeated here.
[0176] In one embodiment, such as Figure 15 As shown, a data synchronization device is provided, including: an acquisition module 1501, a partitioning module 1502, and an execution module 1503, wherein:
[0177] The acquisition module 1501 is used to acquire the difference between the current data and the previous data in the data volume of the master when the master is in dual-write mode; new data written to the master in dual-write mode will be automatically synchronized to the slave.
[0178] The partitioning module 1502 is used to partition the intervals containing the differential data to obtain multiple differential intervals;
[0179] The execution module 1503 is used to perform read-lock data synchronization operations on each difference interval respectively. During the data synchronization operation, if new data that needs to be written to the difference interval without read lock is received, a write-lock operation is performed on the difference interval without read lock to write the new data. The data synchronization operation is used to synchronize the data between the master and slave ends.
[0180] In one embodiment, the execution module 1503 includes:
[0181] The acquisition unit is used to acquire the operation order of data synchronization operations that acquire read locks for each difference interval; the execution unit is used to perform data synchronization operations that acquire read locks for each difference interval in sequence according to the operation order.
[0182] In one embodiment, the acquisition unit includes:
[0183] The first acquisition subunit is used to acquire the write probability of new data being written to each difference interval during the data synchronization operation.
[0184] The execution subunit is used to determine the order of operations for performing read lock acquisition on each difference interval based on the write probability.
[0185] In one embodiment, the execution unit includes:
[0186] The locking subunit is used to acquire a read lock on any difference interval.
[0187] The second acquisition subunit is used to acquire the data in the difference interval and copy the data in the difference interval to the data volume of the slave end;
[0188] The first release subunit is used to receive an acknowledgment message from the slave end confirming that the data was successfully written, and to release the read lock on the difference interval.
[0189] In one embodiment, the execution module 1503 includes:
[0190] The locking unit is used to add a write lock to the difference interval that is not currently read-locked;
[0191] The write unit is used to write new data into the write-locked difference range and to synchronously write new data into the slave's data volume.
[0192] The release unit is used to receive an acknowledgment message from the slave end confirming that the new data has been successfully written, and to release the write lock on the difference range that was locked.
[0193] In one embodiment, the device 1500 further includes:
[0194] The replication module is used to copy data from the master's data volume to the slave's data volume when the master is not in dual-write mode.
[0195] The comparison module is used to write new data to the master's data volume each time it receives new data, and to perform incremental replication operations on the master's data volume based on the current data and the data at the previous moment.
[0196] In one embodiment, the device 1500 further includes:
[0197] The adjustment module is used to adjust the master's write mode to dual-write mode in response to the mode adjustment command.
[0198] In one embodiment, the conditions for triggering the mode adjustment instruction include at least one of the following: the duration of the incremental copy operation is less than a preset duration threshold; the amount of new data received is less than a preset quantity threshold; and the number of incremental copies performed is greater than or equal to a preset number threshold.
[0199] Each module in the aforementioned data synchronization device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0200] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 16 As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data synchronization data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communication with external terminals via a network connection. When the computer program is executed by the processor, it implements a data synchronization method.
[0201] Those skilled in the art will understand that Figure 16The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0202] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0203] The implementation principles and technical effects of each step in this embodiment are similar to those of the data synchronization method described above, and will not be repeated here.
[0204] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0205] The implementation principles and technical effects of each step when the computer program is executed by the processor in this embodiment are similar to those of the data synchronization method described above, and will not be repeated here.
[0206] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0207] The implementation principles and technical effects of each step when the computer program is executed by the processor in this embodiment are similar to those of the data synchronization method described above, and will not be repeated here.
[0208] 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 authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0209] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this 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), magnetic 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0210] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0211] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A data synchronization method, characterized in that, The method includes: When the master is in dual-write mode, the difference between the current data and the previous data in the master's data volume is obtained; new data written to the master in dual-write mode is automatically synchronized to the slave. The intervals containing the differential data are divided to obtain multiple differential intervals; Obtain the operation order of performing read lock data synchronization operations on each of the said difference intervals, and according to the operation order, sequentially acquire read locks on each of the said difference intervals to synchronize the data in each of the said difference intervals to the slave end; During the data synchronization operation, if new data that needs to be written to the unlocked difference interval is received, a write lock is acquired on the unlocked difference interval, the new data is written into the write-locked difference interval, and the new data is synchronously written to the slave's data volume.
2. The method according to claim 1, characterized in that, The step of obtaining the data synchronization operation sequence for performing read locks on each of the said difference intervals includes: Obtain the write probability of the new data being written to each of the difference intervals during the data synchronization operation; Based on the write probabilities, determine the order of operations for performing the read lock data synchronization operation on each of the difference intervals.
3. The method according to claim 1, characterized in that, The step of synchronizing the data in each of the aforementioned difference intervals to the slave device includes: For any difference interval, a read lock is acquired on the difference interval; Obtain the data in the difference interval and copy the data in the difference interval to the data volume on the slave end; Receive the confirmation message sent by the slave end confirming the successful data write, and release the read lock on the difference interval.
4. The method according to any one of claims 1-3, characterized in that, The method further includes; Receive the confirmation message from the slave end confirming the successful writing of new data, and release the write lock on the difference range of the write lock.
5. The method according to any one of claims 1-3, characterized in that, The method further includes: When the master end is not in the dual-write mode, the data in the data volume of the master end is copied to the data volume of the slave end; Each time new data is received, the new data is written to the data volume of the master terminal, and an incremental copy operation is performed on the data volume of the master terminal based on the current data and the data at the previous moment.
6. The method according to claim 5, characterized in that, The method further includes: In response to the mode adjustment command, the write mode of the master terminal is adjusted to the dual write mode.
7. The method according to claim 6, characterized in that, The conditions for triggering the mode adjustment command include at least one of the following: The duration of the incremental copy operation is less than a preset duration threshold; The amount of new data received is less than a preset threshold. The number of incremental copies performed is greater than or equal to a preset threshold number.
8. A data synchronization device, characterized in that, The device includes: The acquisition module is used to acquire the difference between the current data and the previous data in the data volume of the master end when the master end is in dual-write mode; new data written to the master end in dual-write mode will be automatically synchronized to the slave end; The segmentation module is used to divide the intervals containing the difference data to obtain multiple difference intervals; The execution module is used to obtain the operation order of data synchronization operations that perform read locks on each of the said difference intervals, and according to the operation order, sequentially acquire read locks on each of the said difference intervals to synchronize the data in each of the said difference intervals to the slave end; during the execution of the data synchronization operation, if new data that needs to be written to a difference interval that is not acquired with a read lock is received, then a write lock is acquired on the difference interval that is not acquired with a read lock, the new data is written to the difference interval with the write lock, and the new data is synchronously written to the data volume of the slave end.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Read-write lock implement method
CN102999378A
Read lock operation method, write lock operation method and system
CN104572568A