Data consistency detection method and system
By building a distributed hash table and usage status information in a distributed storage system for rapid comparison, the problem of inefficiency of traditional methods in high concurrency environments is solved, and efficient data consistency detection and optimized system performance is achieved.
Patent Information
- Application Number
- CN202412000491.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Traditional data consistency detection and repair methods lead to response delay and inefficiency in high concurrency environments, and cannot meet the requirements of modern distributed storage systems for high availability and high performance.
By constructing a distributed hash table (DHT), quickly locate the data block replica nodes, and use the first state information and the second state information to quickly compare, automatically coordinate the cluster nodes for data consistency detection.
It significantly improves the speed and efficiency of data consistency detection, reduces resource consumption, and optimizes system performance and user experience.
Smart Images

Figure CN119828981A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of storage technology, and in particular to a data consistency detection method and system. Background Art
[0002] In modern distributed storage systems, with the rapid increase in data volume and the diversification of application scenarios, distributed storage systems have become the main choice for enterprises and organizations to store and manage data. However, the frequent occurrence of data inconsistency has seriously affected the system performance and user experience.
[0003] Traditional data consistency detection and repair methods, such as the timestamp method, the two-phase commit method, and the remote multi-active method, have solved the data consistency problem to a certain extent, but have exposed a series of inefficient core defects in practical applications. First, the relevant technologies rely on frequent inter-node communication to ensure data consistency, which not only increases network overhead, but also causes significant communication delays, thereby affecting the overall performance of the system. This delay is particularly obvious in a high-concurrency environment. Users often experience obvious response delays when performing data read and write operations, which affects the user experience. Secondly, the process of comprehensive detection and repair of all replicas by the relevant technologies will introduce a lot of time delays, especially when the amount of data is large or the number of replicas is large, the efficiency of detection and repair is significantly reduced.
[0004] As data volumes increase and business needs change, the limitations of related technologies become increasingly apparent, and they are unable to meet the high availability and high performance requirements of modern distributed storage systems. Summary of the invention
[0005] The embodiments of the present disclosure provide a data consistency detection method and system, aiming to solve the problems existing in the above-mentioned background technology.
[0006] In order to solve the above technical problems, the present disclosure is implemented as follows: In a first aspect, an embodiment of the present disclosure provides a data consistency detection method, the method comprising: Determine the identifier of the target logical data block to be detected; Determine the identifier of the storage node where each of the multiple copies of the target logical data block is located according to the identifier of the target logical data block and a pre-created distributed hash table, wherein the distributed hash table is used to represent the identifier of the storage node where the multiple copies of each logical data block are located; According to the identifiers of the storage nodes where the multiple copies of the target logical data block are respectively located, locate the storage nodes where the multiple copies are respectively located, and obtain the first state information and the second state information of the copy from the storage nodes where the multiple copies are respectively located, wherein the first state information represents the number of state updates experienced by the copy in the distributed storage system, and the second state information represents the number of times the copy successfully writes data; Whether data consistency is satisfied between the multiple copies of the target logical data block is determined according to the first status information and / or the second status information of each of the multiple copies of the target logical data block.
[0007] Optionally, the distributed hash table is created according to the following steps: Creating a virtual disk in a distributed storage system, and dividing the virtual disk into a plurality of logical data blocks, each logical data block being assigned a one-to-one corresponding identifier; Determine a plurality of storage nodes in the distributed storage system and respective identifiers of the plurality of storage nodes; Performing hash calculations on the identifiers of the plurality of logical data blocks and the plurality of storage nodes, respectively, and mapping the plurality of data blocks and the plurality of storage nodes to a hash ring; For each logical data block, sequentially traverse the hash ring, and determine the n storage nodes closest to the logical data block as storage nodes that respectively store n copies of the logical data block, where n is an integer greater than or equal to 1; Based on the mapping relationship between the multiple copies of each logical data block and the storage nodes where the multiple copies of each logical data block are located, a distributed hash table is established to characterize the identifiers of the storage nodes where the multiple copies of each logical data block are located.
[0008] Optionally, the method further comprises: Obtaining third state information of the replica from the storage nodes where each of the multiple replicas is located, where the third state information is used to indicate whether the replica exists in the corresponding storage node; According to the third state value of each of the multiple copies of the target logical data block, determining whether the multiple copies of the target logical data block exist in the respective corresponding storage nodes; In the case where the copy of the target logical data block exists in the corresponding storage node, obtaining the first state information and the second state information of the copy from the storage node where the copy is located; In a case where the copy of the target logical data block does not exist in the corresponding storage node, it is determined that data missing exists between the multiple copies of the target logical data block.
[0009] Optionally, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are not all equal, it is determined that the multiple copies of the target logical data block do not satisfy data consistency.
[0010] Optionally, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are all equal, comparing the second status information of the multiple copies of the target logical data block; When the second status information of the multiple copies of the target logical data block are all equal, it is determined that the multiple copies of the target logical data block satisfy data consistency.
[0011] Optionally, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are all equal, comparing the second status information of the multiple copies of the target logical data block; When the second state information of the multiple copies of the target logical data block is not equal, reading the data content of the preset size of the target logical data block from the storage nodes where the multiple copies of the target logical data block are located respectively; Input the data content into a SHA1 hash function to obtain a string message digest of each of the multiple copies of the target logical data block; Comparing the character string message digests of the multiple copies of the target logical data block on the storage nodes where the multiple copies of the target logical data block are located; When the character string message digests of the multiple copies of the target logical data block are all equal, determining that data consistency is satisfied between the multiple copies of the target logical data block; When the character string message digests of the multiple copies of the target logical data block are not equal, it is determined that data consistency is not satisfied between the multiple copies of the target logical data block.
[0012] Optionally, the method further comprises: In the case where it is determined that there is data missing between the multiple copies of the target logical data block, or in the case where it is determined that the multiple copies of the target logical data block do not satisfy data consistency, among the multiple copies of the target logical data block, a copy having the largest value of the first state information or the largest value of the second state information is used as the latest copy of the target logical data block; Obtaining data content of the latest copy from the storage node where the latest copy of the target logical data block is located; The data content of the latest copy of the target logical data block is copied to the storage nodes where other copies of the target logical data block are located.
[0013] Optionally, the method further comprises: Monitoring the distributed storage system; In the case where a write operation to the virtual disk is detected, a logical data block to which data is to be written is determined as a write target data block; Locate the storage nodes where the multiple copies of the write object data block are located according to the identifier of the write object data block and the pre-created distributed hash table; On the storage nodes where the multiple copies of the write object data block are located, respectively writing the data into the multiple copies of the write object data block, wherein each copy has a space reserved in a data space of a preset size for recording the first state information and the second state information; When it is detected that the data is written successfully, the second status information of the copy where the data is written successfully is increased by one; The method further comprises: Monitoring the distributed storage system; When a change in the state of the distributed storage system is detected, the first state information of each replica in the distributed cluster is increased by one.
[0014] Optionally, the method further comprises: Monitoring the distributed cluster to identify risk anomalies; In the case where a risk anomaly is detected in the distributed cluster, a respective data consistency detection task is assigned to all storage nodes in the distributed cluster, wherein the data consistency detection task is used to instruct the storage node to determine whether multiple copies of the target logical data block to be detected satisfy data consistency; The method further comprises: In response to the detection command from the user end, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster.
[0015] Optionally, monitoring the distributed cluster and identifying abnormal risk conditions includes: Monitoring whether multiple storage nodes in the distributed cluster are in a fault state or an operation and maintenance state, and determining that the distributed cluster has a risk anomaly when any storage node is in a fault state or an operation and maintenance state; Monitoring the network delay between the plurality of storage nodes in the distributed cluster, and determining that the distributed cluster has a risk anomaly when the network delay is greater than a set threshold time; Monitoring whether an error is reported when the upper-layer business performs IO reading and writing on the virtual disk, and determining that a risk abnormality exists in the distributed cluster when an error is reported when the upper-layer business performs IO reading and writing on the virtual disk is monitored; The method further comprises: Monitor all the logical data blocks for data writing failures in their respective copies. If data writing failures are detected in any copy, determine that the distributed cluster has risk anomalies. If the total number of IO tasks for all storage nodes in the distributed cluster is less than a preset task threshold, assign respective data consistency detection tasks to all storage nodes in the distributed cluster.
[0016] Optionally, allocating data consistency detection tasks to all storage nodes in the distributed cluster includes: Determine, according to the identifier of the logical data block and the distributed hash table, respective initial lists of all storage nodes in the distributed cluster, wherein the initial lists are used to represent respective copies of a plurality of logical data blocks stored locally in the storage nodes; Determine duplicate copies from the initial lists of all storage nodes, and remove duplicate copies other than the first copy from their respective initial lists to obtain the final lists of all storage nodes; Based on the final list, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster, wherein the data consistency detection task of the replica stored locally in the storage node is preferentially assigned to the storage node.
[0017] Optionally, the method further comprises: When the number of replicas in the final lists of all storage nodes is unbalanced, the final lists are adjusted by the following formula:
[0018] In the formula,N is the number of storage nodes in the distributed cluster, M Indicates i The number of logical data blocks in the final list of storage nodes, C Indicates the number of copies, Indicates the total number of data detection tasks for all nodes. Indicates i The weight of the replica of the storage node in the local node, Indicates i The weight of the replicas of the storage node in other remote nodes; The allocating respective data consistency detection tasks to all storage nodes in the distributed cluster based on the final list includes: Based on the final lists adjusted by all storage nodes, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster, and the arg value of the final list after adjustment is less than the arg value of the final list before adjustment.
[0019] In a second aspect, an embodiment of the present disclosure provides a data consistency detection system, the system comprising a coordination node and a plurality of storage nodes, each storage node storing a copy of a plurality of logical data blocks; The coordination node is used to determine the identifier of the target logical data block to be detected; determine the identifier of the storage node where the multiple copies of the target logical data block are located according to the identifier of the target logical data block and a pre-created distributed hash table, and the distributed hash table is used to represent the identifier of the storage node where the multiple copies of each logical data block are located; locate the storage node where the multiple copies are located according to the identifier of the storage node where the multiple copies of the target logical data block are located, and obtain the first status information and the second status information of the copy from the storage node where the multiple copies are located, the first status information represents the number of status updates experienced by the copy in the distributed storage system, and the second status information represents the number of times the copy successfully writes data; The multiple storage nodes are used to determine whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block.
[0020] The technical solution provided by the embodiments of the present disclosure brings at least the following beneficial effects: The present disclosure significantly improves the ability to quickly locate the replica nodes of the target logical data block through the distributed hash table (DHT) technology. The core of DHT lies in efficient hash calculation, which enables each node to independently access and operate metadata (hash table), thereby realizing autonomous search and allocation of tasks. The dependence on the master node is eliminated, and the computing power of each node is fully utilized, thereby improving the overall computing efficiency. In addition, the present disclosure also introduces the first state information and the second state information, which provides an identification basis for the consistency judgment of the replica data. By quickly comparing the first state information and the second state information, inconsistent replicas can be quickly identified, avoiding the tedious one-by-one detection process in the related technology. The technical solution provided by the embodiment of the present disclosure not only speeds up the speed of consistency detection, but also reduces the consumption of resources. While improving the detection efficiency, it also optimizes the system performance and user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 It is a schematic diagram of the steps of a data consistency detection method provided by an embodiment of the present disclosure; Figure 2 It is a complete flow chart of a data consistency detection method provided by an embodiment of the present disclosure; Figure 3 It is a schematic diagram of the architecture of a data consistency detection system provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present disclosure to clearly and completely describe the technical solutions in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0024] In distributed storage systems, data inconsistency is a common and serious problem that directly affects the correctness of the system's business logic and user experience. Data inconsistency may be caused by a variety of factors, including network latency, node failure, data write failure or update error, concurrency control issues, and system design and implementation defects. Traditional data consistency detection and repair methods, such as timestamp methods, two-phase commit methods, and remote multi-active methods, usually require large network overhead and are prone to communication delays between nodes, thus affecting the normal operation of upper-level businesses. In addition, traditional methods are time-consuming and fail to fully utilize the computing power of distributed clusters.
[0025] In order to solve the inefficiency of the above-mentioned traditional consistency detection method, the embodiment of the present disclosure proposes to realize the rapid location of data copies by constructing a distributed hash table (DHT), and automatically coordinate cluster nodes to perform data consistency detection concurrently in combination with rapid comparison of status information. Figure 1 is a schematic diagram of the steps of a data consistency detection method provided by an embodiment of the present disclosure, such as Figure 1 As shown, the method includes: Step S101, determining the identifier of the target logical data block to be detected.
[0026] A logical data block (OBJ) is a basic unit for storing data in a distributed storage system. It divides a larger virtual disk into smaller, fixed-size data blocks for easy management and storage. In the disclosed design example, the size of the logical data block is set to 4M. Each logical data block has a unique identifier, which is a UUID (Universally Unique Identifier). The UUID is a string consisting of 12 hexadecimal digits, where the first 4 digits represent the serial number of the virtual disk (LUN) and the last 8 digits represent the serial number of the logical data block. The target logical data block is the object selected by the user or system for consistency detection and repair in a distributed storage system.
[0027] Step S102, determining the identifiers of the storage nodes where the multiple copies of the target logical data block are located according to the identifier of the target logical data block and a pre-created distributed hash table, wherein the distributed hash table is used to represent the identifiers of the storage nodes where the multiple copies of each logical data block are located.
[0028] The basic principle of the distributed hash table is to map the UUID of the logical data block to a hash ring through a hash function. On the hash ring, the UUIDs of the storage node and the data block are regarded as the positions on the ring, and the node storing the copy of the logical data block can be quickly found based on the UUID. Assume that the virtual disk LUN is divided into multiple logical data blocks (OBJs), and the UUID of each logical data block is as follows: OBJ1: UUID = A00100000001; OBJ2: UUID = A00100000002; OBJ3: UUID = A00100000003. At the same time, assume that there are three storage nodes, namely Node1, Node2 and Node3. Through hash function calculation, the following mapping relationship is obtained: The hash value of OBJ1 is mapped to Node1; The hash value of OBJ2 is mapped to Node2; The hash value of OBJ3 is mapped to Node3. The distributed hash table represents the mapping relationship shown in Table 1:
[0029] Table 1 Since each logical data block may have multiple copies, assuming that each logical data block has two copies, the distributed hash table actually represents the mapping relationship shown in Table 2:
[0030] Table 2 In this example, the target logical data block is assumed to be OBJ1, and multiple copies of the target logical block are stored on Node1 and Node2. By consulting the distributed hash table, the storage node where the copy of the target logical data block is located can be quickly found, so as to perform subsequent state information acquisition and consistency detection.
[0031] Step S103, according to the identifiers of the storage nodes where the multiple copies of the target logical data block are respectively located, locate the storage nodes where the multiple copies are respectively located, and obtain the first status information and the second status information of the copy from the storage nodes where the multiple copies are respectively located, the first status information represents the number of status updates experienced by the copy in the distributed storage system, and the second status information represents the number of times the copy successfully writes data.
[0032] Use known storage node identifiers to locate the specific storage node where each replica is located. This can be implemented through a network protocol (such as TCP / IP), sending a request to each node to obtain the status information of the relevant replica. The status information includes first status information and second status information. The first status information is cls_epoch, which represents the number of status updates experienced by the replica in the distributed storage system. It can be a counter that records the number of status changes experienced by the replica in the distributed storage system since its creation. The second status information is wr_num, which represents the number of times the replica successfully writes data. It can also be a counter that records the number of data operations that have been successfully written to the replica.
[0033] Step S104: determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block.
[0034] In a distributed storage system, data consistency means that all replicas should have the same data state at a certain moment. As described in step S103, the first state information cls_epoch records the number of state updates experienced by the replica in the distributed storage system. Whenever the state of the replica changes (for example, data writing, updating or fault recovery, etc.), the value of cls_epoch will increase automatically. By comparing the cls_epoch values of all replicas, it is determined whether these replicas have experienced the same state update. If the cls_epoch values of all replicas are the same, it means that their state updates are synchronized and data consistency is satisfied; if the cls_epoch values of a replica are different, it indicates that the replica may not be updated in time, and there is a risk of data inconsistency. The second state information wr_num records the number of times the replica successfully writes data, reflecting the number of successful data write operations received by the replica. By comparing the wr_num values of all replicas, it is determined whether the data writes of these replicas are consistent. If the wr_num values of all replicas are the same, it means that they have successfully received the same number of data write operations and data consistency is satisfied; if the wr_num values of a replica are different, it indicates that the replica may have data loss or fail to write data in time, resulting in data inconsistency.
[0035] The present disclosure significantly improves the ability to quickly locate the replica nodes of the target logical data block through the distributed hash table (DHT) technology. The core of DHT lies in efficient hash calculation, which enables each node to independently access and operate metadata (hash table), thereby realizing autonomous search and allocation of tasks. The dependence on the master node is eliminated, and the computing power of each node is fully utilized, thereby improving the overall computing efficiency. In addition, the present disclosure also introduces the first state information and the second state information, which provides an identification basis for the consistency judgment of the replica data. By quickly comparing the first state information and the second state information, inconsistent replicas can be quickly identified, avoiding the tedious one-by-one detection process in the related technology. The technical solution provided by the embodiment of the present disclosure not only speeds up the speed of consistency detection, but also reduces the consumption of resources. While improving the detection efficiency, it also optimizes the system performance and user experience.
[0036] In an optional implementation, the distributed hash table is created according to the following steps: Creating a virtual disk in a distributed storage system, and dividing the virtual disk into a plurality of logical data blocks, each logical data block being assigned a one-to-one corresponding identifier; Determine a plurality of storage nodes in the distributed storage system and respective identifiers of the plurality of storage nodes; Performing hash calculations on the identifiers of the plurality of logical data blocks and the plurality of storage nodes, respectively, and mapping the plurality of data blocks and the plurality of storage nodes to a hash ring; For each logical data block, sequentially traverse the hash ring, and determine the n storage nodes closest to the logical data block as storage nodes that respectively store n copies of the logical data block, where n is an integer greater than or equal to 1; Based on the mapping relationship between the multiple copies of each logical data block and the storage nodes where the multiple copies of each logical data block are located, a distributed hash table is established to characterize the identifiers of the storage nodes where the multiple copies of each logical data block are located.
[0037] The distributed hash algorithm used in step S102 is combined with a hash ring, that is, the distributed hash algorithm uses the structure of the hash ring to implement data storage and access. Figure 2 This is a complete flow chart of a data consistency detection method provided by an embodiment of the present disclosure. Figure 2 , here corresponds to Figure 2 The process of creating a distributed hash table in . In a distributed storage system, the user first creates a virtual disk (LUN). The virtual disk is a logical storage unit used to store data. In order to efficiently manage and store data in a distributed system, the virtual disk will be divided into multiple smaller logical data blocks (OBJs). Each logical data block has a unique identifier (UUID) for subsequent data management and access. Suppose the user creates a virtual disk of size 16MB. When dividing it into logical data blocks, the size of each data block is set to 4MB, so the virtual disk will be divided into 4 logical data blocks, namely: OBJ1: UUID = A00100000001; OBJ2: UUID = A00100000002; OBJ3: UUID = A00100000003; OBJ4: UUID = A00100000004. Next, multiple storage nodes in the distributed storage system are identified. Each storage node is responsible for storing part of the data, and each node has a unique identifier. The number and distribution of storage nodes will affect the storage strategy and access efficiency of the data. Assume that there are 3 storage nodes in the distributed storage system, namely: Node1: identified as N001; Node2: identified as N002; Node3: identified as N003. For the UUID of each logical data block and the identifier of each storage node, a hash function is used for hash calculation. The hash function converts the input identifier (UUID) into a fixed-length hash value, which will be mapped to a logical hash ring, which is a virtual structure used to represent the distribution of data blocks and storage nodes. Assuming that the SHA-256 hash function is used for calculation, the hash values obtained (simplified as an example) are: OBJ1: hash value = H1; OBJ2: hash value = H2; OBJ3: hash value = H3; OBJ4: hash value = H4; Node1: hash value = HN1; Node2: hash value = HN2; Node3: hash value = HN3. For each logical data block, traverse the hash ring sequentially to find the n storage nodes closest to the logical data block (n is an integer greater than or equal to 1). These storage nodes will be selected as the locations to store copies of the logical data block. Assuming n=2, after traversal: For OBJ1 (hash value H1), find the two nearest storage nodes as Node1 (HN1) and Node2 (HN2); For OBJ2 (hash value H2), find the two nearest storage nodes as Node2 (HN2) and Node3 (HN3); For OBJ3 (hash value H3), the two nearest storage nodes are found to be Node3 (HN3) and Node1 (HN1); For OBJ4 (hash value H4), the two nearest storage nodes are found to be Node1 (HN1) and Node2 (HN2). Based on the above mapping relationship, a distributed hash table (as shown in Table 3) is established to represent the identification of the storage nodes where multiple copies of each logical data block are located. The distributed hash table can be used to quickly find the location of the copy of the data block, thereby improving the efficiency of data access.
[0038]
[0039] Table 3 Through the above steps, the data organization structure is ensured to be clear, and the data distribution and access path are optimized. Multiple copies of each data block are stored on the nearest storage node, which enhances the redundancy of the data. The established distributed hash table can quickly locate the copy location of the data block, thereby improving the efficiency of data access and the reliability of the system and reducing the risk of data loss.
[0040] In an optional embodiment, the method further includes: Obtaining third state information of the replica from the storage nodes where each of the multiple replicas is located, where the third state information is used to indicate whether the replica exists in the corresponding storage node; According to the third state value of each of the multiple copies of the target logical data block, determining whether the multiple copies of the target logical data block exist in the respective corresponding storage nodes; In the case where the copy of the target logical data block exists in the corresponding storage node, obtaining the first state information and the second state information of the copy from the storage node where the copy is located; In a case where the copy of the target logical data block does not exist in the corresponding storage node, it is determined that data missing exists between the multiple copies of the target logical data block.
[0041] In a distributed storage system, each logical data block (OBJ) has multiple copies stored on different storage nodes. In order to ensure the reliability of the data, it is necessary to obtain the third state information (exist) related to the copy from each storage node. The third state information is used to characterize whether the copy actually exists in the corresponding storage node. Assume that there are three copies of the logical data block OBJ1, which are stored in Node1, Node2 and Node3 respectively. Requesting the third state information of OBJ1 from these three storage nodes may result in: Node1: exist = true (copy exists); Node2: exist = false (copy does not exist); Node3: exist = true (copy exists). Based on the third state information obtained from each storage node, determine whether multiple copies of the target logical data block exist in their corresponding storage nodes, which corresponds to Figure 2 The data existence detection process shown in FIG. 1 is a flow chart of data existence detection. If all copies exist, the data is complete. In this case, the first state information and the second state information of the copy are further obtained from the corresponding storage node. On the contrary, if any copy does not exist, it will be determined that there is data missing between multiple copies of the target logical data block. Continuing with OBJ1 as an example, it is checked that the copy of Node2 does not exist, so it is determined that the copy of OBJ1 is missing, and the subsequent repair task for the data missing will be initiated. It should be noted that Figure 2The data existence check and data consistency check shown can be performed in a logical order, first checking the data existence, and then checking the data consistency if the data existence passes. It can also be used as two separate judgment processes, that is, judging whether the data existence and data consistency are satisfied respectively, and starting the subsequent data repair process according to the corresponding judgment results.
[0042] Through the above steps, the distributed storage system can effectively monitor and manage the replica status of logical data blocks, and promptly identify and handle data missing problems.
[0043] In an optional implementation, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first state information and / or the second state information of each of the multiple copies of the target logical data block includes: Step S201, comparing first status information of each of the multiple copies of the target logical data block; As mentioned above, the first state information (cls_epoch) represents the number of state updates that the replica has experienced in the distributed storage system, that is, a serial number used to represent the version of the replica or the cluster state. Whenever the cluster state changes (for example, node failure, data update, etc.), the value of the first state information cls_epoch will increase. In an optional embodiment, the method also includes: monitoring the distributed storage system; when a change in the state of the distributed storage system is detected, increasing the first state information of each replica in the distributed cluster by one.
[0044] See also Figure 2 In the disclosed embodiments, the environment of the distributed storage system is continuously monitored. Monitoring involves tracking various parameters such as the health status of each node, data integrity, network connection, load conditions, etc. The purpose is to promptly discover potential problems and state changes in the system. During the monitoring process, changes in the state of the distributed storage system are captured, including: node failures (such as power outages, network interruptions, etc.), data updates or write operations, system maintenance or upgrades, and load changes. The detection of state changes can be achieved by setting thresholds, event triggering mechanisms, or regular polling. When a state change is detected, the first state information (cls_epoch) of each replica in the distributed cluster is updated. Specifically, the first state information cls_epoch value of each replica is increased by one to reflect changes in the cluster state.
[0045] The first state information cls_epoch values of the collected multiple copies of the target logical data block are compared. The purpose of the comparison is to check whether the states of all copies are consistent to ensure that they reflect the same version of data.
[0046] Step S202: When the first status information of the multiple copies of the target logical data block are not equal, it is determined that the multiple copies of the target logical data block do not satisfy data consistency.
[0047] If it is found during the comparison process that the cls_epoch values of the multiple copies of the target logical data block are not all equal, that is, there are at least two copies with unequal values of the first state information, it will be determined that the multiple copies of the target logical data block meet data consistency, which means that the data of at least one copy may be outdated or out of sync.
[0048] In an optional implementation, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first state information and / or the second state information of each of the multiple copies of the target logical data block includes: Step S301: compare first status information of a plurality of copies of the target logical data block.
[0049] Similar to step S201 , the collected first state information cls_epoch values of the multiple copies of the target logical data block are compared.
[0050] Step S302: When the first status information of the multiple copies of the target logical data block are all equal, compare the second status information of the multiple copies of the target logical data block.
[0051] If the result of the judgment in step S301 is that the cls_epoch values of all replicas are equal, the second status information (wr_num) of all replicas is further checked. The second status information wr_num represents the number of times the replica successfully writes data, and is used to measure the frequency of data updates. In an optional embodiment, the method also includes: monitoring the distributed storage system; in the case of monitoring a write operation to a virtual disk, determining the logical data block to which the data is written as a write object data block; locating the storage nodes where the multiple replicas of the write object data block are located according to the identifier of the write object data block and a pre-created distributed hash table; writing the data to the multiple replicas of the write object data block on the storage nodes where the multiple replicas of the write object data block are located, wherein each replica has space reserved in a data space of a preset size for recording the first status information and the second status information; in the case of detecting that the data is written successfully, increasing the second status information of the replica to which the data is written successfully by one.
[0052] Continuously monitor the environment of the distributed storage system to capture various operations and status changes. When a write operation to a virtual disk is monitored, identify which logical data blocks need to be written. These written data blocks are used as write object data blocks. According to the identifier (UUID) of the write object data block and the pre-created distributed hash table, quickly locate the storage node where multiple copies of the data block are located. On the determined storage node, write the data to multiple copies of the write object data block respectively. Each copy has a space reserved for recording the first state information and the second state information in its preset size of data space. The reserved space enables each copy to independently record its state, which is convenient for subsequent data consistency detection and repair. When it is detected that the data is written successfully, the second state information of the successfully written copy is increased by one. For example, if Node1 successfully writes the data, the second state information of Node1 will increase by 1, reflecting the update of the number of write times of the copy.
[0053] Step S303: When the second status information of the multiple copies of the target logical data block are all equal, it is determined that the multiple copies of the target logical data block satisfy data consistency.
[0054] If the second status information wr_num values of all replicas are equal, it means that all replicas have received the same number of write operations in the same time, and it is determined that data consistency is satisfied among the multiple replicas of the target logical data block.
[0055] In an optional implementation, determining whether data consistency is satisfied between the multiple copies of the target logical data block according to the first state information and / or the second state information of each of the multiple copies of the target logical data block includes: Step S401: compare first status information of a plurality of copies of the target logical data block.
[0056] Step S402: When the first status information of the multiple copies of the target logical data block are all equal, compare the second status information of the multiple copies of the target logical data block.
[0057] Step S403, when the second state information of the multiple copies of the target logical data block is not equal, read the data content of the preset size of the target logical data block from the storage nodes where the multiple copies of the target logical data block are located respectively.
[0058] Contrary to the judgment result of step S402, when the second state information of multiple copies of the target logical data block are not equal, that is, when there are copies with unequal second state information wr_num values, the data content of a preset size of the target logical data block is read from the storage node where each copy is located.
[0059] Step S404: input the data content into a SHA1 hash function to obtain a character string message digest of each of the multiple copies of the target logical data block.
[0060] The data content read by each replica is input into the SHA1 hash function to generate a string message digest for each replica. A 40-byte string message digest of each replica is obtained to characterize the data content. The string message digest is a unique representation of the data content and can be effectively used to compare the consistency of data. The disclosed embodiment proposes to compare the digests instead of directly comparing the data content, which can improve efficiency because the size of the digest is much smaller than the original data.
[0061] Step S405 , comparing the character string message digests of the multiple copies of the target logical data block on the storage nodes where the multiple copies of the target logical data block are located.
[0062] On the storage nodes where the multiple copies of the target logical data block are located, the string message digest generated by each copy is compared.
[0063] Step S406: When the character string message digests of the multiple copies of the target logical data block are all equal, it is determined that the multiple copies of the target logical data block satisfy data consistency.
[0064] If the string message digests of all replicas are equal, it means that the data contents of these replicas are consistent, and it is determined that data consistency is satisfied among multiple replicas of the target logical data block.
[0065] Step S407, when the string message digests of the multiple copies of the target logical data block are not equal, it is determined that the multiple copies of the target logical data block do not meet data consistency. In other words, in a distributed storage system, all copies contain the same data, and user access to data is reliable.
[0066] On the contrary, if the string message digests of all the replicas are not equal, that is, there are at least two replicas whose string message digests are not equal, it is determined that data consistency is not satisfied among the multiple replicas of the target logical data block.
[0067] By gradually comparing the first state information / second state information and data content of the replicas, the consistency of data in a distributed storage environment can be effectively detected and confirmed, ensuring the accuracy of data in a multi-copy environment, thereby reducing the risk of data loss and inconsistency.
[0068] In an optional embodiment, the method further includes: When it is determined that there is data missing between multiple copies of the target logical data block, or when it is determined that data consistency is not satisfied between the multiple copies of the target logical data block, the copy with the largest value of the first state information or the largest value of the second state information among the multiple copies of the target logical data block is used as the latest copy of the target logical data block; the data content of the latest copy is obtained from the storage node where the latest copy of the target logical data block is located; and the data content of the latest copy of the target logical data block is copied to the storage nodes where other copies of the target logical data block are located.
[0069] See also Figure 2 , when it is detected that there is data missing (some copies do not exist) or data inconsistency (the contents between copies are different) between multiple copies of the target logical data block, the following measures need to be taken to restore consistency, that is, to start the repair process for these two situations (data missing, data inconsistency). Select one from multiple copies as the latest copy, and the latest copy contains the latest valid data. The selection criteria are as follows: compare the first state information cls_epoch values of all copies and select the copy with the largest value. This means that the copy is the latest, because cls_epoch reflects the update status of the copy. If there are multiple copies with the same first state information cls_epoch value, further compare the second state information wr_num values of these copies and select the copy with the largest value. The second state information wr_num represents the number of writes, which is used to measure the update frequency of the copy. The copy with the largest value of the first state information or the second state information can also be randomly selected as the latest copy of the target logical data block.
[0070] Obtaining the data content from the storage node where the latest replica is located is equivalent to obtaining the latest valid data. Copying the data content obtained from the latest replica to the storage nodes where other replicas are located, that is, synchronizing the latest valid data to all replicas to ensure consistency between them. The above description is a general data repair process for data missing and data inconsistency. Users can also make corresponding configurations as needed, and this disclosure does not limit this.
[0071] Through the above steps, when faced with data loss or inconsistency in the distributed storage system, data consistency can be restored quickly and effectively. By selecting the latest copy and copying its data content, data accuracy is maintained, thereby improving the overall system availability and user experience.
[0072] In an optional embodiment, the method further includes: monitoring the distributed cluster to identify risk anomalies; when risk anomalies are detected in the distributed cluster, allocating respective data consistency detection tasks to all storage nodes in the distributed cluster, wherein the data consistency detection tasks are used to instruct the storage nodes to determine whether data consistency is satisfied between multiple copies of the target logical data blocks to be detected.
[0073] See also Figure 2 , the trigger mechanism of consistency detection provided by the embodiment of the present disclosure includes automatic trigger detection and manual automatic trigger detection. First, the mechanism of automatic trigger detection is introduced. Continuously monitor the distributed cluster to identify risk abnormalities. In an optional implementation, the monitoring of the distributed cluster to identify risk abnormalities includes: monitoring whether the multiple storage nodes in the distributed cluster are in a fault state or an operation and maintenance state, and determining that the distributed cluster has a risk abnormality when any storage node is in a fault state or an operation and maintenance state; monitoring the network delay between the multiple storage nodes in the distributed cluster, and determining that the distributed cluster has a risk abnormality when the network delay is greater than the set threshold time; monitoring whether the upper-layer business has an error when performing IO reading and writing on the virtual disk, and determining that the distributed cluster has a risk abnormality when it is monitored that the upper-layer business has an error when performing IO reading and writing on the virtual disk.
[0074] First, continuously monitor the status of multiple storage nodes in the distributed cluster, including: fault status (nodes cannot work properly due to hardware failure, software crash, network disconnection, etc.) and operation and maintenance status (nodes are undergoing maintenance operations, such as restart, upgrade or other maintenance activities, and may be temporarily unavailable). Nodes in fault or operation and maintenance status may cause data unavailability or data consistency problems. If any storage node is in a fault state or operation and maintenance state, it is determined that there is a risk abnormality in the distributed cluster. Second, monitor the network latency between storage nodes to ensure smooth communication between nodes. Excessive network latency may cause data synchronization delays, request timeouts and reduced user experience. If the network latency exceeds the set threshold (for example, exceeds a certain time limit), it is determined that there is a risk abnormality in the distributed cluster. Third, monitor whether there is an error when the upper-layer business performs input and output (IO) operations on the virtual disk. Errors in IO operations may indicate data corruption, storage node failure or other problems. If errors are detected during the IO reading and writing process (for example, write failure, read error, etc.), it is determined that there is a risk abnormality in the distributed cluster.
[0075] Once a risk anomaly is detected, each storage node in the cluster is automatically assigned a data consistency detection task. The data consistency detection task instructs each storage node to check whether the multiple copies of the target logical data block it manages meet the data consistency. The task content of the data consistency detection task includes the task process of comparing the status information of the copies, reading the data content, generating the hash summary, etc. as described above to determine the consistency between the copies.
[0076] The method also includes: monitoring whether there are data writing failures in the respective copies of all logical data blocks, determining that there is a risk abnormality in the distributed cluster when any copy is monitored to have a data writing failure, and assigning respective data consistency detection tasks to all storage nodes in the distributed cluster when the total number of IO tasks of all storage nodes in the distributed cluster is less than a preset task volume threshold.
[0077] Active triggering also includes a situation, which is described in detail below, monitoring whether there is a failure in the data write operation of each copy of all logical data blocks. If it is found during the monitoring process that any copy has a data write failure (for example, write timeout, storage node cannot respond, etc.), the data write failure may cause data loss or inconsistency, and it will be determined that there is a risk abnormality in the distributed cluster. At the same time, the total number of IO tasks of all storage nodes in the distributed cluster is monitored and compared with the preset task volume threshold. When the total number of IO tasks is less than the preset task volume threshold, all storage nodes in the distributed cluster will be assigned their own data consistency detection tasks. That is, when it is confirmed that there is a data write failure and the number of IO tasks is small, a data consistency detection task is actively assigned to each storage node, instructing them to check the data consistency between the logical data block copies they manage. In the case of such active triggering, the embodiment of the present disclosure is intended to perform detection when there are fewer IO tasks, which can effectively utilize system resources and avoid detection under high load conditions, thereby reducing the impact on upper-level services.
[0078] The method further includes: in response to a detection command from the user end, allocating respective data consistency detection tasks to all storage nodes in the distributed cluster.
[0079] Here we introduce the mechanism of manually triggering detection. Users can actively trigger data consistency detection by sending detection commands. Users can send detection commands to the distributed storage system through the management interface or command line interface. The detection command can be a detection request for a specific logical data block, or a comprehensive consistency check for the entire cluster.
[0080] Upon receiving a detection command from the user, it immediately responds and assigns each storage node in the distributed cluster its own data consistency detection task. Optionally, the detection results can be fed back to the user to help the user make further decisions, such as whether data repair or other maintenance operations are needed.
[0081] In an optional embodiment, the data consistency detection task is assigned to all storage nodes in the distributed cluster, including: determining the initial list of all storage nodes in the distributed cluster according to the identifier of the logical data block and the distributed hash table, the initial list being used to represent the copies of multiple logical data blocks stored locally in the storage node; determining duplicate copies from the initial lists of all storage nodes, and removing duplicate copies other than the first copy from the corresponding initial lists to obtain the final lists of all storage nodes; based on the final list, allocating data consistency detection tasks to all storage nodes in the distributed cluster, wherein storage nodes are preferentially allocated data consistency detection tasks for the copies stored locally in the storage nodes.
[0082] As mentioned above, each logical data block has a unique identifier (UUID). The distributed hash table DHT is used to store and locate the replica information of the logical data block and map the identifier of the logical data block to the address of the storage node.
[0083] Assume that there are three logical data blocks: OBJ1, OBJ2, and OBJ3, which are distributed on three storage nodes (Node A, Node B, Node C). According to the distributed hash table, the initial list may be as follows: Node A: OBJ1 (copy 1), OBJ2 (copy 1), OBJ3 (copy 1); Node B: OBJ1 (copy 2), OBJ2 (copy 1); Node C: OBJ1 (copy 3), OBJ3 (copy 2). Considering that the same logical data block may have multiple copies on multiple nodes, duplicate detection not only wastes computing resources and time, but may also cause unnecessary network overhead and load. The disclosed embodiment proposes to remove redundant duplicate copies and retain only one copy for detection, which can ensure that the detection process is more efficient, reduce the system burden, and avoid potential inconsistency problems caused by duplicate detection.
[0084] From the initial list of all storage nodes, duplicate copies are identified. Duplicate copies are when there are multiple copies of the same logical data block on different nodes. In the above example, OBJ1 has copies on three nodes (copy 1, 2, 3), so it is a duplicate copy. OBJ2 has copies on both Node A and Node B, and OBJ3 has copies on Node A and Node C. For each duplicate copy, keep the first copy and remove the others from their respective initial lists. After processing, the final list of the above example will look like this: Node A (keep copy 1): OBJ1 (copy 1), OBJ2 (copy 1), OBJ3 (copy 1); Node B (remove copy 2 of OBJ1): OBJ2 (copy 1); Node C (remove copy 3 of OBJ1 and copy 2 of OBJ3): (none).
[0085] According to the final list, each storage node is assigned a data consistency check task. The nodes are given priority to be assigned data consistency check tasks for locally stored replicas. In the above example, node A will perform the tasks of checking OBJ1 (replica 1), checking OBJ2 (replica 1), and checking OBJ3 (replica 1). Node B will perform the task of checking OBJ2 (replica 1).
[0086] Node C has no replicas and therefore no detection tasks.
[0087] Through the above steps, the distributed storage system can effectively assign data consistency detection tasks to each storage node. By identifying and removing duplicate copies, each node only needs to check its locally stored copies, thereby improving detection efficiency and reducing unnecessary workload.
[0088] In an optional embodiment, the method further includes: When the number of replicas in the final lists of all storage nodes is unbalanced, the final lists are adjusted by the following formula:
[0089] In the formula, N is the number of storage nodes in the distributed cluster, M Indicates i The number of logical data blocks in the final list of storage nodes, C Indicates the number of copies, Indicates the total number of data detection tasks for all nodes. Indicates i The weight of the replica of the storage node in the local node, Indicates i The weight of the replicas of a storage node in other remote nodes.
[0090] In a distributed storage system, ensuring that the detection tasks of each storage node are balanced can avoid the situation where some nodes are overloaded while other nodes are idle. To achieve this goal, when the number of copies in the final list of all storage nodes is uneven, the final list can be adjusted by the above formula. Local weight Indicates the weight of the replica of the i-th storage node in the local node, which is related to the read and write rate of the node. The higher the read and write rate, the smaller the weight, which means that the node can handle more tasks. Remote weight Represents the weight of the replica of the i-th storage node in other remote nodes, which is related to the network transmission rate from this node to the remote node. The higher the transmission rate, the smaller the weight, which means that the communication efficiency between nodes is higher. The arg value before adjustment is large, which means that there are more detection tasks to be processed in the distributed storage system. Specifically, there are two reasons. On the one hand, the number of replicas between storage nodes is unevenly distributed, resulting in some nodes taking on too many detection tasks. On the other hand, there are redundant detection tasks, which may be because the replicas of the same data block are repeatedly detected on multiple nodes. The embodiment of the present disclosure calculates the task volume of each node through the above formula to determine the number of detection tasks that each node should undertake. After calculating the weight and task volume of each node, task redistribution will be performed. Specifically, nodes with a large number of replicas and a large task volume (overloaded nodes) are found. Nodes with a small number of replicas and a small task volume (idle nodes) are identified. Some detection tasks in overloaded nodes are transferred to idle nodes to achieve load balancing. Through the above adjustment logic, the arg value will reach a minimum, and the task volume of all nodes will tend to be balanced.
[0091] The allocating respective data consistency detection tasks to all storage nodes in the distributed cluster based on the final list includes: Based on the final lists adjusted by all storage nodes, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster, and the arg value of the final list after adjustment is less than the arg value of the final list before adjustment.
[0092] In the disclosed embodiment, by calculating weights, evaluating task volumes and reallocating tasks, the distributed storage system can effectively adjust the final list of storage nodes to ensure balanced distribution of data consistency detection tasks, thereby improving system performance, optimizing resource utilization, and reducing potential failure risks.
[0093] Figure 3 is a schematic diagram of the architecture of a data consistency detection system provided by an embodiment of the present disclosure, such as Figure 3 As shown, the system includes a coordination node and multiple storage nodes, and each storage node stores respective copies of multiple logical data blocks.
[0094] The coordination node, as the management and control center of the system, is responsible for task management, replica location, status information acquisition consistency judgment, decision-making and scheduling, and is the main body for allocating data consistency detection tasks. Figure 3The coordination node is deployed in the task allocation and delivery device, and is used to determine the identifier of the target logical data block to be detected; according to the identifier of the target logical data block and the pre-created distributed hash table, the identifier of the storage node where the multiple copies of the target logical data block are located is determined, and the distributed hash table is used to represent the identifier of the storage node where the multiple copies of each logical data block are located; according to the identifier of the storage node where the multiple copies of the target logical data block are located, the storage node where the multiple copies are located is located, and the first status information and the second status information of the copy are obtained from the storage node where the multiple copies are located, the first status information represents the number of status updates experienced by the copy in the distributed storage system, and the second status information represents the number of times the copy successfully writes data.
[0095] The multiple storage nodes, as the basic components of this system, rely on the data consistency detection device to implement the data detection function, and are used to determine whether the multiple copies of the target logical data block meet data consistency based on the first status information and / or second status information of each of the multiple copies of the target logical data block.
[0096] See also Figure 3 In addition to the task allocation and delivery device, the data distribution device, the copy status identification device, the detection trigger device, the data consistency detection device and the data repair device work in coordination with the task allocation and delivery device and multiple storage nodes through step-by-step linkage to realize the above-mentioned data consistency detection method disclosed in the present invention.
[0097] Specifically, the data distribution device is responsible for dividing the virtual disk into multiple logical data blocks and distributing these data blocks to different storage nodes, and creating a distributed hash table to record the copy of each logical data block and its corresponding storage node.
[0098] The replica state identification device records state information in each replica, including first state information and second state information of the replica. The replica state identification device is used to provide state information of the replica for subsequent data consistency detection and repair process.
[0099] The detection trigger device is responsible for monitoring the system status and user instructions and triggering data consistency detection. It is used to decide when to perform data consistency detection based on risk assessment results and user commands.
[0100] The data consistency detection device determines whether the data copies meet the consistency based on the status information of each copy. The data consistency detection device compares the first status information and / or the second status information of the copy, identifies the inconsistent copy and marks it as an object that needs to be repaired, thereby ensuring the reliability of the data.
[0101] The data repair device is responsible for performing data repair operations when data inconsistency or copy loss is detected. The data repair device is used to restore the copy with missing data or inconsistent data with the help of the latest copy.
[0102] The task allocation and delivery device is responsible for allocating data consistency detection and repair tasks to each storage node. The task allocation and delivery device is used to coordinate the work of each storage node so that each node can independently and parallelly perform detection and repair tasks.
[0103] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, devices, electronic devices, and storage media. Therefore, the embodiments of the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present disclosure may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0104] The embodiments of the present disclosure are described with reference to the flowcharts and / or block diagrams of the methods and systems according to the embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing terminal device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable terminal device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0105] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure.
[0106] Finally, it should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "include..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements. A data consistency detection method and system provided by the present disclosure are described in detail above. The principles and implementation methods of the present disclosure are described in this article using specific examples. The description of the above embodiments is only used to help understand the method and its core idea of the present disclosure; at the same time, for those of ordinary skill in the art, according to the idea of the present disclosure, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present disclosure.
Claims
1. A data consistency detection method, characterized in that: The method comprises: Determine the identifier of the target logical data block to be detected; Determine the identifier of the storage node where each of the multiple copies of the target logical data block is located according to the identifier of the target logical data block and a pre-created distributed hash table, wherein the distributed hash table is used to represent the identifier of the storage node where the multiple copies of each logical data block are located; According to the identifiers of the storage nodes where the multiple copies of the target logical data block are respectively located, locate the storage nodes where the multiple copies are respectively located, and obtain the first state information and the second state information of the copy from the storage nodes where the multiple copies are respectively located, wherein the first state information represents the number of state updates experienced by the copy in the distributed storage system, and the second state information represents the number of times the copy successfully writes data; Whether data consistency is satisfied between the multiple copies of the target logical data block is determined according to the first status information and / or the second status information of each of the multiple copies of the target logical data block.
2. The method according to claim 1, characterized in that Follow the steps below to create the distributed hash table: Creating a virtual disk in a distributed storage system, and dividing the virtual disk into a plurality of logical data blocks, each logical data block being assigned a one-to-one corresponding identifier; Determine a plurality of storage nodes in the distributed storage system and respective identifiers of the plurality of storage nodes; Performing hash calculations on the identifiers of the plurality of logical data blocks and the plurality of storage nodes, respectively, and mapping the plurality of data blocks and the plurality of storage nodes to a hash ring; For each logical data block, sequentially traverse the hash ring, and determine the n storage nodes closest to the logical data block as storage nodes that respectively store n copies of the logical data block, where n is an integer greater than or equal to 1; Based on the mapping relationship between the multiple copies of each logical data block and the storage nodes where the multiple copies of each logical data block are located, a distributed hash table is established to characterize the identifiers of the storage nodes where the multiple copies of each logical data block are located.
3. The method according to claim 1, characterized in that The method further comprises: Obtaining third state information of the replica from the storage nodes where each of the multiple replicas is located, where the third state information is used to indicate whether the replica exists in the corresponding storage node; According to the third state value of each of the multiple copies of the target logical data block, determining whether the multiple copies of the target logical data block exist in the respective corresponding storage nodes; In the case where the copy of the target logical data block exists in the corresponding storage node, obtaining the first state information and the second state information of the copy from the storage node where the copy is located; In a case where the copy of the target logical data block does not exist in the corresponding storage node, it is determined that data missing exists between the multiple copies of the target logical data block.
4. The method according to claim 1, characterized in that: The determining, according to the first status information and / or the second status information of each of the multiple copies of the target logical data block, whether the multiple copies of the target logical data block satisfy data consistency includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are not all equal, it is determined that the multiple copies of the target logical data block do not satisfy data consistency.
5. The method according to claim 1, characterized in that The determining, according to the first status information and / or the second status information of each of the multiple copies of the target logical data block, whether the multiple copies of the target logical data block satisfy data consistency includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are all equal, comparing the second status information of the multiple copies of the target logical data block; When the second status information of the multiple copies of the target logical data block are all equal, it is determined that the multiple copies of the target logical data block satisfy data consistency.
6. The method according to claim 1, characterized in that The determining, according to the first status information and / or the second status information of each of the multiple copies of the target logical data block, whether the multiple copies of the target logical data block satisfy data consistency includes: Comparing first status information of each of the multiple copies of the target logical data block; When the first status information of the multiple copies of the target logical data block are all equal, comparing the second status information of the multiple copies of the target logical data block; When the second state information of the multiple copies of the target logical data block is not equal, reading the data content of the preset size of the target logical data block from the storage nodes where the multiple copies of the target logical data block are located respectively; Input the data content into a SHA1 hash function to obtain a string message digest of each of the multiple copies of the target logical data block; Comparing the character string message digests of the multiple copies of the target logical data block on the storage nodes where the multiple copies of the target logical data block are located; When the character string message digests of the multiple copies of the target logical data block are all equal, determining that data consistency is satisfied between the multiple copies of the target logical data block; When the character string message digests of the multiple copies of the target logical data block are not equal, it is determined that data consistency is not satisfied between the multiple copies of the target logical data block.
7. The method according to claim 3, characterized in that The method further comprises: In the case where it is determined that there is data missing between the multiple copies of the target logical data block, or in the case where it is determined that the multiple copies of the target logical data block do not satisfy data consistency, among the multiple copies of the target logical data block, a copy having the largest value of the first state information or the largest value of the second state information is used as the latest copy of the target logical data block; Obtaining data content of the latest copy from the storage node where the latest copy of the target logical data block is located; The data content of the latest copy of the target logical data block is copied to the storage nodes where other copies of the target logical data block are located.
8. The method according to claim 1, characterized in that The method further comprises: Monitoring the distributed storage system; In the case where a write operation to the virtual disk is detected, a logical data block to which data is to be written is determined as a write target data block; Locate the storage nodes where the multiple copies of the write object data block are located according to the identifier of the write object data block and the pre-created distributed hash table; On the storage nodes where the multiple copies of the write object data block are located, respectively writing the data into the multiple copies of the write object data block, wherein each copy has a space reserved in a data space of a preset size for recording the first state information and the second state information; When it is detected that the data is written successfully, the second status information of the copy where the data is written successfully is increased by one; The method further comprises: Monitoring the distributed storage system; When a change in the state of the distributed storage system is detected, the first state information of each replica in the distributed cluster is increased by one.
9. The method according to claim 1, characterized in that: The method further comprises: Monitoring the distributed cluster to identify risk anomalies; In the case where a risk anomaly is detected in the distributed cluster, a respective data consistency detection task is assigned to all storage nodes in the distributed cluster, wherein the data consistency detection task is used to instruct the storage node to determine whether multiple copies of the target logical data block to be detected satisfy data consistency; The method further comprises: In response to the detection command from the user end, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster.
10. The method according to claim 9, characterized in that The monitoring of the distributed cluster and identifying risk anomalies includes: Monitoring whether multiple storage nodes in the distributed cluster are in a fault state or an operation and maintenance state, and determining that the distributed cluster has a risk anomaly when any storage node is in a fault state or an operation and maintenance state; Monitoring the network delay between the plurality of storage nodes in the distributed cluster, and determining that the distributed cluster has a risk anomaly when the network delay is greater than a set threshold time; Monitoring whether an error is reported when the upper-layer business performs IO reading and writing on the virtual disk, and determining that a risk abnormality exists in the distributed cluster when an error is reported when the upper-layer business performs IO reading and writing on the virtual disk is monitored; The method further comprises: Monitor all the logical data blocks for data writing failures in their respective copies. If data writing failures are detected in any copy, determine that the distributed cluster has risk anomalies. If the total number of IO tasks for all storage nodes in the distributed cluster is less than a preset task threshold, assign respective data consistency detection tasks to all storage nodes in the distributed cluster.
11. The method according to claim 9, characterized in that The allocating data consistency detection tasks to all storage nodes in the distributed cluster includes: Determine, according to the identifier of the logical data block and the distributed hash table, respective initial lists of all storage nodes in the distributed cluster, wherein the initial lists are used to represent respective copies of a plurality of logical data blocks stored locally in the storage nodes; Determine duplicate copies from the initial lists of all storage nodes, and remove duplicate copies other than the first copy from their respective initial lists to obtain the final lists of all storage nodes; Based on the final list, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster, wherein the data consistency detection task of the replica stored locally in the storage node is preferentially assigned to the storage node.
12. The method according to claim 11, characterized in that The method further comprises: When the number of replicas in the final lists of all storage nodes is unbalanced, the final lists are adjusted by the following formula: In the formula, N is the number of storage nodes in the distributed cluster, M Indicates i The number of logical data blocks in the final list of storage nodes, C Indicates the number of copies, Indicates the total number of data detection tasks for all nodes. Indicates i The weight of the replica of the storage node in the local node, Indicates i The weight of the replicas of the storage node in other remote nodes; The allocating respective data consistency detection tasks to all storage nodes in the distributed cluster based on the final list includes: Based on the final lists adjusted by all storage nodes, respective data consistency detection tasks are assigned to all storage nodes in the distributed cluster, and the arg value of the final list after adjustment is less than the arg value of the final list before adjustment.
13. A data consistency detection system, characterized in that: The system includes a coordination node and multiple storage nodes, each storage node storing a copy of multiple logical data blocks; The coordination node is used to determine the identifier of the target logical data block to be detected; determine the identifier of the storage node where the multiple copies of the target logical data block are located according to the identifier of the target logical data block and a pre-created distributed hash table, and the distributed hash table is used to represent the identifier of the storage node where the multiple copies of each logical data block are located; locate the storage node where the multiple copies are located according to the identifier of the storage node where the multiple copies of the target logical data block are located, and obtain the first status information and the second status information of the copy from the storage node where the multiple copies are located, the first status information represents the number of status updates experienced by the copy in the distributed storage system, and the second status information represents the number of times the copy successfully writes data; The multiple storage nodes are used to determine whether data consistency is satisfied between the multiple copies of the target logical data block according to the first status information and / or the second status information of each of the multiple copies of the target logical data block.
Citation Information
Patent Citations
File processing method based on distributed file system, system, and client
CN102843403A
Distributed parallel high-speed read-write system and method based on IPFS
CN111274222A
Distributed database self-adaptive copy selection method and device
CN116610756A
Distributed block storage data access method based on stateful DHT and storage system
CN116627315A
Data processing method, system and apparatus, storage medium, and electronic device
WO2024148824A1