Data writing method, distributed storage system, device and storage medium

By dividing the data to be written into padding data and encoding results in a distributed storage system, and using erasure coding, the problem of wasted storage space caused by multi-replica storage is solved, and a balance between data reliability and storage efficiency is achieved.

CN115268786BActive Publication Date: 2026-08-25ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210894005.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-27
Publication Date
2026-08-25
Estimated Expiration
2042-07-27

AI Technical Summary

Technical Problem

In existing distributed storage systems, the multi-replica storage method causes data to be amplified too much when stored in the foreground, occupying a large amount of storage space and affecting storage efficiency.

Method used

By dividing the data to be written into padding data and encoding results, and writing them into the data area and verification area of ​​the first and second storage node sets according to preset requirements, and using erasure coding, the total amount of data written is reduced.

Benefits of technology

While ensuring data reliability, it reduces redundant data storage in the distributed storage system and improves the efficiency of storage space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115268786B_ABST
    Figure CN115268786B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data writing method, a distributed storage system, a device and a storage medium. The method comprises: writing to-be-written data satisfying a preset requirement in size into at least one data area of a storage node; if the at least one data area is not full, writing padding data into the not full data area, performing erasure code encoding on the padding data and the to-be-written data, and writing the encoding result into a check area of the storage node. The preset requirement is determined according to the size of any data area in the at least one data area, an encoding parameter of the erasure code encoding and a preset number of copies. The to-be-written data satisfying the requirement has a total writing amount in the writing process, which is the sum of the to-be-written data, the padding data and the encoding result, less than a data amount corresponding to repeated writing of the preset number of copies. Therefore, the amplification multiple of the to-be-written data in the above process is smaller, and the space waste caused by storage of redundant data in the storage node can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of storage, and more particularly to a data writing method, a distributed storage system, a device, and a storage medium. Background Technology

[0002] With the continuous development of computer computing, distributed storage systems are being applied in various scenarios. Common distributed storage systems include distributed database systems and distributed file storage systems, among others.

[0003] To ensure data reliability in a distributed storage system, asynchronous writing is typically employed. This involves first storing multiple copies of the data to be written in write-ahead log files and caches on each storage node within the distributed storage system. Once the caches are full, each storage node in the distributed storage system then uses erasure coding to store the data. In other words, multiple copies are first stored in the foreground of the distributed storage system, and then erasure coding is performed in the background.

[0004] In practice, multi-replica storage typically uses three or more replicas. During foreground storage, a single copy of data to be written can be amplified three times or more. This redundant data consumes a significant amount of storage space in the distributed storage system, leading to low storage space utilization. Therefore, reducing the amplification factor of data to be written during foreground storage, while ensuring data reliability, becomes a pressing issue. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a data writing method, a distributed storage system, a device, and a storage medium for reducing the amplification factor of data to be written during foreground storage.

[0006] In a first aspect, embodiments of the present invention provide a data writing method, including:

[0007] Write data to be written that meets the preset size requirement to at least one data area corresponding to the first storage node set, wherein the preset requirement is determined based on the size of any data area in the at least one data area, the encoding parameters of erasure coding, and the preset number of replicas;

[0008] If the data to be written is not filled in the at least one data area, then fill data is written into the target data area that is not filled in the at least one data area;

[0009] The encoding result obtained by erasure coding the data to be written and the filling data is written into the verification area corresponding to the second storage node set. The first storage node set and the second storage node set are contained in the distributed storage system.

[0010] Secondly, embodiments of the present invention provide a distributed storage system, including: a first set of storage nodes and a second set of storage nodes;

[0011] The storage nodes in the first storage node set are used to control the writing of data to be written to at least one data area corresponding to the first storage node set, wherein the preset requirements are determined based on the size of any data area in the at least one data area, the encoding parameters of erasure coding, and the preset number of replicas.

[0012] If the data to be written is not filled in at least one data area, then control the filling data to be written into the unfilled target data area in the at least one data area;

[0013] The data to be written and the filling data are encoded using erasure coding.

[0014] The storage nodes in the second set of storage nodes are used to control the encoding results and write them into the verification area corresponding to the second set of storage nodes.

[0015] Thirdly, embodiments of the present invention provide an electronic device, including a processor and a memory, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions, when executed by the processor, implement the data writing method described in the first aspect above. The electronic device may also include a communication interface for communicating with other devices or communication networks.

[0016] Fourthly, embodiments of the present invention provide a non-transitory machine-readable storage medium storing executable code, which, when executed by a processor of an electronic device, enables the processor to at least implement the data writing method as described in the first aspect.

