Copy processing method and device and storage medium

By creating a new destination copy and performing data synchronization during the copy balancing process, the problem of data loss caused by Data-Master's inability to perceive the copy length in real time is solved, ensuring that the copy deleted after balancing is consistent with the source copy, avoiding data loss, and setting the source The read-only status of the replica prevents IO requests from pushing data.

CN118733335APending Publication Date: 2024-10-01BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310341849.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

In the Quorum mechanism, due to the disorder and delay in the query and processing processes, the Data-Master cannot sense in real time which replica has the longest data, resulting in the problem of data loss when selecting the data source during the replica balancing process.

Method used

By creating a new destination replica, setting its status to unserviceable, and then adding it to the replica list, select a replica as the source replica when replica balancing starts, set it to read-only status, and execute data transfer from the source replica to the destination replica. Synchronization, after the synchronization is completed, modify the status of the destination copy to the serviceable state and delete the source copy.

Benefits of technology

It avoids deleting long and leaving short ones during the copy balancing process, ensuring that data is not lost, and avoiding data loss caused by IO requests by setting the source copy to read-only status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733335A_ABST
    Figure CN118733335A_ABST
Patent Text Reader

Abstract

The invention relates to a copy processing method and device and a storage medium, and the method comprises the steps: building a new target copy, setting the state of the target copy as an unserviceable state, and adding the target copy into a copy list; in the starting process of copy balancing, one copy is selected from a plurality of copies of a current data block, the selected copy is determined as a source copy, the source copy is set to be in a read-only state, and data in the source copy is source data of data synchronization; performing data synchronization from the source copy to the destination copy; and after data synchronization is completed, modifying the state of the target copy into a serviceable state, and deleting the source copy. Through the method and the device, the problem of data loss caused by the fact that Data-Master selects a copy with incomplete data as a data source to perform copy balancing in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a copy processing method, device and storage medium. Background Art

[0002] In the process of replica balancing in the Quorum mechanism, due to disorder and delay in the query and processing process, the control flow center node (Data-Master) cannot perceive in real time which replica actually has the longest data. Therefore, the data source selected by the control flow center node for replica balancing will cause data loss.

[0003] There is currently no effective technical solution to the above-mentioned problems in the relevant technologies. Summary of the invention

[0004] The present application provides a method, device and storage medium for processing replicas to solve the problem in the prior art that the Data-Master selects a replica with incomplete data as a data source for replica balancing, resulting in data loss.

[0005] In the first aspect, the present application provides a method for processing replicas, including: creating a new destination replica, setting the status of the destination replica to an unserviceable state, and then adding it to a replica list; at the beginning of replica balancing, selecting a replica from multiple replicas of the current data block and determining the selected replica as a source replica and setting the source replica to a read-only state, wherein the data in the source replica is the source data for data synchronization; performing data synchronization from the source replica to the destination replica; after the data synchronization is completed, modifying the status of the destination replica to a serviceable state, and deleting the source replica.

[0006] In the second aspect, the present application provides a replica processing device, including: a first processing module, used to create a new destination replica, set the status of the destination replica to an unserviceable state, and then add it to the replica list; a second processing module, used to select a replica from multiple replicas of the current data block and determine the selected replica as the source replica and set the source replica to a read-only state during the start of replica balancing, wherein the data in the source replica is the source data for data synchronization; a synchronization module, used to perform data synchronization from the source replica to the destination replica; a third processing module, used to modify the status of the destination replica to a serviceable state and delete the source replica after the data synchronization is completed.

[0007] In a third aspect, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0008] Memory, used to store computer programs;

[0009] A processor is used to implement the steps of the copy processing method described in any embodiment of the first aspect when executing a program stored in a memory.

[0010] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for processing a copy as described in any embodiment of the first aspect are implemented.

[0011] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:

[0012] In an embodiment of the present application, the copy deleted after replica balancing is performed and the copy previously used as the source data for data synchronization is the same copy, thereby avoiding the situation where the longer is deleted and the shorter is retained during the replica balancing process. Furthermore, in an embodiment of the present application, the copy used as the source data is set to a read-only state, further avoiding the problem of data loss due to IO requests continuing to push the data of the source copy and resulting in the inability to perceive the true length of the copy in real time. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0014] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0015] Figure 1 A schematic diagram of a quorum mechanism in an embodiment of the present application;

