A data consistency detection method and system
By using distributed hash table (DHT) technology to quickly locate data block replica nodes and use state information for consistency judgment, the problem of low efficiency in traditional methods is solved, and the speed of data consistency detection and system performance are improved.
Patent Information
- Application Number
- CN202412000491.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-12-31
AI Technical Summary
Traditional data consistency detection methods are inefficient in distributed storage systems, resulting in high network overhead and communication latency, which affects system performance and user experience, and fails to meet the requirements of high availability and high performance.
Distributed Hash Table (DHT) technology is used to quickly locate data block replica nodes, and consistency judgment is performed by using first and second state information, eliminating the dependence on the master node and improving computational efficiency and detection speed.
It significantly improves the speed and system performance of data consistency detection, reduces resource consumption, and optimizes the user experience.
Smart Images

Figure CN119828981B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of storage technology, and in particular to a data consistency detection method and system. Background Technology
[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 primary choice for enterprises and organizations to store and manage data. However, the frequent occurrence of data inconsistencies severely impacts system performance and user experience.
[0003] Traditional data consistency detection and repair methods, such as timestamp methods, two-phase commit methods, and multi-site active-active methods, while solving data consistency problems to some extent, have revealed a series of core inefficiencies in practical applications. First, these technologies rely on frequent inter-node communication to ensure data consistency, which not only increases network overhead but also leads to significant communication latency, thus impacting overall system performance. This latency is particularly noticeable in high-concurrency environments, where users often experience significant response delays when performing data read and write operations, affecting user experience. Second, the process of comprehensively detecting and repairing all replicas introduces substantial time latency, especially when dealing with large amounts of data or numerous replicas, significantly reducing the efficiency of detection and repair.
[0004] As data volume increases and business needs change, the limitations of related technologies become increasingly apparent, failing to meet the high availability and high performance requirements of modern distributed storage systems. Summary of the Invention
[0005] This disclosure provides a data consistency detection method and system, which aims to solve the problems existing in the background art.
[0006] To solve the above-mentioned technical problems, this disclosure is implemented as follows:
[0007] In a first aspect, embodiments of this disclosure provide a data consistency detection method, the method comprising:
[0008] Determine the identifier of the target logical data block to be detected;
[0009] Based on the identifier of the target logical data block and a pre-created distributed hash table, the identifiers of the storage nodes where the multiple replicas of the target logical data block reside are determined. The distributed hash table is used to represent the identifiers of the storage nodes where the multiple replicas of each logical data block reside.
[0010] Based on the identifiers of the storage nodes where the multiple replicas of the target logical data block are located, the storage nodes where the multiple replicas are located are located, and the first state information and the second state information of the replica are obtained from the storage nodes where the multiple replicas are located. The first state information represents the number of state updates that the replica has undergone in the distributed storage system, and the second state information represents the number of times the replica has successfully written data.
[0011] Based on the first state information and / or second state information of each of the multiple replicas of the target logical data block, determine whether the multiple replicas of the target logical data block satisfy data consistency.
[0012] Alternatively, the distributed hash table can be created by following these steps:
[0013] In a distributed storage system, a virtual disk is created and divided into multiple logical data blocks, with each logical data block assigned a one-to-one corresponding identifier.
[0014] Determine multiple storage nodes in the distributed storage system and the identifiers of each of the multiple storage nodes;
[0015] Hash calculations are performed on the identifiers of the plurality of logical data blocks and the plurality of storage nodes, and the plurality of data blocks and the plurality of storage nodes are mapped onto a hash ring;
[0016] For each logical data block, the hash ring is traversed sequentially, and the n storage nodes closest to the logical data block are determined as storage nodes that store n copies of the logical data block respectively, where n is an integer greater than or equal to 1;
[0017] Based on the mapping relationship between multiple replicas of each logical data block and their respective storage nodes, a distributed hash table is established to represent the identifiers of the storage nodes where the multiple replicas of each logical data block reside.
[0018] Optionally, the method further includes:
[0019] The third state information of a replica is obtained from the storage node where each replica resides. The third state information is used to characterize whether the replica exists in the corresponding storage node.
[0020] Based on the third state value of each of the multiple replicas of the target logical data block, determine whether the multiple replicas of the target logical data block exist in their respective corresponding storage nodes;
[0021] If a copy of the target logical data block exists in the corresponding storage node, the first and second state information of the copy are obtained from the storage node where the copy is located.
[0022] If a copy of the target logical data block does not exist in the corresponding storage node, it is determined that there is a data gap among multiple copies of the target logical data block.
[0023] Optionally, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0024] The first state information of each of the multiple copies of the target logical data block is compared;
[0025] If the first state information of the multiple replicas of the target logical data block is not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency.
[0026] Optionally, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0027] The first state information of each of the multiple copies of the target logical data block is compared;
[0028] If the first state information of each of the multiple replicas of the target logical data block is equal, then the second state information of each of the multiple replicas of the target logical data block is compared.
[0029] If the second state information of each of the multiple replicas of the target logical data block is equal, it is determined that the multiple replicas of the target logical data block satisfy data consistency.
[0030] Optionally, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0031] The first state information of each of the multiple copies of the target logical data block is compared;
[0032] If the first state information of each of the multiple replicas of the target logical data block is equal, then the second state information of each of the multiple replicas of the target logical data block is compared.
[0033] When the second state information of the multiple replicas of the target logical data block is not equal, the data content of the target logical data block of a preset size is read from the storage node where each of the multiple replicas of the target logical data block is located.
[0034] The data content is input into the SHA1 hash function to obtain the string message digests of multiple copies of the target logical data block.
[0035] On the storage nodes where the multiple replicas of the target logical data block are located, the string message digests of each replica are compared.
[0036] If the string message digests of the multiple replicas of the target logical data block are all equal, it is determined that the multiple replicas of the target logical data block satisfy data consistency.
[0037] If the string message digests of the multiple replicas of the target logical data block are not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency.
[0038] Optionally, the method further includes:
[0039] If it is determined that there is a data gap among multiple replicas of the target logical data block, or if it is determined that the data consistency is not satisfied among multiple replicas of the target logical data block, the replica with the largest value of the first state information or the largest value of the second state information among the multiple replicas of the target logical data block shall be taken as the latest replica of the target logical data block.
[0040] Obtain the data content of the latest copy from the storage node where the latest copy of the target logical data block is located;
[0041] The data content of the latest copy of the target logical data block is copied to the storage node where other copies of the target logical data block are located.
[0042] Optionally, the method further includes:
[0043] Monitor the distributed storage system;
[0044] When a write operation to a virtual disk is detected, the logical data block to which the data is written is identified as the write target data block;
[0045] Based on the identifier of the written object data block and the pre-created distributed hash table, the storage nodes where the multiple replicas of the written object data block are located are located.
[0046] On the storage nodes where the multiple copies of the write object data block are located, data is written to the multiple copies of the write object data block respectively, wherein each copy reserves space in a preset size data space to record the first state information and the second state information;
[0047] If a successful data write is detected, increment the second status information of the copy where the data was successfully written by one.
[0048] The method further includes:
[0049] Monitor the distributed storage system;
[0050] If a change in the state of the distributed storage system is detected, the first state information of each replica in the distributed cluster is incremented by one.
[0051] Optionally, the method further includes:
[0052] Monitor the distributed cluster and identify any risky or abnormal situations;
[0053] If a risk or anomaly is detected in the distributed cluster, a data consistency detection task is assigned to each storage node in the distributed cluster. The data consistency detection task is used to instruct the storage node to determine whether multiple replicas of the target logical data block to be detected meet the data consistency requirement.
[0054] The method further includes:
[0055] In response to the detection command from the user, each storage node in the distributed cluster is assigned its own data consistency detection task.
[0056] Optionally, monitoring the distributed cluster and identifying risky or abnormal situations includes:
[0057] Monitor whether multiple storage nodes in the distributed cluster are in a fault state or an operation and maintenance state. If any storage node is in a fault state or an operation and maintenance state, determine that the distributed cluster has a risk anomaly.
[0058] Monitor the network latency between multiple storage nodes in the distributed cluster, and determine that the distributed cluster has a risk anomaly if the network latency exceeds a set threshold time.
[0059] Monitor whether there are errors when the upper-layer business performs IO read and write operations on the virtual disk. If errors are detected when the upper-layer business performs IO read and write operations on the virtual disk, it is determined that the distributed cluster has a risk anomaly.
[0060] The method further includes:
[0061] Monitor whether there are data write failures in the replicas of all logical data blocks. If a data write failure is detected in any replica, it is determined that there is a risk anomaly in the distributed cluster. If the total number of IO tasks of all storage nodes in the distributed cluster is less than a preset task volume threshold, data consistency detection tasks are assigned to all storage nodes in the distributed cluster.
[0062] Optionally, assigning data consistency detection tasks to all storage nodes in the distributed cluster includes:
[0063] Based on the identifier of the logical data block and the distributed hash table, an initial list is determined for each of the storage nodes in the distributed cluster. The initial list is used to represent the copies of multiple logical data blocks stored locally on the storage nodes.
[0064] Duplicate copies are identified from the initial lists of all storage nodes, and all duplicate copies except the first copy are removed from their respective initial lists to obtain the final lists of all storage nodes.
[0065] Based on the final list, each storage node in the distributed cluster is assigned a data consistency detection task, with priority given to assigning data consistency detection tasks to the local replicas stored on the storage node.
[0066] Secondly, embodiments of this disclosure provide a data consistency detection system, the system including a coordination node and multiple storage nodes, each storage node storing multiple copies of logical data blocks;
[0067] The coordination node is used to determine the identifier of the target logical data block to be detected; based on the identifier of the target logical data block and a pre-created distributed hash table, it determines the identifier of the storage node where each of the multiple replicas of the target logical data block is located, the distributed hash table being used to represent the identifier of the storage node where each of the multiple replicas of the logical data block is located; based on the identifier of the storage node where each of the multiple replicas of the target logical data block is located, it locates the storage node where each of the multiple replicas is located, and obtains the first state information and the second state information of the replica from the storage node where each of the multiple replicas is located, the first state information representing the number of state updates the replica has undergone in the distributed storage system, and the second state information representing the number of times the replica has successfully written data.
[0068] The plurality of storage nodes are configured to determine whether the multiple replicas of the target logical data block satisfy data consistency based on the first state information and / or second state information of each of the multiple replicas of the target logical data block.
[0069] The technical solutions provided by the embodiments of this disclosure have at least the following beneficial effects:
[0070] This disclosure significantly improves the ability to quickly locate replica nodes of target logical data blocks through Distributed Hash Table (DHT) technology. The core of DHT lies in efficient hash calculation, enabling each node to independently access and manipulate metadata (hash table), thereby achieving autonomous task lookup and allocation. This eliminates the dependence on the master node, fully utilizes the computing power of each node, and thus improves overall computing efficiency. Furthermore, this disclosure introduces first and second state information, providing a standardized basis for replica data consistency judgment. By quickly comparing the first and second state information, inconsistent replicas can be rapidly identified, avoiding the tedious step-by-step detection process in related technologies. The technical solution provided by the embodiments of this disclosure not only accelerates the consistency detection speed but also reduces resource consumption, improving detection efficiency while optimizing system performance and user experience. Attached Figure Description
[0071] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0072] Figure 1 This is a schematic flowchart of a data consistency detection method provided in an embodiment of this disclosure;
[0073] Figure 2 This is a complete flowchart illustrating a data consistency detection method provided in an embodiment of this disclosure;
[0074] Figure 3 This is a schematic diagram of the architecture of a data consistency detection system provided in an embodiment of this disclosure. Detailed Implementation
[0075] The technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this disclosure. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this disclosure.
[0076] In distributed storage systems, data inconsistency is a common and serious problem, directly impacting the correctness of system business logic and user experience. Data inconsistency can be caused by a variety of factors, including network latency, node failures, data write failures or update errors, concurrency control issues, and system design and implementation flaws. Traditional data consistency detection and repair methods, such as timestamp methods, two-phase commit methods, and multi-site active-active methods, typically require significant network overhead, easily leading to communication delays between nodes and thus affecting the normal operation of upper-layer services. Furthermore, traditional methods are time-consuming and fail to fully utilize the computing power of distributed clusters.
[0077] To address the inefficiency of traditional consistency detection methods, this disclosure proposes constructing a distributed hash table (DHT) to quickly locate data replicas and, combined with rapid comparison of state information, automatically coordinating concurrent data consistency detection across cluster nodes. Figure 1 This is a flowchart illustrating the steps of a data consistency detection method provided in this embodiment of the disclosure, as follows: Figure 1 As shown, the method includes:
[0078] Step S101: Determine the identifier of the target logical data block to be detected.
[0079] A logical data block (OBJ) is the basic unit for storing data in a distributed storage system. It involves dividing a large virtual disk into smaller, fixed-size data blocks for easier management and storage. In the design example of this disclosure, the size of the logical data block is set to 4MB. Each logical data block has a unique identifier, a UUID (Universally Unique Identifier). The UUID is a 12-digit hexadecimal string, where the first 4 digits represent the sequence number of the virtual disk (LUN), and the last 8 digits represent the sequence number of the logical data block. The target logical data block is the object selected by the user or system for consistency checks and repairs in the distributed storage system.
[0080] Step S102: Based on the identifier of the target logical data block and the pre-created distributed hash table, determine the identifier of the storage node where each of the multiple replicas of the target logical data block is located. The distributed hash table is used to represent the identifier of the storage node where the multiple replicas of each logical data block are located.
[0081] The basic principle of a distributed hash table is to map the UUID of a logical data block to a hash ring using a hash function. On the hash ring, both the storage node and the UUID of the data block are considered positions on the ring, allowing for quick location of the node storing a copy of the logical data block based on its UUID. Assume a virtual disk LUN is partitioned into multiple logical data blocks (OBJs), with the following UUIDs for each logical data block:
[0082] OBJ1: UUID = A00100000001;
[0083] OBJ2: UUID = A00100000002;
[0084] OBJ3: UUID = A00100000003. Also, assume there are three storage nodes: Node1, Node2, and Node3. The following mapping relationship is obtained through hash function calculation:
[0085] The hash value of OBJ1 is mapped to Node1;
[0086] The hash value of OBJ2 is mapped to Node2;
[0087] The hash value of OBJ3 is mapped to Node3. The distributed hash table represents the mapping relationship as shown in Table 1:
[0088]
[0089] Table 1
[0090] Since each logical data block may have multiple replicas, assuming each logical data block has two replicas, the distributed hash table actually represents the mapping relationship shown in Table 2:
[0091]
[0092] Table 2
[0093] In this example, the target logical data block is assumed to be OBJ1, and multiple replicas of the target logical data block are stored on Node1 and Node2 respectively. By consulting the distributed hash table, the storage nodes where the replicas of the target logical data block are located can be quickly found, thereby enabling subsequent state information retrieval and consistency checks.
[0094] Step S103: Based on the identifiers of the storage nodes where the multiple replicas of the target logical data block are located, locate the storage nodes where the multiple replicas are located, and obtain the first state information and the second state information of the replica from the storage nodes where the multiple replicas are located. The first state information represents the number of state updates that the replica has undergone in the distributed storage system, and the second state information represents the number of times the replica has successfully written data.
[0095] The specific storage node where each replica resides is located using a known storage node identifier. This can be achieved via 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, representing the number of state updates the replica has undergone in the distributed storage system. This can be a counter that records the number of state changes the replica has experienced in the distributed storage system since its creation. The second status information is wr_num, representing the number of times data has been successfully written to the replica. This can also be a counter that records the number of data operations that have been successfully written to the replica.
[0096] Step S104: Determine whether the multiple replicas of the target logical data block satisfy data consistency based on their respective first state information and / or second state information.
[0097] In a distributed storage system, data consistency means that all replicas should have the same data state at any given time. As described in step S103, the first state information, cls_epoch, records the number of state updates experienced by the replicas in the distributed storage system. Whenever the state of a replica changes (e.g., data writing, updating, or fault recovery), the value of cls_epoch increments. 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 indicates that their state updates are synchronized, and data consistency is satisfied; if the cls_epoch value of a certain replica is different, it indicates that the replica may have failed to update in time, posing a risk of data inconsistency. The second state information, wr_num, records the number of times a replica has successfully written 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 indicates that they have successfully received the same number of data write operations, and data consistency is satisfied; if the wr_num value of a certain replica is different, it indicates that the replica may have experienced data loss or failure to write data in time, leading to data inconsistency.
[0098] This disclosure significantly improves the ability to quickly locate replica nodes of target logical data blocks through Distributed Hash Table (DHT) technology. The core of DHT lies in efficient hash calculation, enabling each node to independently access and manipulate metadata (hash table), thereby achieving autonomous task lookup and allocation. This eliminates the dependence on the master node, fully utilizes the computing power of each node, and thus improves overall computing efficiency. Furthermore, this disclosure introduces first and second state information, providing a standardized basis for replica data consistency judgment. By quickly comparing the first and second state information, inconsistent replicas can be rapidly identified, avoiding the tedious step-by-step detection process in related technologies. The technical solution provided by the embodiments of this disclosure not only accelerates the consistency detection speed but also reduces resource consumption, improving detection efficiency while optimizing system performance and user experience.
[0099] In one alternative implementation, the distributed hash table is created according to the following steps:
[0100] In a distributed storage system, a virtual disk is created and divided into multiple logical data blocks, with each logical data block assigned a one-to-one corresponding identifier.
[0101] Determine multiple storage nodes in the distributed storage system and the identifiers of each of the multiple storage nodes;
[0102] Hash calculations are performed on the identifiers of the plurality of logical data blocks and the plurality of storage nodes, and the plurality of data blocks and the plurality of storage nodes are mapped onto a hash ring;
[0103] For each logical data block, the hash ring is traversed sequentially, and the n storage nodes closest to the logical data block are determined as storage nodes that store n copies of the logical data block respectively, where n is an integer greater than or equal to 1;
[0104] Based on the mapping relationship between multiple replicas of each logical data block and their respective storage nodes, a distributed hash table is established to represent the identifiers of the storage nodes where the multiple replicas of each logical data block reside.
[0105] The distributed hash algorithm used in step S102 is combined with a hash ring, that is, the distributed hash algorithm uses the structure of a hash ring to realize the storage and access of data. Figure 2 This is a complete flowchart illustrating a data consistency detection method provided in this disclosure embodiment. Please refer to [link / reference]. Figure 2 , here corresponds Figure 2This section describes the process of creating a distributed hash table. In a distributed storage system, the user first creates a virtual disk (LUN). This virtual disk is a logical storage unit used to store data. To efficiently manage and store data in a distributed system, the virtual disk is divided into multiple smaller logical data blocks (OBJs). Each logical data block has a unique identifier (UUID) for subsequent data management and access. Assume the user creates a virtual disk with a size of 16MB. When dividing it into logical data blocks, each data block is set to 4MB, therefore the virtual disk will be divided into 4 logical data blocks:
[0106] OBJ1: UUID = A00100000001;
[0107] OBJ2: UUID = A00100000002;
[0108] OBJ3: UUID = A00100000003;
[0109] OBJ4: UUID = A00100000004. Next, we determine the multiple storage nodes in the distributed storage system. Each storage node is responsible for storing a portion of the data, and each node has a unique identifier. The number and distribution of storage nodes affect the data storage strategy and access efficiency. Assume there are 3 storage nodes in the distributed storage system: 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 is mapped onto a logical hash ring. This hash ring is a virtual structure used to represent the distribution of data blocks and storage nodes. Assuming the SHA-256 hash function is used for calculation, the resulting hash values (simplified 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, the hash ring is traversed sequentially to find the n nearest storage nodes (n is an integer greater than or equal to 1) to the logical data block. These storage nodes will be selected as the locations for storing copies of the logical data block. Assuming n=2, after traversal:
[0110] For OBJ1 (hash value H1), find the two nearest storage nodes as Node1 (HN1) and Node2 (HN2).
[0111] For OBJ2 (hash value H2), the two nearest storage nodes are Node2 (HN2) and Node3 (HN3).
[0112] For OBJ3 (hash value H3), find the two nearest storage nodes as Node3 (HN3) and Node1 (HN1).
[0113] 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 built to represent the identifiers of the storage nodes where multiple replicas of each logical data block reside. The distributed hash table can be used to quickly find the replica location of a data block, thereby improving the efficiency of data access.
[0114]
[0115] Table 3
[0116] The above steps ensure a clear data organization structure and optimize data distribution and access paths. Multiple copies of each data block are stored on the nearest storage node, enhancing data redundancy. The established distributed hash table enables rapid location of data block replicas, thereby improving data access efficiency and system reliability, and reducing the risk of data loss.
[0117] In an optional implementation, the method further includes:
[0118] The third state information of a replica is obtained from the storage node where each replica resides. The third state information is used to characterize whether the replica exists in the corresponding storage node.
[0119] Based on the third state value of each of the multiple replicas of the target logical data block, determine whether the multiple replicas of the target logical data block exist in their respective corresponding storage nodes;
[0120] If a copy of the target logical data block exists in the corresponding storage node, the first and second state information of the copy are obtained from the storage node where the copy is located.
[0121] If a copy of the target logical data block does not exist in the corresponding storage node, it is determined that there is a data gap among multiple copies of the target logical data block.
[0122] In a distributed storage system, each logical data block (OBJ) has multiple replicas stored on different storage nodes. To ensure data reliability, it is necessary to obtain third-state information (exist) related to each replica from each storage node. This third-state information characterizes whether the replica actually exists in its corresponding storage node. Assume logical data block OBJ1 has three replicas, stored on Node1, Node2, and Node3 respectively. Requesting the third-state information of OBJ1 from these three storage nodes might yield the following results: Node1: exist = true (replica exists); Node2: exist = false (replica does not exist); Node3: exist = true (replica exists). Based on the third-state information obtained from each storage node, it is determined whether the multiple replicas of the target logical data block exist in their respective storage nodes. Figure 2 The diagram illustrates the data existence detection process. If all replicas exist, the data is complete. In this case, the first and second status information of the corresponding replica is obtained from the storage node. Conversely, if any replica is missing, it is determined that there is a data gap among multiple replicas of the target logical data block. Continuing with OBJ1 as an example, if the replica of Node2 is found to be missing, it is determined that the replica of OBJ1 is missing, and subsequent data gap repair tasks will be initiated. It should be noted that... Figure 2 The data existence check and data consistency check shown can be performed in a logical order: first, the data existence is checked, and if the data existence is passed, then the data consistency is checked. Alternatively, they can be treated as two separate judgment processes, that is, separately judging whether the data existence and data consistency are satisfied, and initiating the subsequent data repair process based on the corresponding judgment results.
[0123] 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 loss issues.
[0124] In one optional implementation, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0125] Step S201: Compare the first state information of each of the multiple replicas of the target logical data block;
[0126] As previously mentioned, the first state information (cls_epoch) characterizes the number of state updates a replica has undergone in the distributed storage system, i.e., a sequence number used to indicate the replica's version or cluster state. Whenever the cluster state changes (e.g., node failure, data update, etc.), the value of the first state information cls_epoch is incremented. In an optional implementation, the method further includes: monitoring the distributed storage system; and, upon detecting a change in the state of the distributed storage system, incrementing the first state information of each replica in the distributed cluster by one.
[0127] Please see Figure 2 In this embodiment, 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 connectivity, and load. The purpose is to promptly detect potential problems and state changes in the system. During monitoring, changes in the state of the distributed storage system are captured, including node failures (such as power outages, network interruptions, etc.), data update or write operations, system maintenance or upgrades, and load changes. Detection of state changes can be achieved through setting thresholds, event triggering mechanisms, or periodic polling. Upon detecting a state change, the first state information (cls_epoch) of each replica in the distributed cluster is updated. Specifically, the cls_epoch value of each replica is incremented by one to reflect the change in cluster state.
[0128] The first state information cls_epoch values of multiple replicas of the collected target logical data block are compared. The purpose of the comparison is to check whether the states of all replicas are consistent, to ensure that they reflect the same version of the data.
[0129] Step S202: If the first state information of the multiple replicas of the target logical data block is not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency.
[0130] If, during the comparison process, it is found that the cls_epoch values of multiple replicas of the target logical data block are not equal—that is, at least two replicas have unequal values for their first state information—it will be determined that the multiple replicas of the target logical data block satisfy data consistency. This implies that at least one replica's data may be outdated or out of sync.
[0131] In one optional implementation, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0132] Step S301: Compare the first state information of each of the multiple copies of the target logical data block.
[0133] Similar to step S201, the first state information cls_epoch values of multiple copies of the collected target logical data block are compared.
[0134] Step S302: If the first state information of each of the multiple replicas of the target logical data block is equal, the second state information of each of the multiple replicas of the target logical data block is compared.
[0135] If the result of step S301 indicates 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 data has been successfully written to a replica, and is used to measure the frequency of data updates. In an optional implementation, the method further includes: monitoring the distributed storage system; when a write operation to a virtual disk is detected, identifying the logical data block to be written as the write object data block; locating the storage nodes where the multiple replicas of the write object data block reside based on the identifier of the write object data block and a pre-created distributed hash table; writing data to the multiple replicas of the write object data block on the storage nodes where the multiple replicas reside, wherein each replica reserves space in a preset size data space to record the first status information and the second status information; when a successful data write is detected, incrementing the second status information of the replica where the data was successfully written by one.
[0136] The distributed storage system environment is continuously monitored to capture various operations and state changes. When a write operation to a virtual disk is detected, it identifies which logical data blocks need to be written. These written data blocks are designated as write object data blocks. Based on the identifier (UUID) of the write object data block and a pre-created distributed hash table, the storage nodes where multiple replicas of the data block reside are quickly located. On the identified storage nodes, data is written to the multiple replicas of the write object data block. Each replica reserves space in its preset data space for recording first and second state information. This reserved space allows each replica to independently record its state, facilitating subsequent data consistency detection and repair. When a successful data write is detected, the second state information of the successfully written replica is incremented by one. For example, if Node1 successfully writes data, the second state information of Node1 will be incremented by 1, reflecting the update status of the write count for that replica.
[0137] Step S303: If the second state information of each of the multiple replicas of the target logical data block is equal, determine that the multiple replicas of the target logical data block satisfy data consistency.
[0138] If the second state information wr_num values of all replicas are equal, it means that all replicas received the same number of write operations within the same time period, thus confirming that the multiple replicas of the target logical data block satisfy data consistency.
[0139] In one optional implementation, determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes:
[0140] Step S401: Compare the first state information of each of the multiple copies of the target logical data block.
[0141] Step S402: If the first state information of each of the multiple replicas of the target logical data block is equal, the second state information of each of the multiple replicas of the target logical data block is compared.
[0142] Step S403: When the second state information of the multiple replicas of the target logical data block is not equal, read the data content of the target logical data block of a preset size from the storage node where each of the multiple replicas of the target logical data block is located.
[0143] In contrast to the judgment result in step S402, when the second state information of the multiple replicas of the target logical data block is not equal, that is, when there are replicas with different values of the second state information wr_num, the data content of the target logical data block of a preset size is read from the storage node where each replica is located.
[0144] Step S404: Input the data content into the SHA1 hash function to obtain the string message digests of each of the multiple copies of the target logical data block.
[0145] The data content read from each replica is input into the SHA1 hash function to generate a string message digest for each replica. A 40-byte string message digest is obtained for each replica to represent the data content. This string message digest is a unique representation of the data content and can be effectively used to compare data consistency. This disclosure proposes comparing digests instead of directly comparing data content, which improves efficiency because the size of the digest is much smaller than the original data.
[0146] Step S405: On the storage nodes where the multiple replicas of the target logical data block are located, compare the string message digests of the multiple replicas respectively.
[0147] The string message digests generated by each replica are compared on the storage nodes where the multiple replicas of the target logical data block reside.
[0148] Step S406: If the string message digests of the multiple replicas of the target logical data block are all equal, determine that the multiple replicas of the target logical data block satisfy data consistency.
[0149] If all replicas have the same string message digest, it means that the data content of these replicas is consistent, and it is determined that the multiple replicas of the target logical data block meet the data consistency requirement.
[0150] Step S407: If the string message digests of the multiple replicas of the target logical data block are not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency. In other words, in a distributed storage system, all replicas contain the same data, and user access to the data is reliable.
[0151] Conversely, if the string message digests of all replicas are not equal, that is, there are at least two replicas with unequal string message digests, it is determined that the data consistency is not satisfied among the multiple replicas of the target logical data block.
[0152] By progressively comparing the first / second state information and data content of replicas, data consistency in a distributed storage environment can be effectively detected and confirmed. This ensures data accuracy in a multi-replica environment, thereby reducing the risk of data loss and inconsistency.
[0153] In an optional implementation, the method further includes:
[0154] If it is determined that there is a data gap among multiple replicas of the target logical data block, or if it is determined that the multiple replicas of the target logical data block do not meet the data consistency requirement, the replica with the largest value of the first state information or the second state information among the multiple replicas of the target logical data block shall be taken as the latest replica of the target logical data block; the data content of the latest replica shall be obtained from the storage node where the latest replica of the target logical data block is located; and the data content of the latest replica of the target logical data block shall be copied to the storage nodes where the other replicas of the target logical data block are located.
[0155] Please see Figure 2If data loss (some replicas are missing) or data inconsistency (replicas contain different content) is detected among multiple replicas of a target logical data block, the following measures need to be taken to restore consistency; that is, a repair process is initiated for these two situations (data loss and data inconsistency). One replica is selected from multiple replicas as the latest replica, containing the most recent valid data. The selection criteria are as follows: compare the first state information cls_epoch values of all replicas and select the replica with the largest value. This indicates that the replica is the latest, as cls_epoch reflects the update status of the replica. If multiple replicas have the same first state information cls_epoch value, further compare the second state information wr_num values of these replicas and select the replica with the largest value. The second state information wr_num represents the number of writes and is used to measure the update frequency of the replica. Alternatively, the replica with the largest value in either the first or second state information can be randomly selected as the latest replica of the target logical data block.
[0156] Retrieving the data content from the storage node where the latest replica resides is equivalent to retrieving the latest valid data. The data content retrieved from the latest replica is then copied to the storage nodes where other replicas reside; that is, the latest valid data is synchronized to all replicas to ensure consistency among them. The above describes a general data repair process for missing and inconsistent data. Users can also configure it as needed, and this disclosure does not impose any restrictions.
[0157] By following the steps described above, data consistency can be quickly and effectively restored when data is missing or inconsistent in a distributed storage system. By selecting the latest replica and copying its data content, data accuracy is maintained, thereby improving the overall system availability and user experience.
[0158] In an optional implementation, the method further includes: monitoring the distributed cluster and identifying risk anomalies; and, if a risk anomaly is detected in the distributed cluster, assigning a data consistency detection task to each storage node in the distributed cluster, wherein the data consistency detection task is used to instruct the storage nodes to determine whether multiple replicas of the target logical data block to be detected satisfy data consistency.
[0159] Please see Figure 2The consistency detection triggering mechanism provided in this disclosure includes automatic triggering detection and manual / automatic triggering detection. First, the mechanism of automatic triggering detection is introduced. Continuous monitoring of the distributed cluster to identify risky or abnormal situations is implemented. In one optional embodiment, monitoring the distributed cluster to identify risky or abnormal situations includes: monitoring whether multiple storage nodes in the distributed cluster are in a faulty or under-maintenance state; if any storage node is in a faulty or under-maintenance state, it is determined that the distributed cluster has a risky or abnormal situation; monitoring the network latency between multiple storage nodes in the distributed cluster; if the network latency exceeds a set threshold time, it is determined that the distributed cluster has a risky or abnormal situation; and monitoring whether upper-layer services report errors when performing I / O read / write operations on the virtual disk; if errors are detected in upper-layer services when performing I / O read / write operations on the virtual disk, it is determined that the distributed cluster has a risky or abnormal situation.
[0160] Firstly, continuously monitor the status of multiple storage nodes in the distributed cluster, specifically including: fault status (nodes cannot function normally due to hardware failure, software crashes, network disconnections, etc.) and maintenance status (nodes are undergoing maintenance operations, such as restarts, upgrades, or other maintenance activities, and may be temporarily unavailable). Faulty or maintenance nodes may cause data unavailability or data consistency issues. If any storage node is in a faulty or maintenance state, the distributed cluster is identified as having an anomaly. Secondly, monitor network latency between storage nodes to ensure smooth communication. Excessive network latency may lead to data synchronization delays, request timeouts, and a degraded user experience. If network latency exceeds a set threshold (e.g., exceeding a certain time limit), the distributed cluster is identified as having an anomaly. Thirdly, monitor for errors when upper-layer services perform input / output (IO) operations on the virtual disk. IO operation errors may indicate data corruption, storage node failures, or other problems. If errors are detected during IO read / write operations (e.g., write failures, read errors, etc.), the distributed cluster is identified as having an anomaly.
[0161] Once an anomaly is detected, a data consistency detection task is automatically assigned to each storage node in the cluster. This task instructs each storage node to check whether multiple replicas of the target logical data block it manages meet data consistency requirements. The data consistency detection task includes the aforementioned steps of comparing replica status information, reading data content, and generating hash digests to determine consistency between replicas.
[0162] The method further includes: monitoring whether there is a data write failure in each replica of all logical data blocks; if a data write failure is detected in any replica, it is determined that there is a risk anomaly in the distributed cluster; and if the total number of IO tasks of all storage nodes in the distributed cluster is less than a preset task threshold, data consistency detection tasks are assigned to each storage node in the distributed cluster.
[0163] Active triggering also includes a scenario, detailed below, where monitoring is conducted to check for write failures in the individual replicas of all logical data blocks. If a write failure is detected in any replica during monitoring (e.g., write timeout, storage node unresponsiveness), the distributed cluster is identified as having an anomaly due to the potential for data loss or inconsistency. Simultaneously, the total number of IO tasks across all storage nodes in the distributed cluster is monitored and compared to a preset task volume threshold. When the total number of IO tasks is less than the preset threshold, a data consistency check task is assigned to each storage node in the distributed cluster. In other words, when a write failure is confirmed and the number of IO tasks is low, a data consistency check task is proactively assigned to each storage node, instructing them to check the data consistency between the replicas of the logical data blocks they manage. In this proactive triggering scenario, this embodiment aims to perform detection when IO tasks are low, effectively utilizing system resources and avoiding detection under high load, thereby reducing the impact on upper-layer services.
[0164] The method further includes: in response to a detection command from the user terminal, assigning a data consistency detection task to each storage node in the distributed cluster.
[0165] This section describes the mechanism for manually triggering checks, where users can proactively initiate data consistency checks by sending check commands. Users can send check commands to the distributed storage system through the management interface or command-line interface. These check commands can be checks targeting specific logical data blocks or comprehensive consistency checks across the entire cluster.
[0166] Upon receiving a user's detection command, the system immediately responds and assigns a data consistency detection task to each storage node in the distributed cluster. Optionally, the detection results can be fed back to the user to help them make further decisions, such as whether data repair or other maintenance operations are needed.
[0167] In one optional implementation, the step of allocating data consistency detection tasks to all storage nodes in the distributed cluster includes: determining an initial list for each storage node in the distributed cluster based on the identifier of the logical data block and the distributed hash table, wherein the initial list represents the copies of multiple logical data blocks stored locally on the storage node; identifying duplicate copies from the initial lists of all storage nodes and removing duplicate copies other than the first copy from their respective initial lists to obtain a final list for each storage node; and allocating data consistency detection tasks to all storage nodes in the distributed cluster based on the final list, wherein priority is given to allocating data consistency detection tasks to the copies stored locally on the storage node.
[0168] As mentioned earlier, each logical data block has a unique identifier (UUID). The Distributed Hash Table (DHT) is used to store and locate replica information of logical data blocks, mapping the identifier of the logical data block to the address of the storage node.
[0169] Suppose there are three logical data blocks: OBJ1, OBJ2, and OBJ3, distributed across three storage nodes (node A, node B, and node C). Based on a distributed hash table, the initial list might look like this:
[0170] Node A: OBJ1 (replica 1), OBJ2 (replica 1), OBJ3 (replica 1);
[0171] Node B: OBJ1 (replica 2), OBJ2 (replica 1);
[0172] Node C: OBJ1 (replica 3), OBJ3 (replica 2). Considering that the same logical data block may have multiple replicas on multiple nodes, duplicate detection not only wastes computing resources and time but may also lead to unnecessary network overhead and load. This disclosure proposes removing redundant duplicate replicas and retaining only one replica for detection. This ensures a more efficient detection process, reduces system load, and avoids potential inconsistencies caused by duplicate detection.
[0173] Duplicate copies are identified from the initial list of all storage nodes. A duplicate copy refers to the existence of multiple copies of the same logical data block on different nodes. In the example above, OBJ1 has copies on three nodes (copy 1, 2, and 3), therefore it is a duplicate copy. OBJ2 has copies on nodes A and B, while OBJ3 has copies on nodes A and C. For each duplicate copy, the first copy is retained, and the other copies are removed from their respective initial lists. After processing, the final list of the above example will be as follows:
[0174] Node A (Retaining Replica 1): OBJ1 (Replica 1), OBJ2 (Replica 1), OBJ3 (Replica 1);
[0175] Node B (removes copy 2 of OBJ1): OBJ2 (copy 1);
[0176] Node C (Remove copy 3 of OBJ1 and copy 2 of OBJ3): (None).
[0177] Based on the final list, assign data consistency check tasks to each storage node. Prioritize assigning data consistency check tasks to locally stored replicas on each node. In the example above, node A will execute the tasks of checking OBJ1 (replica 1), checking OBJ2 (replica 1), and checking OBJ3 (replica 1). Node B will execute the task of checking OBJ2 (replica 1).
[0178] Node C has no replicas, therefore no detection task is performed.
[0179] Through the steps above, the distributed storage system can effectively assign data consistency detection tasks to each storage node. By identifying and removing duplicate copies, it ensures that each node only needs to check its locally stored copy, thereby improving detection efficiency and reducing unnecessary workload.
[0180] Figure 3 This is a schematic diagram of the architecture of a data consistency detection system provided in an embodiment of this disclosure, such as... Figure 3 As shown, the system includes a coordination node and multiple storage nodes, each of which stores multiple copies of logical data blocks.
[0181] The coordination node, acting as the management and control center of this system, is responsible for task management, replica location, consistency judgment of status information acquisition, and decision-making and scheduling. It is the main entity responsible for allocating data consistency detection tasks. Please refer to [link / reference]. Figure 3 The coordination node is deployed within the task allocation and distribution device to determine the identifier of the target logical data block to be detected; based on the identifier of the target logical data block and a pre-created distributed hash table, it determines the identifier of the storage node where each of the multiple replicas of the target logical data block resides, the distributed hash table being used to represent the identifier of the storage node where each of the multiple replicas of the logical data block resides; based on the identifier of the storage node where each of the multiple replicas of the target logical data block resides, it locates the storage node where each of the multiple replicas resides, and obtains the first state information and the second state information of the replica from the storage node where each of the multiple replicas resides, the first state information representing the number of state updates the replica has undergone in the distributed storage system, and the second state information representing the number of times the replica has successfully written data.
[0182] The multiple storage nodes, as the basic components of this system, rely on the data consistency detection device to realize the data detection function, which is used to determine whether the multiple replicas of the target logical data block meet the data consistency requirement based on the first state information and / or second state information of each of the multiple replicas of the target logical data block.
[0183] Please see Figure 3 In addition to the task allocation and distribution device, the data distribution device, the replica status identification device, the detection triggering device, the data consistency detection device, and the data repair device work in coordination with the task allocation and distribution device and multiple storage nodes through hierarchical linkage to realize the data consistency detection method described above in this disclosure.
[0184] Specifically, the data distribution device is responsible for dividing the virtual disk into multiple logical data blocks and allocating these blocks to different storage nodes. A distributed hash table is created to record a copy of each logical data block and its corresponding storage node.
[0185] The replica status identification device records status information in each replica, including first and second status information. This device provides the replica status information for subsequent data consistency checks and repair processes.
[0186] The detection triggering device is responsible for monitoring system status and user commands, and triggering data consistency checks. It determines when to perform data consistency checks based on risk assessment results and user commands.
[0187] The data consistency detection device determines whether data replicas meet consistency requirements based on the status information of each replica. By comparing the first and / or second status information of the replicas, the device identifies inconsistent replicas and marks them as objects requiring repair, thus ensuring data reliability.
[0188] The data repair unit is responsible for performing data repair operations when data inconsistency or missing copies are detected. It is used to restore missing or inconsistent copies using the most up-to-date copy.
[0189] The task allocation and distribution unit is responsible for distributing data consistency detection and repair tasks to each storage node. This unit coordinates the work of each storage node, enabling each node to execute detection and repair tasks independently and in parallel.
[0190] Those skilled in the art will understand that embodiments of this disclosure can be provided as methods, apparatus, electronic devices, and storage media. Therefore, embodiments of this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this disclosure can take the form of a computer program product embodied 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.
[0191] This disclosure describes embodiments of methods and systems according to embodiments of this disclosure with reference to flowchart illustrations and / or block diagrams. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing terminal device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing terminal device to operate in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The functions specified in one or more boxes. These computer program instructions may also be loaded onto a computer or other programmable data processing terminal equipment to cause a series of operational steps to be performed on the computer or other programmable terminal equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable terminal equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0192] While preferred embodiments of the present disclosure have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the present disclosure.
[0193] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the term "comprising" or any other variations thereof is intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or terminal device. Without further limitations, an element defined by the phrase "comprising..." does not exclude the presence of other identical elements in the process, method, article, or terminal device that includes said element. The above provides a detailed description of a data consistency detection method and system provided by this disclosure. Specific examples have been used to illustrate the principles and implementation methods of this disclosure. The descriptions of the above embodiments are only for the purpose of helping to understand the method and its core ideas; at the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of this disclosure. Therefore, the content of this specification should not be construed as a limitation of this disclosure.
Claims
1. A data consistency detection method, characterized in that, The method includes: Determine the identifier of the target logical data block to be detected; Based on the identifier of the target logical data block and a pre-created distributed hash table, the identifiers of the storage nodes where the multiple replicas of the target logical data block reside are determined. The distributed hash table is used to represent the identifiers of the storage nodes where the multiple replicas of each logical data block reside. Based on the identifiers of the storage nodes where the multiple replicas of the target logical data block are located, the storage nodes where the multiple replicas are located are located, and the first state information and the second state information of the replica are obtained from the storage nodes where the multiple replicas are located. The first state information represents the number of state updates that the replica has undergone in the distributed storage system, and the second state information represents the number of times the replica has successfully written data. Based on the first state information and / or second state information of each of the multiple replicas of the target logical data block, determine whether the multiple replicas of the target logical data block satisfy data consistency.
2. The method according to claim 1, characterized in that, Create the distributed hash table by following these steps: In a distributed storage system, a virtual disk is created and divided into multiple logical data blocks, with each logical data block assigned a one-to-one corresponding identifier. Determine multiple storage nodes in the distributed storage system and the identifiers of each of the multiple storage nodes; Hash calculations are performed on the identifiers of the plurality of logical data blocks and the plurality of storage nodes to map the plurality of data blocks and the plurality of storage nodes onto a hash ring; For each logical data block, the hash ring is traversed sequentially, and the n storage nodes closest to the logical data block are determined as storage nodes that store n copies of the logical data block respectively, where n is an integer greater than or equal to 1; Based on the mapping relationship between multiple replicas of each logical data block and their respective storage nodes, a distributed hash table is established to represent the identifiers of the storage nodes where the multiple replicas of each logical data block reside.
3. The method according to claim 1, characterized in that, The method further includes: The third state information of a replica is obtained from the storage node where each replica resides. The third state information is used to characterize whether the replica exists in the corresponding storage node. Based on the third state value of each of the multiple replicas of the target logical data block, determine whether the multiple replicas of the target logical data block exist in their respective corresponding storage nodes; If a copy of the target logical data block exists in the corresponding storage node, the first and second state information of the copy are obtained from the storage node where the copy is located. If a copy of the target logical data block does not exist in the corresponding storage node, it is determined that there is a data gap among multiple copies of the target logical data block.
4. The method according to claim 1, characterized in that, The step of determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes: The first state information of each of the multiple copies of the target logical data block is compared; If the first state information of the multiple replicas of the target logical data block is not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency.
5. The method according to claim 1, characterized in that, The step of determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes: The first state information of each of the multiple copies of the target logical data block is compared; If the first state information of each of the multiple replicas of the target logical data block is equal, then the second state information of each of the multiple replicas of the target logical data block is compared. If the second state information of each of the multiple replicas of the target logical data block is equal, it is determined that the multiple replicas of the target logical data block satisfy data consistency.
6. The method according to claim 1, characterized in that, The step of determining whether data consistency is satisfied among the multiple replicas of the target logical data block based on their respective first and / or second state information includes: The first state information of each of the multiple copies of the target logical data block is compared; If the first state information of each of the multiple replicas of the target logical data block is equal, then the second state information of each of the multiple replicas of the target logical data block is compared. When the second state information of the multiple replicas of the target logical data block is not equal, the data content of the target logical data block of a preset size is read from the storage node where each of the multiple replicas of the target logical data block is located. The data content is input into the SHA1 hash function to obtain the string message digests of multiple copies of the target logical data block. On the storage nodes where the multiple replicas of the target logical data block are located, the string message digests of each replica are compared. If the string message digests of the multiple replicas of the target logical data block are all equal, it is determined that the multiple replicas of the target logical data block satisfy data consistency. If the string message digests of the multiple replicas of the target logical data block are not equal, it is determined that the multiple replicas of the target logical data block do not satisfy data consistency.
7. The method according to claim 3, characterized in that, The method further includes: If it is determined that there is a data gap among multiple replicas of the target logical data block, or if it is determined that the data consistency is not satisfied among multiple replicas of the target logical data block, the replica with the largest value of the first state information or the largest value of the second state information among the multiple replicas of the target logical data block shall be taken as the latest replica of the target logical data block. Obtain the 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 node where other copies of the target logical data block are located.
8. The method according to claim 1, characterized in that, The method further includes: Monitor the distributed storage system; When a write operation to a virtual disk is detected, the logical data block to which the data is written is identified as the write target data block; Based on the identifier of the written object data block and the pre-created distributed hash table, the storage nodes where the multiple replicas of the written object data block are located are located. On the storage nodes where the multiple copies of the write object data block are located, data is written to the multiple copies of the write object data block respectively, wherein each copy reserves space in a preset size data space to record the first state information and the second state information; If a successful data write is detected, increment the second status information of the copy where the data was successfully written by one. The method further includes: Monitor the distributed storage system; If a change in the state of the distributed storage system is detected, the first state information of each replica in the distributed cluster is incremented by one.
9. The method according to claim 1, characterized in that, The method further includes: Monitor distributed clusters and identify risky or abnormal situations; If a risk or anomaly is detected in the distributed cluster, a data consistency detection task is assigned to each storage node in the distributed cluster. The data consistency detection task is used to instruct the storage node to determine whether multiple replicas of the target logical data block to be detected meet the data consistency requirement. The method further includes: In response to the detection command from the user, each storage node in the distributed cluster is assigned its own data consistency detection task.
10. The method according to claim 9, characterized in that, The monitoring of the distributed cluster identifies risky and abnormal situations, including: Monitor whether multiple storage nodes in the distributed cluster are in a fault state or an operation and maintenance state. If any storage node is in a fault state or an operation and maintenance state, determine that the distributed cluster has a risk anomaly. Monitor the network latency between multiple storage nodes in the distributed cluster, and determine that the distributed cluster has a risk anomaly if the network latency exceeds a set threshold time. Monitor whether there are errors when the upper-layer business performs IO read and write operations on the virtual disk. If errors are detected when the upper-layer business performs IO read and write operations on the virtual disk, it is determined that the distributed cluster has a risk anomaly. The method further includes: Monitor whether there are data write failures in the replicas of all logical data blocks. If a data write failure is detected in any replica, it is determined that there is a risk anomaly in the distributed cluster. If the total number of IO tasks of all storage nodes in the distributed cluster is less than a preset task volume threshold, data consistency detection tasks are assigned to all storage nodes in the distributed cluster.
11. The method according to claim 9, characterized in that, The process of assigning data consistency detection tasks to all storage nodes in the distributed cluster includes: Based on the identifier of the logical data block and the distributed hash table, an initial list is determined for each of the storage nodes in the distributed cluster. The initial list is used to represent the copies of multiple logical data blocks stored locally on the storage nodes. Duplicate copies are identified from the initial lists of all storage nodes, and all duplicate copies except the first copy are removed from their respective initial lists to obtain the final lists of all storage nodes. Based on the final list, each storage node in the distributed cluster is assigned a data consistency detection task, with priority given to assigning data consistency detection tasks to the local replicas stored on the storage node.
12. A data consistency detection system, characterized in that, The system includes a coordination node and multiple storage nodes, each of which stores multiple copies of logical data blocks. The coordination node is used to determine the identifier of the target logical data block to be detected; based on the identifier of the target logical data block and a pre-created distributed hash table, it determines the identifier of the storage node where each of the multiple replicas of the target logical data block is located, the distributed hash table being used to represent the identifier of the storage node where each of the multiple replicas of the logical data block is located; based on the identifier of the storage node where each of the multiple replicas of the target logical data block is located, it locates the storage node where each of the multiple replicas is located, and obtains the first state information and the second state information of the replica from the storage node where each of the multiple replicas is located, the first state information representing the number of state updates the replica has undergone in the distributed storage system, and the second state information representing the number of times the replica has successfully written data. The plurality of storage nodes are configured to determine whether the multiple replicas of the target logical data block satisfy data consistency based on the first state information and / or second state information of each of the multiple replicas of the target logical data block.
Citation Information
Patent Citations
File processing method based on distributed file system, system, and client
CN102843403A
Data processing method, system and apparatus, storage medium, and electronic device
WO2024148824A1