[0017] The data writing method provided in this invention involves writing data of a preset size to at least one data area corresponding to a first set of storage nodes. If the data to be written does not fill at least one data area, padding data is written into the unfilled target data area, and erasure coding is applied to the padding data and the data to be written. Finally, the encoding result is written to the check area corresponding to a second set of storage nodes. All of the aforementioned storage node sets are contained within a distributed storage system. Erasure coding can ensure data reliability while completing the data writing process.

[0018] Compared to the method mentioned in the background art that ensures data reliability by writing N copies (N≥3), this approach requires writing N copies of a single piece of data to the distributed storage system, resulting in the data being amplified N times and containing a large amount of redundant data. However, using the method provided in this embodiment, the data to be written to the distributed storage system for a single piece of data includes the data to be written, the encoding result, and padding data. The aforementioned preset requirements are determined based on the size of any data area in at least one data region, the encoding parameters of the erasure coding, and the preset number of copies. After meeting these requirements, the total amount of data written during the data writing process is the sum of the data to be written, the padding data, and the encoding result. This total amount of data is less than the total amount of data corresponding to repeatedly writing multiple copies (i.e., the preset number of copies). Therefore, using the method provided in this embodiment, the amplification factor of the data to be written is less than that of the aforementioned multi-copy writing method, ensuring data reliability while also improving the space waste caused by redundant data storage in the distributed storage system. Attached Figure Description

[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0020] Figure 1 A schematic diagram illustrating a data writing method provided in an embodiment of the present invention;

[0021] Figure 2 A schematic diagram of a data storage area provided in an embodiment of the present invention;

[0022] Figure 3 A flowchart of a data writing method provided in an embodiment of the present invention;

[0023] Figure 4 Write the data to be written and fill the data. Figure 2 A schematic diagram of the data storage area shown;

[0024] Figure 5 A flowchart of another data writing method provided in an embodiment of the present invention;

[0025] Figure 6 A flowchart illustrating yet another data writing method provided in an embodiment of the present invention;

[0026] Figure 7 for Figure 2 The diagram shows the structure of the target data area within the data storage region shown.

[0027] Figure 8 This is a schematic diagram of the structure of a distributed storage system provided in an embodiment of the present invention;

[0028] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0029] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0030] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” used in the embodiments of this invention and the appended claims are also intended to include the plural forms, unless the context clearly indicates otherwise. “Multiple” generally includes at least two, but does not exclude the inclusion of at least one.

[0031] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0032] Depending on the context, the words “if” or “suppose” as used here can be interpreted as “when” or “in response to determination” or “in response to identification.” Similarly, depending on the context, the phrases “if determination” or “if identification (of the condition or event of the statement)” can be interpreted as “when determination” or “in response to determination” or “when identification (of the condition or event of the statement)” or “in response to identification (of the condition or event of the statement).”

[0033] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a product or system comprising a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a product or system. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the product or system that includes said element.

[0034] The following detailed description of some embodiments of the present invention is provided in conjunction with the accompanying drawings. Where there is no conflict between the embodiments, the following embodiments and features can be combined with each other. Furthermore, the timing of the steps in the following method embodiments is merely an example and not a strict limitation.

[0035] As described in the background section, common distributed storage systems include distributed database systems and distributed file storage systems, among others. Furthermore, for any storage node in a distributed storage system, updated data is generated after executing a transaction or responding to a user's edit operation on a file. Specifically, the updated data generated by the storage node executing a transaction is called transaction data, and the updated data generated by the storage node in response to an edit operation is called edit data. The file edited by the user can be a text document, image, video, etc.

[0036] The aforementioned updated data and its metadata can both be written to the distributed storage system asynchronously as data to be written. Before describing the various embodiments provided by this invention in detail below, this asynchronous writing process can be described in detail first:

[0037] In a distributed storage system, after a storage node obtains the data to be written, it can first perform a data write operation, writing the data to both the write-ahead log file and the cache configured on that storage node. Optionally, the write-ahead log file can be the redo log of that storage node. To ensure data reliability, this updated data can also be written to the write-ahead log files and caches of other storage nodes, thus achieving multi-replica writing of the updated data.

[0038] The above process can be considered as the process of writing data to the front end of the distributed storage system, that is, ensuring the reliability of data storage in the front end through multiple replicas. The physical resources used for log writing in the distributed storage system can constitute the front end of the system.

[0039] When the caches configured on each storage node in the system are full, erasure coding can be applied to the data in the caches, and the data and coding results can be flushed to the datafiles on each storage node, i.e., another write operation can be performed. Optionally, this storage node can specifically represent a server. In this case, the aforementioned write-ahead log files and data files are stored on the server's disk.

[0040] The process of encoding and storing data in the cache described above can be considered the background operation of a distributed storage system. That is, erasure coding ensures the reliability of data storage in the background. The physical resources used to write data files in a distributed storage system constitute the system's background.

[0041] The asynchronous write process described above can also be combined with Figure 1 understand.