[0016] Figure 2 A schematic diagram of a specific quorum mechanism example in an embodiment of the present application;

[0017] Figure 3 A flowchart of a method for processing a copy provided in an embodiment of the present application;

[0018] Figure 4 One of the optional flow charts of a method for processing a copy provided in an embodiment of the present application;

[0019] Figure 5 A second optional flow chart of a method for processing a copy provided in an embodiment of the present application;

[0020] Figure 6 A schematic diagram of the structure of a copy processing device provided in an embodiment of the present application;

[0021] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0023] First, the terms in this application are explained accordingly;

[0024] EBS (Elastic Block Store): an elastically scalable distributed block storage service.

[0025] ESSD (Enhanced SSD): is the best performing product form of EBS currently.

[0026] Replica: Business data in distributed storage is usually written into multiple copies, and each copy of the data becomes a replica.

[0027] Data-Client: The client that initiates writing to multiple replicas in ESSD.

[0028] Data-Server (data stream service node): a module for single-node data IO disk placement and resource management on the data path in ESSD.

[0029] Data-Master (control flow center node): The module responsible for all data-server resource management, replica recovery and balancing on the ESSD control path.

[0030] Block-server: It is a module that calls the Data-Client interface to initiate read / write (IO) to the Data-Server where all replicas are located. It is responsible for accepting customer IO, applying for resources, issuing IO and establishing indexes.

[0031] Quorum mechanism: majority mechanism in distributed protocols.

[0032] Raft mechanism: A distributed protocol that uses a leader role to achieve data synchronization.

[0033] Block: The smallest unit for data writing at the data-server layer in ESSD, and also the smallest unit for Data-Master storage resource management.

[0034] Sequential block: only accepts blocks written sequentially.

[0035] Random block: A block that can accept random writes.

[0036] Seal: If the length of the copy is smaller than the length specified in the seal operation, the copy will not be truncated until the data behind it is recovered from other copies. Then the seal operation will be performed again. The truncated length is the size specified in the seal operation request and is set to non-writable.

[0037] It should be noted that ESSD is the fourth-generation distributed block storage product of EBS. Its core goal is to provide extreme performance while ensuring system availability and data reliability. Distributed storage improves data reliability through multiple copies. ESSD shields the details of reading and writing multiple copies from the upper layer through the underlying DBS layer and provides a unified interface.

[0038] Currently, DBS uses Data-Client to implement the quorum write / read mechanism, Data-Server to implement the underlying IO storage, and Data-Master to manage and allocate underlying resources. Data-Client uses the majority quorum mechanism instead of the raft mechanism to read and write replica data.

[0039] like Figure 1 As shown in the figure, in the quorum mechanism, assuming the number of replicas is N, W represents the number of replicas that are successfully written, and R represents the number of replicas that are successfully read. The quorum mechanism requires that W+R>N.

[0040] According to the drawer principle, after W copies of N copies are successfully written, at least one copy of the R copies successfully read must contain the most recently successfully written data.

[0041] like Figure 2 As shown, if N=5, W=3, R=3. V2 represents the latest written data, and V1 represents the old version of data before V2 is written. The dashed box represents the versions of the three replicas read. Consider the following three read scenarios a / b / c:

[0042] Scenario (a): It can be determined that the data read from the three replicas is the latest data.

[0043] Scenario (b): The data currently read and written is v1, v2, v2. According to the majority theory, if the remaining two replicas are v1, it means that the latest data is v1 instead of v2. Therefore, when the data currently read and written is v1, v2, v2, it cannot be directly assumed that the latest data is v2, because the previously written data may also be (v1, v2, v2, v1, v1). In this case, according to the majority theory, v1 is the latest data because v1 has one more replica than v2 and has reached the majority. It can be seen that based on the current quorum read view alone, it cannot be assumed that v2 is definitely the latest successfully written data. Other replicas must continue to be read until a certain version of data reaches W times.

[0044] Scenario (c): According to the majority theory, the latest data is v2. However, the data currently read and written is v1, v1, v2, and the remaining two replicas may be v1 or v2. If the remaining two replicas are v1, the written data may also be (v2, v2, v1, v1, v1). Based on the current quorum read view, it cannot be assumed that v2 is definitely the latest successfully written data. Other replicas must continue to be read until a certain version of data reaches W times.

