Lease consistency maintenance method, lease consistency maintenance system, lease consistency maintenance equipment and readable storage medium
By maintaining independent logical time for virtual disks and implementing a dual verification mechanism, the problem of inconsistency in lease computing caused by split brain networks in distributed storage systems is solved, ensuring data consistency and system reliability.
Patent Information
- Application Number
- CN202510463054.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-07-22
AI Technical Summary
In distributed storage systems, the problem of inconsistency in lease calculations between virtual disk instances caused by split brain networks may cause data overwriting conflicts and meta-information inconsistencies, seriously affecting data integrity.
Maintain independent logical time for virtual disks, incremental synchronization is performed through preset time intervals, and a dual verification mechanism is implemented under the split brain network to ensure the validity and consistency of lease requests.
It avoids the lease time deviation caused by time server switching, ensures the consistency of leases under the split-brain network, prevents illegal data writing, and improves the reliability and flexibility of the distributed storage system.
Smart Images

Figure CN120353394A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of distributed storage, and particularly relates to a method, system, device and readable storage medium for lease consistency maintenance. Background Art
[0002] Distributed storage is a technology that disperses data storage across multiple independent nodes (servers or storage devices) and achieves unified management and access through software and network protocols. Its core goal is to achieve high availability, scalability, and fault tolerance through a distributed architecture. A virtual disk is a disk device simulated by software that abstracts physical storage resources (such as local hard disks, distributed storage) into a logically "disk" for use by virtual machines (VMs) or containers.
[0003] Distributed storage can support a large number of virtual disks, and virtual disks provide flexible storage for virtual machines / containers. The combination of the two can provide an efficient and elastic storage solution for modern cloud computing, big data, and other scenarios.
[0004] However, in the prior art, when a network split occurs in the network where the virtual disk is located, there may be an instance of a virtual disk in each of the two networks generated by the split. These two instances can respectively make lease requests. At the same time, due to time deviations caused by the switching of the time server between different nodes, this will all cause problems with inconsistent lease calculations.
[0005] Therefore, in view of the above technical problems, it is necessary to provide a method, system, device and readable storage medium for lease consistency maintenance.
[0006] The information disclosed in this background art section is only intended to enhance the overall understanding of the present invention and should not be regarded as an admission or any form of implication that this information constitutes prior art already known to those of ordinary skill in the art. Summary of the Invention
[0007] The purpose of the present invention is to provide a method, system, device and readable storage medium for lease consistency maintenance, which can avoid problems with inconsistent lease calculations caused by time server switching or split networks.
[0008] To achieve the above purpose, the technical solution provided by a specific embodiment of the present invention is as follows:
[0009] In a first aspect, the present invention provides a method for lease consistency maintenance, which is applied to a distributed storage system and includes:
[0010] Maintain an independent logical time for the virtual disk, and perform incremental synchronization of the logical time based on a preset time interval;
[0011] When a virtual disk instance in a lease - free or lease - expired state receives an IO instruction, the virtual disk instance in the lease - free or lease - expired state sends a lease request to the lease server;
[0012] If all other virtual disk instances associated with the same virtual disk in a split - brain network are lease - free or lease - expired, in response to the lease request, configure a valid lease with a preset duration for the virtual disk instance that sent the lease request;
[0013] Based on the logical time of the virtual disk instance that obtains the valid lease, update the lease expiration time of the virtual disk instance, record the lease expiration time in the IO instruction, and execute the IO instruction.
[0014] In one or more embodiments of the present invention, the method further includes:
[0015] After sending a lease request to the lease server, if there are other virtual disk instances associated with the same virtual disk in the split - brain network that are within the lease validity period, reject the lease request and make the IO instruction fail.
[0016] In one or more embodiments of the present invention, determining whether there are other virtual disk instances associated with the same virtual disk in the split - brain network with a valid lease includes:
[0017] Maintain an independent version number for the virtual disk, where the version number includes a disk identifier and a version number. Whenever a write or modification operation is performed on the virtual disk instance corresponding to the virtual disk, the version number of the virtual disk is incremented by one, and the virtual disk instance that performs the write or modification operation inherits the version number after the increment;
[0018] In response to the lease request of the virtual machine instance, traverse the virtual disk instances in the lease record whose disk identifiers are the same as those of the virtual disk instance that sent the lease request;
[0019] If there is a virtual disk instance whose version number is inconsistent with that of the virtual disk instance that sent the lease request and whose lease expiration time is later than the current logical time, then there are other virtual disk instances associated with the same virtual disk in the current split - brain network that are within the lease validity period;
[0020] If there is no virtual disk instance whose version number is inconsistent with that of the virtual disk instance that sent the lease request or all virtual disk instances whose version numbers are inconsistent with that of the virtual disk instance that sent the lease request have lease expiration times earlier than the current logical time, then all other virtual disk instances associated with the same virtual disk in the current split - brain network are lease - free or lease - expired.
[0021] In one or more embodiments of the present invention, the formula for updating the lease expiration time of the virtual disk instance is:
[0022] T_expire = T_current + T_lease
[0023] Wherein, T_current is the logical time corresponding to the virtual disk obtained by the most recent synchronization; T_expire is the lease expiration time this time; T_lwase is the preset duration for configuring an effective lease for the virtual disk instance.
[0024] In one or more embodiments of the present invention, executing the IO instruction includes:
[0025] Issuing the IO instruction recording the lease expiration time to the disk copy corresponding to the virtual disk instance;
[0026] Based on the lease expiration time of the virtual disk instance, determining whether the lease has expired;
[0027] If so, sending a lease request to the lease server based on the disk copy;
[0028] If not, executing the process of the IO instruction in the disk copy.
[0029] In one or more embodiments of the present invention, performing incremental synchronization of the logical time includes:
[0030] At every preset time interval, the time server increments the logical time corresponding to the virtual disk by one;
[0031] Periodically synchronizing the logical time corresponding to the virtual disk with the time server.
[0032] In one or more embodiments of the present invention, determining whether the lease has expired includes:
[0033] Based on Δt = (t_current - t_lease) / c, calculating the logical duration elapsed from this lease to the current moment;
[0034] If the elapsed logical duration is greater than or equal to the preset duration for configuring an effective lease for the virtual disk instance, the lease has expired;
[0035] If the elapsed logical duration is less than the preset duration for configuring an effective lease for the virtual disk instance, the lease has not expired;
[0036] Wherein, t_current is the current physical time; t_lease is the physical time when the lease is obtained; c is the preset time interval for incrementing the logical time by one.
[0037] In a second aspect, the present invention provides a lease consistency maintenance system applied to the lease consistency maintenance method, which includes:
[0038] A clock module for maintaining an independent logical time for the virtual disk and performing incremental synchronization of the logical time based on a preset time interval;
[0039] A request module for, when a virtual disk instance in a lease-free or lease-expired state receives an IO instruction, sending a lease request to a lease server based on the virtual disk instance in the lease-free or lease-expired state;
[0040] A leasing module for, when all other virtual disk instances associated with the same virtual disk under a split-brain network are lease-free or lease-expired, responding to the lease request and configuring a valid lease with a preset duration for the virtual disk instance that sends the lease request;
[0041] An update module for updating the lease expiration time of the virtual disk instance based on the logical time of the virtual disk instance that obtains a valid lease, recording the lease expiration time in the IO instruction and executing the IO instruction.
[0042] In a third aspect, the present invention provides a computer device, which includes: a memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to execute the lease consistency maintenance method.
[0043] In a fourth aspect, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the lease consistency maintenance method.
[0044] Compared with the prior art, the lease consistency maintenance method provided by the present invention maintains an independent logical time for the virtual disk through a time server, avoiding lease time deviation. Even if there is a conversion of the time server, data that should not be written will not be written to the physical medium;
[0045] Furthermore, the present invention performs double verification of the lease validity period both at the disk instance and the replica layer, which better ensures the operation order of the switch in an environment with a large network delay. It avoids the problem that the lease expires during the transmission of the IO instruction from the disk to the replica layer and conflicts occur in the execution of the IO instruction by the replica, further ensuring the lease consistency.
[0046] Meanwhile, the present invention optimizes the lease request method. The lease request can be made either through the disk instance or through the replica layer, further improving the flexibility and response speed of the present invention in scenarios with large network latency. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments recorded in the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0048] Figure 1 is a schematic diagram of the lease consistency maintenance scenario in an embodiment of the present invention;
[0049] Figure 2 is a flowchart of the lease consistency maintenance method in an embodiment of the present invention;
[0050] Figure 3 is a structural block diagram of the lease consistency maintenance system in an embodiment of the present invention;
[0051] Figure 4 is a structural block diagram of the electronic device in an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0052] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0053] Unless otherwise clearly stated, throughout the specification and claims, the term "comprising" or its variations such as "including" or "having" etc. will be understood to include the stated elements or components, without excluding other elements or other components.
[0054] Today, the lease duration calculation of distributed storage services highly depends on the absolute time between the local and the lease server. In fact, the lease allocation mechanism based on absolute timestamps has potential risks of time reference deviation in highly available distributed systems. Specifically, when the lease server fails over, if there is a clock synchronization problem among nodes, the lease term calculation result cannot ensure consistency.
[0055] In the above distributed storage system architecture, the potential risks in the Split-Brain scenario deserve particular attention. Specifically, when a cluster experiences a split-brain and forms independent subnets, the split subsystems may each maintain service instances associated with the same virtual disk. Such dual-active instances, due to having concurrent write permissions to the underlying physical storage medium, may lead to serious data integrity problems such as data overwrite conflicts and metadata inconsistencies at the storage medium level if the time offset (Δt) of the above lease service is superimposed. It is particularly noteworthy that such a failure mode may cause irreversible data damage and fundamentally undermine the transaction consistency guarantee mechanism of the distributed storage system.
[0056] The inventors of the present invention have discovered the problem of difficult lease consistency maintenance in the above distributed storage system architecture and proposed a new technical implementation idea based on the shortcomings of the prior art: maintaining an independent logical time for the virtual disk. The change of the logical time is not affected by the switching of the time server, so it can accurately represent the start and end of the corresponding lease period. In addition, in order to address the possible lease allocation chaos and the resulting illegal data writing problems under the split-brain network. The present invention provides a dual verification mechanism based on disk instances and disk replicas, as well as an adaptive request mechanism. It effectively reduces the IO error rate caused by lease expiration and provides an innovative solution for the reliable operation of the distributed storage system in complex scenarios such as 5G edge computing and hybrid clouds.
[0057] Please refer to Figure 1 , which shows a schematic diagram of the application scenario of the lease consistency maintenance method provided by the present invention in an embodiment. This scenario specifically includes: virtual disk users, virtual disks, replicas, lease servers, and clock servers.
[0058] It should be noted that in the distributed storage service system, communication connections are set between the above virtual disk users, virtual disks, replicas, lease servers, and clock servers. The communication network derived from the above communication connections can include various connection types, including but not limited to: wired connections, wireless connections, or fiber optic cable connections, etc. At the same time, this communication network can be a local area network, a metropolitan area network, a wide area network, or any combination of the three.
[0059] A virtual disk is a logical storage unit that simulates the behavior of a physical hard disk and is managed by virtualization software or a cloud platform to provide storage space for virtual machines. A time server, as a computer network instrument, can obtain the actual time from a reference clock and then transmit the time information to the distributed storage system through the computer network. A lease server (lease server) can record lease issuance information and at the same time configure a valid lease with a preset duration to the virtual disk instance that sends a lease request.
[0060] It should be noted that the user terminal corresponding to the virtual disk user is installed with a computer software program that matches the lease consistency maintenance method provided by this method; the user terminal may include, but is not limited to, portable electronic devices such as desktop computers (PCs), desktop computers, smart phones, handheld computers, tablet computers, personal digital assistants (PDAs), etc. or wearable electronic devices, and the embodiments of the present invention do not limit the above contents.
[0061] It should also be noted that the lease consistency maintenance method of the embodiments of the present invention can be applied to the lease consistency maintenance system of the embodiments of the present invention. The lease consistency maintenance system can be configured in the terminal. The terminal may include, but is not limited to, PCs (Personal Computers), PDAs (tablet computers), smart phones, smart wearable devices, etc.
[0062] Please refer to Figure 2 As shown, it is a schematic flowchart of the lease consistency maintenance method in an embodiment of the present invention. The lease consistency maintenance method specifically includes the following steps:
[0063] S201: Maintain an independent logical time for the virtual disk, and perform incremental synchronization of the logical time based on a preset time interval;
[0064] It should be noted that conventional logical clocks are mostly used to maintain the causal relationship of events occurring in a distributed storage system. The causal relationship is also the partial order relationship of the sending and receiving of events or times on the absolute clock. This kind of logical clock will increase the clock value as events occur in the system to solve the timing problem in the distributed system. Different from the above logical clock, the independent logical time maintained by the present invention for the virtual disk can continuously increment at a certain time interval and does not depend on the occurrence of events for update.
[0065] Furthermore, a virtual disk is a logical storage unit that simulates the behavior of a physical hard disk, is managed by virtualization software or a cloud platform, and provides storage space for virtual machines. Since a virtual disk usually appears as a file (such as.vmdk,.vhd,.qcow2, etc.), it cannot maintain its own clock by itself. It is necessary to rely on a clock server to maintain the above logical time. A time server, as a kind of computer network instrument, can obtain the actual time from a reference clock and then transmit the time information to the distributed storage system through the computer network.
[0066] It is understandable that using logical time instead of absolute time can avoid the problem of clock desynchronization caused by the time server switching between different nodes and the problem of inconsistent lease term calculation results. For example, in the initial deployment stage, the lease service instance runs on node A. When the node fails and the service switches to node B, if there is an offset Δt in the system clocks between the nodes, the lease expiration time calculated based on their respective local clocks will have a calculation deviation of the order of Δt. This time sequence misalignment may lead to misjudgment of the lease status, and further trigger critical section access conflicts or resource preemption exceptions in the distributed system.
[0067] The present invention uses the method of logical time to avoid time deviation. Even if the time server switches, it still continues to increment the logical time corresponding to the virtual disk at a preset interval, without causing time deviation due to the time server switch.
[0068] In an exemplary embodiment, performing the incremental synchronization of the logical time includes: at every preset time interval, the time server adds one to the logical time corresponding to the virtual disk; the distributed storage system synchronizes the logical time corresponding to the virtual disk with the time server periodically. Based on the above generation and application principles of the logical time, it can be understood that the present invention does not limit the format, initial value, and preset time interval of the logical time. At the same time, it can be understood that the smaller the cycle time for synchronizing with the time server, the more accurate the lease calculation, but the relatively more resource consumption.
[0069] For example, the logical clock can be represented as a natural number, binary number, etc.; at every 1 s, the time server adds one to the logical time; at every 10 s, the logical time value corresponding to the current virtual disk is synchronized with the practice server.
[0070] S202: When a virtual disk instance in a lease-free or lease-expired state receives an IO instruction, based on the virtual disk instance in the lease-free or lease-expired state, a lease request is sent to the lease server;
[0071] It should be noted that in a common lease system, there are two types of roles, lease managers and lease users. Lease managers are responsible for issuing leases, and lease users are responsible for judging and using the leases they own. A lease indicates the work that a lease user can be authorized to do within a certain period of time.
[0072] Corresponding to the distributed storage system applied in the present invention, holding a lease is a necessary condition for a virtual disk instance to rewrite the disk content. The lease manager corresponds to a preset lease server, which can record lease issuance information and at the same time configure a valid lease of a preset duration to the virtual disk instance that sends a lease request.
[0073] When a virtual disk instance receives an IO instruction, in order to execute the IO instruction, it needs to first check whether it holds a valid lease. If it is in a state of no lease or expired lease, it needs to send a lease request to the lease server based on the virtual disk instance in the state of no lease or expired lease. When the lease request returns successfully, the virtual disk instance can receive a corresponding expiration time and can execute the IO instruction within the period; if the return fails, the corresponding IO instruction will also fail.
[0074] In an exemplary embodiment of the present invention, determining whether the lease has expired includes: calculating and obtaining the logical duration elapsed from this lease to the current moment; if the elapsed logical duration is greater than or equal to the preset duration for configuring a valid lease for the virtual disk instance, the lease has expired; if the elapsed logical duration is less than the preset duration for configuring a valid lease for the virtual disk instance, the lease has not expired.
[0075] Specifically, in one implementation manner, the calculation formula for the logical duration elapsed from this lease to the current moment is:
[0076] Δt = (t_current - t_lease) / c
[0077] Wherein, t_current is the current physical time; t_lease is the physical time when the lease is obtained; c is a preset time interval for incrementing the logical time by one.
[0078] Since the update frequency of the logical time increment synchronization is usually less than the update time of the physical time, in order to ensure accurate control of the lease expiration time, within the premise of the unified time server during the lease validity period, the physical time can be used to calculate and obtain the duration elapsed from the lease to the current moment.
[0079] In a specific embodiment, the distributed storage service uses the most recently obtained logical time plus the difference between the current time and the time when it is obtained to compare with the lease expiration time. Since the distributed storage service synchronizes the time every 10s, theoretically, there may be a situation inconsistent with the time server. It is speculated that there are two cases of inconsistency. The time calculated by the storage service is faster than the cluster time (for example: the storage system logical time is 20, and the cluster logical time is 10) or slower than the cluster time (for example: the storage logical time is 20, and the cluster logical time is 35).
[0080] For the above theoretical misjudgment case 1: In fact, it will not cause problems during actual use. For example, if the time server fails, the logical time will stagnate. Then there may be a situation where the time calculated by the storage service is faster than the logical time, that is, it will cause the IO to expire in advance. However, because the expired IO will send a lease request again, it will not cause misjudgment due to this reason, resulting in data that should not be written being written to the physical medium.
[0081] For the above-mentioned theoretical misjudgment case 2: that is, the time calculated by the storage service is slower than the logical time (for example, the IO expiration time is 30, while the time calculated by the storage service is 20, but the actual time of the cluster is 35), then this expired IO will be written to the physical medium, causing an error. However, this kind of error is impossible to occur because the real time interval from the last synchronization time of the storage service to the present will not make a mistake. If the storage service is accidentally shut down, then the whole process will start over after restart. Although the time server updates the logical time every 1 s, the update interval may be greater than 1 s due to service interruption.
[0082] It can be seen that this embodiment can solve all the theoretically possible abnormal situations, so it can be seen that this embodiment has high fault tolerance and adaptability.
[0083] In another embodiment, if the time server is frequently replaced in the usage scenario, at this time, the physical time may have a large deviation, affecting the calculation of the above-mentioned logical time. In this scenario, it can be configured that when the virtual disk instance obtains a valid lease, a logical time synchronization is immediately performed; when it is necessary to judge whether the lease is valid, a logical time synchronization is also immediately performed. Take the difference between the two logical times to obtain the logical duration elapsed from the lease acquisition to the present.
[0084] Similarly, in the above scenario, it is also possible to appropriately increase the frequency of logical time synchronization between the distributed storage system and the time server based on the system's load pressure, improve the accuracy of the logical time at each moment, so as to directly calculate the interval between two logical time points without additional configuration and obtain the logical duration elapsed from the lease acquisition to the present.
[0085] S203: If all other virtual disk instances associated with the same virtual disk under the split-brain network have no lease or the lease has expired, then in response to the lease request, configure a valid lease with a preset duration for the virtual disk instance that sends the lease request;
[0086] It should be noted that in order to ensure the consistency of disk data, when a certain virtual disk instance performs an IO operation and writes to the physical medium corresponding to the virtual disk, other instances associated with this virtual disk will not be able to perform similar operations on the virtual disk at this time. Specifically, when a certain virtual disk instance obtains a lease, all other instances associated with the same virtual disk will enter the access locked state until the current lease is released. In short, the lease is essentially a time-limited access authorization credential, and its core feature is that only a single instance is allowed to hold a valid lease at the same time. When the lease is granted to an instance, the system will automatically reject the lease application of other instances, thereby realizing write control at the physical storage layer.
[0087] However, during the operation of a distributed storage system, there may be a situation where due to network errors, some cluster members are unable to connect to other members of the cluster, which is called split brain. Under a split-brain network, instances associated with the same virtual disk cannot communicate with each other, but the instances within each subset can still independently access the physical medium underlying the virtual disk, thereby enabling modification of the disk content. In this case, virtual disk instances in different subsets may misjudge themselves as the only surviving nodes and simultaneously send lease or renewal requests, resulting in multiple associated instances holding valid leases at the same time.
[0088] To solve the problem that leases cannot be agreed upon due to the inability of instances associated with the same virtual disk to communicate under a split-brain network, after receiving a lease request, the lease manager of the present invention will traverse other virtual disk instances within the cluster. If all other virtual disk instances associated with the same virtual disk have no lease or the lease has expired, a lease will be configured for the instance that sent the request; otherwise, after sending a lease request to the lease server, if there are other virtual disk instances associated with the same virtual disk under the split-brain network that are within the lease validity period, the lease request will be rejected and the IO instruction will fail.
[0089] Specifically, in an exemplary embodiment of the present invention, determining whether there are other virtual disk instances associated with the same virtual disk that have a valid lease under a split-brain network includes: maintaining an independent version number for the virtual disk, the version number including a disk identifier and a version number. Whenever a virtual disk instance corresponding to the virtual disk performs a write or modification operation, the version number of the virtual disk is incremented by one, and the virtual disk instance that performs the write or modification operation inherits the version number after the increment; in response to a lease request from a virtual machine instance, traverse the virtual disk instances in the lease record that have the same disk identifier as the virtual disk instance that sent the lease request; if there are virtual disk instances with a version number different from that of the virtual disk instance that sent the lease request and a lease expiration time later than the current logical time, then there are other virtual disk instances associated with the same virtual disk under the current split-brain network that are within the lease validity period; if there are no virtual disk instances with a version number different from that of the virtual disk instance that sent the lease request or all virtual disk instances with a version number different from that of the virtual disk instance that sent the lease request have a lease expiration time earlier than the current logical time, then all other virtual disk instances associated with the same virtual disk under the current split-brain network have no lease or the lease has expired.
[0090] For example, in a specific embodiment, the current logical time is 10, and the virtual disk version number is V0, where V is the disk identifier of the virtual disk and 0 is the current version number of the virtual disk. In a split-brain network, the virtual disk is respectively mounted to form virtual disk instance A and virtual disk instance B. At a certain moment, virtual disk instance A receives an IO. At this time, the version numbers of the virtual disk and virtual disk instance A are updated to V1. However, virtual disk instance B under the split-brain network remains at version V0. At the next moment, virtual disk instance B receives an IO. At this time, the virtual disk version number is incremented by one, and the version number is updated to V2. Virtual disk instance B is also updated to version V2, and virtual disk instance A remains at V1.
[0091] When the lease server receives a lease request sent by a virtual disk instance with version number V1, if there are other virtual disk instances with the same disk identifier but different version numbers (such as V0, V2, etc.) in the historical record that are within the lease validity period, it indicates that other instances associated with the same virtual disk under the current split-brain network hold leases. To ensure lease consistency, the lease configuration for the instance that sent the request should be rejected. Otherwise, it can be configured for it.
[0092] S204: Based on the logical time of the virtual disk instance that obtains a valid lease, update the lease expiration time of the virtual disk instance, record the lease expiration time in the IO instruction, and execute the IO instruction.
[0093] It should be noted that the formula for updating the lease expiration time of the virtual disk instance is:
[0094] T_expire = T_current + T_lease
[0095] Wherein, T_current is the logical time corresponding to the virtual disk obtained by the most recent synchronization; T_expire is the lease expiration time for this time; T_lease is the preset duration for configuring a valid lease for the virtual disk instance.
[0096] Furthermore, the IO instruction is an input / output instruction. In the embodiments of the present invention, it may include, but is not limited to, read operations, write operations, etc. on the virtual disk. In an exemplary embodiment, the execution of the IO instruction includes: sending the IO instruction recording the lease expiration time to the disk copy corresponding to the virtual disk instance; based on the lease expiration time of the virtual disk instance, determining whether the lease has expired; if so, sending a lease request to the lease server based on the disk copy; if not, executing the process of the IO instruction on the disk copy.
[0097] Due to network latency, it is possible that the lease of the virtual disk instance expires during the process of issuing the IO instruction to the virtual disk replica. As described above, holding a valid lease is a necessary condition for modifying the disk content, that is, executing the IO instruction. Therefore, the replica will not be able to execute the IO instruction at this time. However, if the disk instance needs to send a lease request through the network to the instance, it is too cumbersome. Therefore, in the embodiment of the present invention, each replica will separately judge the lease validity when receiving the IO instruction. If it is invalid, it can directly send a lease request containing the version number to the lease server with the current replica. Among them, judging whether the lease of the virtual disk instance expires can be consistent with the above-mentioned implementation method of lease verification on the virtual disk instance side.
[0098] Please refer to Figure 3 As shown, based on the same inventive concept as the foregoing lease consistency maintenance method, an embodiment of the present invention provides a lease consistency maintenance system 300, which includes: a clock module 301, a request module 302, a leasing module 303, and an update module 304.
[0099] Specifically, the clock module 301 is used to maintain an independent logical time for the virtual disk and perform incremental synchronization of the logical time based on a preset time interval; the request module 302 is used to send a lease request to the lease server based on the virtual disk instance in the no-lease or lease-expired state when the virtual disk instance in the no-lease or lease-expired state receives an IO instruction; the leasing module 303 is used to configure a valid lease with a preset duration for the virtual disk instance that sends the lease request when other virtual disk instances associated with the same virtual disk under the split-brain network are all in the no-lease or lease-expired state; the update module 304 is used to update the lease expiration time of the virtual disk instance based on the logical time of the virtual disk instance that obtains the valid lease, record the lease expiration time in the IO instruction, and execute the IO instruction.
[0100] Please refer to Figure 4 As shown, an embodiment of the present invention also provides an electronic device 400, which includes at least one processor 401, a memory 402 (such as a non-volatile memory), a memory 403, and a communication interface 404, and at least one processor 401, the memory 402, the memory 403, and the communication interface 404 are connected together via an internal bus 405. At least one processor 401 is used to call at least one program instruction stored or encoded in the memory 402 so that at least one processor 401 executes various operations and functions of the lease consistency maintenance method described in each embodiment of this specification.
[0101] In the embodiments of the present specification, the electronic device 400 may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile electronic devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable electronic devices, consumer electronic devices, and so on.
[0102] An embodiment of the present invention also provides a computer-readable medium having computer-executable instructions stored thereon. When the computer-executable instructions are executed by a processor, they can be used to implement various operations and functions of the lease consistency maintenance method described in the embodiments of the present specification.
[0103] The computer-readable medium in the present invention may be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may, for example, be, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in connection with an instruction execution system, apparatus, or device.
[0104] In the present invention, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination of the above.
[0105] Those skilled in the art will understand that the embodiments of the present invention can be provided as a method, a system, or a computer program product. Therefore, the present invention can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present invention can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0106] The present invention is described with reference to the flowcharts and / or block diagrams of methods, apparatuses, systems, and computer program products according to the embodiments of the present invention. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, as well as the combination of flows and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate means for implementing the functions specified in Figure 1 one or more of the flows Figure 1 or multiple flows and / or blocks
[0107] The foregoing description of the specific exemplary embodiments of the present invention is for the purposes of illustration and exemplification. These descriptions are not intended to limit the present invention to the precise forms disclosed, and it is apparent that many changes and variations are possible in light of the above teachings. The purpose of selecting and describing the exemplary embodiments is to explain the specific principles of the present invention and its practical applications, so that those skilled in the art can implement and utilize the various different exemplary embodiments of the present invention, as well as various different selections and changes. The scope of the present invention is intended to be defined by the claims and their equivalents.
[0108] For those skilled in the art, it is obvious that the present invention is not limited to the details of the above-described exemplary embodiments, and without departing from the spirit or basic characteristics of the present invention, the present invention can be implemented in other specific forms. Therefore, in any aspect, the embodiments should be regarded as exemplary and non-limiting. The scope of the present invention is defined by the appended claims rather than the above description. Therefore, it is intended to embrace all changes within the meaning and scope of the equivalent elements of the claims in the present invention. Any reference signs in the claims should not be regarded as limiting the claims involved.
[0109] In addition, it should be understood that although this specification is described in terms of embodiments, not every embodiment contains only one independent technical solution. This narrative style of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A lease consistency maintenance method, applied to a distributed storage system, characterized in that Including: Maintaining an independent logical time for the virtual disk, and performing incremental synchronization of the logical time based on a preset time interval; When a virtual disk instance in a lease-free or lease-expired state receives an IO instruction, sending a lease request to the lease server based on the virtual disk instance in the lease-free or lease-expired state; If all other virtual disk instances associated with the same virtual disk in a split-brain network are lease-free or lease-expired, then in response to the lease request, configuring a valid lease with a preset duration for the virtual disk instance that sent the lease request; Based on the logical time of the virtual disk instance that obtains a valid lease, updating the lease expiration time of the virtual disk instance, recording the lease expiration time in the IO instruction, and executing the IO instruction.
2. The lease consistency maintenance method according to claim 1, characterized in that The method further includes: After sending a lease request to the lease server, if there are other virtual disk instances associated with the same virtual disk in the split-brain network that are within the lease validity period, rejecting the lease request and causing the IO instruction to fail.
3. The lease consistency maintenance method according to claim 1, characterized in that Judging whether there are other virtual disk instances associated with the same virtual disk in the split-brain network with a valid lease includes: Maintaining an independent version number for the virtual disk, where the version number includes a disk identifier and a version number. Whenever a write or modification operation is performed on the virtual disk instance corresponding to the virtual disk, the version number of the virtual disk is incremented by one, and the virtual disk instance that performs the write or modification operation inherits the version number after the increment; In response to a lease request from a virtual machine instance, traversing the virtual disk instances in the lease record that have the same disk identifier as the virtual disk instance that sent the lease request; If there is a virtual disk instance with a version number different from that of the virtual disk instance that sent the lease request and a lease expiration time later than the current logical time, then there are other virtual disk instances associated with the same virtual disk in the current split-brain network that are within the lease validity period; If there is no virtual disk instance with a version number different from that of the virtual disk instance that sent the lease request or all virtual disk instances with a version number different from that of the virtual disk instance that sent the lease request have a lease expiration time earlier than the current logical time, then all other virtual disk instances associated with the same virtual disk in the current split-brain network are lease-free or lease-expired.
4. The lease consistency maintenance method according to claim 1, characterized in that The formula for updating the lease expiration time of the virtual disk instance is: T_expire = T_current + T_lease Wherein, T_current is the logical time corresponding to the virtual disk obtained by the most recent synchronization; T_expire is the lease expiration time for this time; T_lease is the preset duration for configuring a valid lease for the virtual disk instance.
5. The lease consistency maintenance method according to claim 1, characterized in that Executing the IO instruction includes: Issuing the IO instruction recording the lease expiration time to the disk copy corresponding to the virtual disk instance; Based on the lease expiration time of the virtual disk instance, judging whether the lease has expired; If so, sending a lease request to the lease server based on the disk copy; If not, executing the process of the IO instruction on the disk copy.
6. The lease consistency maintenance method according to claim 5, wherein Performing incremental synchronization of the logical time includes: At every preset time interval, the time server increments the logical time corresponding to the virtual disk by one; Periodically synchronize the logical time corresponding to the virtual disk with the time server.
7. The lease consistency maintenance method according to claim 6, wherein The determination of whether the lease has expired includes: Based on Δt = (t_current - t_lease) / c, calculate the logical duration elapsed from this lease to the current moment; If the elapsed logical duration is greater than or equal to the preset duration of the valid lease configured for the virtual disk instance, the lease has expired; If the elapsed logical duration is less than the preset duration of the valid lease configured for the virtual disk instance, the lease has not expired; where t_current is the current physical time; t_lease is the physical time when the lease is obtained; and c is the preset time interval for incrementing the logical time by one.
8. A lease consistency maintenance system is applied to the lease consistency maintenance method described in any one of claims 1-7, and is characterized in that, Includes: A clock module for maintaining an independent logical time for the virtual disk and performing incremental synchronization of the logical time based on a preset time interval; A request module for, when a virtual disk instance in a lease-free or lease-expired state receives an IO instruction, sending a lease request to the lease server based on the virtual disk instance in the lease-free or lease-expired state; A leasing module for, when all other virtual disk instances associated with the same virtual disk under a split-brain network are lease-free or lease-expired, responding to the lease request and configuring a valid lease of a preset duration for the virtual disk instance that sent the lease request; An update module for updating the lease expiration time of the virtual disk instance based on the logical time of the virtual disk instance that obtained the valid lease, recording the lease expiration time in the IO instruction and executing the IO instruction.
9. A computer device, characterized in that, Includes: A memory and a processor, the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to execute the lease consistency maintenance method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing a computer to execute the lease consistency maintenance method according to any one of claims 1-7.
Citation Information
Cited By
Simulation data analysis method and system for virtual training of emergency personnel
CN121839173A