[0042] As described above, while the front-end of a distributed storage system can ensure data reliability through multi-copy writing, it also generates data amplification. That is, to ensure the reliability of one copy of the data to be written, N copies of the data are actually written to the distributed storage system, typically N ≥ 3. Furthermore, the redundant data generated by this amplification consumes a large amount of storage space in the distributed storage system, resulting in low storage space utilization. Therefore, to reduce the amplification factor of data during front-end storage while ensuring data reliability, the inventors have proposed a new data writing method. The following detailed description, in conjunction with the accompanying drawings, illustrates various embodiments. Furthermore, the embodiments and features described below can be combined with each other unless there is a conflict between them. Additionally, the timing of the steps in the following method embodiments is merely an example and not a strict limitation.

[0043] Furthermore, before describing in detail the data writing methods provided in the various embodiments of the present invention, the data storage method in a distributed storage system can be described first. The embodiments of the present invention provide a data storage area suitable for a distributed storage system, such as... Figure 2 As shown, the data storage area can be divided into multiple data containers (chunks), each data container contains multiple stripes, and each stripe includes a data area (all data blocks) and a parity area (all parity blocks). Each stripe is the same size, and each data area and parity area within each stripe is also the same size. However, the size of a data area is larger than the size of a parity area. Furthermore, each data area is divided into at least one data sub-area (one data block) of equal size, and each parity area is also divided into at least one parity sub-area (one parity block) of equal size.

[0044] Furthermore, the aforementioned at least one data sub-area or at least one parity sub-area can be considered as a data storage area provided by a storage node in a distributed storage system. For the sake of brevity and clarity in the following description, the at least one storage node providing a data sub-area can be collectively referred to as the first storage node set, and the multiple data areas provided by each storage node in the first storage node set can also be referred to as the first storage area. Similarly, the at least one storage node providing a parity sub-area can be collectively referred to as the second storage node set, and the multiple parity areas provided by each storage node in the second storage node set can also be referred to as the second storage area. In a distributed storage system, the number of data sub-areas in a data area can be the same as the number of storage nodes in the first storage node set of the system; similarly, the number of parity sub-areas in a parity area can also be the same as the number of storage nodes in the second storage node set of the system.

[0045] Based on the data storage area of ​​the above structure, Figure 3 This is a flowchart illustrating a data writing method provided in an embodiment of the present invention. This method can be executed by a storage node in a distributed storage system. Figure 3 As shown, the method may include the following steps:

[0046] S101, write the data to be written that meets the preset requirements into at least one data area corresponding to the first storage node set, wherein the preset requirements are determined based on the size of any data area in the at least one data area, the encoding parameters of the erasure coding, and the preset number of replicas.

[0047] In response to a data write operation, the storage nodes in the first set of storage nodes can obtain the data to be written corresponding to the write operation. The size of the data to be written meets preset requirements. The principles for setting these preset requirements can be found in the relevant descriptions below. Furthermore, the specific content of the data to be written can differ for different distributed storage systems. As described above, for database storage systems, the data to be written can be transaction data and metadata. For distributed file storage systems, the data to be written can be edit data and its metadata. That is, the data to be written includes updated data and the metadata of this updated data.

[0048] Furthermore, the data to be written is specifically written to at least one data area corresponding to the first set of storage nodes. Optionally, the first set of storage nodes may include at least one storage node in a distributed storage system.

[0049] Example of step S101: Assume the size of the data to be written is 10 KiB. Figure 2In the data storage area shown, the size of a data sub-area is 2 KiB, and the number of storage nodes in the first storage node set is 4. In this case, as an option, the data to be written can be written horizontally, that is, sequentially written to the 5 data sub-areas provided by different storage nodes in the first storage node set. Figure 4 Data sub-areas 1 through 5 are included. Alternatively, the data to be written can also be written vertically, that is, sequentially written to the five data sub-areas provided by the same storage node in the first storage node set. Figure 4 The data sub-regions are 1, 5, 9, 13, and 17.

[0050] like Figure 2 The sizes of the data containers, stripes, data sub-areas, and parity sub-areas in the data storage area shown can all be preset. Optionally, the size of the data sub-area can be set based on the common size of the data to be written. In practice, the size of the data to be written is usually small, such as 4 KiB, so the size of a data sub-area can be set to 2 KiB.

[0051] S102, if the data to be written has not filled at least one data area, then fill data is written into the target data area that has not been filled in at least one data area.

[0052] S103, the encoding result obtained by erasure coding of the data to be written and the data to be filled is written into the verification area corresponding to the second storage node set. The first storage node set and the second storage node set are contained in the distributed storage system.

[0053] After the data to be written is written to at least one data area provided by each storage node in the first storage node set, the storage nodes in the first storage node set can further determine whether the data to be written has filled at least one data area, that is, whether the size of the data to be written meets the preset encoding requirements. The preset encoding requirements are the requirements that the erasure coding of the data to be written must meet.

