Copy processing method and device and storage medium
By selecting the one with longer data from the two copies in the Quorum mechanism as the data source, the problem of data loss caused by Data-Master selecting a copy with incomplete data is solved and the complete recovery of data blocks is ensured.
Patent Information
- Application Number
- CN202310341837.1
- 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
In the Quorum mechanism, Data-Master may select a copy with incomplete data as the data source to restore a new copy, resulting in data loss.
When the number of available replicas on the current data block is 2, the one with longer data is determined from the two replicas as the data source to restore the data block.
By selecting a copy with longer data as the data source, data loss is avoided, data integrity after copy recovery is ensured, and the data loss problem caused by Data-Master selecting a copy with incomplete data in the existing technology is avoided.
Smart Images

Figure CN118733334A_ABST
Abstract
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 replenishment in the Quorum mechanism, data loss or errors may occur. For example, after disabling an underlying data disk, only two available replicas of a block remain, one on 10.177.18.145 and one on 10.177.18.144 of the control flow service node (Data-Server). After initiating the replica replenishment process, the control flow center node (Data-Master) selected 10.177.18.144 to restore the newly added replica, but 10.177.18.144 did not receive the write at that time, and the read-write size was 0. As a result, when writing, two of the three replicas are long and one is short (two long and one short), and when reading, two of the three replicas are short and one is long (two short and one long). According to the current business logic, the size of the replica data obtained later is smaller than that recorded in the upper-level metadata, that is, data loss has occurred. Summary of the invention
[0003] The present application provides a copy processing method, device and storage medium to solve the problem in the prior art that the Data-Master selects a copy with incomplete data as the data source to restore a new copy, resulting in data loss.
[0004] In a first aspect, the present application provides a method for processing replicas, comprising: when the number of available replicas on a current data block is 2, determining a first replica from two replicas, wherein the two available replicas on the current data block include the first replica and a second replica, and data of the first replica is longer than or equal to data of the second replica; determining the first replica as a data source to restore the replica on the current data block.
[0005] In a second aspect, the present application provides a replica processing device, comprising: a determination module, used to determine a first replica from two replicas when the number of available replicas on a current data block is two, wherein the two available replicas on the current data block include the first replica and a second replica, and the data of the first replica is longer than or equal to the data of the second replica; a first processing module, used to determine the first replica as a data source to restore the replica on the current data block.
[0006] 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;
[0007] Memory, used to store computer programs;
[0008] 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.
[0009] 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.
[0010] The above technical solution provided by the embodiment of the present application has the following advantages compared with the prior art:
[0011] Normally, the number of replicas on a data block is 3. If the number of available replicas on the current data block is 2, the replicas on the data block need to be supplemented. In the prior art, when supplementing the replicas, the Data-Master may select a shorter replica for replica recovery, resulting in data loss. Through the method in this application, a replica with longer data is selected from the remaining 2 replicas as the data source for data recovery, ensuring that data will not be lost after the replica is restored, and avoiding the problem of data loss caused by the Data-Master selecting an incomplete replica as the data source to restore a new replica in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] 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.
[0013] 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.
[0014] Figure 1 A schematic diagram of a quorum mechanism in an embodiment of the present application;
[0015] Figure 2 A schematic diagram of a specific quorum mechanism example in an embodiment of the present application;
[0016] Figure 3 A flowchart of a method for processing a copy provided in an embodiment of the present application;
[0017] Figure 4 A schematic diagram of replica recovery in a specific application scenario provided in an embodiment of the present application;
[0018] Figure 5 One of the optional flow charts of a method for processing a copy provided in an embodiment of the present application;
[0019] Figure 6 A second optional flow chart of a method for processing a copy provided in an embodiment of the present application;
[0020] Figure 7 A third optional flow chart of a method for processing a copy provided in an embodiment of the present application;
[0021] Figure 8 A schematic diagram of the structure of a copy processing device provided in an embodiment of the present application;
[0022] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] 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.
[0024] First, the terms in this application are explained accordingly;
[0025] EBS (Elastic Block Store): an elastically scalable distributed block storage service.
[0026] ESSD (Enhanced SSD): is the best performing product form of EBS currently.
[0027] Replica: Business data in distributed storage is usually written into multiple copies, and each copy of the data becomes a replica.
[0028] Data-Client: The client that initiates writing to multiple replicas in ESSD.
[0029] Data-Server (data stream service node): a module for single-node data IO disk placement and resource management on the data path in ESSD.
[0030] Data-Master (control flow center node): The module responsible for all data-server resource management, replica recovery and balancing on the ESSD control path.
[0031] 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.
[0032] Quorum mechanism: majority mechanism in distributed protocols.
[0033] Raft mechanism: A distributed protocol that uses a leader role to achieve data synchronization.
[0034] 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.
[0035] Sequential block: only accepts blocks written sequentially.
[0036] Random block: A block that can accept random writes.
[0037] 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.
[0038] 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.
[0039] 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.
[0040] 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.
[0041] 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.
[0042] 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:
[0043] Scenario (a): It can be determined that the data read from the three replicas is the latest data.
[0044] 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, because v1 is more than v2, v1 is the latest data. 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.
[0045] 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.
[0046] 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.
[0047] Figure 3 A flowchart of a method for processing a copy provided in an embodiment of the present application is shown as follows: Figure 3 As shown, the steps of the method include:
[0048] Step 301, when the number of available replicas on the current data block is 2, determine a first replica from the two replicas, wherein the two available replicas on the current data block include the first replica and the second replica, and data of the first replica is longer than or equal to data of the second replica;
[0049] Step 302: determine the first copy as a data source to restore the copy on the current data block.
[0050] It should be noted that under normal circumstances, the number of replicas on a data block is 3. If the number of available replicas on the current data block is 2, the replicas on the data block need to be supplemented. In the prior art, when supplementing the replicas, the Data-Master may select a shorter replica for replica recovery, resulting in data loss. Through the method in this application, a replica with longer data is selected from the remaining 2 replicas as the data source for data recovery. If the data length of the two replicas is the same, any replica can be selected, ensuring that the data will not be lost after the replica is restored, avoiding the problem of data loss caused by the Data-Master selecting an incomplete replica as the data source to restore the new replica in the prior art.
[0051] In addition, in a specific example, the execution subject of the method steps of the embodiment of the present application may be a Data-Master.
[0052] In the specific example, based on the quorum mechanism, combined with 3 copies of data-client, such as Figure 4 As shown in the figure, the problem of how to recover data if one copy is lost is solved when N=3W=2R=2, where v2 represents the latest copy, N represents the total number of copies, W represents the number of copies successfully written, and R represents the number of copies successfully read.
[0053] The following discusses Figure 4 The results of recovering data using strategies (a) and (b) are shown in Tables 1 and 2:
[0054]
[0055] Table 1
[0056]
[0057] Table 2
[0058] It can be seen that according to strategy (b), selecting the new version of data (v2) as the data source for data recovery will not cause data loss, while according to strategy (a), selecting the data (v1) that is not the latest version as the data source for data recovery will cause data loss. Currently, Data-Master can periodically obtain the length of the block of each Data-Server, and Data-Master can also actively obtain the length of the corresponding replica under the Data-Server.
[0059] In an optional implementation manner of the embodiment of the present application, the method of determining the first copy from the two copies involved in step 301 in the embodiment of the present application may further include the following methods:
[0060] Method 1) Figure 5 As shown, it includes step 501, when two available copies on the current data block are both encapsulated copies, comparing the lengths of the two encapsulated available copies, and then determining the copy with the longer length as the first copy;
[0061] It should be noted that for all encapsulated replicas, since the length of the encapsulated replicas will not be advanced any further, the longest replica obtained by the subsequent query of Data-Master is the longest replica.
[0062] Method 2) Figure 6 As shown, it includes step 601, in which, when one of the two available copies on the current data block is an encapsulated copy and the other is an unencapsulated copy, the encapsulated copy of the two available copies on the current data block is determined as the first copy.
[0063] In this regard, for the case where one copy is encapsulated and the other copy is not encapsulated, if the copy length does not reach the specified length of the encapsulation operation, it will not be encapsulated. In other words, the encapsulated copy is longer than the data of the unencapsulated copy. In other words, the unencapsulated copy is definitely shorter. The encapsulated copy is selected as the source data for recovery. The encapsulated copy is the relatively longest copy, so the relatively longest copy is selected.
[0064] Method 3) Figure 7 As shown, step 701 includes the following situations:
[0065] A. If both the two available replicas on the current data block are unsealed replicas and the continuous writing of the current data block is successful, any one of the two available replicas on the current data block is determined as the first replica, wherein the continuous writing progress of the unsealed replicas is consistent;
[0066] That is to say, if the continuous write is successful, the remaining two copies will move forward synchronously, and the copy lengths will be consistent. Therefore, no data loss will occur when any copy is selected as the source data for recovery.
[0067] B. When both available copies of the current data block are unencapsulated copies and continuous writing to the current data block fails, the copy with longer data among the two available copies of the current data block is determined as the first copy;
[0068] It can be seen that in the case of continuous write failures, the remaining two writable copies will not move forward synchronously, so one copy will be longer than the other. Based on the current Data-Client's never-stop writing mechanism, it will trigger switching to a new block to write. At this time, the relatively longer copy behind can be selected as the data source for recovery, and data loss will not occur.
[0069] C. When both the two available copies of the current data block are unencapsulated copies and there is no continuous writing to the current data block, the copy with longer data among the two available copies of the current data block is determined as the first copy.
[0070] It can be seen that since the replica length will not be advanced any further at this time, the longest replica obtained by the Data-Master query later is indeed the longest replica. However, if the original data before the replica was lost was two short and one long, and now it becomes two long and one short, additional data is recovered: in this regard, if this part of data belongs to the seq data block, it will be ignored because there is no such data in the Index block; if this part of data belongs to the Index block, it will be ignored because its actual length exceeds the length of the upper-layer metadata record. Therefore, it will not affect the upper-layer business.
[0071] In the embodiment of the present application, the above-mentioned method of determining the copy with longer data in the two available copies of the current data block as the first copy includes the following two methods:
[0072] Method 1) querying the periodic statistical record to select the copy with longer data from the two available copies on the current data block to determine it as the first copy; wherein the periodic statistical record is used to periodically count the data lengths of the copies on all data blocks;
[0073] In this regard, in a specific example, the method of using periodic statistics can be specifically: using the mechanism of Data-Master to periodically count the lengths of all replicas on the Data-Server, when replicas need to be supplemented, before actually starting to supplement the replicas, initiate a round of queries on the length and status of the replicas on all Data-Servers to obtain the lengths of all replicas, select the relatively long replicas as the data source, and then perform the actual replica supplement operation.
[0074] Method 2) Send a query request to the current data block, and select a copy with longer data from the two available copies on the current data block as the first copy based on the query request; wherein the query request is used to request a query on the data length of the two copies on the current data block.
[0075] In this regard, in a specific example, the active query method can be: before the Data-Master initiates the copy replenishment, it first initiates a query on the sizes of the two copies. After the query is completed, the longer one is selected as the data source and then the copies are replenished.
[0076] It can be seen that in the specific example, the current Data-Master will periodically obtain the length of each Data-Server block, and the Data-Master can also actively obtain the length of the corresponding replica under the Data-Server. In addition, for blocks with IO, the Data-Client also records the length of each replica in real time. According to the method by which the Data-Master obtains the relatively long replica among the remaining replicas, that is, before initiating the copy supplement, the Data-Master obtains the length of all replicas that may serve as data sources from the Data-Server, and then selects the longest one as the data source.
[0077] Corresponding to the above Figure 3 , the embodiment of the present application also provides a copy processing device, such as Figure 8 As shown, the device comprises:
[0078] A determination module 82 is configured to determine a first copy from two copies when the number of available copies on the current data block is two, wherein the two available copies on the current data block include the first copy and the second copy, and data of the first copy is longer than or equal to data of the second copy;
[0079] The first processing module 84 is used to determine the first copy as the data source to restore the copy on the data block.
[0080] Through the device in the present application, a copy with longer data is selected from the two remaining copies as the data source for data recovery, ensuring that the data will not be lost after the copy is restored, and avoiding the problem of data loss caused by the Data-Master in the prior art selecting a copy with incomplete data as the data source to restore a new copy.
[0081] In an optional implementation of an embodiment of the present application, the determination module 82 may further include: a comparison unit, used to compare the lengths of two encapsulated available copies when both of the two available copies on the current data block are encapsulated copies; and a first determination unit, used to determine the copy with the longer length as the first copy.
[0082] In an optional implementation of an embodiment of the present application, the determination module 82 may further include: a second determination unit, used to determine the encapsulated copy of the two available copies on the current data block as the first copy when one of the two available copies on the current data block is an encapsulated copy and the other is an unencapsulated copy.
[0083] In an optional implementation manner of an embodiment of the present application, the determination module 82 may further include: a third determination unit, used to determine any one of the two available copies on the current data block as the first copy when both the two available copies on the current data block are unencapsulated copies and continuous writing to the current data block is successful, wherein the continuous writing progress of the unencapsulated copies is consistent; a fourth determination unit, used to determine the copy with longer data among the two available copies on the current data block as the first copy when both the two available copies on the current data block are unencapsulated copies and continuous writing to the current data block fails; a fifth determination unit, used to determine the copy with longer data among the two available copies on the current data block as the first copy when both the two available copies on the current data block are unencapsulated copies and there is no continuous writing to the current data block.
[0084] In an optional implementation of an embodiment of the present application, the determination module 82 further includes at least one of the following: a query unit, used to query periodic statistical records to select a copy with longer data from two available copies on the current data block to determine as the first copy; wherein the periodic statistical records are used to periodically count the data lengths of copies on all data blocks; a processing unit, used to send a query request to the current data block, and based on the query request, select a copy with longer data from two available copies on the current data block to determine as the first copy; wherein the query request is used to request a query on the data lengths of the two copies on the current data block.
[0085] like Fig. 9As shown, an embodiment of the present application provides an electronic device, including a processor 911, a communication interface 912, a memory 913 and a communication bus 914, wherein the processor 911, the communication interface 912, and the memory 913 communicate with each other through the communication bus 914.
[0086] Memory 913, used for storing computer programs;
[0087] In one embodiment of the present application, the processor 911 is used to execute the program stored in the memory 913 to implement the copy processing method provided by any of the aforementioned method embodiments, and the effects achieved are similar and will not be repeated here.
[0088] 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.
[0089] 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.
[0090] 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: When the number of available replicas on the current data block is 2, determine a first replica from the two replicas, wherein the two available replicas on the current data block include the first replica and the second replica, and data of the first replica is longer than or equal to data of the second replica; The first copy is determined as a data source to restore the copy on the current data block.
2. The method according to claim 1, characterized in that Determining the first copy from the two copies includes: When the two available copies of the current data block are both encapsulated copies, the lengths of the two encapsulated available copies are compared; The copy with the longer length is determined as the first copy.
3. The method according to claim 1, characterized in that: Determining the first copy from the two copies includes: In the case that one of the two available copies on the current data block is an encapsulated copy and the other is an unencapsulated copy, the encapsulated copy of the two available copies on the current data block is determined as the first copy.
4. The method according to claim 1, characterized in that: Determining the first replica from the two replicas includes at least one of the following: When both the two available replicas on the current data block are unpackaged replicas and the continuous writing of the current data block is successful, any one of the two available replicas on the current data block is determined as the first replica, wherein the continuous writing progress of the unpackaged replicas is consistent; When both the two available copies of the current data block are unencapsulated copies and continuous writing to the current data block fails, the copy with longer data among the two available copies of the current data block is determined as the first copy; When both the two available copies on the current data block are unencapsulated copies and there is no continuous writing to the current data block, the copy with longer data among the two available copies on the current data block is determined as the first copy.
5. The method according to any one of claims 2 to 4, characterized in that: Determining the first replica from the two replicas includes at least one of the following: Querying the periodic statistical record to select a copy with longer data from two available copies on the current data block to determine as the first copy; wherein the periodic statistical record is used to periodically count the data lengths of the copies on all data blocks; A query request is sent to the current data block, and based on the query request, a copy with longer data is selected from two available copies on the current data block to be determined as the first copy; wherein the query request is used to request a query on the data length of the two copies on the current data block.
6. A copy processing device, characterized in that: include: a determination module, configured to determine a first copy from two copies when the number of available copies on the current data block is two, wherein the two available copies on the current data block include the first copy and a second copy, and data of the first copy is longer than or equal to data of the second copy; The first processing module is used to determine the first copy as a data source to restore the copy on the current data block.
7. The device according to claim 6, characterized in that The determination module comprises: A comparison unit, configured to compare the lengths of the two encapsulated available copies when both the two available copies on the current data block are encapsulated copies; The first determining unit is configured to determine the copy with a longer length as the first copy.
8. The device according to claim 6, characterized in that The determination module comprises: The second determining unit is used to determine the encapsulated copy of the two available copies on the current data block as the first copy when one of the two available copies on the current data block is an encapsulated copy and the other is an unencapsulated copy.
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.