[0045] It should be noted that the strict sequential append write model of the Data Server layer ensures that the longest copy of the data must have the latest data; during the ACK process of each copy to the upper layer, only the farthest position of the continuous write point of the current copy is returned; when the Data-Master queries the copy size, this continuous write point is also returned. This position reflects the length of this copy.

[0046] Based on this, in the existing technology, under the quorum mechanism, due to the disorder and delay in the query and processing process, the Data-Master cannot perceive in real time which replica actually has the longest data, which leads to incomplete data when performing replica balancing from the data source selected by the Data-Master. The specific example of data loss process includes the following steps:

[0047] S1, the original three replicas are created and distributed:

[0048] 2022-08-12_11:19:58_178661 created

[0049] 2022-08-12_11:26:09_821161 allocation

[0050] S2, before 2022-08-12 11:31:37, Data-Client saw two long and one short copies, among which the two long copies received the encapsulation request; two long and one short means two long copies and one short copy;

[0051] S3, 2022-08-12_11:31:50_639649 Data-Master initiates balancing because it cannot perceive the largest replica in real time and accidentally selects a short replica as the source data to initiate balancing;

[0052] S4, after the new replica completes the data from the replica with short data, it selects a long replica and deletes it;

[0053] S5, 2022-08-12_11:32:00_986520 Data-Master initiates balancing again. Since it cannot perceive the largest replica in real time, it still selects a shorter replica as the source data to initiate balancing;

[0054] S6, after the new copy completes the data from the short data copy, it selects a long encapsulated copy and deletes it.

[0055] In this regard, the prior art does not balance the unencapsulated data blocks, but only balances the encapsulated blocks. However, the statistical online and offline data are shown in Table 1 below, and it can be seen that the proportion of unencapsulated blocks in the system storage space is not small, and actually they also need to be balanced.

[0056]

[0057] Table 1

[0058] In this regard, a flowchart of a method for processing a copy provided in an embodiment of the present application is as follows: Figure 3 As shown, the steps of the method include:

[0059] Step 301, create a new destination replica, set the state of the destination replica to unserviceable state, and then add it to the replica list;

[0060] Step 302, in the process of starting replica balancing, a replica is selected from multiple replicas of the current data block and the selected replica is determined as a source replica and the source replica is set to a read-only state; wherein the data in the source replica is the source data for data synchronization;

[0061] Step 303, performing data synchronization from the source copy to the destination copy;

[0062] Step 304: After data synchronization is completed, the state of the destination copy is modified to a serviceable state, and the source copy is deleted.

[0063] The specific example of replica balancing involved in the above steps 301 to 304 is to convert the replicas on three different servers A / B / C into four replicas on A / B / C / D. D is a newly added replica (destination replica), and replica B (source replica) is selected as the data source and is set to be non-writable. After replica balancing, data needs to be synchronized from replica B to replica D. After data synchronization is completed, replica B needs to be deleted, and the final replicas are 3 replicas A / B / D.

[0064] It can be seen that through the above steps 301 to 304, the copy deleted after replica balancing is the same copy as the copy used as the source data for data synchronization before, thereby avoiding the situation where the longer is deleted and the shorter is retained during the replica balancing process. Furthermore, in the embodiment of the present application, the copy used as the source data is set to a read-only state, thereby avoiding the problem of data loss due to the inability to perceive the actual length of the copy in real time due to IO requests continuing to push the data of the source copy.

[0065] The above problem exists in the copy balancing method in the prior art, because it may delete the actual longer copy and retain the relatively short copy, resulting in data loss. In the present application, it is adopted to ensure that the copy deleted after balancing is the same copy as the copy used as the source data before. In addition, in the scenario where there is an IO (read / write) request and two long and one short copies appear and the relatively long copy is selected as the source data, after the new copy is restored, the source data block becomes longer than the target block due to the previous request that may continue to push the data forward, resulting in data loss. Therefore, in the embodiment of the present application, the source data copy is also set to a read-only state to avoid IO requests from continuing to push data to it. In conjunction with specific examples, the following is an explanation of the balancing scenario with or without IO. As shown in Table 2 (balancing scenario without IO) and Table 3 (balancing scenario with continuous IO), no data loss occurs after setting the source data to read-only (src readonly).

[0066]

[0067] Table 2

[0068]

[0069] Table 3

[0070] As can be seen from Tables 2 and 3 above, if the source copy is not set to read-only status, data loss may still occur. Therefore, in the process of copy balancing in this application, in order to ensure that data is not lost after balancing, the copy of the source data needs to be deleted after balancing. In addition, the copy of the source data needs to be set to read-only status.