[0054] Erasure coding (EC) is a fault-tolerance coding technique that uses k original data sets to generate m parity data sets through a verification calculation method. This ensures that extracting any k data sets from these k+m data sets will reconstruct the k original data sets. Here, the m data sets are the parity data sets. Using this coding technique, the reliability of the original data in a distributed storage system can be guaranteed even if some data is lost. Here, m and k can be called coding parameters, and k and m can have a preset ratio, such as k=4, m=2.

[0055] It is evident that erasure coding requires a certain size of the original data, i.e., the amount of data. Therefore, the above judgment process is also to determine whether the size of the data to be written is the same as the size of k original data.

[0056] Furthermore, when using erasure coding in a distributed storage system, it is necessary to ensure that k+m copies of data are stored on k+m storage nodes. That is, k can be the same number of storage nodes as the first set of storage nodes in the distributed storage system, and m can be the same number of storage nodes as the second set of storage nodes. Therefore, if the size of the data to be written is the same as the size of the k original data copies, the data to be written can fill at least one data area corresponding to the first set of storage nodes. The above-mentioned preset coding requirement can also be considered as the size of the data to be written being an integer multiple of the size of any data area.

[0057] If the data to be written does not fill at least one data area, it indicates that the size of the data to be written is insufficient, meaning the data to be written does not meet the preset encoding conditions. In this case, the unfilled data area in at least one data area corresponding to the first storage node set can be identified as the target data area, and fill data can be written into this target data area to fill it. After filling, the total amount of the data to be written and the fill data meets the preset encoding conditions. Then, erasure coding can be performed on both, and the encoding result can be written to the check area corresponding to the second storage node set in the discrete storage system. At this point, the writing of the data to be written is completed, and the reliability of the data to be written can also be guaranteed by using the encoding result written to the check area.

[0058] Continuing with the example in step S101, the execution process of steps S102 to S103 will be explained: 10 KiB of data to be written can be sequentially written horizontally to two data areas, that is, written to the five data sub-areas provided by different storage nodes in the first storage node set, i.e., written... Figure 4 The first data area (i.e., data sub-areas 1 to 4) and data sub-area 5 in the second data area are used. At this point, neither data area is full, meaning the size of the data to be written does not meet the preset encoding requirements. Therefore, 6 KiB of padding data can be written into the last three data sub-areas (i.e., data sub-areas 6 to 8) of the second data area. The 10 KiB of written data and the 6 KiB of padding data are then used as the original data for erasure coding to obtain the encoding result. The encoding result can be written to the parity area provided by each storage node in the second storage node set. For example, with k=4 and m=2, the size of the encoding result is 8 KiB. The above example can also be combined with... Figure 4 understand.

[0059] Regarding the preset requirements in step S101, it should be noted that the preset requirements can be set according to the size of any data area in at least one data area, the encoding parameters, and the preset number of copies, i.e., N value. The principle for setting the preset requirements is to ensure that the total amount of data to be written, filling data, and encoding results is less than the total amount of data corresponding to writing the data to be written N times repeatedly.

[0060] Optionally, taking the above example with k=4, m=2, preset replica count N=3, and a data area size of 8KiB, the preset requirement can be half the size of any data area. That is, if the size of the data to be written is not less than half the size of any data area, then the size of the data to be written meets the preset requirement. In practice, the encoding parameters, preset replica count, and data area size can optionally have different values, and they can all be set according to the above principles. For example, when k=8, m=3, N=4, and the size of a data area is 8KiB, the preset requirement for the data to be written can be one-third the size of a data area.

[0061] In this embodiment, data to be written, meeting preset size requirements, can first be written to at least one data area corresponding to the first storage node set. If this at least one data area is not full, padding data is written to the unfilled target data area, and erasure coding is performed on the padding data and the data to be written. Finally, the encoding result is written to the check area corresponding to the second storage node set. Erasure coding can ensure data reliability while completing data writing.

[0062] When ensuring data reliability using the method of writing N copies (N≥3) mentioned in the background technology, for a single piece of data to be written, N copies actually need to be written in the distributed storage system. The data to be written is magnified N times, resulting in a large amount of redundant data stored in the distributed storage system. However, using the method provided in this embodiment, for a single piece of data to be written, the data to be written in the distributed storage system includes the data to be written, padding data, and encoding results. Since the preset requirements can be determined based on the size of any data area in at least one data region, the encoding parameters of erasure coding, and the preset number of copies, the sum of the data volume of the data to be written, padding data, and encoding results that meets this requirement is less than N copies of the data to be written. Therefore, using the method provided in this embodiment, the magnification factor of the data to be written will not exceed N times, that is, less than the aforementioned N-copy writing method. This ensures data reliability while also improving the space waste caused by the storage of redundant data in the distributed storage system.

