Method and device for quickly synchronizing time in distributed storage system
By introducing a dynamic analysis mechanism for time deviation limits in the distributed storage system, combined with the smooth time synchronization mode of the NTPD service, fast and stable time synchronization is achieved, solving the problems of slow synchronization speed and time jump in existing technologies, and improving the stability and operation and maintenance efficiency of the system.
Patent Information
- Application Number
- CN202510893363.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-11-07
AI Technical Summary
Existing time synchronization methods for distributed storage systems struggle to balance efficiency and stability, leading to excessively long synchronization times or time jumps that affect system stability and data consistency. This is especially problematic in high-concurrency, high-reliability environments, where it limits system availability and operational efficiency.
A dynamic analysis mechanism for system time deviation limits is introduced, combined with the smooth time synchronization mode of NTPD service. Through phased time synchronization and one-time adjustment of remaining time, the system can achieve fast and efficient time synchronization under the premise of stable operation.
It improves time synchronization efficiency, avoids system service anomalies caused by time jumps, enhances system stability and fault tolerance, improves system compatibility and adaptability, reduces operation and maintenance difficulty, and improves system security and automation level.
Smart Images

Figure CN120915799A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a distributed storage system, and in particular to a method and device for fast time synchronization in a distributed storage system. BACKGROUND
[0002] Time synchronization, as a key technology in a distributed storage system, is widely used in cloud computing, big data processing and high-availability storage architecture. Its core role is to ensure the data consistency between nodes, the correctness of log timing and the reliability of fault recovery. In related technologies, a time synchronization system for a distributed system is constructed through the collaborative work of NTP protocol, system clock management module and storage service state control mechanism. Specifically, the system covers the whole process from time deviation detection, synchronization strategy selection to clock adjustment execution, including key links such as time source communication, clock drift compensation and service timeout control. With the expansion of the scale of the distributed system and the improvement of the requirement for time accuracy, the balance between efficiency and stability of the traditional time synchronization mechanism becomes a technical challenge to be solved.
[0003] However, in the existing time synchronization method, the smooth time or step time mode of NTPD service is directly used, and the time deviation tolerance limit of the distributed storage system under different operating states is not fully considered, which may cause the synchronization process to take too long or the time to jump, or trigger the service to stop when the deviation is too large, thereby affecting the system stability and data consistency. Specifically, the adjustment rate of the smooth time mode is limited (such as only 0.5 ms per second), which is difficult to meet the fast synchronization requirement; the step time is fast, but the time jump may cause service exceptions; in addition, when the deviation exceeds 1000 seconds, the NTPD service will automatically terminate, resulting in the system being unable to continue synchronization. These defects are particularly prominent in a high-concurrency and high-reliability storage environment, limiting the usability and operation efficiency of the system. SUMMARY
[0004] The purpose of the present application is to provide a method and device for fast time synchronization based on a distributed storage system, to solve the problems of slow time synchronization speed, system exception caused by time jump, and service stop when the time deviation is too large in the prior art. By introducing a dynamic analysis mechanism of system time deviation limit and combining the smooth time mode of NTPD service, fast and efficient time synchronization is realized under the premise of ensuring stable operation of the system, thereby improving the data consistency, operation stability and operation efficiency of the distributed storage system.
[0005] To this end, the first purpose of the present application is to propose a method for fast time synchronization in a distributed storage system.
[0006] The second purpose of the present application is to propose a device for fast time synchronization in a distributed storage system.
[0007] A third object of the present application is to provide an electronic device.
[0008] A fourth object of the present application is to provide a computer-readable storage medium.
[0009] A fifth object of the present application is to provide a computer program product.
[0010] To achieve the above objects, a first aspect of the present application provides a method for fast time synchronization in a distributed storage system, comprising:
[0011] In response to a timing detection request, obtaining a time deviation value between a current node and a time source node;
[0012] When the time deviation value exceeds a preset time deviation threshold, starting a fast time synchronization service;
[0013] After starting the fast time synchronization service, dynamically obtaining timeout time parameters of each service in the storage system, including storage system management service effective time, storage system management service timeout time, storage system metadata service timeout time, and client waiting timeout time;
[0014] Setting the time synchronization time of each time to the storage system management service effective time, and setting the time interval for time synchronization to the maximum of the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time;
[0015] In response to the setting of the time synchronization start flag, entering a loop time synchronization state, periodically obtaining a time deviation value, and based on the comparison of the time deviation value and a time deviation limit, performing a phased time synchronization operation;
[0016] When the time deviation value is less than or equal to the time deviation limit, adjusting the remaining time deviation at one time, and exiting the loop time synchronization state, switching the storage system from maintenance mode back to normal operation mode.
[0017] Optionally, the NTPD service is used to communicate with the time source node to obtain the time deviation value between the current node and the time source node.
[0018] Optionally, the time deviation value is obtained by periodically detecting a preset period, and the preset period is dynamically adjusted according to system load and node quantity.
[0019] Optionally, only the deviation amount not exceeding the storage system management service effective time is adjusted in each time synchronization, and the time interval for time synchronization is waited after each time synchronization.
[0020] To achieve the above object, the second aspect of the present application proposes a device for fast time synchronization based on a distributed storage system, comprising:
[0021] a time deviation detection module, configured to obtain a time deviation value between a current node and a time source node in response to a timing detection request;
[0022] a fast time synchronization service starting module, configured to start a fast time synchronization service through the fast time synchronization service starting module when the time deviation value exceeds a preset time deviation threshold;
[0023] a time deviation limit analysis module, configured to dynamically obtain timeout time parameters of each service in the storage system after the fast time synchronization service is started, including a storage system management service effective time, a storage system management service timeout time, a storage system metadata service timeout time, and a client waiting timeout time;
[0024] a phased time synchronization control module, configured to set a time synchronization time of each time as the storage system management service effective time, and set a time synchronization interval time as a maximum value among the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time;
[0025] a time synchronization start flag setting module, configured to set a time synchronization start flag to identify the start of a time synchronization process;
[0026] a loop time synchronization logic execution module, configured to periodically obtain a time deviation value in response to the time synchronization start flag entering a loop time synchronization state, and perform a phased time synchronization operation based on a comparison between the time deviation value and a time deviation limit;
[0027] a remaining time adjustment module, configured to adjust a remaining time deviation at one time and exit the loop time synchronization state when the time deviation value is less than or equal to the time deviation limit;
[0028] a system state switching module, configured to switch the storage system from a maintenance mode back to a normal operation mode.
[0029] Optionally, the time deviation detection module communicates with the time source node through an NTPD service to obtain the time deviation value between the current node and the time source node.
[0030] Optionally, the time deviation limit analysis module includes a plurality of sub-modules for obtaining the storage system management service effective time, the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time, respectively.
[0031] Optionally, the time deviation limit analysis module obtains timeout time parameters of a plurality of services in the storage system, takes the maximum value of the time synchronization time, the storage system management service timeout time, the storage system metadata service timeout time and the client waiting timeout time as the time synchronization interval time to ensure that the service timeout is not triggered in the time synchronization process.
[0032] To achieve the above object, the third aspect of the present application provides an electronic device, comprising: a processor, and a memory connected with the processor in communication;
[0033] The memory stores computer execution instructions.
[0034] The processor executes the computer execution instructions stored in the memory to implement the method according to any one of the first aspect.
[0035] To achieve the above object, the fourth aspect of the present application provides a computer readable storage medium, wherein the computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by a processor to implement the method according to any one of the first aspect.
[0036] To achieve the above object, the fifth aspect of the present application provides a computer program product, wherein the computer program is executed by a processor to implement the method according to any one of the first aspect.
[0037] The technical scheme provided by the embodiments of the present application at least brings the following beneficial effects:
[0038] By introducing the dynamic analysis mechanism of the time deviation limit of the distributed storage system, combining with the smooth time synchronization mode of the NTPD service, the intelligent control of the system running state is realized in the time synchronization process, so that the efficiency of time synchronization is significantly improved on the premise of ensuring the stable operation of the system. The specific beneficial effects include:
[0039] 1. Improve the efficiency of time synchronization: by combining the phased time synchronization with the one-time adjustment of the remaining time, the time required for time synchronization is shortened, and the problem of slow adjustment speed in the traditional smooth time synchronization mode is avoided;
[0040] 2. Avoid time jump: time adjustment is performed in the maintenance mode, which avoids the system service exception caused by time jump, and guarantees the data consistency and the accuracy of log record;
[0041] 3. Enhance system stability: when the time deviation is large, the system enters the maintenance mode for gradual adjustment, which avoids the problem that the NTPD service stops due to too large time deviation, and improves the fault tolerance of the system;
[0042] 4. Improve system compatibility and adaptability: By dynamically obtaining the timeout parameter of each service in the system, and setting the time synchronization strategy accordingly, the time synchronization mechanism can adapt to distributed storage systems of different sizes and loads;
[0043] 5. Reduce operation and maintenance difficulty: The time synchronization process has little impact on system operation, and operation and maintenance personnel do not need to intervene frequently, improving the automation level and maintainability of the system;
[0044] 6. Improve system security: Avoids the problem of security mechanism failure caused by time jump, such as authentication, log audit, etc., thereby enhancing the overall security of the system.
[0045] Additional aspects and advantages of the application will be in part apparent and in part pointed out hereinafter. BRIEF DESCRIPTION OF DRAWINGS
[0046] The above and / or additional aspects and advantages of the application will become apparent and be readily appreciated from the following description, including the accompanying drawings, wherein:
[0047] Figure 1 A flowchart of a method for fast synchronization of time based on a distributed storage system provided by an embodiment of the application. DETAILED DESCRIPTION
[0048] The embodiments of the application are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference signs represent the same or similar elements or elements having the same or similar functions throughout. The embodiments described below are exemplary and are intended to explain the application, and cannot be understood as limiting the application.
[0049] As Figure 1 shown, the application provides a method for fast synchronization of time based on a distributed storage system, the core of which is to realize efficient and stable time synchronization by dynamically analyzing the time deviation limit that the system can withstand, combined with the smooth time synchronization mode of NTPD service. The following will be combined with the accompanying Figure 1 , the method embodiment is described in detail.
[0050] As Figure 1 shown, the method comprises the following steps:
[0051] Step S1: In response to a timing detection request, obtain the time deviation value between the current node and the time source node.
[0052] In a distributed storage system, a node needs to be selected as a time synchronization detection node first. This node will be responsible for periodically detecting the time deviation between other nodes in the system and the time source node. The detection node can be any node with sufficient computing and network resources, usually the master node or the node with low load in the system.
[0053] In a specific embodiment, the system communicates with the time source node through the NTPD (Network Time Protocol Daemon) service. The NTPD service can use the standard NTP protocol to periodically obtain accurate time from external time sources. The function of NTPD is to synchronize the system time of the local computer with the time source node to ensure the consistency and accuracy of time. During the detection period, the NTPD service will actively send a synchronization request to the set time source node to obtain the current time value and compare it with the local node's time to calculate the time deviation between the local node and the time source. This deviation value is the clock difference between the node and the time source, in seconds.
[0054] It should be noted that the detection period is a configurable parameter that can be dynamically adjusted according to the changes in system load and the number of nodes. In the case of low load, time synchronization detection can be performed more frequently, and it is recommended to set the detection period to 10 seconds, which helps to maintain high synchronization accuracy in real-time scenarios. In the case of high load, frequent time synchronization requests may increase the system burden due to the shortage of system resources, so the detection period can be appropriately extended. At this time, it is recommended to set it to 60 seconds to balance the accuracy of time synchronization and the impact of system load.
[0055] In addition, the adjustment of the detection period not only considers the current load, but also dynamically optimizes according to the number of nodes, storage load and other factors. The specific adjustment algorithm can be based on the response time of the node, network delay and system health status data, etc. to automatically determine the best detection period through intelligent algorithms.
[0056] After each detection is completed, the current time deviation value is recorded, and further processing is performed according to the size of the deviation value. If the deviation value exceeds the preset threshold, the embodiment of the application will enter the next step of the fast time synchronization service to ensure the accuracy of the system time.
[0057] Through the implementation of this step, effective monitoring and adjustment of system time synchronization can be achieved, thereby providing accurate data support for subsequent time synchronization services and dynamically optimizing synchronization strategies in the case of system load changes to improve the stability of the overall system and the accuracy of time synchronization.
[0058] Step S2: when the time deviation value exceeds the preset time deviation threshold, starting the fast time synchronization service.
[0059] In step S1, the system periodically acquires the time deviation value between the current node and the time source node through the NTPD service. When this time deviation value exceeds the preset time deviation threshold, the fast time synchronization service is triggered. Specifically, the system determines whether the time deviation exceeds the set threshold. If the threshold is exceeded, it is considered that there is a large time difference in the system, and the fast time synchronization service must be started to quickly restore time synchronization.
[0060] It can be understood that the setting of the time deviation threshold needs to be flexibly adjusted according to the time consistency requirements of the system. For example, in a financial transaction system, the requirement for time is extremely strict, and the accuracy of transactions and time stamps are crucial to business, so the time deviation threshold can be set to 50ms. In a general distributed storage system, the requirement for time consistency is lower, and the time deviation threshold can be set to 100ms. By setting an appropriate time deviation threshold, the system can start the time synchronization service in time, thereby reducing the impact of time errors on business operation. The selection of the threshold should consider the actual needs and fault tolerance capabilities of the system to ensure that the system operates normally within the allowable error range.
[0061] When the time deviation exceeds the preset threshold, the fast time synchronization process is automatically triggered. This process accelerates the time synchronization process in the following ways: In order to avoid service interruption caused by time jump, the system will first switch the storage system to maintenance mode. After entering maintenance mode, the system will suspend some non-critical services to ensure the stable progress of the time synchronization process. Compared with the traditional step-by-step time synchronization mode (such as the step-by-step time synchronization in NTPD), the embodiments of the present application use a smooth time synchronization strategy, which accurately calculates the maximum time deviation that the system can tolerate, and combines the smooth time synchronization mode of NTPD. The system will try to avoid service interruption caused by time jump. After entering maintenance mode, the system will use an accurate time adjustment mechanism within the maximum allowable deviation range to gradually reduce the time deviation until the system returns to normal state.
[0062] It should be noted that the prior art (such as the step-by-step time synchronization mode of NTPD) usually directly performs a time jump operation when the time deviation exceeds the threshold. Although this approach can quickly adjust the time, it may cause a short interruption of system services, especially in a distributed storage system, due to the inconsistency of time, which may cause data loss or service interruption. Unlike the prior art, the present application avoids the risks brought by directly performing a time jump through the mechanism of maintenance mode switching. During the time synchronization process, the system will maintain the normal operation of some services to reduce the impact on business. This greatly improves the availability and stability of the system.
[0063] In addition, in actual operation, some failure scenarios may be encountered, such as time source unavailability or network interruption. In these cases, the system must have sufficient fault tolerance capability to automatically recover when problems occur.
[0064] As a possible implementation, if the time source is detected to be unavailable or the network is interrupted, the system will trigger a retry mechanism. According to the design, the system will re-detect the status of the time source after 30 seconds. If the time source becomes available again, the system will continue to perform time synchronization. If the time source remains unavailable, the system will enter an error handling state and wait for further recovery operations.
[0065] As another possible implementation, the system also has a retry mechanism. The retry mechanism ensures that the system can quickly recover time synchronization after the network is restored or the time source becomes available. The system will preferentially obtain the time source from the network and recalculate the time deviation, thereby ensuring the stability and time consistency of the system.
[0066] Through the technical solution of the present application, the system can start the fast time synchronization service when the time deviation exceeds the preset threshold, and avoid the service interruption problem caused by time jump in the traditional method through maintenance mode switching. Combined with the retry mechanism of the failure scenario analysis, the system can recover in time when the network is interrupted or the time source is unavailable, providing higher stability and availability for distributed storage systems.
[0067] Step S3: After the fast time synchronization service is started, dynamically obtain the timeout time parameters of each service in the storage system, including the storage system management service valid time, the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time.
[0068] In step S2, when the system detects that the time deviation value exceeds the preset threshold, the fast time synchronization service is triggered. In order to ensure the stability and consistency of the system, the timeout time parameters of each service must be dynamically obtained in order to take reasonable measures during time synchronization.
[0069] After the fast time synchronization service is started, the system will perform synchronization operations according to the timeout time parameters of each service. The following is the acquisition and role of each timeout time parameter:
[0070] Storage system management service valid time (leasetime): This parameter represents the valid time of the storage system management service. During time synchronization, the system needs to determine whether the current time synchronization is still valid according to this valid time, and provide a time reference for subsequent operations. leasetime is usually closely related to the maintenance window of the storage system.
[0071] Storage system management service timeout (mtimeout): The mtimeout parameter is used to set the timeout time for storage system management services. During time synchronization, if the system fails to synchronize successfully for a long time, the timeout mechanism will be triggered. The system will determine whether to re-synchronize or enter the error handling mechanism based on the timeout time. This parameter ensures that the system can recover in time in the case of time synchronization failure, preventing long-term blocking.
[0072] Storage system metadata service timeout (beacontime): During fast time synchronization, the metadata service of the storage system needs to interact with other nodes continuously. Beacontime defines the timeout time for the metadata service, which determines the operation (such as re-sending requests or waiting for retries) that the system should take if it does not receive the expected response during data interaction. This parameter helps maintain data consistency, especially when multiple nodes are synchronized.
[0073] Client waiting timeout (ctimeout): Ctimeout is the maximum waiting time allowed by the client during the response waiting process. For distributed storage systems, the client may need to wait for confirmation responses from the server, and in the case of high load or unstable network, it is necessary to set the client's timeout time appropriately. Ctimeout ensures that the client can perform timeout processing when waiting for too long, rather than waiting indefinitely, ensuring the response efficiency of the system.
[0074] As a possible implementation, the latest values of these parameters can be obtained in real time by interacting with the configuration file or database of the storage system. The system should provide relevant interfaces to ensure that the timeout time settings can be read on demand.
[0075] In addition, after obtaining the timeout time parameters, the system can dynamically adjust the parameter values based on the current system state (such as network load, node status, storage capacity, etc.). For low-load scenarios, the timeout time can be appropriately extended to ensure smooth service execution; for high-load or high-network-delay scenarios, the timeout time can be shortened to improve system response speed.
[0076] In addition, the system also needs to regularly check the reasonableness of these timeout time parameters to avoid improper parameter settings. For the timeout time settings of common storage system management services, existing best practices can be referred to, and adjustments can be made according to actual business needs.
[0077] As an example, suppose the current system is handling a high-load environment, where leasetime is set to 120 seconds, mtimeout to 60 seconds, beacontime to 30 seconds, and ctimeout to 10 seconds. During time synchronization, the system first adjusts the synchronization frequency and response time based on these values. If a service times out, the system will retry or enter a recovery state based on the adjusted timeout to avoid prolonged unresponsiveness.
[0078] By dynamically acquiring the timeout parameters of each service in the storage system after the fast time synchronization service starts, this application ensures that the time synchronization process is efficient and stable, and can flexibly adjust the synchronization strategy under different loads and network environments. This method not only improves the synchronization accuracy of the system, but also enhances its stability and fault tolerance, and reduces system interruptions and performance degradation caused by synchronization failures.
[0079] Step S4: Set the time synchronization time for each time to the valid time of the storage system management service, and set the time synchronization interval to the maximum value among the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time.
[0080] In step S3, the system dynamically obtains the timeout parameters of each service in the storage system, including the storage system management service validity period (leasetime), storage system management service timeout period (mtimeout), storage system metadata service timeout period (beacontime), and client wait timeout period (ctimeout). In step S4, the system needs to set the time synchronization time for each operation.
[0081] In this embodiment, the time synchronization setting should be the leasetime of the storage system management service. Leasetime represents the validity period of the management service and is a key parameter affecting the time synchronization of the storage system. Setting the time synchronization time to leasetime ensures that the system performs time synchronization according to the lifecycle of the storage management service. In this way, the system can ensure that the time is adjusted in a timely manner during the validity period of the management service to maintain accurate time synchronization in subsequent periods.
[0082] In addition, setting the time interval is to ensure that the system does not frequently trigger time synchronization operations during time synchronization, thus avoiding unnecessary load. In step S4, the time interval needs to be set to the maximum value among the storage system management service timeout (mtimeout), storage system metadata service timeout (beacontime), and client wait timeout (ctimeout).
[0083] The reason for this setting is:
[0084] Management service timeout time (mtimeout): This is the maximum response time for the management service of the storage system. If the time synchronization frequency is too high, the management service may be affected by a large load, causing the service response to be delayed. By setting a maximum value, frequent time synchronization requests can be avoided, reducing CPU and network load.
[0085] Metadata service timeout time (beacontime): Metadata service is one of the key services in the storage system, responsible for handling data structures and metadata in the storage device. When time synchronization is performed, if the timeout time of this service is too short, it may cause the time synchronization request to fail to respond in time, so it needs to be set reasonably.
[0086] Client waiting timeout time (ctimeout): The client waiting timeout time is the maximum duration that the client waits for a response. For the client, if the timeout time is set too small, it may cause the client to timeout too early in a high latency or high load scenario. Conversely, if it is set too large, it may cause the client to wait for a long time without response.
[0087] In the embodiments of the present application, by setting the time synchronization interval to the maximum value among these timeout time parameters, the system can balance the time synchronization frequency and system load, ensuring that the time synchronization operation is not too frequent, thereby effectively reducing resource consumption.
[0088] In addition, in the embodiments of the present application, the system needs to specially consider the influence of the management service's leasetime and other timeout times. Specifically:
[0089] Too small leasetime: If the leasetime is set too small, the system will frequently perform time synchronization operations, causing the system to constantly adjust the time, increasing the burden on the CPU. In addition, frequent time synchronization requests may also affect network bandwidth, thereby affecting the execution of other tasks of the system. Therefore, it is necessary to set the leasetime within a reasonable range to ensure that the synchronization operation does not frequently interfere with the normal operation of the system.
[0090] Too large leasetime: If the leasetime is set too large, the system may miss the opportunity to synchronize the time in time. Because the time interval for time synchronization is too long, the time difference between nodes may continue to increase, especially in a high network latency and load environment, and failure to adjust the time in time may cause system services to be inconsistent. Therefore, reasonable setting of leasetime is crucial to ensure the timeliness of time synchronization.
[0091] Therefore, the leasetime should be adjusted according to actual needs, so that the time synchronization operation is neither too frequent nor causes too large time error.
[0092] By reasonably setting the time synchronization time as the effective time of the storage system management service, and setting the time synchronization interval time according to the maximum of the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time, the application can effectively balance the system load and the accuracy requirement of time synchronization. This mechanism can ensure that the system does not increase too much computing resource consumption when performing time synchronization, and can also timely maintain the accuracy of system time, avoiding too large time deviation affecting system stability.
[0093] Step S5: In response to the setting of the time synchronization start flag, enter the cyclic time synchronization state, periodically obtain the time deviation value, and perform the phased time synchronization operation based on the comparison of the time deviation value and the time deviation limit.
[0094] In the embodiment of the application, after the system starts the fast time synchronization service and enters the subsequent time synchronization process, it is first necessary to judge whether there is a time synchronization start flag. The time synchronization start flag is a flag used by the system to indicate that the time synchronization task is ready to start. If the time synchronization start flag exists, it means that the system can continue to perform the time synchronization process; if there is no flag, the system exits the current time synchronization process.
[0095] The generation of the time synchronization start flag can be achieved in the following ways:
[0096] (1) Manual triggering: The system administrator can manually set the time synchronization start flag according to needs, for example, at the initial start of the system, or when a large time deviation is found, the administrator triggers the flag to start the time synchronization process.
[0097] (2) Automatic triggering: The system can automatically set the time synchronization start flag according to real-time monitoring data, for example, when the system detects that the time deviation exceeds a preset threshold, it automatically enters the time synchronization process.
[0098] Once it is judged that there is a time synchronization start flag, the system enters the cyclic time synchronization state. In this state, the system will periodically obtain the time deviation value between the node and the clock source node, and perform subsequent operations according to these deviation values. The purpose of the cyclic time synchronization state is to ensure that the system can continuously monitor and correct the deviation of time synchronization, so as to ensure the stability of the system in long-time running.
[0099] The specific steps are as follows:
[0100] (1) Obtain time offset: The system communicates with the clock source node through the NTP protocol (or other suitable time synchronization protocol) to obtain the time offset value between the current node and the clock source node. This offset value is a key data in time operation, representing the difference between the current node and the standard time.
[0101] (2) Periodic acquisition: According to the set time interval (which can refer to the timeout setting in step S4), the system will repeatedly obtain the time offset within a certain period. This periodic process can help the system detect and correct time errors in time synchronization, maintaining the accuracy of system time.
[0102] After obtaining the time offset value, the system needs to determine whether the offset value exceeds the preset time offset threshold. This threshold is set according to the time consistency requirements of the system and may be adjusted according to the needs of specific business scenarios. For example, in high-precision real-time trading systems, the offset threshold is small; while in some ordinary storage systems, the offset threshold can be appropriately relaxed.
[0103] When the time offset value exceeds the set threshold, the system will perform a phased time synchronization operation. The phased time synchronization operation is mainly completed by adjusting the time synchronization effective time (leasetime) and the waiting interval time (i.e. the maximum value of mtimeout, beacontime, ctimeout in step S4).
[0104] During the execution process, the system will shorten the time synchronization period each time, making the time synchronization operation more frequent, thereby minimizing time errors. The system can also adjust the time synchronization strategy according to the load and node response, such as dynamically adjusting the frequency of time synchronization according to the load, to optimize resource consumption and time synchronization accuracy.
[0105] If the time offset value is less than or equal to the set threshold, it means that the time synchronization has reached the predetermined accuracy, and the system will perform step S6 to complete the time synchronization operation and enter the normal running state. In this state, the system will stop the time synchronization operation and wait for the next detection period.
[0106] It is important to note that during the loop time synchronization process, the system will continuously detect the time offset and dynamically adjust according to the offset. When the following conditions are met, the system will exit the loop time synchronization state:
[0107] (1) Time offset reaches stable range: If the system detects that the time offset value is continuously below the threshold and remains stable, the system will consider that the current time synchronization has reached the expected effect and exit the loop time synchronization.
[0108] (2) External intervention: If the system detects that the time source is unavailable or other failures occur during the time process (such as network interruption), a timeout exit mechanism can be set to exit the loop time synchronization state.
[0109] (3) Manual stop: The administrator can also manually stop the time synchronization process according to actual needs, especially when performing time synchronization tasks with long execution periods.
[0110] It can be understood that when performing time synchronization, the system needs to balance the relationship between time synchronization frequency and resource consumption. If the time synchronization process is too frequent, it will consume a large amount of computing and network resources, which may affect other functions of the system. Therefore, when designing the time synchronization frequency, the system load, network bandwidth and storage requirements should be considered to ensure that the system can maintain high time synchronization accuracy under low load.
[0111] By responding to the time synchronization start flag and entering the loop time synchronization state, the system can continuously monitor and adjust the time deviation, ensuring the stability and accuracy of time synchronization. This method dynamically compares the time deviation and threshold, flexibly performs phased time synchronization operations, and avoids excessive consumption of system resources while ensuring high-precision synchronization. In addition, the system also provides an exit mechanism to ensure that the time synchronization operation can be stopped in time in the event of external interference or system failure, improving the stability and fault tolerance of the system.
[0112] Step S6: When the time deviation value is less than or equal to the time deviation limit, adjust the remaining time deviation at once, and exit the loop time synchronization state, switching the storage system from maintenance mode back to normal operation mode.
[0113] In the last stage of the time synchronization process, when the system detects that the time deviation value is less than or equal to the preset time deviation limit, the system will perform the adjustment operation of the remaining time deviation. This operation is to correct the time deviation to the minimum at once, ensuring the high consistency of the system time.
[0114] Specifically, the system will eliminate the last time error through smooth time synchronization, avoiding the time jump that may be caused by traditional methods. Compared with traditional time jump, the system adopts a more fine-tuned adjustment method to avoid service interruption or data inconsistency problems.
[0115] After the time deviation adjustment is completed, the system exits the loop time state. This means that the time synchronization has reached the expected accuracy, and the clocks of all nodes have been highly consistent with the clock of the time source node, meeting the system's time synchronization requirements. At this time, the system switches from maintenance mode back to normal operation mode, restoring all services of the storage system. Services that were suspended due to time synchronization will resume normal operation, including storage system management, metadata services, and client request processing. After recovery, the system continues to operate in normal mode and ensures data consistency and stability.
[0116] In this way, the system can ensure high-precision time synchronization while avoiding excessive resource consumption, ensuring efficient operation of the system. This process not only improves the stability of the system, but also ensures time consistency over a long period of time, avoiding business interruptions or data errors caused by time deviation.
[0117] To achieve the above embodiments, the present application also proposes a device for fast synchronization of time based on a distributed storage system. The device comprises:
[0118] A time deviation detection module for obtaining the time deviation value between the current node and the time source node in response to a timing detection request;
[0119] A fast time synchronization service start module for starting the fast time synchronization service through the fast time synchronization service start module when the time deviation value exceeds the preset time deviation threshold;
[0120] A time deviation limit analysis module for dynamically obtaining the timeout time parameters of each service in the storage system after the fast time synchronization service is started, including the storage system management service effective time, the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time;
[0121] A phased time synchronization control module for setting the time synchronization time for each time to the storage system management service effective time, and setting the time synchronization interval time to the maximum of the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time;
[0122] A time synchronization start marker setting module for setting a time synchronization start marker to identify the start of the time synchronization process;
[0123] A loop time synchronization logic execution module for entering a loop time synchronization state in response to the time synchronization start marker, periodically obtaining the time deviation value, and performing phased time synchronization operations based on the comparison of the time deviation value and the time deviation limit;
[0124] The remaining time adjustment module is configured to adjust the remaining time deviation once and exit the loop time synchronization state when the time deviation value is less than or equal to the time deviation limit.
[0125] The system state switching module is configured to switch the storage system from the maintenance mode back to the normal operation mode.
[0126] Optionally, the time deviation detection module communicates with the time source node through an NTPD service to obtain the time deviation value between the current node and the time source node.
[0127] Optionally, the time deviation limit analysis module includes a plurality of sub-modules respectively configured to obtain a storage system management service valid time, a storage system management service timeout time, a storage system metadata service timeout time, and a client waiting timeout time.
[0128] Optionally, the time deviation limit analysis module obtains the timeout time parameters of a plurality of services in the storage system, takes the storage system management service valid time as the time synchronization time each time, and takes the maximum value among the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time as the time interval for time synchronization, so as to ensure that the service timeout is not triggered during the time synchronization.
[0129] As to the device in the above-mentioned embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments of the method, and thus will not be described in detail here.
[0130] In order to achieve the above-mentioned embodiments, the present application further provides an electronic device, comprising a processor and a memory connected with the processor in communication; the memory stores computer execution instructions; and the processor executes the computer execution instructions stored in the memory to realize the method provided in the above-mentioned embodiments.
[0131] In order to achieve the above-mentioned embodiments, the present application further provides a computer readable storage medium, wherein the computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to realize the method provided in the above-mentioned embodiments.
[0132] In order to achieve the above-mentioned embodiments, the present application further provides a computer program product, comprising a computer program, and the computer program is executed by the processor to realize the method provided in the above-mentioned embodiments.
[0133] The collection, storage, use, processing, transmission, provision, and disclosure of user personal information involved in the present application comply with relevant laws and regulations and do not violate public order and good customs.
[0134] It is important to note that user's personal information shall be collected for legitimate and reasonable uses of the service and not shared or sold outside of those legitimate uses. Further, such collection / sharing shall occur after receiving the consent of the users, including but not limited to, informing the users to read the user agreement / user notice before using the function, and signing the agreement / authorization including the authorization of relevant user information. In addition, any necessary steps shall be taken to protect and secure access to such personal information data, and ensure that other individuals with access to the personal information data follow their privacy policies and procedures.
[0135] The present application contemplates that the embodiments can provide a user the ability to disable the collection or use of personal information data. That is, the present disclosure contemplates providing the user with control to permit or deny the collection of personal information data by the service or application. The user's consent is obtained before the collection of personal information data, including but not limited to, the user's agreement to the terms of service, the user's agreement to the terms of the privacy policy, and / or the user's explicit consent obtained through a menu selection or other interaction.
[0136] In the foregoing detailed description, reference is made to descriptive terms such as "one embodiment", "some embodiments", "an example", "a specific example" or "some examples" etc. which indicate that the particular feature, structure, material, or characteristic being described is included in at least one embodiment or example of the application. The illustrative examples described in this specification are not meant to be limiting. Other embodiments can be used, and other changes can be made, without departing from the scope of the application. The terms "one embodiment", "some embodiments", "an example", "a specific example" or "some examples" etc. are not necessarily referring to the same embodiment or example. Furthermore, the described features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples. It will be apparent to those skilled in the art that the described embodiments and examples are illustrative only. Changes can be made without departing in spirit from the scope of the application, and that the scope of the application is limited only by the claims.
[0137] In addition, the terms "first", "second", etc. are used herein only to describe different instances, and do not imply or suggest relative importance or a number of indicated technical features. Thus, the features defined with "first", "second" can include at least one of the features, explicitly or implicitly. In the description of the application, the meaning of "a plurality of" is at least two, for example, two, three, etc., unless otherwise specifically limited.
[0138] Any processes or methods described in the flow charts or elsewhere in this specification can be understood as representing code modules, segments, or portions of code which include one or more executable instructions for implementing specific logic functions (or steps) of the application, and that the various functions or steps can be performed in the sequence illustrated or in other sequences, that can be substantially simultaneous, that can be performed, or overlapped, in various groupings, or that can be performed at different times, depending on implementation needs and requirements. Thus, the description is not intended to limit the scope of the application, as claimed, but is merely one illustration of the many possible embodiments of the application.
[0139] The logic and / or steps represented in the flowcharts and / or described herein, for example, can be considered as a sequence of instructions to implement logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device, such as a computer-based system, processor- based system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can be a computer- readable storage medium or a computer-readable signal medium. The computer- readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include the following: an electrical connection having one or more wires (electrical connections), a portable computer diskette (a magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium can even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, for example, via optical scanning of the paper or other medium, then compiled, interpreted, or otherwise processed in a suitable manner, if necessary, and then stored in a computer memory.
[0140] It should be understood that aspects of the application can be implemented in hardware, software, firmware or combinations thereof. In the above embodiments, various steps or methods can be implemented in software or firmware that is stored in memory and executed by a suitable instruction execution system. As such, in some embodiments, specifically configured hardware can be used to implement at least some of the functionality described herein. For example, if implemented in hardware, the hardware can include any or a combination of the following: a discrete logic circuit having logic gates for implementing logic functions upon data signals, an application specific integrated circuit having appropriate combinational logic gates, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0141] Those of skill in the art would understand that information and signals can be represented using any of a variety of technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips that can be referenced throughout the above description can be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, optical fields or particles, or any combination thereof.
[0142] In addition, each of the function units in each embodiment of the present application can be integrated in one processing module, or each unit can be physically present separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module. When the integrated module is realized in the form of a software function module and sold or used as an independent product, it can also be stored in a computer readable storage medium.
[0143] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it should be understood that the above embodiments are exemplary and should not be construed as limiting the present application, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the present application.
[0144] It should be understood that the various forms of flow shown above can be reordered, added or deleted steps. For example, each step described in the present application can be executed in parallel, sequentially or in different order, as long as the desired results of the technical solutions of the present application can be achieved, which is not limited herein.
[0145] The above detailed description does not constitute a limitation on the scope of protection of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and replacements can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements within the spirit and principles of the present application should be included in the scope of protection of the present application.
Claims
1. A method for fast synchronization of time based on a distributed storage system, characterized in that, The method comprises the following steps: In response to a timing detection request, a time deviation value between a current node and a time source node is obtained; When the time deviation value exceeds a preset time deviation threshold, a fast time synchronization service is started; After the fast time synchronization service is started, timeout parameters of each service in the storage system are dynamically obtained, including a storage system management service validity time, a storage system management service timeout time, a storage system metadata service timeout time, and a client waiting timeout time; The time synchronization time of each time is set as the storage system management service validity time, and the time interval for time synchronization is set as the maximum of the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time; In response to the setting of a time synchronization start flag, a loop time synchronization state is entered, the time deviation value is periodically obtained, and based on the comparison between the time deviation value and a time deviation limit, a phased time synchronization operation is performed; When the time deviation value is less than or equal to the time deviation limit, the remaining time deviation is adjusted at one time, and the loop time synchronization state is exited, and the storage system is switched from the maintenance mode back to the normal operation mode.
2. The method of claim 1, wherein, The method of claim 1, wherein the time deviation value between the current node and the time source node is obtained through an NTPD service and the time source node.
3. The method of claim 2, wherein, The time deviation value is obtained by performing detection at a preset period, and the preset period is dynamically adjusted according to system load and node quantity.
4. The method of claim 3, wherein, In each time synchronization, the deviation amount does not exceed the storage system management service validity time, and after each time synchronization, the time interval for time synchronization is waited.
5. An apparatus for fast synchronization of time based on a distributed storage system, the apparatus comprising: It comprises: A time deviation detection module is configured to obtain a time deviation value between a current node and a time source node in response to a timing detection request; A fast time synchronization service starting module is configured to start a fast time synchronization service when the time deviation value exceeds a preset time deviation threshold through the fast time synchronization service starting module; A time deviation limit analysis module is configured to dynamically obtain timeout parameters of each service in the storage system after the fast time synchronization service is started, including a storage system management service validity time, a storage system management service timeout time, a storage system metadata service timeout time, and a client waiting timeout time; A phased time synchronization control module is configured to set the time synchronization time of each time as the storage system management service validity time, and set the time interval for time synchronization as the maximum of the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time; A time synchronization start flag setting module is configured to set a time synchronization start flag to identify the start of a time synchronization process; A loop time synchronization logic execution module is configured to enter a loop time synchronization state in response to the time synchronization start flag, periodically obtain a time deviation value, and perform a phased time synchronization operation based on the comparison between the time deviation value and a time deviation limit; A remaining time adjustment module is configured to adjust the remaining time deviation at one time when the time deviation value is less than or equal to the time deviation limit, and exit the loop time synchronization state. The system state switching module is configured to switch the storage system from the maintenance mode back to the normal operation mode.
6. The apparatus of claim 5, wherein, The time deviation detection module communicates with a time source node through an NTPD service to obtain a time deviation value between the current node and the time source node.
7. The apparatus of claim 6, wherein, The time deviation limit analysis module includes a plurality of sub-modules configured to obtain a storage system management service valid time, a storage system management service timeout time, a storage system metadata service timeout time, and a client waiting timeout time.
8. The apparatus of claim 7, wherein, The time deviation limit analysis module obtains timeout time parameters of a plurality of services in the storage system, takes the storage system management service valid time as a time synchronization time each time, and takes the maximum value among the storage system management service timeout time, the storage system metadata service timeout time, and the client waiting timeout time as a time synchronization interval time, to ensure that service timeout is not triggered during time synchronization.
9. An electronic device, comprising: The method comprises: a processor, and a memory connected to the processor in communication; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method of any one of claims 1-4.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are executed by the processor to implement the method of any one of claims 1-4.
11. A computer program product, characterised in that, The computer program is executed by the processor to implement the method of any one of claims 1-4.