CN112860488A - Object recovery method and device, electronic equipment and storage medium - Google Patents

Object recovery method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112860488A
CN112860488A CN202110192139.0A CN202110192139A CN112860488A CN 112860488 A CN112860488 A CN 112860488A CN 202110192139 A CN202110192139 A CN 202110192139A CN 112860488 A CN112860488 A CN 112860488A
Authority
CN
China
Prior art keywords
target
fragment
target object
node
objects
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110192139.0A
Other languages
Chinese (zh)
Inventor
张丞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Cloud Network Technology Co Ltd
Original Assignee
Beijing Kingsoft Cloud Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Cloud Network Technology Co Ltd filed Critical Beijing Kingsoft Cloud Network Technology Co Ltd
Priority to CN202110192139.0A priority Critical patent/CN112860488A/en
Publication of CN112860488A publication Critical patent/CN112860488A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1435Saving, restoring, recovering or retrying at system level using file system or storage system metadata

Abstract

The application provides a method and a device for recovering an object, an electronic device and a storage medium, wherein the method comprises the following steps: respectively sending an object identification set to a plurality of first nodes, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects; receiving first fragments of each target object returned by each first node according to the object identification set to obtain a fragment set of each target object, wherein the first fragments of each target object are fragments of each target object stored on each first node; and performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.

Description