[0063] Continuing with the example above where k=4, m=2, the preset number of replicas N=3, and the size of a data area is 8KiB, writing 10KiB of data actually requires writing 21KiB (10KiB + 6KiB + 8KiB) of data to the distributed storage system. The scaling factor of the data to be written is 2, which is less than the scaling factor of the 3-replica method mentioned above. Furthermore, all embodiments of this invention use k=4, m=2, the preset number of replicas N=3, and the size of a data area of ​​8KiB as an example for explanation.

[0064] Figure 1 The illustrated embodiment shows a scenario where the data to be written is not filled in at least one data area. Otherwise, if the data to be written can fill at least one data area, it indicates that the size of the data to be written meets the standard, meaning the data to be written satisfies the preset encoding conditions. In this case, erasure coding can be directly performed on the data to be written, and the encoding result can be further written to the verification area corresponding to the second set of storage nodes in the discrete storage system. Simultaneously with completing the writing of the data to be written, the reliability of the data to be written can also be ensured by using the encoding result written to the verification area.

[0065] For example, suppose the size of the data to be written is 8KiB, based on Figure 2 The data storage area shown has a sub-area size of 2KiB, so a data area consisting of 4 storage nodes is also 8KiB in size. If the data to be written can fill one data area, erasure coding can be applied to the data, and the encoded result can be written to a storage node in the second set of storage nodes. Again, using k=4 and m=2 as an example, the encoded result is 4KiB. Therefore, for 8KiB of data to be written, the actual amount of data written to the distributed storage system is 12KiB, resulting in a magnification factor of 1.5. Compared to the 3-replica approach, this magnification factor is halved. This approach ensures data reliability while mitigating space waste caused by redundant data storage in the distributed storage system.

[0066] It should also be noted that in practice, the transaction data in the data to be written is often small, such as a few KiB or a dozen KiB. Therefore, the size of the data sub-area is also set to be small. This is particularly applicable to the data writing method provided in the above and below embodiments of the present invention, so as to reduce the data amplification factor and improve the waste of storage space.

[0067] For the two writing processes of the data to be written, please refer to [link / reference]. Figure 5The flowchart shown illustrates another data writing method provided in this embodiment of the invention. Combining the two scenarios above, if the data to be written can fill at least one data area, it indicates that the data to be written meets the encoding conditions. Therefore, erasure coding can be performed directly, and the size of the encoded result is smaller than the data to be written. In this case, for a single copy of data to be written, to ensure data reliability, the actual size of the data to be written is less than twice the size of the data to be written, i.e., the magnification factor of the data to be written is less than 2, and less than 3 copies.

[0068] If the data to be written cannot fill at least one data area, it indicates that the data to be written does not meet the encoding conditions. In this case, data padding is required. As can be seen from the above embodiments, the size of the padding data is smaller than the size of the data to be written and also smaller than the size of one data area. The size of the encoded result is also smaller than the data to be written. Therefore, to ensure data reliability, the actual size of the data to be written should be less than 3 times the size of the data to be written, that is, the magnification factor of the data to be written should be less than 3, and less than 3 copies.

[0069] Furthermore, as described above, since the methods provided in the above and following embodiments of the present invention can reduce the degree of data amplification during the foreground storage process in a distributed storage system, in this scenario, writing the data to be written to at least one data area can be considered as writing to the write-ahead log files configured for each storage node in the first storage node set. Writing the encoding result to the verification area can be considered as writing to the write-ahead log files configured for each storage node in the second storage node set.

[0070] Optionally, based on Figure 2 The data storage area shown can be further divided into multiple data fragments after the storage nodes in the first storage node set obtain the data to be written, according to the size of any data sub-area. These fragments are then sequentially written into multiple data sub-areas within at least one data area. Optionally, the fragmented data can be processed using... Figure 3 The illustrated embodiments show horizontal or vertical writing methods.

[0071] exist Figure 3 In the illustrated embodiment, when the data to be written (i.e., useful user data) is not filled in at least one data area, data padding is required. This involves writing useless padding data into the unfilled target data area. The padding data can be, for example, all zeros. Erasure coding can be implemented through data padding. However, when the background storage process of the distributed storage system fails, the process of writing user data to the data file cannot be completed. In this case, it is necessary to read the user data and encoding results written in each storage node and perform data recovery.

[0072] In order to achieve data recovery, Figure 6A flowchart illustrating another data writing method provided in an embodiment of the present invention. The method may include:

[0073] S201, write the data to be written that meets the preset requirements into at least one data area corresponding to the first storage node set, wherein the preset requirements are determined based on the size of any data area in the at least one data area, the encoding parameters of the erasure coding, and the preset number of replicas.