[0071] In an optional implementation manner of the embodiment of the present application, if Figure 4 As shown, the method of selecting a copy from multiple copies of the current data block and determining the selected copy as the source copy and setting the source copy to a read-only state in the start process of copy balancing involved in the above step 302 may further include:

[0072] Step 11, selecting a copy from multiple copies of the current data block based on the control flow center node, and determining the selected copy as the source copy;

[0073] Step 12, setting the source copy to a read-only state based on the control flow center node.

[0074] In addition, if Figure 4 As shown, the method of deleting the source copy involved in the above step 304 may further include:

[0075] Step 21, delete the source copy based on the control flow center node.

[0076] For the above steps 11 and 12, as well as step 21, in a specific example, it can be: the control flow center node (Data-Master) selects a copy on a disk with tight space or high IO pressure as the data source (the copy to be migrated); the control flow center node sets the source copy to read-only state, and after the data is balanced, adds the target copy to the copy list, and finally deletes the block corresponding to the source copy.

[0077] The above is an example of setting the read-only state by the control flow center node in the embodiment of the present application. The following will explain the example of setting the read-only state by the data flow service node. Figure 5 As shown, the method of selecting a copy from multiple copies of the current data block and determining the selected copy as the source copy and setting the source copy to a read-only state in the start process of copy balancing involved in the above step 301 may further include:

[0078] Step 31, selecting a copy from multiple copies of the current data block based on the control flow central node, and determining the selected copy as the source copy;

[0079] Step 32: Send a balanced copy request to the data flow service node based on the control flow center node, wherein the balanced copy request carries a field for characterizing the balanced copy;

[0080] Step 33: Set the source copy to a read-only state based on the data stream service node.

[0081] In an optional implementation of the embodiment of the present application, the deletion of the source copy involved in the above step 302 may further include:

[0082] Step 41, delete the source copy based on the control flow center node.

[0083] For the above steps 31 to 33, and step 41, in a specific example, it can be: the control flow center node selects the replica on the disk with tight space or high IO pressure as the data source (replica to be migrated); the current control flow center node internal replica supplement and replica balancing follow the same process (AddReplica), but only replica balancing needs to set the source data to read-only state. In order to distinguish from the process of replica supplement, the control flow center node sends the AddReplica request to the data flow service node with the cause field, set to replica supplement or balance; when the data flow service node receives the AddReplica request to create a new data supplement task, it saves the cause field brought by the request; during the execution of AddReplcia by the Data-Server, the destination block will read data from the source block, and the read request will carry this cause field; if the source data flow service node receives a recovery read request, and the block is a sequential block and the cause field in the current task is balanced, the block of the source replica is set to read-only state; after the data is balanced, the control flow center node sets the destination replica to a serviceable state, and finally the control flow center node deletes the block corresponding to the source replica.

[0084] Corresponding to the above Figure 3 , the embodiment of the present application also provides a copy processing device, such as Figure 6 As shown, the device comprises:

[0085] The first processing module 62 is used to create a new destination replica, set the state of the destination replica to an unserviceable state, and then add it to the replica list;

[0086] The second processing module 64 is used to select a copy from multiple copies of the current data block and determine the selected copy as the source copy and set the source copy to a read-only state during the start of the copy balancing process; wherein the data in the source copy is the source data for data synchronization;

[0087] A synchronization module 66, for performing data synchronization from a source replica to a destination replica;

[0088] The third processing module 68 is used to modify the state of the destination copy to a serviceable state and delete the source copy after data synchronization is completed.

[0089] Through the device in the present application, the copy deleted after replica balancing is the same copy as the copy used as the source data for data synchronization before, thereby avoiding the situation where the longer is deleted and the shorter is retained during the replica balancing process. Furthermore, in the embodiment of the present application, the copy used as the source data is set to a read-only state, further avoiding the problem of data loss caused by the inability to perceive the actual length of the copy in real time due to IO requests continuing to push the data of the source copy.

[0090] In an optional implementation of an embodiment of the present application, the second processing module 64 includes: a first processing unit, used to select a copy from multiple copies of the current data block based on the control flow center node, and determine the selected copy as the source copy; a first setting unit, used to set the source copy to a read-only state based on the control flow center node.