Object recovery method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of data processing, and in particular, to a method and an apparatus for restoring an object, an electronic device, and a storage medium.
Background
In the distributed storage system, data storage may be performed in an EC (Erasure Coding) block manner. The EC code is a redundancy mode, and may cut data into m data blocks, generate m check blocks for the m data blocks, and obtain (m + n) erasure correcting blocks in total, where each erasure correcting block (may be a data block or a check block) may be stored on a different data node, so that the system may tolerate the loss of n erasure correcting blocks at most.
Currently, the recovery process of erasure correction blocks of a distributed storage system is executed according to the granularity of objects. The erasure block to be recovered may contain fragments (fragment data) of a plurality of objects, and each object reads other fragments of the object from all other copies one by one; and then, locally recovering (recovering the fragment of the object on the node), verifying (verifying the object), writing (writing the recovered fragment into a local storage) by using an erasure correction mode, and then recovering the next object until all the objects on the erasure correction block are completely recovered.
For example, for an erasure correction mode of 8+4 (8 data blocks, 4 check blocks), if an object on one of the erasure correction blocks needs to be recovered, other object data of the object may be read from at least 8 other copies, and recovery, checking, and writing are performed locally by using an erasure correction method.
The above-mentioned method for recovering erasure blocks can lead to long time of the whole recovery process if there are more objects to be recovered, the availability of the whole service is reduced during the recovery period, and the low availability time is also increased. Also, too long a recovery time may affect the quality of the read and write of the entire service during the recovery period.
Therefore, the manner of recovering the objects in the erasure block in the related art has a problem in that the availability of the service during the recovery is reduced due to the lengthy recovery flow time.
Disclosure of Invention
The application provides a method and a device for recovering an object, an electronic device and a storage medium, which are used for solving the problem that the usability of a service is reduced during recovery due to too long recovery flow time in a mode of recovering the object in an erasure block in the related art.
According to an aspect of an embodiment of the present application, there is provided a method for restoring an object, including: respectively sending an object identification set to a plurality of first nodes, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects; receiving first fragments of the target objects returned by the first nodes according to the object identification set to obtain fragment sets of the target objects, wherein the first fragments of the target objects are fragments of the target objects stored on the first nodes; and performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is a fragment of each target object in the target erasure correction block.
Optionally, the receiving, by each first node, the first fragment of each target object returned according to the object identifier set, and the obtaining of the fragment set of each target object includes: determining that a shard set of a first target object has been received in the case that the number of received first shards of the first target object is greater than or equal to a target number threshold, wherein the first target object is one of the plurality of target objects.
Optionally, performing erasure recovery on each target object by using the shard set of each target object, and obtaining a second shard of each target object includes: performing erasure recovery on a second target object by using a fragment set of the second target object through a target thread in a plurality of threads to obtain a candidate fragment of the second target object, wherein the second target object is one target object which has received a corresponding fragment set, and the plurality of threads are used for performing parallel erasure recovery on the target object which has received the corresponding fragment set; checking the second target object according to the fragment set of the second target object and the candidate fragments of the second target object; and under the condition that the second target object passes the verification, determining the candidate fragment of the second target object as the second fragment of the second target object.
Optionally, after performing erasure recovery on each target object by using the shard set of each target object to obtain a second shard of each target object, the method further includes: and sequentially writing the second fragments of the target objects into the disk of the second node according to a target writing sequence, wherein the target writing sequence is the sequence of the target objects in the target erasure correcting block.
Optionally, sequentially writing the second fragments of the target objects into the disk of the second node according to the target writing sequence includes: determining an object identifier of a third target object according to the target writing sequence, wherein the third target object is the target object to be written currently, and second fragments of the target object with the writing sequence being before the third target object are written into a disk of the second node; searching a target mapping table by taking the object identifier of the third target object as a key word, wherein the target mapping table is used for storing the second fragment of each target object by taking the object identifier of each target object as a key word and taking the second fragment of each target object as a value; and writing the second fragment of the third target object into the disk of the second node under the condition that the second fragment of the third target object is found from the target mapping table.
Optionally, sequentially writing the second fragments of the target objects into the disk of the second node according to the target writing sequence further includes: after the target mapping table is searched by taking the object identifier of the third target object as a key word, under the condition that a second fragment of the third target object is not searched in the target mapping table, the target mapping table is searched again by taking the object identifier of the third target object as a key word at target time intervals until the second fragment of the third target object is searched; and writing the second fragment of the third target object into the disk of the second node.
According to another aspect of the embodiments of the present application, there is also provided a method for restoring an object, including: receiving an object identifier set sent by a second node through a first node, wherein the object identifier set comprises a plurality of object identifiers used for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one; acquiring first fragments of the target objects according to the object identification set, wherein the first fragments of the target objects are fragments of the target objects stored on the first node; and sending the first fragment of each target object to the second node to recover the second fragment of each target object on the second node, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
Optionally, obtaining the first fragment of each target object according to the object identifier set includes: sequentially adding the object identifiers in the object identifier set to a target reading queue according to a target writing sequence, wherein the target writing sequence is the sequence of the target objects in the target erasure correcting block; sequentially acquiring one object identifier from the target reading queue to obtain a first object identifier, wherein the first object identifier is used for identifying a first object in a plurality of target objects; and reading data according to the first object identifier to obtain a first fragment of the first object.
Optionally, obtaining the first fragment of each target object according to the object identifier set includes: when the first fragment of the second object identified by the second object identifier is sent to the second node, acquiring a next object identifier of the second object identifier from the object identifier set to obtain a third object identifier, wherein the second object identifier is one of the plurality of object identifiers; and reading data according to the third object identifier to obtain a first fragment of a third object, wherein the third object is the target object identified by the third object identifier.
According to another aspect of the embodiments of the present application, there is also provided an apparatus for restoring an object, including: a first sending unit, configured to send an object identifier set to each of a plurality of first nodes, where the object identifier set includes a plurality of object identifiers used to identify a plurality of target objects to be recovered in a target erasure correcting block of a second node, and the plurality of object identifiers are in one-to-one correspondence with the plurality of target objects; a first receiving unit, configured to receive a first fragment of each target object returned by each first node according to the object identifier set, to obtain a fragment set of each target object, where the first fragment of each target object is a fragment of each target object stored on each first node; and the recovery unit is configured to perform erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure correction block.
Optionally, the first receiving unit includes: the determining module is configured to determine that the shard set of the first target object is received when the number of received first shards of the first target object is greater than or equal to a target number threshold, where the first target object is one of the plurality of target objects.
Optionally, the recovery unit includes: a recovery module, configured to perform erasure recovery on a second target object by using a fragment set of the second target object through a target thread in multiple threads to obtain a candidate fragment of the second target object, where the second target object is a target object that has received a corresponding fragment set, and the multiple threads are used to perform parallel erasure recovery on the target object that has received the corresponding fragment set; the verification module is used for verifying the second target object according to the fragment set of the second target object and the candidate fragments of the second target object; and the first determining module is used for determining the candidate fragment of the second target object as the second fragment of the second target object under the condition that the second target object passes the verification.
Optionally, the apparatus further comprises: and a writing unit, configured to perform erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, and sequentially write the second fragment of each target object into the disk of the second node according to a target writing order, where the target writing order is an order of the target objects in the target erasure correction block.
Optionally, the writing unit includes: a second determining module, configured to determine an object identifier of a third target object according to the target writing order, where the third target object is the target object to be written currently, and second fragments of the target object whose writing order is located before the third target object are all written into a disk of the second node; a first searching module, configured to search a target mapping table by using the object identifier of the third target object as a key, where the target mapping table is used to store the second fragments of each target object by using the object identifier of each target object as a key and using the second fragments of each target object as values; a first writing module, configured to write the second fragment of the third target object into the disk of the second node when the second fragment of the third target object is found from the target mapping table.
Optionally, the writing unit further includes: a second searching module, configured to search the target mapping table again at target time intervals with the object identifier of the third target object as a key until the second fragment of the third target object is found, when the second fragment of the third target object is not found in the target mapping table after the object identifier of the third target object is used as a key; and the second writing module is used for writing the second fragment of the third target object into the disk of the second node.
According to another aspect of the embodiments of the present application, there is also provided an apparatus for restoring an object, including: a second receiving unit, configured to receive, by a first node, an object identifier set sent by a second node, where the object identifier set includes multiple object identifiers used to identify multiple target objects to be recovered in a target erasure block of the second node, and the multiple object identifiers are in one-to-one correspondence with the multiple target objects; an obtaining unit, configured to obtain, according to the object identifier set, a first fragment of each target object, where the first fragment of each target object is a fragment of each target object stored on the first node; a second sending unit, configured to send the first fragment of each target object to the second node, so as to recover, at the second node, the second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure block.
Optionally, the obtaining unit includes: an adding module, configured to sequentially add the multiple object identifiers in the object identifier set to a target read queue according to a target write order, where the target write order is an order of the multiple target objects in the target erasure block; a first obtaining module, configured to sequentially obtain one object identifier from the target reading queue to obtain a first object identifier, where the first object identifier is used to identify a first object in the multiple target objects; and the first reading module is used for reading data according to the first object identifier to obtain a first fragment of the first object.
Optionally, the obtaining unit includes: a second obtaining module, configured to obtain, while sending a first fragment of a second object identified by a second object identifier to the second node, a next object identifier of the second object identifier from the object identifier set, to obtain a third object identifier, where the second object identifier is one of the object identifiers; and the second reading module is configured to perform data reading according to the third object identifier to obtain a first fragment of a third object, where the third object is the target object identified by the third object identifier.
According to another aspect of the embodiments of the present application, there is also provided an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein the memory is used for storing the computer program; a processor for performing the method steps in any of the above embodiments by running the computer program stored on the memory.
According to a further aspect of the embodiments of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to perform the method steps of any of the above embodiments when the computer program is executed.
In the embodiment of the application, an object identifier set is sent to a plurality of first nodes by adopting a mode that a destination node sends the object identifier set to a source node, wherein the object identifier set comprises a plurality of object identifiers used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifiers correspond to the plurality of target objects one to one; receiving first fragments of each target object returned by each first node according to the object identification set to obtain a fragment set of each target object, wherein the first fragments of each target object are fragments of each target object stored on each first node; the method comprises the steps of performing erasure recovery on each target object by using a fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is a fragment of each target object in a target erasure block, and because a target node (a second node) sends an object identification set to a source node (a first node) instead of sending the object identification set one at a time, the time required for transmitting the object identification can be reduced, and meanwhile, the possibility is provided for concurrently performing recovery of fragments of different objects, so that the purpose of reducing the recovery flow of the erasure block can be realized, the technical effects of shortening the recovery flow time of the erasure block and improving the service availability are achieved, and the problem that the service availability is reduced during recovery due to overlong recovery flow time in the mode of recovering the objects in the erasure block in the related art is solved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art to obtain other drawings without inventive exercise.
FIG. 1 is a schematic diagram of a hardware environment for an alternative object recovery method according to an embodiment of the application;
FIG. 2 is a flow chart illustrating an alternative object recovery method according to an embodiment of the present application;
FIG. 3 is a flow chart illustrating an alternative object recovery method according to an embodiment of the present application;
FIG. 4 is a flow chart illustrating a further alternative object recovery method according to an embodiment of the present application;
FIG. 5 is a block diagram of an alternative object recovery apparatus according to an embodiment of the present application;
FIG. 6 is a block diagram of an alternative object recovery apparatus according to an embodiment of the present application;
fig. 7 is a block diagram of an alternative electronic device according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the application described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to an aspect of an embodiment of the present application, there is provided a method for restoring an object. Alternatively, in this embodiment, the object recovery method may be applied to a distributed storage system including a plurality of data nodes (e.g., database servers) as shown in fig. 1, for example, a hardware environment including the first node 102 and the second node 104. As shown in fig. 1, a first node 102 is connected to a second node 104 through a network, and may be configured to provide services (e.g., game services, application services, etc.) for a terminal or a client installed on the terminal.
The network may include, but is not limited to, at least one of: wired networks, wireless networks. The wired network may include, but is not limited to, at least one of: wide area networks, metropolitan area networks, local area networks, which may include, but are not limited to, at least one of the following: WIFI (Wireless Fidelity), bluetooth. The terminal 102 may not be limited to a PC, a mobile phone, a tablet computer, etc.
The object recovery method according to the embodiment of the present application may be executed by the first node 102, may also be executed by the second node 104, and may also be executed by both the first node 102 and the second node 104. The first node 102 and/or the second node 104 may also perform the object recovery method according to the embodiment of the present application by a client installed thereon.
Taking the second node 104 to execute the object recovery method in this embodiment as an example, fig. 2 is a schematic flowchart of an optional object recovery method according to an embodiment of the present application, and as shown in fig. 2, the flowchart of the method may include the following steps:
step S202, an object identification set is respectively sent to a plurality of first nodes, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects.
The object recovery method in the embodiment of the application can be applied to a distributed storage system which comprises a plurality of data nodes and takes the object as a data storage unit. The data node may be a server, e.g., a database server. An object is a basic unit of data storage in the distributed storage system, and an object may be a combination of file data and a set of attribute information, which may be one or more, and may include a Check value of the object, which is used to Check the object, for example, Cyclic Redundancy Check (CRC). The attribute information may be located at a predetermined position of the file data, for example, in front of the file data. In this embodiment, the type of the attribute information and the positional relationship between the attribute information and the file data are not limited.
An object may be divided into m data slices (a first number of data slices) and n check slices (a second number of check slices) may be generated, m being a positive integer greater than 1 and n being a positive integer greater than or equal to 1. For an object, the distributed storage system may store (m + n) pieces (object pieces, check pieces) of the object, where different pieces are stored on different data nodes or different disks of the same data node.
Alternatively, the check fragments may be generated using an encoding matrix, where the number of rows of the encoding matrix is the total number of fragments (e.g., m + n), the number of columns of the encoding matrix may be the number of data fragments (e.g., m), for example, an object is divided into 4 data fragments, and 2 check fragments may be generated according to formula (1):
Figure BDA0002944874110000081
wherein D is1、D2、D3And D4For 4 data slices, C1And C2Is 2 check fragments. According to 4 data fragments and any 4 fragments of 2 check fragments, other 2 fragments can be recovered according to the coding matrix.
Data may be stored on the data nodes in blocks, where each block may store at least one sharded data for each of a plurality of objects. As can be seen from the coding matrix, there may be a precedence order between the slices. The first data slice (or other slices) may store a check value of the whole object, so as to check when the data is recovered.
The fragments at the same position of different objects may be stored in the same data node or disk, or may be stored in different data nodes or disks. For example, for a scenario in which each object corresponds to 6 slices (4+2), and 6 slices are stored in 6 erasure correction blocks located on different data nodes, the slices at the same position of each object may all be stored in the same erasure correction block (for example, the first slice of each object is stored in the erasure correction block of the first data node), or may not be limited to be stored in the same erasure correction block.
For a second node, the second node may be a data node in the distributed storage system, and belong to a target node cluster including a plurality of nodes (data nodes), each node of the plurality of nodes may store one erasure correction block of a plurality of erasure correction blocks having an association relationship, respectively, where the association relationship may be a relationship generated based on different fragments storing the same object. For example, for multiple slices of a node, the multiple slices may be stored in erasure blocks of multiple nodes, respectively.
The target erasure block on the second node may store fragment data of a plurality of target objects, that is, a plurality of second fragments, where different second fragments belong to different target objects. Due to the occurrence of the exception, the target erasure block needs to be recovered. One recovery scheme for erasure blocks is as follows:
(1) for the erasure block needing to be recovered, finding out a set of all object identifications (such as object numbers) needing to be recovered and information of all servers corresponding to the erasure block;
(2) for each object, firstly sending a read message of the object to all servers, and then starting to perform data erasure mode recovery, data check (for example, CRC check) and data write locally when the number of successfully read fragment data is enough to complete recovery of the object;
(3) the recovery procedure of the above steps is sequentially performed for each object of the erasure correction block.
In the recovery mode of the erasure correction block (the object in the erasure correction block), each object is completely processed in series during reading, recovery and verification, so that the time of the whole recovery process is long, the availability of the whole service is reduced during the recovery period, and the time of low availability is increased; meanwhile, the resources of the system are not fully utilized in the whole recovery process, including a network, a disk and a CPU (Central processing Unit) are far from reaching the bottleneck, and the resource waste is caused; in addition, too long a recovery time may affect the quality of reading and writing of the entire service during this time.
Optionally, in this embodiment, the second node may obtain a plurality of object identifiers of a plurality of target objects to be recovered in the target erasure block, where the plurality of object identifiers correspond to the plurality of target objects one to one, that is, each object identifier is used to uniquely identify one target object. Here, the object identifications of different target objects are different or, to a certain extent, different, e.g. within the target node cluster in which the second node is located.
The second node may also determine a plurality of first nodes corresponding to the target erasure block, where each first node stores a first fragment of each target object, and the first fragment may be a data fragment or a verification fragment. The first fragment of the target object stored on the first node may be used to recover a second fragment of each target object in the target erasure block of the second node, where the second fragment may be a data fragment or a verification fragment.
It should be noted that the first fragment refers to a fragment of the target object stored on the first node, but not to a specific fragment, and the second fragment refers to a fragment of the target object stored on the second node, but not to a specific fragment. The first node and the second node may satisfy:
the first shards of the same target object stored on the same first node may be different (different first shards may be located on different disks);
the first fragments of different target objects stored on the same first node may be different;
the first fragments of the same target object stored on different first nodes may be different;
the first fragments of different target objects stored on different first nodes may be different;
the second fragment of a target object stored on the second node is different from the first fragment of the target object stored on the first node.
For example, for an erasure block to be recovered on a data node, the data node may find all sets of object numbers to be recovered and information of all servers corresponding to the erasure block.
The second node may send a target request message to each of the plurality of first nodes, where the target request message carries an object identifier set, and is used to request to obtain fragment data of each target object stored in each first node. For example, when recovering the erasure block, the destination node (second node) responsible for recovery sends all the object numbers to be recovered to the source node (source node server, first node) to be read. Because a plurality of object identifications are sent at the same time, object reading, recovery and verification can be conveniently carried out for parallel processing, and a foundation is provided for improving the utilization rate of system resources and shortening the recovery time.
It should be further noted that the plurality of first nodes may be all nodes storing other fragments of the target object, or may be some of the nodes. For example, for a scenario in which fragments at the same position of an object are stored in the same data node or disk, an object may correspond to 6(4+2) fragments, and if an erasure block in which one fragment of the object is located on one node needs to be recovered, a read message may be sent to other messages or 4 of the messages.
Step S204, receiving the first fragments of each target object returned by each first node according to the object identification set to obtain the fragment set of each target object, wherein the first fragments of each target object are the fragments of each target object stored on each first node.
After the object identifier set is obtained, each first node may read fragment data of each target object stored thereon, that is, the first fragment of each target object, and send the obtained first fragment of each target object back to the second node in a reply message manner.
There are various ways for the first node to read the first fragment of each target object and send it back to the second node, for example, it may be read sequentially and sent back one by one, or sent back one by one after all is read, or other ways are also possible, which is not limited in this embodiment. Sequential reading means that: the target objects are read one by one according to the order of the target objects in the target erasure block.
The second node may receive the first fragments of the respective target objects returned by the respective first nodes from the respective first nodes, respectively. The time when the second node receives the first fragment of the same target object returned by different first nodes may be different, the time when the second node receives the first fragment of the different target object returned by the same first node may be different, and the time when the second node receives the first fragment of the different target object returned by the different first nodes may also be different, which is not limited in this embodiment.
For a target object, the second node may receive the first fragments of the first target object returned by each first node, respectively, so as to obtain a fragment set of the target object. A sharded set of a target object may include a number of first shards that can recover a second shard of the target object, and may include all or a portion of the first shards of the target object returned by the first node.
Step S206, performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure correction block.
For the target object that has received the corresponding shard set, the second node may perform erasure recovery on the target object using the shard set of the target object, to obtain a second shard of the target object. The target erasure block may be recovered at the second node by recovering the second fragments corresponding to each target one by one.
It should be noted that, for a target object, receiving the object set of the target object and performing erasure recovery on the target object may be performed sequentially; for different target objects, receiving object sets of different target objects and performing erasure recovery on different target objects may be performed in parallel, that is, if it is determined that an object set of one target object has been received, erasure recovery may be performed on the object set of one target object, and it is not necessary to perform erasure recovery on each target object after receiving object sets of all target objects.
In order to ensure the reliability of data, after obtaining the second fragment of a target object, erasure recovery may be performed on the target object, for example, the target object may be determined from the fragment set of the target object, or the fragment set of the target object and the second fragment of the target object, the target object is checked (for example, CRC check), and if the check passes, the second fragment of the target object is written into the disk of the second node.
For example, when a target object is verified, a target verification value may be obtained from a first segment of the target object, then a verification value corresponding to the target object is calculated, the calculated verification value and the target verification value are compared, if the calculated verification value and the target verification value are consistent, the verification is passed, otherwise, the verification is not passed.
If the verification fails, multiple processing manners may be adopted, for example, a shard set of the target object is obtained again from multiple first nodes, and for example, if there is an unused shard in the shard set of the target object, erasure recovery may be performed again on a second shard of the target object. In addition, the failure of the verification may be caused by the presence of an abnormal fragment in the fragment set of the target object, and may also involve recovery of erasure correction blocks on other nodes or recovery of objects on the erasure correction blocks.
Through the steps S202 to S206, an object identifier set is respectively sent to the plurality of first nodes, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers are in one-to-one correspondence with the plurality of target objects; receiving first fragments of each target object returned by each first node according to the object identification set to obtain a fragment set of each target object, wherein the first fragments of each target object are fragments of each target object stored on each first node; and performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block, so that the problem that the availability of service is reduced during recovery due to overlong recovery process time in a method for recovering the object in the erasure correction block in the related art is solved, the recovery process time of the erasure correction block is shortened, and the service availability is improved.
As an alternative embodiment, the receiving the first shards of the target objects returned by the first nodes according to the object identifier sets, and the obtaining the shard set of the target objects includes:
s11, in a case that the received number of first fragments of the first target object is greater than or equal to the target number threshold, determining that the fragment set of the first target object has been received, wherein the first target object is one of the plurality of target objects.
In order to improve the recovery efficiency of the object, for a target object, the second node may determine that the shard set of the target object has been acquired when the number of received first shards of the target object is sufficient to recover a second shard of the target object. For the first fragment of the target object received later, it may also be attributed to the set of fragments of the target object.
For the first target object, if the number of received first shards of the first target object is greater than or equal to the target number threshold, the second node may determine that the shard set of the first target object has been received. The target number threshold may be the number of the data fragments into which the first target object is divided, or may be greater than the number of the data fragments into which the first target object is divided and less than or equal to the total number of the data fragments and the check fragments corresponding to the first target object.
For example, an object may correspond to 6(4+2) shards, and if 4 shards of the object have been received from the source node, the 4 shards may be able to recover the shards needed for the object, and the set of objects that received the object may be determined.
By the embodiment, the target recovery is controlled by configuring the target quantity threshold, so that the efficiency of the target recovery can be improved, the recovery time is shortened, and the influence of the target recovery on the read-write quality of the whole service is reduced.
As an alternative embodiment, performing erasure recovery on each target object by using the shard set of each target object, and obtaining the second shard of each target object includes:
s21, performing erasure recovery on the second target object by using the fragment set of the second target object through a target thread in the multiple threads to obtain a candidate fragment of the second target object, wherein the second target object is a target object which has received the corresponding fragment set, and the multiple threads are used for performing parallel erasure recovery on the target object which has received the corresponding fragment set;
s22, verifying the second target object according to the fragment set of the second target object and the candidate fragments of the second target object;
s23, if the second target object passes the verification, determining the candidate segment of the second target object as the second segment of the second target object.
The erasure correcting recovery process of different target objects can be executed in series, and after one target object completes the erasure correcting recovery process or the erasure correcting recovery and verification process, the erasure correcting recovery process or the erasure correcting recovery and verification process of the next target object is performed. For example, one thread may be responsible for data recovery and data checking of each target object.
In order to improve the utilization rate of system resources, a thread pool can be added on the second node and is specially responsible for data recovery and data check. The thread pool may include a plurality of threads, and the plurality of threads may be configured to perform parallel erasure recovery and data checking on the target object that has received the corresponding shard set. For any one of the multiple threads, after erasure recovery and data verification of one target object are completed, if a target object of the corresponding fragmentation set is received, erasure recovery and data verification can be continuously performed on the target object.
The second target object is a target object which has received the corresponding fragment set, and the target thread in the multiple threads may use the fragment set of the second target object to perform erasure recovery on the second target object, so as to recover a candidate fragment of the second target object, where the candidate fragment of the second target object is a candidate fragment of the second target object.
The target thread may also be used to perform steps of data checking. The target thread may verify the second target object based on the set of shards for the second target object and the candidate shards for the second target object. For example, the second target object is determined according to the fragment set of the second target object and the candidate fragments of the second target object, and a check value corresponding to the second target object is calculated. If the calculated check value is consistent with the target check value (which may be from the first data slice of the second target object), it is determined that the second target object passes the check, and the candidate slice of the second target object is determined as the second slice of the second target object.
Otherwise, if the second target object fails to be verified, the candidate fragment of the second target object may be obtained again in the manner similar to the foregoing type and verification may be performed until the verification passes, so as to obtain the second fragment of the second target object.
By the embodiment, the data recovery and the data verification are performed in parallel through the multiple threads, so that the utilization rate of system resources can be improved, and the resource waste is reduced.
As an alternative embodiment, after performing erasure recovery on each target object by using the shard set of each target object to obtain a second shard of each target object, the method further includes:
and S31, sequentially writing the second fragments of the target objects into the disk of the second node according to a target writing sequence, wherein the target writing sequence is the sequence of the target objects in the target erasure correcting block.
After obtaining the second fragments of each target object, the second fragments may be written into the disk of the target second node, for example, into a spatial region in the disk of the target second node where the target erasure correcting block is located. In order to ensure the accuracy of data writing, the second fragments of the respective target objects may be sequentially written into the disk of the second node according to the order of (the second fragments of) the plurality of target objects in the target erasure correction block, that is, the target writing order.
For example, the erasure block to be recovered stores fragment data of three objects, and the order of the three objects is: object 1, object 2, and object 3, then, when writing the fragment data, it is necessary to write the fragment data of object 1 first, then write the fragment data of object 2, and finally write the fragment data of object 3.
It should be noted that the second slice of the recovery target object and the second slice of the write target object may be executed in parallel, that is, if there is a second slice of a target object satisfying the write condition, the second slice of the target object may be written to the disk without waiting until all the second slices of the target object are recovered and then executing the write process.
By the embodiment, the second fragment data of each target object is written in sequence according to the sequence of the target objects in the target erasure correcting block, so that the accuracy of data writing can be improved.
As an alternative embodiment, sequentially writing the second fragments of the target objects into the disk of the second node according to the target writing order includes:
s41, determining an object identifier of a third target object according to the target writing sequence, wherein the third target object is a target object to be written currently, and second fragments of the target object with the writing sequence before the third target object are written into a disk of a second node;
s42, searching a target mapping table by taking the object identifier of the third target object as a key, wherein the target mapping table is used for storing the second fragments of each target object by taking the object identifier of each target object as a key and the second fragments of each target object as values;
s43, writing the second fragment of the third target object into the disk of the second node when the second fragment of the third target object is found from the target mapping table.
In order to ensure that the second fragments of the target objects are written into the disk of the second node according to the target writing order, after all or part of the second fragments of the target objects are recovered, the recovered second fragments of the target objects may be traversed, and the second fragments of the target objects may be written into the disk of the second node according to the target writing order.
Optionally, in this embodiment, the second fragment of the restored target object may be stored by a target data structure, and the target data structure may store the corresponding second fragment of the target object according to the object identifier, so that it may be determined whether the fragment data of the target object to be written currently is restored by searching the data structure. The target data structure may have a variety of forms, e.g., a mapping table, an array, etc.
In the target write order, the second node may determine an object identifier corresponding to a target object (i.e., a third target object) to be currently written into the second tile. According to the target writing sequence, the second fragments of the target objects before the third target object are written into the disk of the second node.
The second node may look up the target data structure according to the object identification of the third target object and determine whether the second fragment of the third target object has been restored. If the second fragment of the third target object is found, the second fragment of the third target object may be written to the disk of the second node. If the second fragment of the third target object is not found, the target data structure may be found again at target time intervals according to the object identifier of the third target object until the second fragment of the third target object is found.
As an alternative implementation, the target data structure may be: a target mapping table. The mapping table is a data structure that stores data in a key-value manner, and in the target mapping table, second slices of respective target objects are stored with object identifications of the target objects as keys and second slices of the target objects as values. If the second fragment of a target object is recovered and put into the target mapping table, the second fragment of the target object can be found by taking the object identifier of the target object as a keyword; otherwise, the second fragment of the target object cannot be searched by taking the object identifier of the target object as the keyword.
For the third target object, the second node may look up the target mapping table with the object identifier of the third target object as a key. If the second fragment of the third target object is found from the target mapping table, the second node may write the second fragment of the third target object into a disk of the second node.
For example, to ensure that the objects are restored in order, the destination node may add the object number to the map and restore writing to the disk in the order of the objects.
As an alternative implementation, the target data structure may be: a target array. The arrays are written and read with the subscripts. In the target array, the second slice of the target object is stored at a position that is indexed by the object identification of the target object (or the hash value of the object identification of the target object). If the second fragment of a target object is recovered and stored in the target array, the second fragment of the target object can be found at the position in the target array with the object identifier of the target object (or the hash value of the object identifier of the target object) as the subscript; otherwise, the second fragment of the target object cannot be found at the position in the target array with the object identifier of the target object (or the hash value of the object identifier of the target object) as the subscript.
For a third target object, the second node may search for a target position in the target array with the object identifier of the third target object (or the hash value of the object identifier of the third target object) as a subscript; if the second fragment of the third target object is found at the target location, the second node may write the second fragment of the third target object to a disk of the second node.
By the embodiment, the second fragment of the target object is stored by using the data structure which can store the corresponding second fragment of the target object according to the object identifier, so that the objects can be ensured to be restored in sequence, and meanwhile, the search operation during data writing can be simplified.
As an alternative embodiment, sequentially writing the second fragments of the target objects into the disk of the second node according to the target writing order further includes:
s51, after searching the target mapping table by using the object identifier of the third target object as the key word, under the condition that the second fragment of the third target object is not searched in the target mapping table, searching the target mapping table again by using the object identifier of the third target object as the key word at target time intervals until the second fragment of the third target object is searched;
s52, writing the second fragment of the third target object into the disk of the second node.
If the second segment of the third target object is not found from the target mapping table, the target mapping table may be periodically searched (or in another manner, for example, triggered by a target event, the target event may be a condition that data is stored in the target mapping table) with the object identifier of the third target object as a key until the second segment of the third target object is found.
The second node may search the target mapping table once again with the object identifier of the third target object as the key at intervals of the target time interval, if the target mapping table is found, write the second fragment of the third target object into the disk of the second node, otherwise, search the target mapping table once again with the object identifier of the third target object as the key at intervals of the target time interval until the second fragment of the third target object is found.
According to the embodiment, the second fragment data of the target object to be written at present is written into the disk by periodically searching the target mapping table, so that the accuracy and timeliness of data writing can be ensured.
It should be noted that, if the second node can know the write position of the second partition of each target object in the disk through configuration information (for example, the head address of the target erasure correction block, the offset of the head address of the second partition of each target object with respect to the head address of the target erasure correction block, and the like), the recovered second partition of the target object may be directly written to the corresponding position in the disk of the second node according to the recovery order of the second partition of each target object.
For example, after obtaining the second fragment of the fourth target object, the second node may determine a writing position of the second fragment of the fourth target object in the disk of the second node, and write the second fragment of the fourth target object in the disk of the second node according to the determined writing position.
Determining a writing position of the second fragment of the fourth target object in the disk of the second node may include: and determining the writing position of the second fragment of the fourth target object in the disk of the second node according to the target head address and the offset of the head address of the second fragment of the fourth target object relative to the target head address, wherein the target head address is the head address of the target erasure correcting block in the disk of the second node.
According to another aspect of the embodiment of the application, a method for recovering an object is also provided. Optionally, in this embodiment, the object recovery method may be applied to a distributed storage system including a plurality of data nodes (e.g., a database server) as shown in fig. 1, which has already been described and is not described herein again.
Taking the first node 102 as an example to execute the object recovery method in this embodiment, fig. 3 is a schematic flowchart of another optional object recovery method according to this embodiment, and as shown in fig. 3, the flowchart of the method may include the following steps:
step S302, an object identifier set sent by a second node is received by a first node, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure correcting block of the second node, and the plurality of object identifiers are in one-to-one correspondence with the plurality of target objects.
The object recovery method in this embodiment may be applied to a distributed storage system that includes a plurality of data nodes and uses an object as a data storage unit, for example, may be applied to process an object identifier set sent by a second node in the foregoing embodiments.
The first node may receive the aforementioned object identifier set sent by the second node, for example, the first node may receive a target request message sent by the second node, and extract the object identifier set from the target request message. In the foregoing embodiment, the first node, the second node, the object identifier set, and the target request message have been explained, and details are not described herein.
Step S304, acquiring first fragments of each target object according to the object identification set, wherein the first fragments of each target object are fragments of each target object stored on a first node;
after receiving the object identifier sets, the first node may obtain the first fragments of the respective target objects, respectively. The first node may read the fragment data corresponding to each object identifier from the disk according to an order of the plurality of object identifiers (corresponding to the target writing order), thereby obtaining a first fragment of each target object. The process of obtaining the first fragment of different target objects may be executed serially or in parallel, which is not limited in this embodiment.
Step S306, sending the first fragment of each target object to the second node to recover the second fragment of each target object on the second node, where the second fragment of each target object is a fragment of each target object in the target erasure block.
After obtaining the first fragment of a target object, the first node may send the obtained first fragment of the target object to the second node. The first fragment of each target object may be sent in real time, that is, the first fragment of the acquired target object is sent to the second node, regardless of whether the first fragments of other target objects are acquired.
Through the steps S302 to S306, receiving, by the first node, an object identifier set sent by the second node, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure correcting block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one; acquiring first fragments of each target object according to the object identification set, wherein the first fragments of each target object are fragments of each target object stored on a first node; the first fragments of the target objects are sent to the second node, so that the second fragments of the target objects are recovered on the second node, wherein the second fragments of the target objects are fragments of the target objects in the target erasure correction block, the problem that the service availability is reduced in the recovery period due to the fact that the recovery flow time is too long in a method for recovering the objects in the erasure correction block in the related art is solved, the recovery flow time of the erasure correction block is shortened, and the service availability is improved.
As an alternative embodiment, the obtaining the first fragment of each target object according to the object identifier set includes:
s61, sequentially adding a plurality of object identifiers in the object identifier set into the object reading queue according to an object writing sequence, wherein the object writing sequence is the sequence of a plurality of object objects in the object erasure correcting block;
s62, sequentially acquiring an object identifier from the target reading queue to obtain a first object identifier, wherein the first object identifier is used for identifying a first object in a plurality of target objects;
and S63, reading data according to the first object identifier to obtain a first fragment of the first object.
In order to improve the convenience of acquiring the first fragment of the target object, a plurality of object identifiers in the object identifier set can be saved in a queue manner. The first node may sequentially add the plurality of object identifiers in the object identifier set to the target read queue according to the target write order, that is, sequentially add the corresponding object identifiers to the target read queue according to the order of the plurality of target objects in the target erasure correcting block.
If the target read queue is a first-in first-out queue, the object identifier corresponding to the first written target object may be added to the target read queue first, and the object identifier corresponding to the later written target object may be added to the target read queue later, so as to ensure that the order of adding the object identifiers is consistent with the order of the target objects (second fragments of the target objects) in the target erasure block.
The first node may sequentially obtain an object identifier from the target read queue to obtain a first object identifier, where the first object identifier is used to identify a first object in the multiple target objects. The first object may perform data reading according to the first object identifier, and read fragmentation data corresponding to the first object identifier from a disk of the first node, thereby obtaining a first fragment of the first object.
Through this embodiment, a plurality of object identifications are saved through the mode of reading the queue to reading the object identification in proper order from reading the list and carrying out data reading, can improve the orderliness of data reading, and then guarantee the rationality of data recovery.
As an alternative embodiment, the obtaining the first fragment of each target object according to the object identifier set includes:
s71, when the first fragment of the second object identified by the second object identification is sent to the second node, the next object identification of the second object identification is obtained from the object identification set, and a third object identification is obtained, wherein the second object identification is one of the plurality of object identifications;
and S72, reading data according to the third object identifier to obtain a first fragment of a third object, wherein the third object is the target object identified by the third object identifier.
When the first fragment of each target object is obtained, the last read data result can be recovered while the data is read, so that reading and sending are concurrent.
After obtaining the first fragment of the second object identified by the second object identifier, the first node may send the first fragment of the second object to the second node, and obtain a next object identifier of the second object identifier from the object identifier set, for example, read and write an object identifier from the target message queue to obtain a third object identifier.
After the third object identifier is obtained, the first node may continue to read data according to the third object identifier to obtain the first fragment of the third object, and the reading process is similar to the foregoing process, which is not described herein again.
By the embodiment, the data reading and sending are performed concurrently by recovering the last read data result while reading the data, so that the utilization rate of system resources can be improved, and the recovery time of the erasure correction block can be shortened.
The following explains a method of restoring an object in the embodiment of the present application with an optional example. In this example, the first node is a source node (source server), the second node is a destination node (destination server), and the object identifier is an object number.
The object recovery method in this example is to overcome the situation that multiple sub-processes cannot be executed concurrently when recovering erasure correction blocks of data nodes in a distributed storage system, and can implement concurrence of disk reading and reply message sending on a recovered source node; and realizing multithread concurrency of data recovery and data verification at the recovered destination node. And by means of the flow concurrence of the recovered source node and the target node, system resources are fully utilized, and the recovery speed is improved.
As shown in fig. 4, the flow of the object recovery method in this alternative example may include the following steps:
step S402, the target node responsible for restoring sends all the object numbers needing to be restored to the source node needing to be read.
When the check block needs to be restored, the destination node responsible for restoration may send all object numbers in the check block that need to be restored to the source node server that needs to be read through the read message.
Step S404, the source node puts all the object numbers to be restored into a reading queue, sequentially reads the data, and sends the object numbers back one by one through reply messages.
For a source node, after receiving a read message, all object numbers to be restored can be put into a read queue, and the object numbers are sequentially obtained from the read queue, and the fragment data corresponding to the object numbers are read and sent back to a destination node through a reply message. At the source node, the reading of the next object can be continued while the reply message is sent, and the reading and the sending are concurrent.
Step S406, when the destination node receives the reply message, the fragmented data carried in the reply message is used to perform object recovery, so as to recover the check block that needs to be recovered on the destination node.
For each object, the destination node may receive the reply message sent by each source node, read the fragmented data in the reply message, and encapsulate the information to be restored and the check into a context when the number of successfully read fragments is enough to complete restoring the object, where the check may be a target check value in the first data fragment.
In order to perform object recovery, the destination node may add a thread pool specially responsible for data recovery and data verification at startup, to receive the encapsulated context, and perform data recovery and data verification of the object using the encapsulated context.
The destination node can add the object number into the map in a serialization mode, and the objects are ensured to be restored according to the sequence without disorder under the condition of concurrence. The destination node may add the object number to the map, and write the restored object data (fragment data) into the map according to the object number, that is, the map stores the object data in a key-value manner, the key is the object number, the corresponding value is the restored object data, and the disk is written according to the order of the object numbers when the disk is restored.
By the example, the target node sends all the object numbers which need to be recovered to the source node together, and the source node returns the last reading result while reading the data, so that reading and sending are concurrent; the target node performs data recovery and data verification through multiple threads, and a map structure is used for ensuring that the objects perform data downloading in sequence, so that when the target node performs data verification, the source node simultaneously reads data, and the source node synchronously performs data transmission back of the previous object while reading the data; and then data reading, sending, recovering and checking are carried out simultaneously, the utilization rate of resources is improved, and the recovery time of the erasure correction block is shortened.
It should be noted that, for simplicity of description, the above-mentioned method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present application is not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
Through the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but the former is a better implementation mode in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which is stored in a storage medium (e.g., a ROM (Read-Only Memory)/RAM (Random Access Memory), a magnetic disk, an optical disk) and includes several instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the methods according to the embodiments of the present application.
According to still another aspect of the embodiments of the present application, there is also provided an object recovery apparatus for implementing the object recovery method. Fig. 5 is a block diagram illustrating a structure of an apparatus for restoring an optional object according to an embodiment of the present application, and as shown in fig. 5, the apparatus may include:
(1) a first sending unit 502, configured to send an object identifier set to each of the plurality of first nodes, where the object identifier set includes a plurality of object identifiers used to identify a plurality of target objects to be recovered in a target erasure correcting block of the second node, and the plurality of object identifiers are in one-to-one correspondence with the plurality of target objects;
(2) a first receiving unit 504, connected to the first sending unit 502, configured to receive the first fragments of each target object returned by each first node according to the object identifier set, to obtain a fragment set of each target object, where the first fragments of each target object are fragments of each target object stored on each first node;
(3) a recovering unit 506, connected to the first receiving unit 504, configured to perform erasure recovery on each target object by using the shard set of each target object to obtain a second shard of each target object, where the second shard of each target object is a shard of each target object in the target erasure block.
It should be noted that the first sending unit 502 in this embodiment may be configured to execute the step S202, the first receiving unit 504 in this embodiment may be configured to execute the step S204, and the recovering unit 506 in this embodiment may be configured to execute the step S206.
Respectively sending an object identification set to a plurality of first nodes through the module, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects; receiving first fragments of each target object returned by each first node according to the object identification set to obtain a fragment set of each target object, wherein the first fragments of each target object are fragments of each target object stored on each first node; and performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block, so that the problem that the availability of service is reduced during recovery due to overlong recovery process time in a method for recovering the object in the erasure correction block in the related art is solved, the recovery process time of the erasure correction block is shortened, and the service availability is improved.
As an alternative embodiment, the first receiving unit 504 includes:
the determining module is configured to determine that the shard set of the first target object is received when the number of received first shards of the first target object is greater than or equal to a target number threshold, where the first target object is one of the plurality of target objects.
As an alternative embodiment, the restoring unit 506 includes:
the recovery module is used for performing erasure recovery on a second target object by using a fragment set of the second target object through a target thread in a plurality of threads to obtain a candidate fragment of the second target object, wherein the second target object is a target object which has received a corresponding fragment set, and the plurality of threads are used for performing parallel erasure recovery on the target object which has received the corresponding fragment set;
the verification module is used for verifying the second target object according to the fragment set of the second target object and the candidate fragments of the second target object;
and the first determining module is used for determining the candidate fragment of the second target object as the second fragment of the second target object under the condition that the second target object passes the verification.
As an alternative embodiment, the apparatus further comprises:
and the writing unit is used for sequentially writing the second fragments of the target objects into a disk of a second node according to a target writing sequence after the erasure recovery is performed on the target objects by using the fragment sets of the target objects to obtain the second fragments of the target objects, wherein the target writing sequence is the sequence of the target erasure correcting blocks of the target objects.
As an alternative embodiment, the writing unit includes:
a second determining module, configured to determine an object identifier of a third target object according to a target writing order, where the third target object is a target object to be currently written, and second fragments of the target object whose writing order is located before the third target object are all written into a disk of a second node;
the first searching module is used for searching a target mapping table by taking the object identifier of the third target object as a key word, wherein the target mapping table is used for storing the second fragments of each target object by taking the object identifier of each target object as the key word and the second fragments of each target object as values;
and the first writing module is used for writing the second fragment of the third target object into the disk of the second node under the condition that the second fragment of the third target object is found from the target mapping table.
As an alternative embodiment, the writing unit further comprises:
the second searching module is used for searching the target mapping table once again by taking the object identifier of the third target object as the key word at target time intervals under the condition that the second fragment of the third target object is not searched in the target mapping table after the object identifier of the third target object is taken as the key word to search the target mapping table until the second fragment of the third target object is searched;
and the second writing module is used for writing the second fragment of the third target object into the disk of the second node.
According to still another aspect of the embodiments of the present application, there is also provided an object recovery apparatus for implementing the object recovery method. Fig. 6 is a block diagram illustrating a structure of an apparatus for restoring an optional object according to an embodiment of the present application, where as shown in fig. 6, the apparatus may include:
(1) a second receiving unit 602, configured to receive, by a first node, an object identifier set sent by a second node, where the object identifier set includes multiple object identifiers used for identifying multiple target objects to be recovered in a target erasure block of the second node, and the multiple object identifiers are in one-to-one correspondence with the multiple target objects;
(2) an obtaining unit 604, connected to the second receiving unit 602, configured to obtain, according to the object identifier set, a first fragment of each target object, where the first fragment of each target object is a fragment of each target object stored on the first node;
(3) a second sending unit 606, connected to the obtaining unit 604, configured to send the first fragment of each target object to a second node, so as to recover, at the second node, a second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure block.
It should be noted that the second receiving unit 602 in this embodiment may be configured to execute the step S302, the obtaining unit 604 in this embodiment may be configured to execute the step S304, and the second sending unit 606 in this embodiment may be configured to execute the step S306.
Receiving, by the first node, an object identifier set sent by a second node, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one; acquiring first fragments of each target object according to the object identification set, wherein the first fragments of each target object are fragments of each target object stored on a first node; the first fragments of the target objects are sent to the second node, so that the second fragments of the target objects are recovered on the second node, wherein the second fragments of the target objects are fragments of the target objects in the target erasure correction block, the problem that the service availability is reduced in the recovery period due to the fact that the recovery flow time is too long in a method for recovering the objects in the erasure correction block in the related art is solved, the recovery flow time of the erasure correction block is shortened, and the service availability is improved.
As an alternative embodiment, the obtaining unit 604 includes:
the adding module is used for sequentially adding a plurality of object identifiers in the object identifier set into the target reading queue according to a target writing sequence, wherein the target writing sequence is the sequence of the plurality of target objects in the target erasure correcting block;
the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for sequentially acquiring an object identifier from a target reading queue to obtain a first object identifier, and the first object identifier is used for identifying a first object in a plurality of target objects;
and the first reading module is used for reading data according to the first object identifier to obtain a first fragment of the first object.
As an alternative embodiment, the obtaining unit 604 includes:
a second obtaining module, configured to obtain a next object identifier of the second object identifier from the object identifier set while sending the first fragment of the second object identified by the second object identifier to the second node, to obtain a third object identifier, where the second object identifier is one of the object identifiers;
and the second reading module is used for reading data according to the third object identifier to obtain a first fragment of the third object, wherein the third object is a target object identified by the third object identifier.
It should be noted here that the modules described above are the same as the examples and application scenarios implemented by the corresponding steps, but are not limited to the disclosure of the above embodiments. It should be noted that the modules described above as a part of the apparatus may be operated in a hardware environment as shown in fig. 1, and may be implemented by software, or may be implemented by hardware, where the hardware environment includes a network environment.
According to still another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the method for restoring an object, where the electronic device may be a server, a terminal, or a combination thereof.
Fig. 7 is a block diagram of an alternative electronic device according to an embodiment of the present application, as shown in fig. 7, including a processor 702, a communication interface 704, a memory 706 and a communication bus 708, where the processor 702, the communication interface 704 and the memory 706 communicate with each other via the communication bus 708, where,
a memory 706 for storing computer programs;
the processor 702, when executing the computer program stored in the memory 706, performs the following steps:
s1, sending an object identifier set to each of the first nodes, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one.
And S2, receiving the first fragments of the target objects returned by the first nodes according to the object identification sets to obtain fragment sets of the target objects, wherein the first fragments of the target objects are fragments of the target objects stored on the first nodes.
And S3, performing erasure correction recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
Optionally, the processor 702, when executing the computer program stored in the memory 706, implements the following steps:
s1, receiving an object identification set sent by a second node through a first node, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure correcting block of the second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects;
s2, acquiring first fragments of each target object according to the object identification set, wherein the first fragments of each target object are fragments of each target object stored on a first node;
and S3, sending the first fragment of each target object to the second node to recover the second fragment of each target object on the second node, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
Alternatively, in this embodiment, the communication bus may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 7, but this is not intended to represent only one bus or type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The memory may include RAM, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory. Alternatively, the memory may be at least one memory device located remotely from the processor.
As an example, the memory 706 may include, but is not limited to, a first sending unit 502, a first receiving unit 504, and a restoring unit 506 in the restoring apparatus including the object. In addition, other module units in the object recovery apparatus may also be included, but are not limited to these, and are not described in detail in this example.
As another example, the memory 706 may include, but is not limited to, the second receiving unit 602, the obtaining unit 604, and the second sending unit 606 in the recovery apparatus including the object. In addition, other module units in the object recovery apparatus may also be included, but are not limited to these, and are not described in detail in this example.
The processor may be a general-purpose processor, and may include but is not limited to: a CPU (Central Processing Unit), an NP (Network Processor), and the like; but also a DSP (Digital Signal Processing), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
Optionally, the specific examples in this embodiment may refer to the examples described in the above embodiments, and this embodiment is not described herein again.
It can be understood by those skilled in the art that the structure shown in fig. 7 is only an illustration, and the device implementing the object recovery method may be a terminal device (the terminal device may be used as a data ground in a distributed storage system), and the terminal device may be a terminal device such as a smart phone (e.g., an Android phone, an iOS phone, etc.), a tablet computer, a palm computer, a Mobile Internet Device (MID), a PAD, etc. Fig. 7 does not limit the structure of the electronic device. For example, the electronic device may also include more or fewer components (e.g., network interfaces, display devices, etc.) than shown in FIG. 7, or have a different configuration than shown in FIG. 7.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by a program instructing hardware associated with the terminal device, where the program may be stored in a computer-readable storage medium, and the storage medium may include: flash disk, ROM, RAM, magnetic or optical disk, and the like.
According to still another aspect of an embodiment of the present application, there is also provided a storage medium. Optionally, in this embodiment, the storage medium may be configured to execute a program code of a recovery method for an object in any one of the embodiments of the present application.
Optionally, in this embodiment, the storage medium may be located on at least one of a plurality of network devices in a network shown in the above embodiment.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
s1, sending an object identifier set to each of the first nodes, where the object identifier set includes a plurality of object identifiers for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one.
And S2, receiving the first fragments of the target objects returned by the first nodes according to the object identification sets to obtain fragment sets of the target objects, wherein the first fragments of the target objects are fragments of the target objects stored on the first nodes.
And S3, performing erasure correction recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
Optionally, in this embodiment, the storage medium is configured to store program code for performing the following steps:
s1, receiving an object identification set sent by a second node through a first node, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure correcting block of the second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects;
s2, acquiring first fragments of each target object according to the object identification set, wherein the first fragments of each target object are fragments of each target object stored on a first node;
and S3, sending the first fragment of each target object to the second node to recover the second fragment of each target object on the second node, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
Optionally, the specific example in this embodiment may refer to the example described in the above embodiment, which is not described again in this embodiment.
Optionally, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing program codes, such as a U disk, a ROM, a RAM, a removable hard disk, a magnetic disk, or an optical disk.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
The integrated unit in the above embodiments, if implemented in the form of a software functional unit and sold or used as a separate product, may be stored in the above computer-readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or a part of or all or part of the technical solution contributing to the prior art may be embodied in the form of a software product stored in a storage medium, and including instructions for causing one or more computer devices (which may be personal computers, servers, network devices, or the like) to execute all or part of the steps of the method described in the embodiments of the present application.
In the above embodiments of the present application, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the several embodiments provided in the present application, it should be understood that the disclosed client may be implemented in other manners. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, and may also be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The foregoing is only a preferred embodiment of the present application and it should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present application, and these improvements and modifications should also be considered as the protection scope of the present application.

