Snapshot merging method and server
By merging snapshot file groups and generating target snapshot chains, the problem of degradation in query efficiency caused by the increase in the number of snapshot files is solved, and more efficient queries are achieved.
Patent Information
- Application Number
- PCT/CN2024/126724
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-31
- Filing Date
- 2024-10-23
- Publication Date
- 2025-08-07
AI Technical Summary
In the prior art, as the number of snapshot files increases, query efficiency decreases, resulting in an increase in the number of snapshot files when reading data.
By determining the snapshot chain, dividing the snapshot file group, and merging the snapshot file group, generating the target snapshot file, establishing the target snapshot chain, and reducing the number of query snapshots.
Reduce the number of query snapshots and improve query efficiency.
Smart Images

Figure CN2024126724_07082025_PF_FP_ABST
Abstract
Description
Snapshot merging method and server
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on January 31, 2024, with application number 202410140467.X and application name “A Snapshot Merging Method and Server”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of snapshot technology, and in particular to a snapshot merging method and server. Background Art
[0003] To reduce the performance impact of snapshots on storage systems, most current distributed storage systems use the Redirect-on-Write (ROW) snapshot principle. ROW works by first performing a write operation on the source file in the distributed storage system, creating a new snapshot file at the snapshot time, and redirecting the write operation to the newly created snapshot file. Then, at the next snapshot time, another snapshot file is created and the write operation is redirected to the latest snapshot file. This process continues, ultimately ensuring that each snapshot file contains the data written during the corresponding time period.
[0004] In actual applications, snapshot files are generated at specific moments in the storage system's operation. As the storage system runs, the number of snapshot files will continue to increase. When reading data, the number of snapshots that need to be queried will also increase, resulting in reduced query efficiency.
[0005] Summary of the Invention
[0006] The embodiments of the present application provide a snapshot merging method and server, which can reduce the number of query snapshots and improve query efficiency.
[0007] In a first aspect, an embodiment of the present application provides a snapshot merging method, comprising: determining a snapshot chain; the snapshot chain includes multiple snapshot files created in sequence; determining at least one first snapshot file group to be merged, the at least one first snapshot file group containing a first number of snapshot files; merging the snapshot files in the at least one first snapshot file group to obtain at least one target snapshot file; and obtaining a target snapshot chain based on the at least one target snapshot file.
[0008] In this solution, snapshot files can be merged, which can reduce the number of query snapshots and improve query efficiency.
[0009] In one possible implementation, determining at least one first snapshot file group to be merged includes: starting with a source snapshot file, sequentially dividing multiple snapshot files in a snapshot chain according to a first quantity to obtain at least one first snapshot file group.
[0010] In one possible implementation, merging snapshot files in at least one first snapshot file group to obtain at least one target snapshot file includes: merging a first number of snapshot files in each first snapshot file group to obtain multiple first snapshot files; determining at least one second snapshot file group based on the multiple first snapshot files, each second snapshot file group including a second number of first snapshot files; and merging the second number of first snapshot files in each second snapshot file group to obtain at least one target snapshot file.
[0011] In one possible implementation, merging snapshot files in at least one first snapshot file group to obtain at least one target snapshot file includes: merging a first number of snapshot files in each first snapshot file group to obtain multiple first snapshot files; determining at least one second snapshot file group based on the multiple first snapshot files, each second snapshot file group including a second number of first snapshot files; merging the second number of first snapshot files in each second snapshot file group to obtain at least one second snapshot file; and obtaining at least one target snapshot file based on the multiple first snapshot files and the at least one second snapshot file.
[0012] In a possible implementation, the first quantity is equal to the second quantity.
[0013] In one possible implementation, obtaining a target snapshot chain based on at least one target snapshot file includes: determining an arrangement order of the at least one target snapshot file according to a creation time sequence of the snapshot files; and establishing a snapshot path from the source snapshot file to the at least one target snapshot file according to the arrangement order of the at least one target snapshot file to obtain the target snapshot chain.
[0014] In this solution, by establishing a snapshot path from a source snapshot file to a target snapshot file, the number of snapshot files to be searched is reduced, thereby improving query efficiency.
[0015] In a possible implementation, each target snapshot file includes a creation time period, the creation time period is determined according to creation times of multiple snapshot files merged to obtain the target snapshot file, and at least one target snapshot file is arranged in order of the creation time periods.
[0016] In one possible implementation, the method further includes: determining a query instruction, where the query instruction indicates a first snapshot time for starting the query, a second snapshot time for ending the query, and a data identifier; responding to the query instruction, querying the target snapshot chain according to the arrangement order of the target snapshot files to obtain data corresponding to the data identifier.
[0017] In one possible implementation, the snapshot chain is a branch in the snapshot tree; the method further includes: merging at least two snapshot chains in the snapshot tree to obtain at least two target snapshot chains; and obtaining a target snapshot tree based on each target snapshot chain, wherein the connection relationship between each target snapshot chain in the target snapshot tree remains unchanged from the connection relationship between each snapshot chain in the snapshot tree.
[0018] In a second aspect, an embodiment of the present invention provides a snapshot merging device, comprising several modules, each of which is configured to perform each step of the snapshot merging method provided in the first aspect of the embodiment of the present invention. The division of modules is not limited herein. The specific functions performed by each module of the snapshot merging device and the beneficial effects achieved are described in the respective steps of the snapshot merging method provided in the first aspect of the embodiment of the present invention, and will not be further elaborated here.
[0019] For example, the snapshot merging device includes:
[0020] A first snapshot chain determining module is used to determine a snapshot chain; the snapshot chain includes multiple snapshot files created in sequence;
[0021] A file group determining module, configured to determine at least one first snapshot file group to be merged, wherein the at least one first snapshot file group includes a first number of snapshot files;
[0022] a merging module, configured to merge snapshot files in at least one first snapshot file group to obtain at least one target snapshot file;
[0023] The second snapshot chain determining module is configured to obtain a target snapshot chain based on at least one target snapshot file.
[0024] In this solution, snapshot files can be merged, which can reduce the number of query snapshots and improve query efficiency.
[0025] In a possible implementation, the file group determining module is configured to sequentially divide the plurality of snapshot files in the snapshot chain starting with the source snapshot file and according to a first quantity as a unit to obtain at least one first snapshot file group.
[0026] In one possible implementation, the merging module is configured to merge a first number of snapshot files in each first snapshot file group to obtain a plurality of first snapshot files; determine at least one second snapshot file group based on the plurality of first snapshot files, each second snapshot file group including a second number of first snapshot files; and merge the second number of first snapshot files in each second snapshot file group to obtain at least one target snapshot file.
[0027] In one possible implementation, the merging module is configured to merge a first number of snapshot files in each first snapshot file group to obtain a plurality of first snapshot files; determine at least one second snapshot file group based on the plurality of first snapshot files, each second snapshot file group including a second number of first snapshot files; merge the second number of first snapshot files in each second snapshot file group to obtain at least one second snapshot file; and obtain at least one target snapshot file based on the plurality of first snapshot files and the at least one second snapshot file.
[0028] In a possible implementation, the first quantity is equal to the second quantity.
[0029] In one possible implementation, the second snapshot chain determination module is used to determine the arrangement order of at least one target snapshot file according to the creation time sequence of the snapshot files; and establish a snapshot path from the source snapshot file to the at least one target snapshot file according to the arrangement order of the at least one target snapshot file to obtain the target snapshot chain.
[0030] In a possible implementation, each target snapshot file includes a creation time period, the creation time period is determined according to creation times of multiple snapshot files merged to obtain the target snapshot file, and at least one target snapshot file is arranged in order of the creation time periods.
[0031] In one possible implementation, the device also includes: a query module, configured to determine a query instruction, wherein the query instruction indicates a first snapshot time for starting the query, a second snapshot time for ending the query, and a data identifier; in response to the query instruction, querying the target snapshot chain according to the arrangement order of the target snapshot files to obtain data corresponding to the data identifier.
[0032] In one possible implementation, the snapshot chain is a branch in a snapshot tree; the apparatus further includes: a snapshot tree establishment module, configured to merge at least two snapshot chains in the snapshot tree to obtain at least two target snapshot chains; and obtain a target snapshot tree based on each target snapshot chain, wherein the connection relationship between each target snapshot chain in the target snapshot tree remains unchanged from the connection relationship between each snapshot chain in the snapshot tree.
[0033] In a third aspect, an embodiment of the present application provides a server comprising: at least one memory for storing programs; and at least one processor for executing the programs stored in the memory. When the programs stored in the memory are executed, the processor is used to execute the method provided in the first aspect.
[0034] In a fourth aspect, an embodiment of the present application provides a snapshot merging device, which runs computer program instructions to execute the method provided in the first aspect. Exemplarily, the device can be a chip or a processor.
[0035] In one example, the apparatus may include a processor, which may be coupled to a memory, read instructions from the memory, and execute the method provided in the first aspect according to the instructions. The memory may be integrated into a chip or processor, or may be independent of the chip or processor.
[0036] In a fifth aspect, an embodiment of the present application provides a computer storage medium, in which instructions are stored. When the instructions are executed on a computer, the computer executes the method provided in the first aspect.
[0037] In a sixth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method provided in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] FIG1 is a schematic diagram of the structure of a server provided in an embodiment of the present application;
[0039] FIG2 is a flowchart of a snapshot merging method according to an embodiment of the present application;
[0040] FIG3 is a schematic diagram of the structure of a snapshot tree provided in an embodiment of the present application;
[0041] FIG4 is a schematic diagram of a snapshot file merging scenario provided by an embodiment of the present application;
[0042] FIG5 is a schematic diagram of a snapshot file merging scenario of a snapshot chain provided by an embodiment of the present application;
[0043] FIG6 is a second flow chart of the snapshot merging method provided in an embodiment of the present application;
[0044] FIG7 is a third flow chart of the snapshot merging method provided in an embodiment of the present application;
[0045] FIG8 is a schematic structural diagram of a snapshot merging device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described below with reference to the accompanying drawings.
[0047] In the description of the embodiments of the present application, words such as "exemplary," "for example," or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary," "for example," or "for example" in the embodiments of the present application should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary," "for example," or "for example" is intended to present the relevant concepts in a concrete manner.
[0048] In the description of the embodiments of this application, the term "and / or" is simply a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent the following three situations: A exists alone, B exists alone, and A and B exist at the same time. In addition, unless otherwise specified, the term "plurality" means two or more. For example, "multiple systems" refers to two or more systems, and "multiple terminals" refers to two or more terminals.
[0049] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly identifying the technical features being referred to. Thus, features specified as "first" or "second" may explicitly or implicitly include one or more of such features. The terms "include," "comprising," "having," and their variations all mean "including but not limited to," unless otherwise specifically emphasized.
[0050] The following is an explanation of some of the terms used in this embodiment. It should be noted that these explanations are for the purpose of facilitating understanding by those skilled in the art and are not intended to limit the scope of protection claimed by the present invention.
[0051] Snapshot: A fully usable copy of a specified data set, representing an image of the data at a specific point in time (the point in time when the copy begins). A snapshot can be a copy or a replica of the data set it represents. In storage, a data set can be a data block, file, or object; in applications, it can be an image or a web page.
[0052] Qcow2 (Qemu Copy On Write) is a storage format for virtual disk images. The Qcow2 format separates the physical storage layer from the virtual layer by adding a mapping between logical and physical blocks. Each logical block is mapped to its physical offset, so each Qcow volume represents incremental changes to the underlying disk image. This approach supports storage overscaling and virtual machine snapshots.
[0053] In the related art, when reading data, if there are a large number of snapshot files, a large number of snapshot files will be searched when reading the data, and the reading efficiency will be reduced.
[0054] Based on this, an embodiment of the present invention proposes a snapshot merging method.
[0055] This method merges incremental data stored in several previously generated snapshot files into a later snapshot file, reducing the number of snapshots required to read data and improving read efficiency. This is just a brief description of the method; see the following description for more details.
[0056] Next, a storage system to which the snapshot merging method provided in the embodiment of the present invention may be applied is described.
[0057] In an embodiment of the present application, the storage system may include at least one server 101, and the storage system is used to store data; an embodiment of the present application provides a server 101.
[0058] Exemplarily, server 101 can be a server, such as a rack server, or a computing node in a computing device, where a computing node is the smallest computing unit. Here, the computing device can be a high-density server, a blade server, or a whole cabinet server, or a general-purpose server, a GPU server, a DPU server, etc.
[0059] Exemplarily, as shown in FIG1 , the server 101 may include a power supply 121 and a mainboard 110 . The power supply 121 is electrically connected to the mainboard 110 to supply power to devices connected to the mainboard 110 .
[0060] Illustratively, the devices connected to the motherboard 110 may include a processor 111 , a memory 112 , a programmable logic device (PLD) 113 , a baseboard management controller (BMC) 114 , a PCIE slot 115 , a network card 122 , a hard disk 123 , and a fan 124 .
[0061] Among them, the processor 111 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0062] The memory 112 may be provided in a memory module that is inserted into a memory slot to connect to the motherboard 110. The memory 112 may be a random access memory (RAM). By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM). Exemplarily, the memory 112 includes at least two types of memory, for example, the memory may be either a random access memory (RAM) or a read-only memory (ROM). For example, RAM may include dynamic random access memory (DRAM) or storage class memory (SCM).
[0063] Among them, the PCIE slot 115 is suitable for expanding at least one of a GPU card, a network card, a video capture card, an HBA (Host Bus Adapter) card, a RAID (redundant arrays of independent disks) card, and an SSD (solid state disk or solid state drive), and can also support the expansion of various adapter cards.
[0064] The programmable logic device 113 may be a complex logic device (CPLD, a digital integrated circuit in which users construct logic functions according to their own needs) or a field programmable gate array (FPGA).
[0065] The hard disk 123 may be a hard disk drive (HDD) or a solid state drive (SSD). It should be understood that the hard disk 123 is merely an example of a non-volatile memory and does not constitute a specific limitation. In actual applications, a non-volatile memory may be selected based on actual circumstances.
[0066] It should be noted that FIG1 is merely an example of the server 101 and does not constitute a specific limitation. In actual applications, more or fewer devices than those in FIG1 may be included.
[0067] Next, a snapshot merging method provided by an embodiment of the present invention is described in detail. FIG2 is a flow chart of the snapshot merging method provided by an embodiment of the present application. This embodiment can be applied to a storage system, specifically to server 101. As shown in FIG2 , the snapshot merging method provided by an embodiment of the present application includes at least the following steps:
[0068] Step 201: The server 101 determines a snapshot chain; the snapshot chain includes multiple snapshot files created in sequence.
[0069] In actual applications, the server 101 determines a snapshot chain from a snapshot tree. A snapshot tree is composed of at least one snapshot chain, which can be understood as a branch of the snapshot tree. Each snapshot chain includes multiple snapshot files created in sequence. The order of the snapshot files in the snapshot chain indicates the order in which the snapshot files were created. When a snapshot tree is composed of multiple snapshot chains, one of the multiple snapshot chains (referred to as a primary snapshot chain for ease of description and distinction) is connected to other snapshot chains (referred to as secondary snapshot chains for ease of description and distinction), and the secondary snapshot chains are connected to the snapshot files in the primary snapshot chain, serving as branches of the connected snapshot files.
[0070] It should be noted that the snapshot chain includes a source snapshot file and multiple snapshot files. The source snapshot file is the earliest created snapshot file, and the multiple snapshot files are used to store the incremental data of the source snapshot file. For example, assuming that the source snapshot file is represented by Base, the snapshot file can be represented by sni, and i represents the sequential number of the snapshot file; as shown in Figure 3, there are three snapshot chains, denoted as snc1, snc2, and snc3, respectively. Snc1 is base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<- ...<-sn33, snc2 is sn1<-sn1.1<-sn1.2<-…<-sn1.10, and snc3 is sn4<-sn4.1<-sn4.2; among them, base in base<-sn1<-…<-sn33 is the source snapshot file, sn1 in sn1<-sn1.1<-sn1.2<-sn1.3<-sn1.4 is the source snapshot file, and sn4 in sn4<-sn4.1<-sn4.2 is the source snapshot file.
[0071] In a specific implementation, the snapshot tree includes a root file, and snapshot files are created sequentially based on the root file. If a branch of the snapshot file needs to be created, the snapshot file is used as the starting point and snapshot files are created sequentially, thereby forming several snapshot chains, and the snapshot files are used to store the incremental data of the root file. It should be noted that in the process of building the snapshot tree, as the number of snapshot files increases, the snapshot chain is also continuously extended. In the embodiment of the present application, the root file can be understood as a copy of the source data, and the snapshot file is used to store the incremental data of the source data, thereby saving storage space; in addition, the snapshot tree can be understood as a data protection measure that can protect the source data to a certain extent. For example, the source data can be an operating system, software or database, which can be determined in combination with the actual scenario, and the embodiment of the present application does not make specific restrictions on this. It is worth noting that when the snapshot chain starts with the root file as the starting point, the root file can be understood as the source snapshot file.
[0072] It should be noted that in the implementation of this application, a root file includes N data units, each of which represents the smallest unit of data storage, such as a data block, object, or file. A snapshot file also includes N data units. Although the root file and the snapshot file have the same number of data units, the data in the data units may be different.
[0073] In one possible way to build a snapshot chain, the root file of the source data is first used as the root node, and the first snapshot file of the root file is determined. The first snapshot file is used as the snapshot node and connected to the root node. Then, if new data needs to be written, since the new data does not exist in the root file, it is incremental data. The incremental data is written into the data unit of the first snapshot file, and so on. Snapshot files are continuously created and incremental data is written to extend the snapshot chain.
[0074] Step 202: The server 101 determines at least one first snapshot file group to be merged, where the at least one first snapshot file group includes a first number of snapshot files.
[0075] In a specific implementation, server 101 sequentially divides the plurality of snapshot files in the snapshot chain into units of a first quantity starting with the source snapshot file to obtain at least one first snapshot file group. The source snapshot file is the earliest created snapshot file in the snapshot chain, and the plurality of snapshot files in the snapshot chain are used to store incremental data relative to the source snapshot file.
[0076] For example, as shown in Figure 3, assuming that the snapshot chain is base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<-……<-sn33, base is the source snapshot file, and the first quantity is 4, then sn1~sn4 are used as the first snapshot file group; sn5~ and sn8 are used as the first snapshot file group; sn9~ and sn12 are used as the first snapshot file group; sn13~ and sn16 are used as the first snapshot file group; sn17~ and sn20 are used as the first snapshot file group; sn21~ and sn24 are used as the first snapshot file group; sn25~ and sn28 are used as the first snapshot file group; and sn29~ and sn32 are used as the first snapshot file group.
[0077] Step 203: The server 101 merges the snapshot files in at least one first snapshot file group to obtain at least one target snapshot file.
[0078] It should be noted that snapshot file merging can be understood as retaining the latest data and overwriting the old data; in specific implementation, for each data unit in the snapshot file, if the data unit does not have data in the multiple snapshot files that need to be merged, the data unit is empty; if the data unit only has data in one of the multiple snapshot files that need to be merged (for the sake of ease of description and distinction, called the target snapshot file), the data of the data unit is the data of the data unit in the target snapshot file; if the data unit has data in multiple target snapshot files among the multiple snapshot files that need to be merged, the data of the data unit is the data of the data unit in the target snapshot file created latest among the multiple target snapshot files.
[0079] For example, as shown in Figure 4, assume there is a root file volume. The root file volume consists of 10 data blocks, designated D1, D2, ..., D10. Data 1, 2, 3, and 4 are written to data blocks D3, D4, D6, and D7. A new snapshot, named snapshap1, is created, and the root file volume's data becomes read-only. New data is written to data blocks within snapshap1, and data is written to data blocks D4, D5, and D8, with data a, b, and c, respectively. A new snapshot, named snapshap2, is created, and the root file volume's data becomes read-only. New data is written to data blocks within snapshap2, with data A and B, respectively, written to data blocks D3 and D5. If snapshap1 and snapshap2 are merged, the data in D1, D2, ..., D10 becomes empty, empty, A, a, B, 3, 4, c, empty, and empty, respectively.
[0080] In an embodiment of the present application, for each target snapshot file, the target snapshot file includes multiple consecutive snapshot files on the snapshot chain; specifically, to obtain the target snapshot file, it is necessary to merge multiple consecutive snapshot files on the snapshot chain, and different snapshot files need to be merged to obtain different target snapshot files.
[0081] In some possible implementations, in step 203, the first number of snapshot files in each first snapshot file group may be merged to obtain at least one target snapshot file. The snapshot files are merged to retain the latest data. For details, see the description of snapshot file merging and FIG. 4 above, and will not be repeated here.
[0082] For example, as shown in Figure 5, assuming that the snapshot chain is base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<-……<-sn33, base is the source snapshot file, the first number is 4, then sn1~sn3 are merged into sn4 to obtain the merged file sn4 (for the convenience of description and distinction, it can be called m1*sn4). It should be noted that m1 represents the first merge and * has no special meaning. In addition, the specific manifestation of merging sn1~sn3 into sn4 is that for each data unit, the data of the data unit does not exist in sn4, and the data of the data unit exists in sn1~sn3. Unit data, write the data of the data unit in sn1~sn3 into sn4; merge sn5~ and sn7 into sn8 to obtain the merged file m1*sn8; merge sn9~ and sn11 into sn12 to obtain the merged file m1*sn12; merge sn13~ and sn15 into sn16 to obtain the merged file m1*sn16; merge sn17~ and sn19 into sn20 to obtain the merged file m1*sn20; merge sn21~ and sn23 into sn24 to obtain the merged file m1*sn24; merge sn25~ and sn27 into sn28 to obtain the merged file m1*sn28; merge sn29~ and sn31 into sn32 to obtain the merged file m1*sn32.
[0083] In some possible implementations, in step 203, a first number of snapshot files in each first snapshot file group may be merged to obtain multiple first snapshot files; at least one second snapshot file group may be determined based on the multiple first snapshot files, each second snapshot file group including a second number of first snapshot files; and the second number of first snapshot files in each second snapshot file group may be merged to obtain at least one target snapshot file. It should be noted that the second number of first snapshot files in the second snapshot file group is merged to retain the latest data. For details, see the above description of snapshot file merging and FIG. 4 , and will not be repeated here. Exemplarily, the first number and the second number may be the same. It should be noted that the first number and the second number being the same is merely an example and does not constitute a specific limitation. It should be noted that each second snapshot file is a target snapshot file, and at least some of the multiple first snapshot files are target snapshot files. For example, each first snapshot file other than the first snapshot file with the latest creation time in the second snapshot file group is a target snapshot file.
[0084] For example, as shown in Figure 5, assuming that the second number is 4, in the process of the second merge, the files m1*sn4, m1*sn8, m1*sn12, and m1*sn16 obtained after the first merge can be merged into m1*sn16 to obtain the second merged file sn16 (for the convenience of description and distinction, it can be called m2*sn16). It should be noted that m2 represents the second merge, and * has no special meaning; the files m1*sn20, m1*sn24, m1*sn28, and m1*sn32 obtained after the second merge are merged into m1*sn32 to obtain the second merged file m2*sn32. In some possible situations, m2*sn16 and m2*sn32 obtained after the second merge can be used as target snapshot files; in other possible situations, the files m1*sn4, m1*sn8, m1*sn12, m1*sn20, m1*sn24, m1*sn28 obtained after the first merge and the files m2*sn16 and m2*sn32 obtained after the second merge can be used as target snapshot files.
[0085] It is worth noting that the above two merging methods are only examples of merging. In specific implementation, the server 101 essentially merges the snapshot chain m (a positive integer greater than or equal to 1) times to determine at least one target snapshot file; for each of the m times, a snapshot file group is determined, the snapshot files in the snapshot file group are merged, and the merged file is used as the target snapshot file; in some possible scenarios, the snapshot file in the i-th snapshot file group is the snapshot file on the snapshot chain, and the number of snapshot files in the i-th snapshot file group is greater than the number of snapshot files in the i-1-th snapshot file group, for example, the snapshot file in the i-th snapshot file group is greater than the number of snapshot files in the i-1-th snapshot file group. The ratio of the number of snapshot files in the i-1 snapshot file group to the number of snapshot files in the i-1 snapshot file group is n (a positive integer greater than or equal to 2); in other possible scenarios, when i=1, the snapshot files in the i-th snapshot file group are snapshot files on the snapshot chain; when i is greater than 2, the snapshot files in the i-th snapshot file group are snapshot files merged from the i-1 snapshot file group, and the number of snapshot files in the i-th snapshot file group is the number of the i-1 snapshot file group, for example, the number of snapshot files in the i-th snapshot file group is the same as the number of the i-1 snapshot file group, for example, both are n (a positive integer greater than or equal to 2).
[0086] In some possible examples, if the length of the path formed by multiple snapshot files in the snapshot chain is X, and the snapshot files are identified by sn, then the principle of m-times partitioning and merging is as follows:
[0087] The first division method is to merge in units of n (greater than or equal to 2) sn, sn1 to sn(n) as a snapshot file group to merge snapshot files, for example, merge sn1 to sn(n-1) into sn(n) to obtain m1*sn(n); sn(n+1) to sn(2n) as a snapshot file group to merge snapshot files, for example, merge sn(n+1) to sn(2n-1) into sn(2n) to obtain m1*sn(2n); snapshot files sn(2n+1) to sn(3n) as a snapshot file group to merge snapshot files, for example, merge sn(2n+1) to sn(3n-1) into sn(3n) to obtain m1*sn(3n), and so on.
[0088] The second division is based on n square (n 2 ) snapshot files are merged as a unit, sn1~sn(n 2 ) as a snapshot file group to merge snapshot files, for example, sn1~sn(n 2 -1) merged into sn(n 2 ), we get m2*sn(n 2 ); sn(n 2 +1)~sn(2n 2 ) as a snapshot file group to merge snapshot files, for example, sn(n 2 +1)~sn(2n 2 -1) merged into sn(2n 2 ), we get m2*sn(2n 2 ); snapshot file sn(2n 2 +1)~sn(3n 2 ) as a snapshot file group to merge snapshot files, for example, sn(2n 2 +1)~sn(3n 2 -1) merged into sn(3n 2 ), we get m2*sn(3n 2 ), and so on.
[0089] The third division is based on n3 squared (n 3 ) snapshot files are merged as a unit, sn1~sn(n 3 ) as a snapshot file group to merge snapshot files, for example, sn1~sn(n 3 -1) merged into sn(n 3 ), we get m3*sn(n 3 ); sn(n 3 +1)~sn(2n 3 ) as a snapshot file group to merge snapshot files, for example, sn(n3 +1)~sn(2n 3 -1) merged into sn(2n 3 ), we get m3*sn(2n 3 ); snapshot file sn(2n 3 +1)~sn(3n 3 ) as a snapshot file group to merge snapshot files, for example, sn(2n 3 +1)~sn(3n 3 -1) merged into sn(3n 3 ), we get m3*sn(3n 3 ), and so on.
[0090] The mth division method is to use the square of x of n (n x ) snapshot files are merged as a unit, sn1~sn(n x ) as a snapshot file group to merge snapshot files, for example, sn1~sn(n x -1) merged into sn(n x ), we get m(x)*sn(n x ); sn(n x +1)~sn(2n x ) as a snapshot file group to merge snapshot files, for example, sn(n x +1)~sn(2n x -1) merged into sn(2n x ), we get m(x)*sn(2n x ); snapshot file sn(2n x +1)~sn(3n x ) as a snapshot file group to merge snapshot files, for example, sn(2n x +1)~sn(3n x -1) merged into sn(3n x ), we get m(x)*sn(3n x ), and so on.
[0091] It should be noted that the division method n, n 2 、n x 、n m This is only an example and does not constitute a specific limitation. The specific requirements can be determined based on actual needs.
[0092] Step 204: The server 101 obtains a target snapshot chain based on at least one target snapshot file.
[0093] In specific implementation, the server 101 determines the arrangement order of at least one target snapshot file according to the creation time sequence of the snapshot files; establishes a snapshot path from the source snapshot file to the at least one target snapshot file according to the arrangement order of the at least one target snapshot file to obtain a target snapshot chain.
[0094] Each target snapshot file includes a creation time period, and the creation time period is determined according to the creation time of the multiple snapshot files obtained by merging the target snapshot file. Exemplarily, the creation time period of the target snapshot file is the period between the earliest creation time and the latest creation time of the multiple snapshot files obtained by merging the target snapshot file; at least one target snapshot file is arranged in the order of the creation time period. For example, assuming that the snapshot chain is base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<-sn16, base is the source snapshot file, and the first number is 4, then sn1~sn3 are merged into sn4, and the creation time period of the obtained m1*sn4 is the period from the creation time of sn1 to the creation time of sn; sn5~ and sn7 are merged into sn8, and the creation time period of the obtained m1*sn8 is the period from the creation time of sn5 to the creation time of sn. The creation time period of sn8 is from the time sn9 is created; by merging sn9~ and sn11 into sn12, the creation time period of m1*sn12 is from the time sn9 is created to the time sn12 is created; by merging sn13~ and sn15 into sn16, the creation time period of m1*sn16 is from the time sn13 is created to the time sn16 is created; subsequently, if m1*sn4, m1*sn8, m1*sn12, and m1*sn16 can be further merged into m1*sn16, the creation time period of m2*sn16 is from the time sn1 is created to the time sn1 is created.
[0095] In the process of creating a path from the source snapshot file to the target snapshot file, multiple target snapshot files with consecutive creation time periods are connected in order of their creation time periods from earliest to latest. It is worth noting that for each target snapshot file, there is only one snapshot path from the source snapshot file to the target snapshot file. This snapshot path is used to describe a path that goes directly to the source snapshot file without passing through the target snapshot file, or the snapshot path is formed only by the target snapshot file, thereby reducing the path length. It should be noted that when there are multiple target snapshot files on the snapshot path from the source snapshot file to the target snapshot file, the creation time periods of the multiple target snapshot files do not intersect and are continuous, and are connected in order of their creation time periods from earliest to latest.
[0096] It should be noted that, for each target snapshot file, the target snapshot file is connected to other target snapshot files in the snapshot chain. The snapshot file obtained by merging the target snapshot file is different from the snapshot file obtained by merging other target snapshot files connected to the target snapshot file. The result of merging the target snapshot file and the other target snapshot files connected to it is the result of merging multiple consecutive snapshot files in the snapshot chain. For the source snapshot file in the target snapshot chain, the source snapshot file is connected to several target snapshot files. For the target snapshot file connected to the source snapshot file, obtaining the target snapshot file requires merging multiple consecutive snapshot files connected to the source snapshot file in the snapshot chain.
[0097] It should be noted that, considering that snapshot file merging only retains the latest data, some old data is still in the snapshot file. In order to ensure data integrity, for each target snapshot file, a snapshot path to the target snapshot file is established (for ease of description and distinction, it can be called a branch path). The creation time period of the snapshot file on the branch path is the period between the latest creation time of the two adjacent target snapshot files. Specifically, when there are multiple snapshot files on the branch path, the creation time periods of the multiple snapshot files are continuous and connected in order from early to late creation time periods, and the creation time of the snapshot file on the branch path is earlier than the creation time period of the target snapshot file. Therefore, the target snapshot chain also includes some snapshot files in the snapshot chain. For each snapshot file, there is a unique snapshot between the snapshot file and the source snapshot file. In one example, the snapshot path is used to describe the path directly to the source snapshot file without passing through the target snapshot file. In another example, the snapshot path is used to describe the path from the snapshot file to the target snapshot file, and from the target snapshot file to the source snapshot file.
[0098] As shown in Figure 5, assume that the snapshot chain is: base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<-……<-sn33.
[0099] The first merge is based on 4 snapshot files): merge sn1~sn3 into sn4 to obtain m1*sn4; merge sn5~ and sn7 into sn8 to obtain m1*sn8; merge sn9~ and sn11 into sn12 to obtain m1*sn12; merge sn13~ and sn15 into sn16 to obtain m1*sn16; merge sn17~ and sn19 into sn20 to obtain m1*sn20; merge sn21~ and sn23 into sn24 to obtain m1*sn24; merge sn25~ and sn27 into sn28 to obtain m1*sn28; merge sn29~ and sn31 into sn32 to obtain m1*sn32.
[0100] To obtain m1*sn4, the latest data from s1 to sn4 must be merged. The creation time period of m1*sn4 is the period between the creation time of sn1 and the creation time of sn4. Therefore, sn4 is connected to Base.
[0101] To obtain m1*sn8, the latest data from s5 to sn8 must be merged. The creation time period of m1*sn8 is the period between the creation time of sn5 and the creation time of sn8, which is continuous with the creation time period of m1*sn4. Therefore, m1*sn8 is connected to m1*sn4.
[0102] To obtain m1*sn12, the latest data from s9 to sn12 needs to be merged. The creation time period of m1*sn12 is the period between the creation time of sn9 and the creation time of sn12, which is continuous with the creation time period of m1*sn8. Therefore, m1*sn12 is connected to m1*sn8.
[0103] To obtain m1*sn16, the latest data from s13 to sn16 needs to be merged. The creation time period of m1*sn16 is the period between the creation time of sn13 and the creation time of sn16, which is continuous with the creation time period of m1*sn12. Therefore, m2*sn16 is connected to m1*sn12.
[0104] To obtain m1*sn20, the latest data from sn17 to sn20 needs to be merged. The creation time period of m1*sn20 is the period between the creation time of sn17 and the creation time of sn20, which is continuous with the creation time period of m1*sn16. Therefore, m1*sn20 is connected to m1*sn16.
[0105] To obtain m1*sn24, the latest data from s21 to sn24 needs to be merged. The creation time period of m1*sn24 is the period between the creation time of sn21 and the creation time of sn24, which is continuous with the creation time period of m1*sn20. Therefore, m1*sn24 is connected to m1*sn20.
[0106] To obtain m1*sn28, the latest data from s25 to sn28 needs to be merged. The creation time period of m1*sn28 is the period between the creation time of sn25 and the creation time of sn28, which is continuous with the creation time period of m1*sn24. Therefore, m1*sn28 is connected to m1*sn24.
[0107] To obtain m1*sn32, it is necessary to merge the latest data from s29 to sn32. The creation time period of m1*sn32 is the period between the creation time of sn29 and the creation time of sn32, which is continuous with the creation time period of m1*sn28. Therefore, m1*sn32 is connected to m2*sn28.
[0108] Therefore, for the first merge, the snapshot path from the source snapshot file to the target snapshot file is: Base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-m1*sn32). In addition, the snapshot path from the source snapshot file to the target snapshot file is: base<-sn1<-sn2<-sn3.
[0109] In addition, there is a branch path from the snapshot file to the target snapshot file. For example, for m1*sn4, considering that sn7, sn6, and sn5 are the missing snapshot files between the adjacent m1*sn4 and m1*sn8, and the creation period of sn7, sn6, and sn5 is the latest creation time period of the adjacent m1*sn4 and m1*sn8, the branch path from the snapshot file to the target snapshot file is sn7<-sn6<-sn5<-m1*sn4; m1*sn8, m1*sn12, m1*sn16, m1*sn20, m1*sn24, m1*sn28, and m1*sn32 are similar and will not be repeated here.
[0110] For example, as shown in Figure 5, for sn5 to sn7, the snapshot path becomes base<-m1*sn4<-sn5<-sn6<-sn7, and three snapshot files are reduced on the path; for sn9 to sn11, the snapshot path becomes base<-m1*sn4<-m1*sn8<-sn9<-sn10<-sn11, and six snapshots are reduced on the path; for sn13 to sn15, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn n12<-sn13<-sn14<-sn15, 9 snapshots are reduced on the path; for sn17~sn19, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-sn17<-sn18<-sn19, 12 snapshots are reduced on the path; for sn21~sn23, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1 *sn20<-sn21<-sn22<-sn23, 15 snapshots are reduced on the path; for sn25~sn27, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-sn25<-sn26<-sn27, 18 snapshots are reduced on the path; for sn29~sn31, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-sn25<-sn26<-sn27, -m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-sn29<-sn30<-sn31, and 21 snapshots are reduced on the path. For sn33, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-m1*sn32<-sn33, and 24 snapshots are reduced on the path.
[0111] The second merge is performed in units of 16 snapshot files: sn1 to sn15 are merged into sn16 to obtain m2*sn16; sn17 to sn31 and sn31 are merged into sn32 to obtain m2*sn32.
[0112] To obtain m2*sn16, the latest data from s1 to sn16 must be merged. The creation time period of m2*sn16 is between the creation time of sn1 and the creation time of sn16. Therefore, m2*sn16 is connected to Base. The creation time period of m2*sn16 and the creation time period of m1*sn12 overlap and are not continuous. Therefore, m2*sn16 does not need to be connected to m1*sn12.
[0113] To obtain m2*sn32, it is necessary to merge the latest data from s17 to sn32. The creation time period of m2*sn32 is the period between the creation time of sn17 and the creation time of sn32, which is continuous with the creation time period of m2*sn16. Therefore, m2*sn32 is connected to m2*sn16.
[0114] Therefore, for the second merge, the snapshot path from the source snapshot file to the snapshot file is base<-sn1<-sn2<-sn3; the snapshot path from the source snapshot file to the target snapshot file is Base<-m1*sn4<-m1*sn8<-m1*sn12, Base<-m2*sn16<-m2*sn32; among them, for m2*sn16, there is also a snapshot path from m1*sn28 to m2*sn16: m1*sn28<-m1*sn24<-m1*sn20<-m2*sn16.
[0115] In addition, for m1*sn4, there is also a branch path sn7<-sn6<-sn5<-m1*sn4. m1*sn8, m1*sn12, m1*sn20, m1*sn24, and m1*sn28 are similar and will not be repeated here. For example, as shown in Figure 5, for sn5 to sn7, the snapshot path becomes base<-m1*sn4<-sn5<-sn6<-sn7, and three snapshot files are reduced on the path; for sn9 to sn11, the snapshot path becomes base<-m1*sn4<-m1*sn8<-sn9<-sn10<-sn11, and six snapshots are reduced on the path; for sn13 to sn15, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-sn13<-sn14<-sn15, and nine snapshots are reduced on the path; for sn17 to sn19, the snapshot chain becomes base<-m2*sn16<-sn17<-sn18<-sn19, and 15 snapshots are reduced on the path; for sn21 to sn23 , the snapshot path becomes base<-m2*sn16<-m1*sn20<-sn21<-sn22<-sn23, and 18 snapshots are reduced on the path. For sn25 to sn27, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24<-sn25<-sn26<-sn27, and 21 snapshots are reduced on the path. For sn29 to sn31, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-sn29<-sn30<-sn31, and 24 snapshots are reduced on the path. For sn33, the snapshot path becomes base<-m2*sn16<-m2*sn32<-sn33, and 27 snapshots are reduced on the path.
[0116] In this solution, snapshot files can be merged, which can reduce the number of query snapshots and improve query efficiency.
[0117] FIG6 shows a schematic flow chart of another snapshot merging method provided in an embodiment of the present application.
[0118] As shown in FIG6 , based on steps 201 to 204 shown in FIG2 , in the embodiment of the present application, at least the following steps are further included:
[0119] Step 205: The server 101 obtains a target snapshot tree based on the target snapshot chain after merging at least part of the snapshot chains in the snapshot tree. The connection relationship between each target snapshot chain in the target snapshot tree remains unchanged from the connection relationship between each snapshot chain in the snapshot tree.
[0120] In a specific implementation, the server 101 merges at least two snapshot chains in the snapshot tree according to the method of steps 202 to 204 to obtain at least two target snapshot chains. It should be noted that the server 101 can merge snapshot chains whose number of snapshot files is greater than or equal to a preset number. The preset number needs to be determined in combination with actual conditions, and the embodiment of the present application does not specifically limit this. Then, the server 101 connects at least two target snapshot chains according to the connection relationship between the snapshot chains in the snapshot tree to obtain a target snapshot tree. It should be noted that the snapshot path from the root file in the target snapshot tree to any target snapshot file is unique, and when there are multiple target snapshot files on the snapshot path, the creation time periods of the multiple target snapshot files do not intersect and are continuous, and are connected in order from the earliest to the latest creation time period.
[0121] It should be noted that, in some possible scenarios, for a target snapshot chain in multiple target snapshot chains, if the target snapshot chain corresponds to a snapshot chain connected snapshot file in the snapshot tree, then the target snapshot chain is connected to the target snapshot files or snapshot files in other target snapshot chains, and the creation time period of the target snapshot chain is continuous with the creation time period of the target snapshot file or snapshot file it is connected to. For example, as shown in Figure 4, there are three snapshot chains, denoted as snc1, snc2, and snc3. snc1 is base<-sn1<-sn2<-sn3<-sn4<-sn5<-sn6<-sn7<-sn8<-sn9<-sn10<-sn11<-sn12<-sn13<-sn14<-sn15<-……<-sn33, snc2 is sn1<-sn1.1<-sn1.2<-…<-sn1.10, and snc3 is sn4<-sn4.1<-sn4.2. The target snapshot chain of snc1 can be found in the first merge in Figure 5. Assume that the target snapshot chain of snc2 includes sn1<-m1*sn1.4 (merging the latest data of sn1.1 to sn1.4)<-m1*sn1.8 (merging the latest data of sn1.5 to sn1.8)<-sn1.9<-sn1.10, sn1<-sn1.1<-sn1.2<-sn1.3, sn1.5<-sn1.6<-sn1.7<-m1*sn1.8, and the target snapshot chain of snc2 is connected to sn1 in the target snapshot chain of snc1; snc3 does not merge snapshot files and is connected to m1*sn4 in the target snapshot chain of snc1.
[0122] In an embodiment of the present application, for each target snapshot file in a target snapshot tree, the target snapshot file includes multiple consecutive snapshot files on a snapshot chain; specifically, the target snapshot file is used to merge multiple consecutive snapshot files on a snapshot chain; in addition, for each target snapshot file in a target snapshot tree, the target snapshot file is connected to other target snapshot files in the snapshot chain, and the target snapshot file and the other target snapshot files to which it is connected do not merge the same snapshot file. The result of merging the target snapshot file and the other target snapshot files to which it is connected is the result of merging multiple consecutive snapshot files; for a root file in a target snapshot tree, the root file is connected to several target snapshot files. For a target snapshot file connected to a root file, obtaining the target snapshot file requires merging the snapshot files between the root file in the snapshot chain and the target snapshot file. It should be noted that for any target snapshot file in a target snapshot file, the path from the target snapshot file to the root file is unique, and the snapshot path is formed only by the target snapshot file, thereby reducing the path length. In addition, for each target snapshot file, the target snapshot file is connected to a branch path, and the snapshot files on the branch path are the snapshot files that are missing in the period between the latest creation time of the target snapshot file and another target snapshot file that is later than and adjacent to the target snapshot file; specifically, for the snapshot files in the target snapshot tree, the path between the snapshot file and the root file is unique; in one example, the path is used to describe the path directly to the root file without passing through the target snapshot file; in another example, the path is used to describe the path between the snapshot file and the target snapshot file, and the target snapshot file and the root file.
[0123] For example, as shown in FIG5 , after the second merge, for the target snapshot file m1*sn28, the path from base to m1*sn28 is Base<-m2*sn16<-m1*sn20<-m1*sn24<-m1*sn28. For the snapshot file sn31, the path from base to m1*sn31 is Base<-m2*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-sn29<-sn30<-sn31.
[0124] As shown in FIG7 , based on steps 201 to 204 shown in FIG2 , in the embodiment of the present application, at least the following steps are further included:
[0125] Step 206: The server 101 determines a query instruction, where the query instruction indicates a first snapshot time for starting the query, a second snapshot time for ending the query, and a data identifier.
[0126] The query instruction may be sent from a terminal such as a mobile phone or a computer other than the server 101. The first snapshot time may be a specified time or the current time by default; the second snapshot time may be a specified time or the earliest snapshot file created in the target snapshot chain by default.
[0127] Step 207 : The server 101 responds to the query instruction, queries the target snapshot chain according to the arrangement order of the target snapshot files, and obtains the data corresponding to the data identifier.
[0128] In a specific implementation, the server 101 may start querying from the snapshot file at the first snapshot moment, and query according to the snapshot path from the snapshot file at the first snapshot moment to the source snapshot file in the target snapshot chain.
[0129] In a possible example, as shown in FIG5 , assuming m=1, the data query path is as follows:
[0130] For sn1 to sn3, the snapshot path is base<-sn1<-sn2<-sn3. Assuming that you need to start searching from sn2 and sn2 is not connected to the m1*sn4 merge (the latest data from sn1 to sn4), you can search for data in the order of sn2->sn1->base.
[0131] For m1*sn4, the snapshot path becomes base<-m1*sn4, and three snapshot files are reduced on the path. Assuming that the search needs to start from m1*sn4, data is searched in the order of m1*sn4->base.
[0132] For sn5 to sn7, the snapshot path becomes base<-m1*sn4<-sn5<-sn6<-sn7, and three snapshot files are reduced on the path. Assuming that the search needs to start from sn6, sn6 is not connected to m1*sn4 (merging the latest data from sn1 to sn4), the search is first performed in the order of sn6->sn5. If the search needs to continue upward, since sn5 is connected to m1*sn4 and m1*sn4 is connected to base, in order to improve query efficiency, the data search can be performed in the order of sn5->m1*sn4->base.
[0133] For m1*sn8, the snapshot path becomes base<-m1*sn4<-m1*sn8, and six snapshots are reduced on the path. Assuming that the search needs to start from m1*sn8, data is searched in the order of m1*sn8->m1*sn4->base.
[0134] For sn9 to sn11, the snapshot path becomes base<-m1*sn4<-m1*sn8<-sn9<-sn10<-sn11, and 6 snapshots are reduced on the path. Assuming that the search needs to start from sn10, sn10 is not connected to m1*sn8 (merging the latest data from sn5 to sn8), then the search is first performed in the order of sn10->sn9. If data needs to be searched upward, sn9 is connected to m1*sn8 (merging the latest data from sn5 to sn8), and m1*sn8 is connected to m1*sn4 (merging the latest data from sn1 to sn4). To improve query efficiency, data can be searched in the order of sn9->m1*sn8->m1*sn4->base.
[0135] For m1*sn12, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12, and nine snapshots are missing on the reduction path. Assuming that the search needs to start from m1*sn12, data is searched in the order of m1*sn12->m1*sn8->m1*sn4->base.
[0136] For sn13 to sn15, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-sn13<-sn14<-sn15, and there are 9 fewer snapshots on the path. Assuming that the search needs to start from sn13, sn13 connects to m1*sn12 (merging the latest data from sn9 to sn12), m1*sn12 connects to m1*sn8 (merging the latest data from sn5 to sn8), m1*sn8 connects to m1*sn4 (merging the latest data from sn1 to sn4), and m1*sn4 connects to base. To improve query efficiency, data can be searched in the order of sn13->m1*sn12->m1*sn8->m1*sn4->base.
[0137] For m1*sn16, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16, and 12 snapshots are reduced on the path. Assuming that the search needs to start from m1*sn16, data is searched in the order of m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0138] For sn17 to sn19, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-sn17<-sn18<-sn19, and 12 snapshots are reduced on the path. Assume that you need to start searching from sn18, and sn18 is not connected to m1*sn16 (merging the latest data from sn13 to sn16), then first search in the order of sn18->sn17. If you need to continue searching upwards, considering that sn17 is connected to m1*sn16, m1*sn16 is connected to m1*sn12 (merging the latest data from sn9 to sn12), m1*sn12 is connected to m1*sn8 (merging the latest data from sn5 to sn8), m1*sn8 is connected to m1*sn4 (merging the latest data from sn1 to sn4), and m1*sn4 is connected to base. In order to improve query efficiency, data search can be performed in the order of sn17->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0139] For m1*sn20, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20, reducing 15 snapshots on the path. Assuming that the search starts from m1*sn20, data is searched in the order of m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0140] For sn21 to sn23, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-sn21<-sn22<-sn23, and 15 snapshots are reduced on the path. Suppose you need to start searching from sn22, sn22 is not connected to m1*sn20 (merging the latest data from sn17 to sn20), then first search in the order of sn22->sn21. If you need to continue searching upwards, considering that sn21 is connected to m1*sn20, m1*sn20 is connected to m1*sn16 (merging the latest data from sn13 to sn16), m1*sn16 is connected to m1*sn12 (merging the latest data from sn9 to sn12), m1*sn12 is connected to m1*sn8 (merging the latest data from sn5 to sn8), m1*sn8 is connected to m1*sn4 (merging the latest data from sn1 to sn4), and m1*sn4 is connected to base. In order to improve query efficiency, you can search in the order of sn21->m1*sn20->m1*sn16->m1*sn12->m Data is searched in the order of 1*sn8->m1*sn4->base.
[0141] For m1*sn24, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24, reducing 18 snapshots on the path. Assuming that the search needs to start from m1*sn24, data is searched in the order of m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0142] For sn25 to sn27, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-sn25<-sn26<-sn27, and 18 snapshots are reduced on the path. Assume that you need to start searching from sn26, sn26 is not connected to m1*sn24 (merging the latest data from sn21 to sn24), then first search in the order of sn26->sn25. If you need to continue searching upward, consider sn25 connecting to m1*sn24, m1*sn24 connecting to m1*sn20 (merging the latest data from sn17 to sn20), m1*sn20 connecting to m1*sn16 (merging the latest data from sn13 to sn16), and m1*sn16 connecting to m1*sn1 2 (merge the latest data from sn9 to sn12), m1*sn12 connects to m1*sn8 (merge the latest data from sn5 to sn8), m1*sn8 connects to m1*sn4 (merge the latest data from sn1 to sn4), and m1*sn4 connects to base. To improve query efficiency, data can be searched in the order of sn25->m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0143] For m1*sn28, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28, reducing 21 snapshots on the path. Assuming that the search starts from m1*sn28, data is searched in the order of m1*sn28->m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0144] For sn29 to sn31, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-sn29<-sn30<-sn31, and 21 snapshots are reduced on the path. Assume that you need to start searching from sn30, sn30 is not connected to m1*sn28 (merging the latest data from sn25 to sn28), then first search in the order of sn30->sn29. If you need to continue searching upwards, considering that sn29 is connected to m1*sn28, m1*sn28 is connected to m1*sn24, m1*sn24 is connected to m1*sn20 (merging the latest data from sn17 to sn20), m1*sn20 is connected to m1*sn16 (merging the latest data from sn13 to sn16), and m1*sn16 is connected to m1*sn n12 (merge the latest data from sn9 to sn12), m1*sn12 is connected to m1*sn8 (merge the latest data from sn5 to sn8), m1*sn8 is connected to m1*sn4 (merge the latest data from sn1 to sn4), and m1*sn4 is connected to base. To improve query efficiency, data can be searched in the order of sn30->sn29->m1*sn28->m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0145] For m1*sn32, the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn28<-m1*sn32, reducing 24 snapshots on the path. Assuming that the search needs to start from m1*sn32, data is searched in the order of m1*sn32->m1*sn28->m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0146] For sn33, sn33 connects to m1*sn32 (merging sn29 into the latest data in sn32), and the snapshot path becomes base<-m1*sn4<-m1*sn8<-m1*sn12<-m1*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-m1*sn32<-sn33, reducing 24 snapshots on the path; assuming that the search needs to start from sn33, data search is performed in the order of sn33->m1*sn32->m1*sn28->m1*sn24->m1*sn20->m1*sn16->m1*sn12->m1*sn8->m1*sn4->base.
[0147] In a possible scenario, as shown in Figure 5, assuming m = 2, the data query path is as follows:
[0148] For sn1 to sn3, m1*sn4, sn5 to sn7, m1*sn8, sn9 to sn11, m1*sn12, and sn13 to sn15, the snapshot path is the same as when m=1.
[0149] For m2*sn16, the snapshot path becomes base<-m2*sn16, and 15 snapshots are reduced on the path. Assuming that the search needs to start from m1*sn16, data is searched in the order of m2*sn16->base.
[0150] For sn17 to sn19, the snapshot chain becomes base<-m2*sn16<-sn17<-sn18<-sn19, reducing the number of snapshots along the path by 15. Assuming the search starts at sn18, and sn18 is not connected to m2*sn16 (data from sn1 to sn16 is merged), the search begins in the order sn18->sn17. To continue searching upwards, consider sn17 connected to m2*sn16, which in turn connects to base. To improve query efficiency, the search can be performed in the order sn17->m2*sn16->base.
[0151] For m1*sn20, the snapshot path becomes base<-m2*sn16<-m1*sn20, reducing 18 snapshots on the path. Assuming that the search needs to start from m1*sn20, data is searched in the order of m1*sn20->m2*sn16->base.
[0152] For sn21 to sn23, the snapshot path becomes base<-m2*sn16<-m1*sn20<-sn21<-sn22<-sn23, reducing the number of snapshots. Assuming the search starts at sn22, which is not connected to m1*sn20 (merging the latest data from sn17 to sn20), the search begins in the order sn22->sn21. To continue searching upward, considering that sn21 connects to m1*sn20, m1*sn20 connects to m2*sn16 (merging data from sn1 to sn16), and m2*sn16 connects to base, the search can be performed in the order sn21->m1*sn20->m2*sn16->base to improve query efficiency.
[0153] For m1*sn24, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24, reducing 21 snapshots on the path. Assuming that the search needs to start from m1*sn24, data is searched in the order of m1*sn24->m1*sn20->m2*sn16->base.
[0154] For sn25 to sn27, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24<-sn25<-sn26<-sn27, reducing the number of snapshots. Assuming the search starts at sn26, which is not connected to m1*sn24 (merging the latest data from sn21 to sn24), the search begins in the order sn26 -> sn25. To continue searching upward, considering that m1*sn24 connects to m1*sn20 (merging the latest data from sn17 to sn20), m1*sn20 connects to m2*sn16 (merging data from sn1 to sn16), and m2*sn16 connects to base, the search can be performed in the order sn25 -> m1*sn24 -> m1*sn20 -> m2*sn16 -> base to improve query efficiency.
[0155] For m1*sn28, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24<-m1*sn28. 24 snapshots are reduced on the path, and the query can be performed according to the snapshot path. Assuming that the search needs to start from m1*sn28, data is searched in the order of m1*sn28->m1*sn24->m1*sn20->m2*sn16->base.
[0156] For sn29 to sn31, the snapshot path becomes base<-m2*sn16<-m1*sn20<-m1*sn24<-m1*sn28<-sn29<-sn30<-sn31, and 24 snapshots are reduced on the path. Assume that you need to start searching from sn29, sn29 connects to m1*sn28 (merging the latest data from sn25 to sn28), m1*sn28 connects to m1*sn24 (merging the latest data from sn21 to sn24), m1*sn24 connects to m1*sn20 (merging the latest data from sn17 to sn20), m1*sn20 connects to m2*sn16 (merging data from sn1 to sn16), and m1*sn16 connects to base. In order to improve query efficiency, data search can be performed in the order of sn29->m1*sn28->m1*sn24->m1*sn20->m2*sn16->base.
[0157] For m2*sn32, the snapshot path becomes base<-m2*sn16<-m2*sn32, reducing 27 snapshots on the path. Querying can be done according to the snapshot path. If the search starts from m2*sn32, data is searched in the order of m2*sn32->m2*sn16->base.
[0158] For sn33, the snapshot path becomes base<-m2*sn16<-m2*sn32<-sn33, reducing 27 snapshots on the path. Assuming that you need to search from sn33, you can search for data in the order of sn33->m2*sn32->m2*sn16->base and query according to the snapshot path.
[0159] It should be noted that the target snapshot chain will form a target snapshot tree. In actual application, when server 101 queries data from the target snapshot tree, server 101 can start querying from the snapshot file at the first snapshot moment, and query in order from the creation time from the latest to the earliest according to the path from the snapshot file at the first snapshot moment to the root file in the target snapshot tree, until the snapshot file at the second snapshot moment is queried, and the query is ended and the result is output.
[0160] In an embodiment of the present application, the target snapshot tree can be used for data query. For each snapshot file in the target snapshot tree, during the data query process, the next query path of the snapshot file is the connected snapshot file. In the specific query process, first determine the snapshot file to start searching, then search for data in the snapshot file. If data is found, directly output the data; if no data is found, search for data in the connected snapshot file according to the path from the snapshot file to start searching to the root file. If data is found, directly output the data; if no data is found, search for data in the snapshot file connected to the snapshot file where no data is found, until the data or the source file is found.
[0161] In some possible scenarios, assuming that a database is upgraded, the source file of the database is created as the root file. If data needs to continue to be written to the database, a snapshot file is created and the snapshot files are merged in the manner of steps 201 to 204 to form a target snapshot tree. After that, the database is upgraded. After the upgrade is successful, the data in the database is restored to the latest data by querying the target snapshot tree. In specific implementation, when querying the target snapshot tree, starting from the last created snapshot file, for each data unit in the snapshot file, if there is data in the data unit, the data at the recovery moment is read out; otherwise, the snapshot files are queried sequentially according to the snapshot path from the last created snapshot file to the root file until the data in the data unit is found or the root file is reached.
[0162] In some other possible scenarios, it is assumed that in order to save database storage space, the source file of the database is created as the root file. If data needs to be continued to be written to the database, a snapshot file is created and the snapshot files are merged in the manner of steps 201 to 204 to form a target snapshot tree. Afterwards, if the data at a certain moment is damaged due to various reasons (misoperation, system error, etc.), and the data of the database at a certain moment needs to be restored, the data is rolled back through the target snapshot tree. The data rollback restores the data in the database at a certain moment by querying the target snapshot tree. In specific implementation, when rolling back the data through the target snapshot tree, the snapshot file created at the moment to be restored can be determined. For each data unit in the snapshot file, if there is data in the data unit, the data at the recovery moment is read out. Otherwise, the snapshot files are sequentially queried according to the snapshot path from the snapshot file at the moment to be restored to the root file until the data in the data unit is found or the root file is reached.
[0163] Based on the same concept as the embodiment of the method of the present invention, the embodiment of the present invention also provides a data merging device. The data merging device includes several modules, each module is used to execute each step in the snapshot merging method provided by the embodiment of the present invention, and the division of the modules is not limited here. Those skilled in the art can clearly understand that in actual applications, the various steps in the snapshot merging method provided by the embodiment of the present invention can be assigned to different modules as needed, that is, the internal structure of the device is divided into different modules to complete all or part of the functions described above. The modules in the embodiment can be integrated into one processing unit, or each unit can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the modules in the above-mentioned device can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0164] For example, the data merging device is used to perform the snapshot merging method provided in an embodiment of the present invention. FIG8 is a schematic diagram of the structure of the data merging device provided in an embodiment of the present application. As shown in FIG8, the data merging device provided in an embodiment of the present application includes:
[0165] A first snapshot chain determining module 801 is configured to determine a snapshot chain; the snapshot chain includes a plurality of snapshot files created in sequence;
[0166] A file group determining module 802 is configured to determine at least one first snapshot file group to be merged, wherein the at least one first snapshot file group includes a first number of snapshot files;
[0167] a merging module 803, configured to merge at least one snapshot file in the first snapshot file group to obtain at least one target snapshot file;
[0168] The second snapshot chain determining module 804 is configured to obtain a target snapshot chain based on at least one target snapshot file.
[0169] Based on the same concept as the method embodiment of the present application, the embodiment of the present application also provides a server, including a processor and a memory; wherein the memory is used to store programs; the processor is used to execute the programs stored in the memory, and when the program stored in the memory is executed, the method provided in the above embodiment is executed.
[0170] Exemplarily, the server may be server 101 , and the structure of the server may refer to server 101 in FIG. 1 .
[0171] In a specific application, the hard disk 123 can store a computer program. When the server 101 is running, the processor 111 can read the computer program stored in the hard disk 123 into the memory 112, and read the computer program from the memory 112 to implement the steps in the above-mentioned snapshot merging method, such as steps 201 to 204 in Figure 2, steps 201 to 205 in Figure 6, and steps 201 to 204, step 206, and step 207 in Figure 7.
[0172] For example, a computer program can be divided into one or more modules / units, each of which can be a series of computer program instruction segments capable of performing specific functions. The one or more modules / units are stored in hard disk 123 and executed by processor 111 to implement the present application. For example, the computer program can be divided into a first snapshot chain determination module 801, a file group determination module 802, a merge module 803, and a second snapshot chain determination module 804. The specific functions of each module are described above.
[0173] In addition to the above-mentioned methods, devices and servers, an embodiment of the present application may also provide a computer program product, which includes computer program instructions, which, when executed by a processor, enable the processor to execute the steps in the snapshot merging method of the various embodiments of the present application described in the above-mentioned "Method" section of this specification. Among them, the computer program product can be written in any combination of one or more programming languages to write computer program codes for performing the operations of the embodiments of the present application, and the programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as "C" language or similar programming languages. Among them, the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer program code can be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0174] In addition, an embodiment of the present application may also provide a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, causes the processor to perform the steps of the snapshot merging method according to various embodiments of the present disclosure described in the "Method" section above. The computer-readable storage medium may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may, for example, include but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0175] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0176] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0177] The basic principles of the present application have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, strengths, and effects mentioned in this application are merely illustrative and not restrictive, and it should not be assumed that these advantages, strengths, and effects are required of each embodiment of the present disclosure. In addition, the specific details disclosed above are merely illustrative and for ease of understanding, and are not restrictive. The above details do not limit the present disclosure to necessarily being implemented using the above specific details.
[0178] The block diagrams of the devices, devices, equipment, and systems involved in this disclosure are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As will be appreciated by those skilled in the art, these devices, devices, equipment, and systems can be connected, arranged, or configured in any manner. Words such as "include," "comprise," "have," and the like are open-ended words, meaning "including but not limited to," and can be used interchangeably therewith. The words "or" and "and" used herein refer to the words "and / or" and can be used interchangeably therewith, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to," and can be used interchangeably therewith.
[0179] It should also be noted that in the apparatus, device, and method of the present disclosure, each component or each step can be decomposed and / or recombined. Such decomposition and / or recombination should be regarded as equivalent solutions of the present disclosure.
[0180] The above description has been provided for the purpose of illustration and description. In addition, this description is not intended to limit the embodiments of the present disclosure to the forms disclosed herein. Although a number of example aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.
[0181] It will be understood that the various numerical numbers involved in the embodiments of the present application are merely distinctions for the convenience of description and are not intended to limit the scope of the embodiments of the present application.
Claims
1. A snapshot merging method, characterized in that: include: Determine the snapshot chain; The snapshot chain includes multiple snapshot files created in sequence; Determine at least one first snapshot file group to be merged, where the at least one first snapshot file group includes a first number of snapshot files; Merging at least one snapshot file in the first snapshot file group to obtain at least one target snapshot file; A target snapshot chain is obtained based on at least one target snapshot file.
2. The method according to claim 1, characterized in that The determining of at least one first snapshot file group to be merged includes: Starting with the source snapshot file, multiple snapshot files in the snapshot chain are sequentially divided according to the first number to obtain at least one first snapshot file group.
3. The method according to claim 1 or 2, characterized in that Merging at least one snapshot file in the first snapshot file group to obtain at least one target snapshot file includes: Merging a first number of snapshot files in each of the first snapshot file groups to obtain a plurality of first snapshot files; determining at least one second snapshot file group according to the plurality of first snapshot files, each second snapshot file group including a second number of first snapshot files; A second number of first snapshot files in each second snapshot file group are merged to obtain at least one target snapshot file.
4. The method according to claim 1 or 2, characterized in that Merging at least one snapshot file in the first snapshot file group to obtain at least one target snapshot file includes: Merging a first number of snapshot files in each of the first snapshot file groups to obtain a plurality of first snapshot files; determining at least one second snapshot file group according to the plurality of first snapshot files, each second snapshot file group including a second number of first snapshot files; merging a second number of first snapshot files in each second snapshot file group to obtain at least one second snapshot file; At least one target snapshot file is obtained based on the multiple first snapshot files and the at least one second snapshot file.
5. The method according to claim 4, characterized in that The first number is equal to the second number.
6. The method according to any one of claims 1 to 5, characterized in that: The obtaining of a target snapshot chain based on at least one target snapshot file includes: determining an arrangement order of the at least one target snapshot file according to a creation time sequence of the snapshot files; According to the arrangement order of the at least one target snapshot file, a snapshot path from the source snapshot file to the at least one target snapshot file is established to obtain the target snapshot chain.
7. The method according to claim 6, characterized in that Each target snapshot file includes a creation time period, which is determined according to creation times of multiple snapshot files merged to obtain the target snapshot file. The at least one target snapshot file is arranged in the order of the creation time periods.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Determine a query instruction, where the query instruction indicates a first snapshot time for starting the query, a second snapshot time for ending the query, and a data identifier; In response to the query instruction, the target snapshot chain is queried according to the arrangement order of the target snapshot files to obtain data corresponding to the data identifier.
9. The method according to any one of claims 1 to 8, characterized in that: The snapshot chain is a branch in the snapshot tree; the method further includes: Merging at least two snapshot chains in the snapshot tree to obtain at least two target snapshot chains; A target snapshot tree is obtained based on each target snapshot chain, and the connection relationship between each target snapshot chain in the target snapshot tree remains unchanged from the connection relationship between each snapshot chain in the snapshot tree.
10. A server, characterized in that: comprising a processor and a memory; wherein, The memory is used to store programs; The processor is configured to execute the program stored in the memory. When the program stored in the memory is executed, the method according to any one of claims 1 to 9 is executed.
Citation Information
Patent Citations
Light-weight realization method based on qcow2 format incremental snapshot
CN106055278A
Snapshot merging method, apparatus and device, and storage medium
CN110941511A
Snapshot chain management method and device and storage medium
CN113312309A
Snapshot merging method and server
CN118035173A
Management method, management device and management program
JP2014006845A