[0074] S202, if the data to be written has not filled at least one data area, then fill data is written into the target data area that has not been filled in at least one data area.

[0075] The unfilled data sub-area in the target data area can be called the filling area, and the filling data is specifically written into the filling area of ​​the target data area. The filling area is usually located at the end of the target data area. Furthermore, the execution process of steps S201 to S202 can be found in [link to documentation]. Figure 3 The relevant descriptions in the illustrated embodiments will not be repeated here.

[0076] S203, obtain the metadata of the filling data. The total amount of filling data, metadata and data to be written is an integer multiple of the target data area size.

[0077] S204, Write metadata to the target data area.

[0078] S205, write the encoding result obtained by erasure coding of the padding data, metadata and data to be written into the verification area.

[0079] Furthermore, while filling in the data, metadata for the filling data can also be obtained. The total amount of the filling data, its metadata, and the data to be written can be an integer multiple of the target data area size, meaning the filling data, metadata, and data to be written can fill at least one data area corresponding to the first storage node set, thus satisfying the preset encoding requirements. At this point, the metadata can be written to the target data area. More specifically, the metadata for the filling data is written to the filling area within at least one data area. The metadata for updated data in the data to be written can also be written to this filling area. The filling data and the updated data in the data to be written are written to other areas within at least one data area.

[0080] Next, erasure coding is performed on the data that fills at least one data area, and the encoded result is finally written into the check area corresponding to the second storage node set.

[0081] Optionally, the storage structure of any data area corresponding to the first set of storage nodes, such as the target data area, can be as follows: Figure 7As shown, the data area can contain multiple complete data sub-areas and data sub-areas with padding areas. The metadata for the padding data can include: the size of the data to be written; the difference between the size of at least one data area filled after padding and the size of the data to be written is the size of the padding data. Optionally, the metadata can also include Cyclic Redundancy Check (CRC) information for verifying the correctness of the data to be written (i.e.,... Figure 7 In addition to the CRC (CRC in the data), it can also include other auxiliary information, such as verification information that validates the validity of metadata in the padding area (i.e., ... Figure 7 The M in the data includes, for example, version information for filling in the data (i.e., Figure 7 (V in the text) etc.

[0082] Optionally, the metadata of the data to be written in the filling area may include the size of the data to be written (i.e., Figure 7 The size in the file can include the offset address of the data to be written relative to the data corresponding to the first data write request (i.e., ...). Figure 7 The offset in step S101 corresponds to the first data write request.

[0083] After performing the above steps, the metadata of the data to be written and the data to be filled will be recorded in the filling area of ​​a data sub-area. Therefore, when the background storage process of the distributed storage system fails, the data can be recovered by reading the metadata in the filling area, thereby ensuring the normal operation of the background storage.

[0084] In this embodiment, a data padding process may occur before erasure coding. During this process, the metadata for the padding data can be written to the padding area at the end of a data sub-area within the data area. The metadata in the padding area can be used for data recovery in the event of a background storage failure. Furthermore, in this embodiment, the padding area contains metadata related to the data to be written corresponding to a single data write request. Compared to writing all the data to be written corresponding to multiple data write requests to the padding area, the amount of metadata in the padding area is smaller, which also helps to mitigate the space waste caused by excessive metadata in distributed storage systems.

[0085] Figure 8 This is a schematic diagram of a distributed storage system provided in an embodiment of the present invention. The distributed storage system may include a first set of storage nodes and a second set of storage nodes. For the sake of brevity and clarity in the following description, the storage nodes in the first set of storage nodes may be referred to as first storage nodes, and the storage nodes in the second set of storage nodes may be referred to as second storage nodes.

[0086] In response to a data write request, the first storage node obtains the data to be written corresponding to the request and writes this data to at least one data area corresponding to the first storage node set. The size of the data to be written satisfies a preset requirement, which is determined based on the size of any data area in the at least one data area, the erasure coding parameters, and a preset number of replicas.

[0087] Next, the first storage node continues to determine whether at least one data area has been filled. In one case, if at least one data area is filled, the data to be written is directly encoded with erasure coding, and the second storage node controls the writing of the encoded result into the corresponding check area of ​​the second storage node set.

[0088] In another scenario, if at least one data area is not filled, padding data is written to the unfilled target data area to ensure that the data to be written and the padding data fill at least one data area. Further, erasure coding is performed on the data to be written and the padding data. The second storage node then controls the writing of the coding result to the corresponding checksum area of ​​the second storage node set.

[0089] Optionally, when filling data is written to the target data area, the first storage node can also obtain the metadata of the filling data. The total amount of the filling data, its metadata, and the data to be written is an integer multiple of the target data area, meaning at least one data area is filled. At this time, the first storage node controls the metadata of the filling data to also be written to the target data area, and performs erasure coding on the written data. The second storage node controls the coding result to be written to the verification area.

[0090] Since the methods provided in the above and following embodiments of the present invention can reduce the degree of data amplification during the foreground storage process in a distributed storage system, in this scenario, optionally, writing the data to be written to at least one data area can be considered as writing to the write-ahead log file configured by each storage node in the first storage node set. Writing the encoding result to the verification area can be considered as writing to the write-ahead log file configured by each storage node in the second storage node set.

[0091] Furthermore, for details not described in this embodiment and the technical effects that can be achieved, please refer to the above. Figures 1 to 7 The relevant descriptions in the illustrated embodiments will not be repeated here.

[0092] It should be noted that the processing procedure executed by the first storage node is specifically executed by the processor in that storage node, namely the first processor. Similarly, the processing procedure executed by the second storage node is specifically executed by the processor in that storage node, namely the second processor.

[0093] For ease of understanding, the following description uses a database system as an example to illustrate the data writing methods and distributed storage system provided in the above embodiments. The following process can also be combined with... Figure 4 understand.

[0094] Assume the database system comprises a first set of storage nodes and a second set of storage nodes. The first set of storage nodes contains 4 storage nodes, and the second set of storage nodes contains 2 storage nodes. This means that a data area in the system contains 4 data sub-areas and 2 parity sub-areas. Each data sub-area and parity sub-area is 2 KiB in size, meaning a data area is 8 KiB and a parity sub-area is 4 KiB. Furthermore, during erasure coding, m = 4, k = 2, and the preset number of replicas N = 3.

[0095] Based on the above assumptions, in one scenario, the transaction data and its metadata generated after executing a database transaction are 16 KiB in size (i.e., the data to be written in the above embodiments). In this case, taking horizontal writing as an example, the 16 KiB of data to be written can be written sequentially to data sub-areas 1 to 8, that is, exactly filling two data sub-areas. At this time, the first storage node performs erasure coding on it to obtain an 8 KiB encoding result. This encoding result can be written to check sub-areas 1 to 4.

[0096] At this point, the writing of the data to be written is complete. Furthermore, for a 16KiB dataset, to ensure data reliability, 24KiB (16KiB + 8KiB) is actually written to the distributed storage system, resulting in a data amplification factor of 1.5. Compared to ensuring data reliability by writing three copies, the data amplification factor is reduced by half, thus mitigating the space waste caused by redundant data storage in the distributed storage system.

[0097] In another scenario, after executing a database transaction, the size of the transaction data and its metadata is 10 KiB (i.e., the data to be written in the above embodiments). Taking a horizontal write as an example, the 10 KiB of data to be written can be written sequentially to data sub-areas 1 through 5. If this doesn't fill both data sub-areas, padding data can be written to data sub-areas 6 through 8, ensuring that the data to be written, the padding data, and its metadata fill both data sub-areas. The size of the padding data and its metadata is 6 KiB. After filling, the first storage node performs erasure coding to obtain an 8 KiB encoded result. This encoded result can then be written to check sub-areas 1 through 4.

[0098] At this point, the writing of the data to be written is complete. Furthermore, for a 10KiB dataset, to ensure data reliability, 24KiB (10KiB + 6KiB + 8KiB) is actually written to the distributed storage system, resulting in a data amplification factor of approximately 2. Compared to ensuring data reliability by writing three copies, this reduces the data amplification factor and mitigates space waste caused by redundant data storage in the distributed storage system.

[0099] Meanwhile, since the filling area contains metadata related to the data to be written for a single data write request, compared to writing the data to be written for multiple data write requests, the amount of metadata in the filling area is smaller. This can also improve the space waste caused by excessive metadata in distributed storage systems.

[0100] In one possible design, the data writing methods provided in the above embodiments can be applied to an electronic device, such as... Figure 9 As shown, the electronic device may include a processor 21 and a memory 22. The memory 22 is used to store data supporting the electronic device in performing the above-described actions. Figures 1 to 7 The data writing method program provided in the illustrated embodiment is configured to execute the program stored in the memory 22.

[0101] The program includes one or more computer instructions, wherein when the one or more computer instructions are executed by the processor 21, they can perform the following steps:

[0102] Write data to be written that meets the preset size requirement to at least one data area corresponding to the first storage node set, wherein the preset requirement is determined based on the size of any data area in the at least one data area, the encoding parameters of erasure coding, and the preset number of replicas;

[0103] If the data to be written is not filled in the at least one data area, then fill data is written into the target data area that is not filled in the at least one data area;

[0104] The encoding result obtained by erasure coding the data to be written and the filling data is written into the verification area corresponding to the second storage node set. The first storage node set and the second storage node set are contained in the distributed storage system.

[0105] Optionally, the processor 21 is further configured to perform the aforementioned Figures 1 to 7 All or part of the steps in the illustrated embodiments.

[0106] The structure of the electronic device may also include a communication interface 23 for the electronic device to communicate with other devices or communication networks.

[0107] In addition, embodiments of the present invention provide a computer storage medium for storing computer software instructions used by the aforementioned electronic device, which includes instructions for executing the above-mentioned... Figures 1 to 7 The illustrated method embodiment involves the program related to the data writing method.

[0108] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data writing method, comprising: Write data to be written that meets the preset size requirement to at least one data area corresponding to the first storage node set. The preset requirement is determined based on the size of any data area in the at least one data area, the encoding parameters of erasure coding, and the preset number of replicas. After the preset requirement is met, the total amount of data to be written, filling data, and encoding result is less than the total amount of data corresponding to the preset number of replicas to be written. If the data to be written is not filled in the at least one data area, then fill data is written into the target data area that is not filled in the at least one data area; The encoding result obtained by erasure coding the data to be written and the filling data is written into the verification area corresponding to the second storage node set. The first storage node set and the second storage node set are contained in the distributed storage system.

2. The method according to claim 1, wherein after writing fill data into the unfilled target data area in the at least one data area, the method further comprises: Obtain the metadata of the filling data, wherein the total amount of the filling data, the metadata, and the data to be written is an integer multiple of the size of the target data area; Write the metadata into the target data area; The step of writing the encoding result obtained by erasure coding of the data to be written and the padding data into the verification area in the second storage node set includes: The encoding result obtained by erasure coding the filling data, the metadata, and the data to be written is written into the verification area.

3. The method according to claim 2, wherein the metadata includes: The size of the data to be written and the corresponding verification information.

4. The method according to claim 1, further comprising: If the data to be written fills at least one data area, then the data to be written is encoded with erasure codes. The encoding result is written into the verification area of ​​the second storage node set.

5. The method according to claim 1, wherein any one of the at least one data area comprises at least one data sub-area; The step of writing the data to be written, which meets the preset size requirement, into at least one data area corresponding to the first storage node set includes: The data to be written is divided into multiple data fragments according to the size of any data sub-region. The multiple data fragments are sequentially written into multiple data sub-areas within the at least one data area.

6. The method according to claim 5, wherein sequentially writing the plurality of fragmented data into the plurality of data sub-regions of the at least one data region comprises: The multiple data fragments are sequentially written into the multiple data sub-regions corresponding to the same storage node in the first storage node set; or, The multiple data shards are sequentially written into the multiple data sub-areas corresponding to different storage nodes in the first storage node set.

7. The method according to any one of claims 1 to 6, wherein the at least one data area corresponds to a write-ahead log file contained in any storage node of the first storage node set, and the verification area corresponds to a write-ahead log file contained in any storage node of the second storage node set; The first set of storage nodes and the second set of storage nodes each include at least one storage node in the distributed storage system.

8. A distributed storage system, comprising: First set of storage nodes and second set of storage nodes; The storage nodes in the first storage node set are used to control the writing of data to be written to at least one data area corresponding to the first storage node set, wherein the preset requirement is determined based on the size of any data area in the at least one data area, the encoding parameters of erasure coding, and the preset number of replicas. After the preset requirement is met, the total amount of data to be written, filling data, and encoding results is less than the total amount of data corresponding to the number of data to be written that is repeatedly written to the preset number of replicas. If the data to be written is not filled in at least one data area, then control the filling data to be written into the unfilled target data area in the at least one data area; The data to be written and the filling data are encoded using erasure coding. The storage nodes in the second set of storage nodes are used to control the encoding results and write them into the verification area corresponding to the second set of storage nodes.

9. The system according to claim 8, wherein the storage nodes in the first set of storage nodes are further configured to obtain metadata of the filling data, wherein, The total amount of the filling data, the metadata, and the data to be written is an integer multiple of the size of the target data area; Control the writing of the metadata into the target data area; The padding data, the metadata, and the data to be written will be erasure encoded. The storage nodes in the second set of storage nodes are used to control the writing of the encoding results into the verification area.

10. The system according to claim 8, wherein any storage node in the first set of storage nodes includes a first non-volatile memory, and any storage node in the second set of storage nodes includes a second non-volatile memory; The at least one data area corresponds to the write-ahead log file stored in the first non-volatile memory, and the check area corresponds to the write-ahead log file stored in the second non-volatile memory.

11. An electronic device, comprising: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor performs the data writing method as described in any one of claims 1 to 7.

12. A non-transitory machine-readable storage medium storing executable code that, when executed by a processor of an electronic device, causes the processor to perform the data writing method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing method and device and distributed file system

    CN106227731A

  • Data writing method and system, electronic equipment and storage medium

    CN109683817A