Claims (13)

1. A method for restoring an object, comprising:
respectively sending an object identification set to a plurality of first nodes, wherein the object identification set comprises a plurality of object identifications used for identifying a plurality of target objects to be recovered in a target erasure block of a second node, and the plurality of object identifications are in one-to-one correspondence with the plurality of target objects;
receiving first fragments of the target objects returned by the first nodes according to the object identification set to obtain fragment sets of the target objects, wherein the first fragments of the target objects are fragments of the target objects stored on the first nodes;
and performing erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, wherein the second fragment of each target object is a fragment of each target object in the target erasure correction block.
2. The method of claim 1, wherein receiving the first shard of each target object returned by each first node according to the object identification set, and obtaining the shard set of each target object comprises:
determining that a shard set of a first target object has been received in the case that the number of received first shards of the first target object is greater than or equal to a target number threshold, wherein the first target object is one of the plurality of target objects.
3. The method of claim 1, wherein performing erasure recovery on each of the target objects using the shard set of each of the target objects to obtain a second shard for each of the target objects comprises:
performing erasure recovery on a second target object by using a fragment set of the second target object through a target thread in a plurality of threads to obtain a candidate fragment of the second target object, wherein the second target object is one target object which has received a corresponding fragment set, and the plurality of threads are used for performing parallel erasure recovery on the target object which has received the corresponding fragment set;
checking the second target object according to the fragment set of the second target object and the candidate fragments of the second target object;
and under the condition that the second target object passes the verification, determining the candidate fragment of the second target object as the second fragment of the second target object.
4. The method according to any one of claims 1 to 3, wherein after performing erasure recovery on each target object using the shard set of each target object to obtain a second shard of each target object, the method further comprises:
and sequentially writing the second fragments of the target objects into the disk of the second node according to a target writing sequence, wherein the target writing sequence is the sequence of the target objects in the target erasure correcting block.
5. The method of claim 4, wherein sequentially writing the second fragments of each of the target objects to the disk of the second node in the target writing order comprises:
determining an object identifier of a third target object according to the target writing sequence, wherein the third target object is the target object to be written currently, and second fragments of the target object with the writing sequence being before the third target object are written into a disk of the second node;
searching a target mapping table by taking the object identifier of the third target object as a key word, wherein the target mapping table is used for storing the second fragment of each target object by taking the object identifier of each target object as a key word and taking the second fragment of each target object as a value;
and writing the second fragment of the third target object into the disk of the second node under the condition that the second fragment of the third target object is found from the target mapping table.
6. The method of claim 5, wherein sequentially writing the second fragments of each of the target objects to the disk of the second node in the target writing order further comprises:
after the target mapping table is searched by taking the object identifier of the third target object as a key word, under the condition that a second fragment of the third target object is not searched in the target mapping table, the target mapping table is searched again by taking the object identifier of the third target object as a key word at target time intervals until the second fragment of the third target object is searched;
and writing the second fragment of the third target object into the disk of the second node.
7. A method for restoring an object, comprising:
receiving an object identifier set sent by a second node through a first node, wherein the object identifier set comprises a plurality of object identifiers used for identifying a plurality of target objects to be recovered in a target erasure block of the second node, and the plurality of object identifiers correspond to the plurality of target objects one to one;
acquiring first fragments of the target objects according to the object identification set, wherein the first fragments of the target objects are fragments of the target objects stored on the first node;
and sending the first fragment of each target object to the second node to recover the second fragment of each target object on the second node, wherein the second fragment of each target object is the fragment of each target object in the target erasure correction block.
8. The method of claim 7, wherein obtaining the first fragment of each of the target objects according to the set of object identifiers comprises:
sequentially adding the object identifiers in the object identifier set to a target reading queue according to a target writing sequence, wherein the target writing sequence is the sequence of the target objects in the target erasure correcting block;
sequentially acquiring one object identifier from the target reading queue to obtain a first object identifier, wherein the first object identifier is used for identifying a first object in a plurality of target objects;
and reading data according to the first object identifier to obtain a first fragment of the first object.
9. The method according to claim 7 or 8, wherein obtaining the first fragment of each of the target objects according to the set of object identifiers comprises:
when the first fragment of the second object identified by the second object identifier is sent to the second node, acquiring a next object identifier of the second object identifier from the object identifier set to obtain a third object identifier, wherein the second object identifier is one of the plurality of object identifiers;
and reading data according to the third object identifier to obtain a first fragment of a third object, wherein the third object is the target object identified by the third object identifier.
10. An apparatus for restoring an object, comprising:
a first sending unit, configured to send an object identifier set to each of a plurality of first nodes, where the object identifier set includes a plurality of object identifiers used to identify a plurality of target objects to be recovered in a target erasure correcting block of a second node, and the plurality of object identifiers are in one-to-one correspondence with the plurality of target objects;
a first receiving unit, configured to receive a first fragment of each target object returned by each first node according to the object identifier set, to obtain a fragment set of each target object, where the first fragment of each target object is a fragment of each target object stored on each first node;
and the recovery unit is configured to perform erasure recovery on each target object by using the fragment set of each target object to obtain a second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure correction block.
11. An apparatus for restoring an object, comprising:
a second receiving unit, configured to receive, by a first node, an object identifier set sent by a second node, where the object identifier set includes multiple object identifiers used to identify multiple target objects to be recovered in a target erasure block of the second node, and the multiple object identifiers are in one-to-one correspondence with the multiple target objects;
an obtaining unit, configured to obtain, according to the object identifier set, a first fragment of each target object, where the first fragment of each target object is a fragment of each target object stored on the first node;
a second sending unit, configured to send the first fragment of each target object to the second node, so as to recover, at the second node, the second fragment of each target object, where the second fragment of each target object is a fragment of each target object in the target erasure block.
12. An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein said processor, said communication interface and said memory communicate with each other via said communication bus,
the memory for storing a computer program;
the processor configured to perform the method steps of any one of claims 1 to 6, or to perform the method steps of any one of claims 7 to 9, by running the computer program stored on the memory.
13. A computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to carry out the method steps of any of claims 1 to 6 or the method steps of any of claims 7 to 9 when executed.
CN202110192139.0A 2021-02-19 2021-02-19 Object recovery method and device, electronic equipment and storage medium Pending CN112860488A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110192139.0A CN112860488A (en) 2021-02-19 2021-02-19 Object recovery method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110192139.0A CN112860488A (en) 2021-02-19 2021-02-19 Object recovery method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112860488A true CN112860488A (en) 2021-05-28

