Global index block generation method and fault recovery method in distributed storage system
By generating global index blocks in the distributed storage system and loading only incremental index information and metadata during fault recovery, the problem of excessively long recovery time caused by full loading is solved, and rapid service recovery is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
- Filing Date
- 2026-01-06
- Publication Date
- 2026-04-28
AI Technical Summary
In existing technologies, when a distributed storage system recovers from a storage node failure, the full loading of index data results in excessively long recovery times, especially in large-capacity logical storage units where the amount of index data reaches gigabyte levels, leading to a lengthy service recovery process.
By monitoring the amount of new data added to the logical storage unit, a global index block is generated when a predetermined threshold is reached. This block contains index data and metadata, with the metadata used to locate the index data. During fault recovery, only the incremental index information and metadata are loaded into memory, while the loading of the index data is temporarily suspended until the actual read and write requests are processed.
It effectively shortens the failure recovery time of storage nodes, so that service recovery no longer depends on the loading time of the full index data, but only on the loading time of the metadata, thus improving recovery efficiency.
Smart Images

Figure CN121934775A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of distributed storage technology, and in particular to a method for generating global index blocks and a method for fault recovery in a distributed storage system. Background Technology
[0002] With the widespread adoption of cloud computing and big data technologies, distributed storage systems have become the cornerstone of data storage. In these systems, data is typically divided into multiple logical storage units (Planes) for management. Each logical storage unit consists of fixed-size data blocks, with a page as the smallest unit for reading and writing. Ensuring rapid recovery of input / output (IO) services after the failure of a single storage node is crucial for guaranteeing the high availability of the entire system.
[0003] In existing technologies, storage node failure recovery typically employs a full index loading scheme. Specifically, when a storage node restarts and resumes service, it needs to fully load all data page index information generated by the logical storage unit during its historical operation into memory.
[0004] However, the recovery time of this full-load mode in existing technologies is directly related to the total amount of index data. For logical storage units with large storage capacity, the amount of index data can reach gigabyte levels, resulting in a long service recovery process. Summary of the Invention
[0005] This application provides a method for generating global index blocks and a method for fault recovery in a distributed storage system to solve the problem that the service recovery process is time-consuming due to the full loading mode in the prior art.
[0006] In a first aspect, this application provides a global index block generation method, applied to a storage node, the storage node being used to manage logical storage units, including: Monitor the amount of new data added to the logical storage unit; When the amount of newly added data reaches a predetermined threshold, the memory global index information of the logical storage unit is obtained; The global memory index information is persistently written to a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information used to query the index data.
[0007] In one possible implementation, the step of persistently writing the memory global index information into a preset data block includes: The index information of multiple data pages in the global memory index information is organized into one or more complete index segments according to the preset index segment capacity; Each index segment is sequentially written into the contiguous storage area of the preset data block.
[0008] In one possible implementation, the metadata includes segment statistics, which are used to locate the logical segment to which the target data page index information belongs in the index data; the method further includes: The data page identifier space of the logical storage unit is divided into multiple consecutive logical segments; For each logical segment, calculate the total number of valid data pages with recorded index information in all logical segments preceding the logical segment; The total number of valid data pages is recorded as the number of valid data pages before the logical segment and entered into the segment statistics information.
[0009] In one possible implementation, the metadata includes a data page existence bitmap, which is used to determine whether the index information of the target data page is recorded in the global index block; the method further includes: Traverse the global memory index information to obtain the identifiers of all data pages that have been written to; For each acquired data page identifier, the bit position of the identifier is set to a valid state value in the data page existence bitmap.
[0010] Secondly, this application provides a storage node fault recovery method based on global index blocks, applied to a storage node used to manage logical storage units, including: When the storage node recovers from a fault, incremental index information is loaded into memory. The incremental index information includes an index of the data written to the logical storage unit after the first historical time period. Obtain a global index block pre-generated for the logical storage unit, and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data. After loading the incremental index information and the metadata, the service status of the storage node is updated to handle read and write requests.
[0011] In one possible implementation, the method further includes: When the service status is normal, in response to a received read request for a target data page, the system queries whether the index information of the target data page exists in the memory. If the index information of the target data page exists in the memory, the target data page is located and read according to the index information in the memory; If the index information of the target data page does not exist in the memory, the index information of the target data page is retrieved from the index data based on the loaded metadata, and the target data page is located and read based on the retrieved index information.
[0012] In one possible implementation, retrieving the index information of the target data page from the index data based on the loaded metadata includes: Based on the identifier of the target data page, query the data page existence bitmap in the metadata to obtain a first query result regarding whether the target data page has been recorded in the global index block; If the first query result indicates that the target data page has been recorded, then based on the identifier of the target data page and the segment statistics information in the metadata, the logical position of the index information of the target data page in the index data is determined, so as to complete the retrieval of the index information.
[0013] In one possible implementation, determining the logical position of the index information of the target data page in the index data based on the identifier of the target data page and the segment statistics information in the metadata includes: The logical segment identifier to which the target data page belongs is determined based on the identifier of the target data page; From the segment statistics, obtain the total number of valid data pages whose indexes have been recorded in all logical segments before the logical segment identifier, and use this as the first quantity; Based on the bitmap of the data page, the number of all valid data pages within the logical segment corresponding to the logical segment identifier and before the target data page is counted, and this number is used as a second quantity. The logical position is determined based on the first quantity and the second quantity.
[0014] In one possible implementation, after determining the logical position of the index information of the target data page in the index data to complete the retrieval of the index information, the method further includes: Based on the logical location, the index data segment storing the index information of the target data page is loaded from the index data into memory; Update the index information of multiple data pages contained in the index data segment to the index query structure in memory.
[0015] In one possible implementation, the step of querying the data page existence bitmap in the metadata based on the identifier of the target data page to obtain a first query result regarding whether the target data page has been recorded in the global index block includes: Based on the identifier of the target data page, determine the bit offset of the target data page in the bitmap of the data page; If the bit value at the bit offset is a first predetermined value, then a first query result indicating that it has been recorded is generated; If the bit value at the bit offset is a second predetermined value, then the first query result indicating that it has not been recorded is generated.
[0016] Thirdly, this application provides a global index block generation apparatus, applied to a storage node, the storage node being used to manage logical storage units, including: A monitoring module is used to monitor the amount of new data added to the logical storage unit; The first acquisition module is used to acquire the memory global index information of the logical storage unit when the amount of newly added data reaches a predetermined threshold. A generation module is used to persistently write the global memory index information into a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information used to query the index data.
[0017] Fourthly, this application provides a storage node fault recovery device based on global index blocks, applied to a storage node, the storage node being used to manage logical storage units, including: A loading module is used to load incremental index information into memory when the storage node recovers from a fault. The incremental index information includes an index of the data written to the logical storage unit after the first historical time period. The second acquisition module is used to acquire a global index block pre-generated for the logical storage unit and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data. The update module is used to update the service status of the storage node after loading the incremental index information and the metadata, so as to handle read and write requests.
[0018] Fifthly, this application provides an apparatus comprising: a processor and a memory, the processor being configured to execute a computer program stored in the memory to implement the global index block generation method described in any one of the first aspects, and / or the storage node fault recovery method based on global index blocks described in any one of the second aspects.
[0019] Sixthly, this application provides a storage medium storing one or more programs that can be executed by one or more processors to implement the global index block generation method described in any one of the first aspects, and / or the storage node fault recovery method based on global index blocks described in any one of the second aspects.
[0020] The technical solutions provided in this application have the following advantages compared with the prior art: The global index block generation method provided in the first aspect monitors the amount of new data added to logical storage units. When a predetermined threshold is reached, it retrieves and persists the global index information in memory, generating a global index block containing both index data and metadata. This structure organizes the index data into index segments, while the metadata only stores query location information. Therefore, any subsequent location operation on the disk index can be guided by querying a small amount of metadata, without needing to traverse the entire index data, thus creating a premise for avoiding full loads at the data structure level.
[0021] The second aspect provides a storage node fault recovery method based on global index blocks. During fault recovery, this method first loads incremental index information and retrieves a pre-generated global index block, loading only its metadata into memory. Subsequently, it updates the storage node's service status to handle read and write requests. This directly utilizes the aforementioned structured global index block, selectively loading only a small amount of metadata during the recovery phase, while temporarily omitting the majority of historical index data. This decouples service status recovery from the loading of all index data. Consequently, the storage node can immediately restore service capabilities after loading the metadata, while deferring the loading of specific index data to be executed on demand when actually handling read and write requests. This transforms the service recovery time from depending on the loading time of all index data to depending only on the loading time of the metadata, effectively solving the technical problem of excessively long recovery times caused by loading the entire index. Attached Figure Description
[0022] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0023] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0024] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.
[0025] Figure 1 A flowchart illustrating an embodiment of a global index block generation method provided in this application; Figure 2 This application provides a schematic diagram of the structure of a global index block according to an embodiment of the present application; Figure 3 This application provides an embodiment of an index structure diagram based on global index blocks and incremental data blocks. Figure 4 A flowchart illustrating an embodiment of a storage node fault recovery method based on global index blocks provided in this application; Figure 5 A flowchart illustrating an embodiment of another storage node fault recovery method based on global index blocks provided in this application; Figure 6 A block diagram illustrating an embodiment of a global index block generation apparatus provided in this application; Figure 7 A block diagram illustrating an embodiment of a storage node fault recovery device based on a global index block provided in this application. Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0027] The following disclosure provides numerous different embodiments or examples for implementing various structures of this application. To simplify the disclosure, specific examples of components and arrangements are described below. These are merely examples and are not intended to limit the scope of this application. Furthermore, reference numerals and / or letters may be repeated in different examples. Such repetition is for simplification and clarity and does not in itself indicate a relationship between the various embodiments and / or arrangements discussed.
[0028] Figure 1 This is a flowchart illustrating an embodiment of a global index block generation method provided in this application. In one embodiment, it is applied to a storage node, which manages logical storage units, such as... Figure 1 As shown, the method includes the following steps: Step 101: Monitor the amount of new data added to the logical storage unit.
[0029] A logical storage unit (Plane) is the smallest data management unit in a distributed storage system that is independently managed and indexed. A logical storage unit typically has a preset maximum capacity (e.g., 32GB), consists of fixed-size data blocks (e.g., 2GB), and uses a page (e.g., 4KB) as the smallest unit for reading and writing.
[0030] New data volume: refers to the total amount of data successfully written to the target logical storage unit within a specific monitoring time window, usually calculated cumulatively in bytes.
[0031] In this embodiment, this step is performed by a dedicated monitoring module or background service thread on the storage node. This module continuously tracks and accumulates the data size involved in I / O (Input / Output) operations written to the logical storage unit. Specifically, after each data write transaction is completed, a counter associated with the logical storage unit can be updated; the value of this counter represents the cumulative amount of newly added data.
[0032] Step 102: When the amount of newly added data reaches a predetermined threshold, obtain the memory global index information of the logical storage unit.
[0033] Preset threshold: This refers to a preset data volume threshold used to trigger the generation of global index blocks. This threshold can be set according to system configuration and performance requirements, for example, 6GB, which is equivalent to 3 standard-sized storage blocks (3 sdbblocks).
[0034] Global memory index information: This refers to a complete data structure stored in the main memory of the storage node that records the index information of all written and valid data pages within the target logical storage unit. This index information typically includes the mapping relationship between the data page identifier (Page ID) and its actual storage location on the physical storage device (such as hard disk, solid-state drive) (such as device number, block address, offset).
[0035] In this embodiment, when the monitoring module in step 101 determines that the cumulative amount of newly added data has reached or exceeded the predetermined threshold (e.g., 6GB), an index persistence event is triggered. The index management module (or data read / write module bs) of the storage node responds to this event and executes this step. Specifically, the module accesses the global index table or index tree maintained in memory for the logical storage unit to obtain its complete current state, i.e., the memory global index information. This information is the source data for subsequently generating persistent global index blocks.
[0036] Step 103: Persist the memory global index information into a preset data block to generate a global index block, wherein the global index block includes index data and metadata: the index data contains multiple index segments, each index segment contains index information of a preset number of data pages; the metadata stores location information for querying the index data.
[0037] Persistent write: refers to the process of writing data from volatile memory to non-volatile persistent storage media (such as hard disks and solid-state drives) to ensure that the data still exists after the system is powered off or restarted.
[0038] Pre-allocated data blocks: These are contiguous storage areas on persistent storage media that are pre-allocated or reserved specifically for storing index information. Their size and location are typically defined by the storage system's metadata management mechanism.
[0039] Global index block: refers to a data structure block generated and persistently stored using this method, containing complete index information of a logical storage unit at a certain point in time.
[0040] Index data: refers to the main part of the global index block used to store index information for specific data pages.
[0041] Index segment: refers to the basic organizational unit within index data. Each index segment is physically stored contiguously and logically contains a predetermined number of data page index entries.
[0042] Index information of a data page: refers to a record that describes the metadata such as the storage location of a data page, which usually includes the page identifier, physical address, and check information.
[0043] Metadata: In this application, it specifically refers to the auxiliary information portion of the global index block that is independent of the index data storage and is used to support efficient querying of the index data.
[0044] Location information: refers to information stored in metadata used to quickly locate the position of a specific data page index within the index data. According to embodiments of this application, this location information mainly includes two types of key data: one type is used to efficiently determine whether the index of a specified data page exists in this global index block; the other type is used to quickly calculate the specific storage location of the index in the index data portion after determining that the index exists.
[0045] In this embodiment, the index management module of the storage node performs this step. The specific implementation includes: Structured organization and writing of index data: All valid data page indexes in the global memory index information obtained in step 102 are organized according to a predefined structured format and persistently written to form the index data portion of the global index block. This structured format ensures that the index data has a clear internal organization pattern in persistent storage, facilitating efficient subsequent queries based on metadata.
[0046] Generate and write metadata: Simultaneously or subsequently, corresponding metadata needs to be generated. This metadata is not the index data itself, but rather auxiliary information specifically calculated and stored to enable efficient subsequent index data queries; it is essentially "location information." The process of generating location information involves analyzing and statistically processing the data page status and index organization of the current logical storage unit, ultimately producing a data structure capable of supporting rapid existence determination and location calculation. This metadata is also written to a predefined data block, typically placed after the index data or in a specific header area.
[0047] Generate a global index block: Write the complete content, including index data (composed of multiple index segments) and metadata (containing location information), into a predefined data block to generate a structured, self-describing global index block. This index block provides a complete and efficient persistent index view for subsequent operations (such as on-demand index loading during node failure recovery).
[0048] This application embodiment monitors the amount of new data added to the logical storage unit. When a predetermined threshold is reached, it obtains and persists the global index information in memory, generating a global index block containing both index data and metadata. This structure organizes the index data into index segments, while the metadata only stores query location information. Therefore, any subsequent location operation on the disk index can be guided by querying a very small amount of metadata, without needing to traverse the entire index data, thus creating a premise for avoiding full loading at the data structure level.
[0049] In one embodiment, step 103 may specifically include the following steps: organizing the index information of multiple data pages in the global memory index information into one or more complete index segments according to a preset index segment capacity; and sequentially writing each index segment into the contiguous storage area of the preset data block.
[0050] Index segment capacity: refers to the maximum number of data page index information that a single index segment can hold. It is a preset fixed value, such as 1024. Complete index segment: refers to a logical unit of index segment whose internal data page index count exactly reaches the index segment capacity. Contiguous storage area: refers to a segment of physical storage space within a preset data block where addresses are adjacent and without gaps.
[0051] In this embodiment, the index management module first extracts all data page index information to be persisted from the global memory index information. Then, it logically groups this index information according to a preset unit: whenever the accumulated number of indexes reaches this unit, these indexes are organized into a complete index segment. Next, the module processes each organized index segment sequentially, serializing all the index information it contains into a predefined binary format and writing it sequentially into a preset data block reserved for the global index block. During writing, the content of the next index segment begins immediately after the end of the previous index segment, thus forming a continuous storage area within the preset data block, sequentially filled with multiple index segments. This continuous area ultimately constitutes the main body of the global index block's index data.
[0052] This solution, through its mechanism of organizing and writing data in segments of fixed capacity in sequence, enables massive amounts of index data to have a regular and predictable physical layout on the disk. This not only simplifies the logic of the writing process, but more importantly, it provides a crucial physical structure foundation for subsequent efficient and accurate index location and on-demand loading based on metadata (such as segment statistics), thereby effectively supporting rapid fault recovery.
[0053] In another embodiment, the metadata includes segment statistics, which are used to locate the logical segment to which the target data page index information belongs in the index data. The method further includes: dividing the data page identifier space of the logical storage unit into multiple consecutive logical segments; for each logical segment, calculating the total number of valid data pages with recorded index information in all logical segments preceding the logical segment; and recording the total number of valid data pages as the number of valid data pages preceding the logical segment in the segment statistics.
[0054] Segment statistics: refers to a data structure stored in metadata that is specifically used to record statistical values related to logical segment divisions to support index location.
[0055] Logical segment: Conceptually, a logical storage unit is divided into multiple equal-length intervals by sequentially and continuously partitioning all data page identifiers (such as Page IDs from 1 to a maximum number). Each interval contains a certain number of consecutive data page identifiers (e.g., 1024). The logical segment here is conceptually related to the index segment in index data, which stores the specific index, but their functions differ.
[0056] Valid data before segment: refers to the total number of valid data pages that have been actually written and are recorded in the global index block for a specific logical segment, which are counted before this logical segment (i.e., among all logical segments with smaller sequence numbers).
[0057] In this embodiment, segment statistics are specifically generated when generating metadata for the global index block. The process is as follows: First, all possible data page identifiers managed by the logical storage unit (e.g., for a 32GB logical storage unit, the page identifier range is 1 to 32G / 4K) are divided into multiple sequentially numbered, consecutive logical segments by a fixed size (e.g., every 1024 page identifiers constitute an interval). Then, for each segment, a statistical calculation is performed: that is, the total number of valid data pages contained in all logical segments preceding this segment (with numbers lower than this segment) is calculated. A data page is considered valid if it has been actually written with user data and its index information has been included in the global memory index information to be persisted. Finally, the total number of valid data pages calculated for each logical segment is used as the number of valid data pages preceding that segment and recorded in the segment statistics structure of the metadata according to the order of the logical segments.
[0058] This solution pre-calculates and stores this series of segment prefixes. When it is necessary to locate the index of a certain data page later, it can first determine which logical segment it belongs to based on its page identifier. Then, by querying the segment prefixes corresponding to that logical segment, it can immediately know how much space (measured by the number of valid page indexes) all the indexes before that logical segment occupy in the index data part of the global index block. This allows for a quick inference of the approximate area where the target index is located (i.e., which index segment it belongs to), greatly accelerating the index retrieval process. It is one of the key positioning mechanisms that supports on-demand index loading.
[0059] In another embodiment, the metadata includes a data page existence bitmap, which is used to determine whether the index information of the target data page is recorded in the global index block; the method further includes: traversing the global index information in memory to obtain the identifiers of all data pages that have been written to; for each obtained data page identifier, setting the bit position of the identifier to a valid status value in the data page existence bitmap.
[0060] Data page existence bitmap: refers to a bit array data structure stored in metadata. Its total number of bits corresponds to the maximum number of data pages supported by the logical storage unit. The boolean value of each bit (usually "1" indicates a valid state and "0" indicates an invalid state) is used to indicate whether the index information of the specific data page corresponding to that bit exists in the current global index block.
[0061] Valid status value: refers to a specific bit value in the data page existence bitmap that indicates that the index of the corresponding data page has been recorded in the global index block, usually a binary "1".
[0062] In this embodiment of the application, when generating the metadata of the global index block, a data page existence bitmap is also generated. The specific process is as follows: First, the memory global index information obtained in step 102 is traversed to extract the unique identifiers (e.g., Page IDs) of all valid data pages that have actually been written to user data and therefore need to be indexed. Then, a bitmap of sufficient length is initialized, the total number of bits of which should cover the entire page identifier space of the logical storage unit (e.g., for a 32GB logical storage unit, the bitmap size is 32G / 4K bits, i.e., 1MB). Next, for the identifier of each valid data page obtained through traversal, the bit position (bit offset) corresponding to the identifier in the bitmap is calculated, and the bit value at that position is set to a predefined valid state value (e.g., set to "1").
[0063] This solution generates and saves a bitmap showing the existence of this data page. During subsequent fault recovery or querying, when it's necessary to determine if the index of a specific target data page exists, there's no need to traverse or query the massive index data. Instead, the bitmap offset is calculated based on the target data page's identifier, and the value of that bit is read. If the bit is a valid status value, the existence of the index can be immediately confirmed, greatly accelerating the index existence determination process and avoiding numerous invalid index retrieval operations. Combined with segment statistics, this forms the foundation for an efficient and accurate index location and on-demand loading mechanism.
[0064] Through the above scheme, the storage node generates, as follows: Figure 2 The global index block shown. Figure 2 The internal structure of this global index block is shown, which mainly includes an index part and a metadata part. The index part consists of multiple consecutive index segments, each containing index information for a predetermined number of data pages. The metadata part contains segment front sums and a bitmap showing the presence of data pages. These pieces of information together constitute the aforementioned location information used for querying, supporting efficient retrieval of the index part.
[0065] Figure 3 This illustrates the relationship between logical storage units, global index blocks, and physical data storage blocks (sdb1-sdb6) from a system architecture perspective. For example... Figure 3 As shown, the global index block, as the index management structure of the logical storage unit, is independent of the data storage block that actually stores user data. This design of separating the index from the data provides a foundation for subsequent rapid fault recovery.
[0066] Figure 4 This document provides a flowchart of an embodiment of a storage node fault recovery method based on a global index block, as illustrated in this application. In one embodiment, the method is applied to a storage node, which manages logical storage units, such as... Figure 4 As shown, the method includes the following steps: Step 401: When the fault state of the storage node is restored, the incremental index information is loaded into memory. The incremental index information includes the index of the data written to the logical storage unit after the first historical time period.
[0067] Incremental index information: refers to the set of indexes corresponding to the data newly written to logical storage units after the first historical time period (i.e. the time point when the last global index block was successfully generated). These indexes record the storage location information of the latest written data.
[0068] In this embodiment, when a storage node recovers from a fault, it first reads and loads incremental index information recording the latest data changes from persistent storage. This information is typically stored independently of the global index block and represents the system's most recent activity state.
[0069] Step 402: Obtain the global index block pre-generated for the logical storage unit, and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data.
[0070] In this embodiment, the storage node then locates the global index block pre-generated for the logical storage unit (the generation method is as described in the previous embodiments). The node only reads the metadata portion (e.g., segment statistics and data page existence bitmap) containing the location information in the global index block and loads it into memory. The index data portion, which records a large amount of historical index details, is not loaded at this stage and remains in persistent storage.
[0071] Step 403: After loading the incremental index information and the metadata, update the service status of the storage node to process read and write requests.
[0072] Service status: refers to the availability status of the storage node in providing services to the outside world.
[0073] In this embodiment, once the incremental index information and metadata are loaded, the storage node marks its internal state as serviceable and begins receiving and processing external data read / write requests. At this point, the node has the basic ability to process requests: for the data page accessed by the request, if its index exists in the loaded incremental index or can be quickly located through metadata, it can be processed normally.
[0074] In this embodiment, during fault recovery, incremental index information is first loaded, and a pre-generated global index block is obtained, with only its metadata loaded into memory. Subsequently, the service status of the storage node is updated to handle read and write requests. This directly utilizes the aforementioned structured global index block, selectively loading only a very small amount of metadata during the recovery phase, while temporarily omitting the majority of historical index data. This decouples service recovery from the loading of all index data. Consequently, the storage node can immediately restore service capabilities after loading the metadata, while deferring the loading of specific index data to be executed on demand when actually processing read and write requests. This transforms the service recovery time from depending on the loading time of all index data to depending only on the loading time of the metadata, effectively solving the technical problem of excessively long recovery times caused by loading the entire index.
[0075] In another embodiment of this application, after steps 401-403, the following steps may be included: When the service status is normal service, in response to a received read request for a target data page, query whether the index information of the target data page exists in the memory; if the index information of the target data page exists in the memory, locate and read the target data page according to the index information in the memory; if the index information of the target data page does not exist in the memory, retrieve the index information of the target data page from the index data according to the loaded metadata, and locate and read the target data page according to the retrieved index information.
[0076] Target data page: refers to the specific data page that the external read / write request wants to access, specified by the unique identifier of the data page (such as Page ID).
[0077] In this embodiment, after the storage node completes fault recovery and enters normal service, the specific process for handling read requests is as follows: When a read request for a target data page is received, the node first queries its index information in memory based on the identifier of the target data page. This query covers two parts of data already loaded into memory: incremental index information and metadata of the global index block. If the index information of the target data page is found in memory, the data is directly located and read based on this information.
[0078] If the index information for the target data page cannot be found in memory, a metadata-based retrieval process is initiated. At this point, the node uses the loaded metadata (especially the bitmap containing the data page) to quickly determine if the target data page's index is recorded in the index data portion of the global index block. If it is found to exist, the node further combines the segment statistics information in the metadata to calculate the specific logical location of its index within the index data portion based on the target data page's identifier. Subsequently, based on this logical location, the node reads the specific index segment containing the target index (this index segment contains multiple contiguously stored data page indexes) from the persistently stored global index block into memory. After parsing this index segment, the precise index information of the target data page is obtained. Finally, the node locates and reads the target data page based on the retrieved index information.
[0079] This solution enables on-demand loading of the index, ensuring that nodes can transparently and efficiently access all historical data while providing services with only a small amount of metadata.
[0080] Figure 5 A flowchart illustrating an embodiment of another storage node fault recovery method based on global index blocks provided in this application. Figure 5 The process shown is in Figure 4 Based on the illustrated process, this section describes in detail how to retrieve the index information of the target data page from the index data according to the loaded metadata, including the following steps: Step 501: Based on the identifier of the target data page, query the data page existence bitmap in the metadata to obtain a first query result regarding whether the target data page has been recorded in the global index block.
[0081] The identifier of the target data page: refers to the number or address information used to uniquely identify a specific data page. In this application, each data page is 4KB in size. Data page existence bitmap: is a data structure in metadata that uses bits to indicate whether the index information of the corresponding data page is stored in the global index block.
[0082] In this embodiment of the application, step 501 may specifically include the following steps: determining the bit offset of the target data page in the bitmap of the data page based on the identifier of the target data page; if the bit value at the bit offset is a first predetermined value, generating a first query result indicating that it has been recorded; if the bit value at the bit offset is a second predetermined value, generating a first query result indicating that it has not been recorded.
[0083] Bit offset: refers to the specific offset of the bit corresponding to the identifier of the target data page in the data page existence bitmap, used to accurately locate the existence status identifier bit of the data page. First predetermined value: refers to the bit value indicating that the data page has been recorded, which is 1 in this embodiment. Second predetermined value: refers to the bit value indicating that the data page has not been recorded, which is 0 in this embodiment.
[0084] This application embodiment is specifically implemented when the storage node performs index retrieval. The process is as follows: First, the specific bit offset of the target data page in the data page existence bitmap is calculated by bit operation according to the identifier of the target data page (i.e., the data page number). Then, the bit value at the offset position is read. If the bit value read is a first predetermined value (1), a first query result indicating that the target data page has been recorded in the global index block is generated. If the bit value read is a second predetermined value (0), a first query result indicating that the target data page has not been recorded in the global index block is generated.
[0085] This scheme achieves rapid determination of the existence status of data pages through a bitmap query mechanism. By leveraging the efficiency of bit operations and the compactness of the bitmap structure, the existence detection can be completed with only one bit offset calculation and bit value reading operation. This determination method has constant-time complexity, which greatly improves the early filtering efficiency of index retrieval, provides a foundation for subsequent precise index positioning, and effectively avoids unnecessary index data loading overhead.
[0086] Step 502: If the first query result indicates that the target data page has been recorded, then based on the identifier of the target data page and the segment statistics information in the metadata, determine the logical position of the index information of the target data page in the index data, so as to complete the retrieval of the index information.
[0087] Segment statistics: These are statistical information in the metadata recording the number of valid forward data pages for each logical segment. In this specific implementation, they are represented as segment forward statistics, with each statistical value stored as a 32-bit unsigned integer (uint32_t). Logical location: This refers to the sequential position of the target data page's index information within the index data.
[0088] In this embodiment of the application, step 502 may specifically include the following steps: determining the logical segment identifier to which the target data page belongs based on the identifier of the target data page; obtaining the total number of valid data pages with recorded indexes in all logical segments before the logical segment identifier from the segment statistics information, as a first quantity; based on the data page existence bitmap, counting the number of all valid data pages in the logical segment corresponding to the logical segment identifier and before the target data page, as a second quantity; and determining the logical position based on the first quantity and the second quantity.
[0089] Logical segment identifier: This refers to the logical segment number to which the target data page belongs. Each logical segment contains 1024 consecutive data page address spaces, calculated by dividing the target data page identifier by 1024 and rounding down. Total number of valid data pages: This refers to the total number of data pages that are actually stored and indexed within the specified logical segment range, obtained by analyzing the bit settings of corresponding bits in the statistical page existence bitmap.
[0090] This application embodiment is specifically implemented by the storage node when performing precise index location. The process is as follows: First, calculate the logical segment identifier (identifier number = data page number / 1024) based on the target data page identifier. Then, read the cumulative value stored at the position before the logical segment identifier from the segment statistics information array to obtain the total number of valid data pages in all logical segments before the logical segment as the first quantity. Next, based on the data page existence bitmap, count the bit values corresponding to all data pages from the starting data page of the current logical segment to the target data page, and count the number of bit values with a first predetermined value as the second quantity. Finally, add the first quantity and the second quantity to obtain the precise logical position of the target data page index in the index data.
[0091] This scheme achieves precise calculation of index positions by combining segmented statistics with bitmap scanning, avoiding the full loading of global index data. It utilizes pre-calculated segment statistics to quickly obtain a wide range of statistical values, and combines this with local bitmap scanning to obtain precise intra-segment offsets, ensuring both computational efficiency and positioning accuracy. This hierarchical positioning mechanism significantly reduces the computational overhead of index retrieval, provides a reliable technical guarantee for quickly obtaining target index information, and effectively improves the index query performance of distributed storage systems.
[0092] Figure 5The process shown achieves efficient retrieval of index information through a two-level query mechanism: first, it quickly filters out requests for non-existent data pages by using a data page existence bitmap, reducing unnecessary retrieval overhead; then, it uses segment statistics to accurately calculate the index position, avoiding a global scan of the index data. This retrieval method not only ensures query efficiency but also minimizes the amount of data that needs to be loaded, effectively improving the overall performance of index retrieval and providing an efficient index query solution for distributed storage systems.
[0093] In another embodiment of this application, after step 502, the method further includes: loading an index data segment storing the index information of the target data page from the index data into memory according to the logical location; and updating the index information of multiple data pages contained in the index data segment into the index query structure in memory.
[0094] Index data segment: This refers to the basic unit of storing contiguous index information within the index data. Each index data segment contains index information for 1024 data pages, organized using a sequential storage structure, and occupies a fixed amount of storage space. In-memory index query structure: This refers to the data structure stored in memory for quickly querying index information for data pages. It uses hash tables, B+ trees, or other efficient query structures to organize and manage index information.
[0095] This embodiment of the application is executed by the storage node after determining the logical location of the target data page. The specific implementation method is as follows: First, based on the calculated logical location, the corresponding index data segment number is determined by division (segment number = logical location / 1024). Then, the entire content (approximately 6KB in size) of the index data segment is read from the index data of the global index block into memory. Next, the 1024 data page index information contained in the index data segment is parsed, and these index information are updated in batches to the index query structure in memory to establish a mapping relationship between data page identifiers and index information for subsequent query use.
[0096] This solution achieves efficient lazy loading of index information through a batch loading and updating mechanism for index data segments. On the one hand, loading by data segments reduces the number of I / O operations and improves data loading efficiency. On the other hand, batch updating multiple index information into the in-memory query structure avoids frequent single index update operations, significantly improving index update efficiency. This mechanism not only ensures on-demand loading of index information but also achieves locality optimization by preloading the index information of adjacent data pages, providing performance optimization for subsequent access to adjacent data pages and effectively improving the overall query performance of the distributed storage system.
[0097] Figure 6 This is a block diagram illustrating an embodiment of a global index block generation apparatus provided in this application. Figure 6 As shown, the device includes: Monitoring module 61 is used to monitor the amount of new data added to the logical storage unit; The first acquisition module 62 is used to acquire the memory global index information of the logical storage unit when the amount of newly added data reaches a predetermined threshold. The generation module 63 is used to persistently write the global memory index information into a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information used to query the index data.
[0098] Figure 7 This is a block diagram illustrating an embodiment of a storage node fault recovery device based on a global index block, provided in this application. Figure 7 As shown, the device includes: The loading module 71 is used to load incremental index information into memory when the fault state of the storage node is restored. The incremental index information includes the index of the data written to the logical storage unit after the first historical time period. The second acquisition module 72 is used to acquire a global index block pre-generated for the logical storage unit and load the metadata in the global index block into memory. The global index block also contains index data. The index data records the index information of the data pages written by the logical storage unit in the first historical time period. The metadata stores the location information for querying the index data. The update module 73 is used to update the service status of the storage node after loading the incremental index information and the metadata, so as to handle read and write requests.
[0099] like Figure 8 As shown in the figure, this application provides a device including a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114. Memory 113 is used to store computer programs; In one embodiment of this application, when processor 111 executes a program stored in memory 113, it implements the global index block generation method and / or the storage node fault recovery method based on the global index block provided in any of the foregoing method embodiments, applied to a storage node, the storage node being used to manage logical storage units, the method comprising: Monitor the amount of new data added to the logical storage unit; When the amount of newly added data reaches a predetermined threshold, the memory global index information of the logical storage unit is obtained; The global memory index information is persistently written to a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information for querying the index data; And / or, When the storage node recovers from a fault, incremental index information is loaded into memory. The incremental index information includes an index of the data written to the logical storage unit after the first historical time period. Obtain a global index block pre-generated for the logical storage unit, and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data. After loading the incremental index information and the metadata, the service status of the storage node is updated to handle read and write requests.
[0100] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the global index block generation method and / or the storage node fault recovery method based on the global index block provided in any of the foregoing method embodiments.
[0101] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.
[0102] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented using software plus a general-purpose hardware platform, or of course, using hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0103] It should be understood that the terminology used herein is for the purpose of describing particular exemplary embodiments only and is not intended to be limiting. Unless the context clearly indicates otherwise, the singular forms “a,” “an,” and “described” as used herein may also include the plural forms. The terms “comprising,” “including,” “containing,” and “having” are inclusive and therefore indicate the presence of the stated features, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, elements, components, and / or combinations thereof. The method steps, processes, and operations described herein are not construed as requiring them to be performed in a particular order described or illustrated unless the order of performance is explicitly indicated. It should also be understood that additional or alternative steps may be used.
[0104] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.
Claims
1. A method for generating a global index block, characterized in that, Applied to a storage node for managing logical storage units, the method includes: Monitor the amount of new data added to the logical storage unit; When the amount of newly added data reaches a predetermined threshold, the memory global index information of the logical storage unit is obtained; The global memory index information is persistently written to a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information used to query the index data.
2. The method according to claim 1, characterized in that, The step of persistently writing the global memory index information into a preset data block includes: The index information of multiple data pages in the global memory index information is organized into one or more complete index segments according to the preset index segment capacity; Each index segment is sequentially written into the contiguous storage area of the preset data block.
3. The method according to claim 1, characterized in that, The metadata includes segment statistics, which are used to locate the logical segment to which the target data page index information belongs in the index data; the method further includes: The data page identifier space of the logical storage unit is divided into multiple consecutive logical segments; For each logical segment, calculate the total number of valid data pages with recorded index information in all logical segments preceding the logical segment; The total number of valid data pages is recorded as the number of valid data pages before the logical segment and entered into the segment statistics information.
4. The method according to claim 1, characterized in that, The metadata includes a data page existence bitmap, which is used to determine whether the index information of the target data page is recorded in the global index block; the method further includes: Traverse the global memory index information to obtain the identifiers of all data pages that have been written to; For each acquired data page identifier, the bit position of the identifier is set to a valid state value in the data page existence bitmap.
5. A storage node fault recovery method based on global index blocks, characterized in that, Applied to a storage node for managing logical storage units, the method includes: When the storage node recovers from a fault, incremental index information is loaded into memory. The incremental index information includes an index of the data written to the logical storage unit after the first historical time period. Obtain a global index block pre-generated for the logical storage unit, and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data. After loading the incremental index information and the metadata, the service status of the storage node is updated to handle read and write requests.
6. The method according to claim 5, characterized in that, The method further includes: When the service status is normal, in response to a received read request for a target data page, the system queries whether the index information of the target data page exists in the memory. If the index information of the target data page exists in the memory, the target data page is located and read according to the index information in the memory; If the index information of the target data page does not exist in the memory, the index information of the target data page is retrieved from the index data based on the loaded metadata, and the target data page is located and read based on the retrieved index information.
7. The method according to claim 6, characterized in that, The step of retrieving the index information of the target data page from the index data based on the loaded metadata includes: Based on the identifier of the target data page, query the data page existence bitmap in the metadata to obtain a first query result regarding whether the target data page has been recorded in the global index block; If the first query result indicates that the target data page has been recorded, then based on the identifier of the target data page and the segment statistics information in the metadata, the logical position of the index information of the target data page in the index data is determined, so as to complete the retrieval of the index information.
8. The method according to claim 7, characterized in that, Determining the logical position of the index information of the target data page in the index data based on the identifier of the target data page and the segment statistics information in the metadata includes: The logical segment identifier to which the target data page belongs is determined based on the identifier of the target data page; From the segment statistics, obtain the total number of valid data pages whose indexes have been recorded in all logical segments before the logical segment identifier, and use this as the first quantity; Based on the bitmap of the data page, the number of all valid data pages within the logical segment corresponding to the logical segment identifier and before the target data page is counted, and this number is used as a second quantity. The logical position is determined based on the first quantity and the second quantity.
9. The method according to claim 7, characterized in that, After determining the logical position of the index information of the target data page in the index data to complete the retrieval of the index information, the method further includes: Based on the logical location, the index data segment storing the index information of the target data page is loaded from the index data into memory; Update the index information of multiple data pages contained in the index data segment to the index query structure in memory.
10. The method according to claim 7, characterized in that, The step of querying the data page existence bitmap in the metadata based on the identifier of the target data page to obtain a first query result regarding whether the target data page has been recorded in the global index block includes: Based on the identifier of the target data page, determine the bit offset of the target data page in the bitmap of the data page; If the bit value at the bit offset is a first predetermined value, then a first query result indicating that it has been recorded is generated; If the bit value at the bit offset is a second predetermined value, then the first query result indicating that it has not been recorded is generated.
11. A global index block generation apparatus, characterized in that, Applied to a storage node for managing logical storage units, the device includes: A monitoring module is used to monitor the amount of new data added to the logical storage unit; The first acquisition module is used to acquire the memory global index information of the logical storage unit when the amount of newly added data reaches a predetermined threshold. A generation module is used to persistently write the global memory index information into a preset data block to generate a global index block; The global index block includes index data and metadata: The index data includes multiple index segments, and each index segment contains index information for a preset number of data pages; The metadata stores location information used to query the index data.
12. A storage node fault recovery device based on global index blocks, characterized in that, Applied to a storage node for managing logical storage units, the device includes: A loading module is used to load incremental index information into memory when the storage node recovers from a fault. The incremental index information includes an index of the data written to the logical storage unit after the first historical time period. The second acquisition module is used to acquire a global index block pre-generated for the logical storage unit and load the metadata in the global index block into memory. The global index block also contains index data, which records the index information of the data pages written by the logical storage unit during the first historical time period. The metadata stores location information for querying the index data. The update module is used to update the service status of the storage node after loading the incremental index information and the metadata, so as to handle read and write requests.
13. An electronic device, characterized in that, include: A processor and a memory, the processor being configured to execute a computer program stored in the memory to implement the global index block generation method of any one of claims 1-4, and / or to implement the storage node fault recovery method based on global index blocks of any one of claims 5-10.
14. A storage medium, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the global index block generation method according to any one of claims 1-4, and / or to implement the storage node fault recovery method based on global index blocks according to any one of claims 5-10.