[0091] In an optional implementation of an embodiment of the present application, the second processing module 64 includes: a second processing unit, used to select a copy from multiple copies of the current data block based on the control flow center node, and determine the selected copy as the source copy; a first sending unit, used to send a balanced copy request to the data flow service node based on the control flow center node, wherein the balanced copy request carries a field for characterizing the balanced copy; a second setting unit, used to set the source copy to a read-only state based on the data flow service node.

[0092] In an optional implementation of the embodiment of the present application, the third processing module 68 in the embodiment of the present application may further include: a deleting unit, which is used to delete the replicas in the replica list based on the control flow center node.

[0093] In an optional implementation of the embodiment of the present application, the device of the embodiment of the present application may also include: an execution module, which is used to perform a data block switching operation before the replica balancing is completed and when the writing of the current data block fails.

[0094] like Figure 7 As shown, an embodiment of the present application provides an electronic device, including a processor 711, a communication interface 712, a memory 713 and a communication bus 714, wherein the processor 711, the communication interface 712, and the memory 713 communicate with each other through the communication bus 714.

[0095] Memory 713, used for storing computer programs;

[0096] In one embodiment of the present application, the processor 711 is used to implement the copy processing method provided by any of the aforementioned method embodiments when executing the program stored in the memory 713, and the effects achieved are similar and will not be repeated here.

[0097] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the copy processing method provided in any of the aforementioned method embodiments are implemented.

[0098] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0099] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for processing a copy, characterized in that: include: Create a new destination replica, set the state of the destination replica to unserviceable state, and then add it to the replica list; In the process of starting replica balancing, a replica is selected from multiple replicas of the current data block and the selected replica is determined as a source replica and the source replica is set to a read-only state, wherein the data in the source replica is the source data for data synchronization; Performing data synchronization from the source replica to the destination replica; After the data synchronization is completed, the state of the destination copy is modified to a serviceable state, and the source copy is deleted.

2. The method according to claim 1, characterized in that In the process of starting the replica balancing, selecting a replica from multiple replicas of the current data block, determining the selected replica as a source replica, and setting the source replica to a read-only state include: Selecting a copy from multiple copies of the current data block based on the control flow central node, and determining the selected copy as the source copy; The source copy is set to a read-only state based on the control flow central node.

3. The method according to claim 1, characterized in that In the process of starting the replica balancing, selecting a replica from multiple replicas of the current data block, determining the selected replica as a source replica, and setting the source replica to a read-only state include: Selecting a copy from multiple copies of the current data block based on the control flow central node, and determining the selected copy as the source copy; Sending a balanced copy request to a data flow service node based on the control flow central node, wherein the balanced copy request carries a field for characterizing the balanced copy; The source copy is set to a read-only state based on the data stream service node.

4. The method according to claim 2 or 3, characterized in that: The deleting the source copy includes: The source copy is deleted based on the control flow central node.

5. The method according to claim 1, characterized in that The method further comprises: Before the replica balancing is completed, and in the event that the writing of the current data block fails, a data block switching operation is performed to write the write data to another data block with a complete replica.

6. A copy processing device, characterized in that: include: The first processing module is used to create a new destination replica, set the state of the destination replica to an unserviceable state, and then add it to the replica list; A second processing module is used to select a copy from multiple copies of the current data block and determine the selected copy as a source copy and set the source copy to a read-only state during the start of copy balancing, wherein the data in the source copy is the source data for data synchronization; A synchronization module, used to perform data synchronization from the source replica to the destination replica; The third processing module is used to modify the state of the destination copy to a serviceable state and delete the source copy after the data synchronization is completed.

7. The device according to claim 6, characterized in that The second processing module comprises: A first processing unit, configured to select a copy from multiple copies of the current data block based on a control flow central node, and determine the selected copy as a source copy; The first setting unit is used to set the source copy to a read-only state based on the control flow central node.

8. The device according to claim 6, characterized in that The second processing module comprises: A second processing unit, configured to select a copy from multiple copies of the current data block based on the control flow central node, and determine the selected copy as the source copy; A first sending unit, configured to send a balanced replica request to a data flow service node based on the control flow central node, wherein the balanced replica request carries a field for characterizing a balanced replica; The second setting unit is used to set the source copy to a read-only state based on the data stream service node.

9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, used to implement the steps of the copy processing method described in any one of claims 1 to 5 when executing the program stored in the memory.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the copy processing method according to any one of claims 1 to 5 are implemented.