Family

ID=75988281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110192139.0A Pending CN112860488A (en) 2021-02-19 2021-02-19 Object recovery method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112860488A (en)

Similar Documents

Publication Publication Date Title
CN107819828B (en) Data transmission method and device, computer equipment and storage medium
CN109831487B (en) Fragmented file verification method and terminal equipment
US20190347160A1 (en) Erasure code-based partial write-in
WO2018000812A1 (en) Data storage method and apparatus
US20170090824A1 (en) Layered queue based coordination of potentially destructive actions in a dispersed storage network memory
US20170285999A1 (en) Using separate read and write memory devices in a distributed storage network
WO2020151323A1 (en) Data slicing-based data storage method, device, and medium
CN111078662B (en) Block chain data storage method and device
KR101983208B1 (en) Data management method, node and system for database cluster
CN112764997B (en) Log storage method and device, computer equipment and storage medium
CN104750428A (en) Block storage access and gateway module, storage system and method, and content delivery apparatus
CN109254956B (en) Data downloading method and device and electronic equipment
CN107832227B (en) Interface parameter testing method, device, equipment and storage medium of business system
CN112988458B (en) Data backup method and device, electronic equipment and storage medium
CN111803917A (en) Resource processing method and device
CN107094085B (en) Signaling transmission method and device
CN112040015B (en) Consensus node list generation method and related device
CN105573872A (en) Hardware maintenance method and device of data storage system
CN115409507A (en) Block processing method, block processing device, computer equipment and storage medium
CN111459399A (en) Data writing method, data reading method and device
CN110765125B (en) Method and device for storing data
CN112860488A (en) Object recovery method and device, electronic equipment and storage medium
CN113312205A (en) Data verification method and device, storage medium and computer equipment
US20180113747A1 (en) Overdrive mode for distributed storage networks
CN115935414A (en) Block chain based data verification method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination