Fault copy switching method and device, electronic equipment and readable storage medium

By monitoring and handling replica write exceptions in distributed storage systems, fast and efficient failed replica switching is achieved, solving the problem of large failover time consumption in traditional methods and improving system performance.

CN118981397APending Publication Date: 2024-11-19SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411227133.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-03
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

Traditional failover in distributed storage systems is not timely due to data copy time consumption, which affects system performance.

Method used

By monitoring replica write exceptions, determining the last write data and exception data of the target replica, freezing the write data of the normal replica service thread, and creating a new replica service thread to re-back up the exception data and the subsequent data, realizing the switching of the failed replica. Avoid copying of data to new copies.

Benefits of technology

Significantly reduces the failed replica switching time, improves system performance, and avoids unnecessary time consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981397A_ABST
    Figure CN118981397A_ABST
Patent Text Reader

Abstract

The invention discloses a fault copy switching method and device, electronic equipment and a computer readable storage medium, and the method comprises the steps: determining a target copy, and executing a write-in backup operation on the target copy by using a preset number of copy service threads; wherein the copy length of the target copy is variable; in the process of executing the write-in backup operation, if it is monitored that copy write-in is abnormal, final write-in data and abnormal data in the target copy are determined; determining a normal copy service thread, and freezing write-in data after the last write-in data corresponding to the normal copy service thread; creating a preset number of new copy service threads, and executing writing backup operation on the abnormal data and the to-be-written data after the abnormal data by utilizing each new copy service thread; and connecting the newly written data corresponding to each new copy service thread to the freezing position to realize fault copy switching. By applying the technical scheme, faster and more efficient fault copy switching can be realized, and the system performance is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data backup, and in particular to a fault copy switching method, and also to a fault copy switching device, an electronic device, and a computer-readable storage medium. Background Art

[0002] In the field of distributed systems (mainly distributed storage), single point failures are very common. Whether it is the disk, network, server or software system itself, failures may occur. Therefore, distributed storage systems are usually designed for failures as a whole. Failure tolerance and processing are considered from the architectural design. Failover is one of the common and important fault-tolerant technologies. However, traditional failover involves copying data from the old copy to the new copy, which will cause a certain amount of time consumption, further causing the problem of untimely switching of the failed copy.

[0003] Therefore, how to achieve faster and more efficient fault replica switching to effectively improve system performance is an urgent problem to be solved by those skilled in the art. Summary of the invention

[0004] The purpose of the present application is to provide a fault copy switching method, which can achieve faster and more efficient fault copy switching, further improving system performance; another purpose of the present application is to provide a fault copy switching device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0005] In a first aspect, the present application discloses a method for switching a fault replica, comprising:

[0006] Determine a target copy, and use a preset number of copy service threads to perform a write backup operation on the target copy; wherein the copy length of the target copy is variable;

[0007] During the execution of the write backup operation, if a copy write abnormality is detected, then the last written data and the abnormal data in the target copy are determined;

[0008] Determine a normal copy service thread, and freeze the written data after the last written data corresponding to the normal copy service thread;

[0009] Creating the preset number of new replica service threads, and using each of the new replica service threads to perform a write backup operation on the abnormal data and the data to be written after the abnormal data;

[0010] The newly written data corresponding to each of the new replica service threads is connected to the frozen position to implement the failed replica switching.

[0011] Optionally, freezing the written data after the last written data corresponding to the normal copy service thread includes:

[0012] Determining metadata of the abnormal data;

[0013] The last written data corresponding to the normal copy service thread is determined according to the metadata, and the written data after the last written data is frozen.

[0014] Optionally, the fault replica switching method further includes:

[0015] When it is monitored that the amount of data written into the target replica exceeds the maximum capacity of the target replica, or when it is monitored that the replica service thread is abnormal, it is determined that the replica write abnormality is monitored.

[0016] Optionally, connecting the newly written data corresponding to each of the new replica service threads to the frozen position to implement the failed replica switching includes:

[0017] In the process of executing the write backup operation by using the new copy service thread, determining whether an abnormality in writing the copy is detected;

[0018] If the write abnormality of the replica is detected, return to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed, and connect the newly written data corresponding to each new replica service thread to the frozen position to achieve the failed replica switching;

[0019] If no abnormality in writing to the replica is detected, the newly written data corresponding to each new replica service thread is connected to the frozen position to implement the failed replica switching.

[0020] Optionally, returning to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed includes:

[0021] Determine whether the current number of backups reaches the preset number;

[0022] If the preset number of times is not reached, returning to the step of determining the last written data and abnormal data in the target copy until the write backup operation of the target copy is completed;

[0023] If the preset number of times is reached, a backup failure prompt is output.

[0024] Optionally, after connecting the newly written data corresponding to each of the new replica service threads to the frozen position and implementing the failed replica switching, the method further includes:

[0025] Determine frozen data, and unfreeze and clean up the frozen data;

[0026] Recycle each of the normal replica service threads.

[0027] Optionally, during the execution of the write backup operation, if a copy write exception is detected, after determining the last written data and the abnormal data in the target copy, the method further includes:

[0028] Determine the abnormal replica service thread;

[0029] Output an abnormal prompt about the abnormal replica service thread and thread information of the abnormal replica service thread.

[0030] In a second aspect, the present application further discloses a fault replica switching device, comprising:

[0031] An execution module, used for determining a target copy, and performing a write backup operation on the target copy using a preset number of copy service threads; wherein the copy length of the target copy is variable;

[0032] A monitoring module, used for determining the last written data and abnormal data in the target copy if abnormal copy writing is detected during the execution of the write backup operation;

[0033] A freezing module, used to determine a normal copy service thread, and freeze the written data after the last written data corresponding to the normal copy service thread;

[0034] A creation module, used to create the preset number of new replica service threads, and use each of the new replica service threads to perform a write backup operation on the abnormal data and the data to be written after the abnormal data;

[0035] The switching module is used to connect the newly written data corresponding to each new copy service thread to the frozen position to achieve the failed copy switching.

[0036] In a third aspect, the present application further discloses an electronic device, comprising:

[0037] Memory for storing computer programs;

[0038] A processor is used to implement the steps of any one of the above-mentioned fault replica switching methods when executing the computer program.

[0039] In a fourth aspect, the present application further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned fault replica switching methods are implemented.

[0040] The present application provides a method for switching a faulty copy, comprising: determining a target copy, and using a preset number of copy service threads to perform a write backup operation on the target copy; wherein the copy length of the target copy is variable; during the execution of the write backup operation, if a copy write abnormality is detected, determining the last written data and abnormal data in the target copy; determining a normal copy service thread, and freezing the written data after the last written data corresponding to the normal copy service thread; creating the preset number of new copy service threads, and using each of the new copy service threads to perform a write backup operation on the abnormal data and the data to be written after the abnormal data; connecting the new written data corresponding to each of the new copy service threads to a frozen position to achieve faulty copy switching.

[0041] By applying the technical solution provided by the present application, in the process of using the replica service thread to write and back up the replica data, it is possible to monitor in real time whether a replica write anomaly occurs in this process. When a replica write anomaly is detected, the data that was last successfully written before the anomaly occurred (i.e., the last written data mentioned above) and the data that failed to be written due to the anomaly (i.e., the abnormal data mentioned above) can be determined. Thus, the written data after the last written data corresponding to the replica service thread that is still in a normal state can be frozen, that is, only the last written data and the data written before it are retained. At this time, the same number of new replica service threads are created to re-backup the write abnormal data and the data after it, and this part of the newly written data is connected to the corresponding frozen positions respectively, so as to realize the switching of faulty replicas. Obviously, the present technical solution does not need to copy the data on the old replica to the new replica, which effectively reduces unnecessary time consumption, greatly improves the efficiency of faulty replica switching, and further improves system performance.

[0042] A fault replica switching device, electronic device, and computer-readable storage medium provided in the present application also have the above-mentioned technical effects, which will not be described in detail in the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the prior art and the embodiments of the present application, the drawings required for use in the description of the prior art and the embodiments of the present application are briefly introduced below. Of course, the drawings described below in relation to the embodiments of the present application are only part of the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the obtained other drawings also belong to the protection scope of the present application.

[0044] FIG1 is a schematic diagram of a flow chart of a method for switching a faulty replica provided by the present application;

[0045] FIG2 is a schematic diagram of a flow chart of another method for switching a faulty replica provided by the present application;

[0046] FIG3 is a schematic diagram of the structure of a fault replica switching device provided by the present application;

[0047] FIG. 4 is a schematic diagram of the structure of an electronic device provided in the present application. DETAILED DESCRIPTION

[0048] The core of the present application is to provide a fault copy switching method, which can achieve faster and more efficient fault copy switching, further improving system performance; another core of the present application is to provide a fault copy switching device, electronic device and computer-readable storage medium, all of which have the above-mentioned beneficial effects.

[0049] In order to describe the technical solutions in the embodiments of the present application more clearly and completely, the technical solutions in the embodiments of the present application will be introduced below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0050] An embodiment of the present application provides a method for switching a fault replica.

[0051] Please refer to FIG. 1 , which is a schematic flow chart of a fault replica switching method provided in the present application. The fault replica switching method may include the following S101 to S105 .

[0052] S101: Determine a target copy, and use a preset number of copy service threads to perform a write backup operation on the target copy; wherein the copy length of the target copy is variable.

[0053] This step is intended to determine the target copy and perform the corresponding write backup operation, wherein the target copy is the copy that needs to be monitored for faults so that it can be switched when a fault occurs, and its copy length is variable, supporting additional writing after the data has been written. In the current system, a certain number of copy service threads can be preset to perform write backup operations for the target copy, such as 3 copy service threads can be preset to achieve redundant backup of the target copy. Of course, the value of the preset number does not affect the implementation of this technical solution, and can be set by technical personnel according to actual needs, and this application does not limit this.

[0054] S102: During the execution of the write backup operation, if a copy write abnormality is detected, the last written data and the abnormal data in the target copy are determined.

[0055] This step aims to realize the abnormal monitoring during the execution of the write backup operation and the determination of abnormal information under abnormal circumstances. Specifically, in the process of executing the write backup operation using each replica service thread, once the replica write abnormality is detected, the corresponding abnormal information can be further determined. The abnormal information mainly includes the data that was last successfully written before the abnormality occurred (i.e., the last written data mentioned above) and the data that failed to be written due to the abnormality (i.e., the abnormal data mentioned above), so as to perform subsequent steps based on these abnormal information to realize the switching of the faulty replica.

[0056] In one embodiment of the present application, the fault replica switching method may further include:

[0057] When it is detected that the amount of data written to the target replica exceeds the maximum capacity of the target replica, or when an abnormality is detected in the replica service thread, it is determined that a replica write abnormality is detected.

[0058] An embodiment of the present application provides an implementation method for determining when a replica write anomaly is detected, mainly including the following two situations: one is that the amount of data written in the target replica exceeds the maximum capacity of the target replica (although the replica length is variable, the maximum capacity is fixed). Specifically, it may be detected that the data to be written next will cause the target replica capacity to exceed the maximum capacity; the other is that one or several replica service threads are detected to be abnormal. Specifically, it may be that the replica service thread is hung up, timed out and unresponsive, or the status is unknown, etc.

[0059] S103: Determine a normal copy service thread, and freeze the written data after the last written data corresponding to the normal copy service thread.

[0060] This step is intended to implement a data freeze operation. Specifically, among all replica service threads, a replica service thread in which a replica write exception occurs can be regarded as an abnormal replica service thread, and a replica service thread in which a replica write exception does not occur can be regarded as a normal replica service thread. On this basis, since the normal replica service thread is in a normal operating state, when the abnormal replica service thread successfully writes the last written data and fails to write the abnormal data, the normal replica service thread will still write all the data normally. At this time, the data successfully written after the last written data corresponding to the normal replica service thread can be frozen, that is, all data after the end position of the last written data will be frozen. In addition, since the abnormal replica service thread fails to write the abnormal data after the last written data, there is no need to perform a data freeze operation on it.

[0061] In one embodiment of the present application, freezing the written data after the last written data corresponding to the normal replica service thread may include:

[0062] Identify metadata for anomalous data;

[0063] The last written data corresponding to the normal replica service thread is determined according to the metadata, and the written data after the last written data is frozen.

[0064] The embodiment of the present application provides a method for determining the last written data corresponding to a normal replica service thread to ensure accurate data freezing. Specifically, after determining the abnormal data corresponding to the abnormal replica service thread, its metadata information, such as offset position information, can be further obtained. Since the write backup operations corresponding to all replica service threads are synchronous and consistent, the last written data corresponding to the normal replica service thread can be directly determined based on the metadata information (it should be noted that the last written data here essentially corresponds to the last written data corresponding to the abnormal replica service thread, and does not refer to the last written data of the normal replica service thread), and all subsequent written data can be frozen.

[0065] S104: Create a preset number of new replica service threads, and use each new replica service thread to perform a write backup operation on the abnormal data and the data to be written after the abnormal data.

[0066] This step is intended to implement write backup processing of abnormal data and the data to be written thereafter. During the implementation process, an equal number (i.e., the preset number mentioned above) of new replica service threads can be created, and each new replica service thread can be used to perform write backup operations on the abnormal data and the data to be written thereafter, wherein a preset number of replica service threads corresponds to a preset number of new replica service threads. Obviously, for the previous abnormal replica service thread, it is equivalent to re-backing up the data that failed to be backed up before; for the previous normal replica service thread, it is equivalent to re-backing up the data that was successfully backed up before. It should be noted that this part of the data only includes all data after the above-mentioned "last written data".

[0067] S105: Connect the newly written data corresponding to each new replica service thread to the frozen position to implement failed replica switching.

[0068] This step aims to achieve faulty replica switching through data connection. As mentioned above, the preset number of replica service threads corresponds to the preset number of new replica service threads. On this basis, for each new replica service thread, the newly written data corresponding to the new replica service thread can be connected to the corresponding frozen positions. Of course, for the abnormal replica service thread, the newly written data can be directly connected to the corresponding successfully written data. At this point, the faulty replica switching is completed.

[0069] In one embodiment of the present application, connecting the newly written data corresponding to each new replica service thread to the frozen position to implement the failed replica switching may include:

[0070] In the process of executing the write backup operation using the new replica service thread, determining whether a replica write anomaly is detected;

[0071] If a replica write anomaly is detected, return to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed, and connect the newly written data corresponding to each new replica service thread to the frozen position to implement the failed replica switching;

[0072] If no replica write anomaly is detected, the newly written data corresponding to each new replica service thread is connected to the frozen position to implement the failed replica switching.

[0073] It should be noted that in the process of using the new replica service thread to perform the write backup operation, the replica write anomaly monitoring can still be performed synchronously, and when the replica write anomaly is detected, return to the step of "determining the last written data and abnormal data in the target replica" in S102, and repeat this cycle until the write backup operation of the target replica is completed, and then execute the data connection to complete the faulty replica switching operation; of course, if the replica write anomaly is not detected, then directly after the write backup operation of the target replica is completed, execute the data connection to complete the faulty replica switching operation.

[0074] In one embodiment of the present application, returning to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed may include:

[0075] Determine whether the current number of backups reaches the preset number;

[0076] If the preset number of times is not reached, return to the step of determining the last written data and abnormal data in the target copy until the write backup operation of the target copy is completed;

[0077] If the preset number of times is reached, a backup failure prompt will be output.

[0078] The embodiment of the present application sets an upper limit on the number of faulty copy switching times. Specifically, when the current number of backups does not reach the preset number, the faulty copy switching operation can be performed cyclically; when the current number of backups reaches the preset number, it can be directly considered that the faulty copy switching has failed. At this time, the corresponding backup failure prompt can be output. Similarly, the specific value of the above preset number does not affect the implementation of the present technical solution, and can be set by technical personnel according to actual conditions. This application does not limit this.

[0079] Furthermore, in order to avoid high system load and space waste caused by frequent execution of fault replica switching operations and retries, a retry time interval can be set, that is, the time interval for cyclic execution of the fault replica switching operation, that is, the fault replica switching operation is repeatedly executed at a preset time interval. More specifically, the time interval for each fault replica switching can be inconsistent. For example, an exponential backoff strategy can be used, that is, as the number of fault replica switching increases, the time interval continues to lengthen.

[0080] It can be seen that the faulty replica switching method provided by the embodiment of the present application can monitor in real time whether a replica writing anomaly occurs in the process of using the replica service thread to write and back up the replica data. When a replica writing anomaly is detected, the data that was last successfully written before the anomaly occurred (i.e., the last written data mentioned above) and the data that failed to be written due to the anomaly (i.e., the abnormal data mentioned above) can be determined. Thus, the written data after the last written data corresponding to the replica service thread that is still in a normal state can be frozen, that is, only the last written data and the data written before it are retained. At this time, the same number of new replica service threads are created to re-backup the write abnormal data and the data after it, and this part of the newly written data is connected to the corresponding frozen positions respectively, thereby realizing the faulty replica switching. Obviously, the technical solution does not need to copy the data on the old replica to the new replica, which effectively reduces unnecessary time consumption, greatly improves the efficiency of faulty replica switching, and further improves system performance.

[0081] Based on the above embodiments:

[0082] In one embodiment of the present application, after connecting the newly written data corresponding to each new replica service thread to the frozen position and implementing the failed replica switching, the following may also be included:

[0083] Determine frozen data, and unfreeze and clean up the frozen data;

[0084] Recycle each normal replica service thread.

[0085] In one embodiment of the present application, during the execution of the write backup operation, if a copy write exception is detected, after determining the last written data and the abnormal data in the target copy, the following may also be included:

[0086] Determine the abnormal replica service thread;

[0087] Outputs an abnormal prompt about the abnormal replica service thread and thread information of the abnormal replica service thread.

[0088] The above embodiment provides a post-processing solution for replica write exceptions and faulty replica switching. When a replica write exception is detected, the corresponding abnormal replica service thread can be determined, and an abnormal prompt about the abnormal replica service thread can be output, and the thread information of the abnormal replica service thread can be output at the same time, so that the user can know the abnormal thread in the system in time and recycle it; after a faulty replica switching is executed, the frozen data can be thawed and cleaned, and the previous normal replica service thread can be recycled to effectively avoid unnecessary resource occupation.

[0089] Based on the above embodiments, an embodiment of the present application provides another method for switching a fault replica.

[0090] First, it should be noted that in the fault copy switching method provided in the embodiment of the present application, the copy length of the data copy (Chunk) is variable and supports "append write", that is, the newly added data will only be added to the end of the existing data without overwriting operation, which is convenient for the subsequent closing and switching operations. It can be understood that variable-length data copies are usually used to describe data units stored and transmitted in the form of blocks in a computer system, which can help the system process and operate large amounts of data more efficiently. Specifically, the data copy can be designed to have a baseline initial size (default 32MB), but a variable length, and storage space can be allocated on demand according to the size of the written data. It can be imagined that this design has the following advantages: (1) High flexibility and high efficiency: Variable-length Chunks allow the system to dynamically allocate storage space according to actual needs, avoiding the space waste that may be caused by fixed sizes; (2) High adaptability: As the amount of data grows or decreases, the size of the Chunk can be automatically adjusted, so that the system can better cope with data of different sizes; (3) Performance optimization: Smaller Chunk sizes help improve the parallel processing capability of data because the system can manage and distribute these Chunks more efficiently.

[0091] Furthermore, the embodiment of the present application provides a technology called "Seal and New" to handle old copies in the event of a failure. The "Seal / Freeze" method aims to simplify system implementation and improve write performance by exchanging space for time. Specifically, when the Chunk being written encounters certain problems, such as: when three copies are written, one copy fails or the status is unknown, the Chunk currently being written is closed / frozen, regardless of whether it is written to the maximum length of a Chunk (the default is 32MB), and a new Chunk is immediately allocated for subsequent writing. In this way, the currently written Chunk becomes an old Chunk after being closed / frozen. The data boundary of this old Chunk, that is, the closed position, is called the "Seal / Freeze Line". The subsequent FastFO (fast failover) process will rely on this Line to complete. This "Seal / Freeze Line" is the actual length of the Chunk at this time. Obviously, through Seal / Freeze, the design and implementation of complex step-by-step transaction processes are avoided, while the process of copying the entire Chunk data from other complete Chunks is avoided. Compared with rewriting the new data of three copies, the overhead of this solution is still much smaller.

[0092] Among them, the Chunk freeze operation (Seal / Freeze) is summarized as follows:

[0093] Dynamically sized chunks: The size of a chunk can change dynamically based on the actual amount of data. This flexibility enables the system to use storage space more efficiently and avoids the space waste that may be caused by fixed-size chunks.

[0094] Freezing condition: When a data write approaches the boundary of the current Chunk, if the next write causes the data size of the current Chunk to exceed the preset maximum length, the system will trigger the Chunk freezing operation.

[0095] Operation process: (1) Detect boundary: The system will monitor the data volume of the current Chunk to determine whether it is close to the maximum length; (2) Freeze operation: Once it is determined that the next write will exceed the capacity limit of the Chunk, the system will trigger the Chunk freeze operation, which means that the current Chunk will be marked as no longer accepting new data writes; (3) Allocate new Chunk: After freezing the current Chunk, the system will be responsible for allocating a new Chunk location for the next data block, which ensures that the system can continue to process new write requests while maintaining data consistency.

[0096] Finally, please refer to FIG. 2 , which is a flow chart of another method for switching a faulty replica provided by the present application, and its implementation process is as follows:

[0097] 1. SDK (system client) requests MetaServer (system center node) to write a copy of the data (i.e. Chunk, which may consist of multiple Chunks, such as Chunk1, Chunk2, and Chunk3 as shown in Figure 2).

[0098] 2. MetaServer assigns three ChunkServers (A, B, C) (replica service threads) to write to it and returns the SDK response.

[0099] 3. ChunkServer writes three data replica chunks in parallel, as shown in Figure 2. Previously, there have been two successfully written chunks of this data, called Chunk1 and Chunk2, which contain data a and b respectively. Now the third chunk is being written, called Chunk3. Assume that data c has been written successfully and data d is being written. At this time, one of the replicas fails and cannot respond.

[0100] 4. The ChunkServers of the remaining two healthy replicas return the information that data d has been written successfully to the SDK.

[0101] 5. At this time, the FastFO process of quickly switching replicas will begin to avoid user write timeouts. The SDK immediately applies to MetaServer for three new ChunkServer writes, called Chunk4, and writes data d to the new Chunk (the two successful Chunks are rewritten). At the same time, MetaServer will record the metadata information of data c written to itself, and seal / freeze the two successfully written Chunks to avoid further writing. At this time, the end boundary of data c is the location of the closed faulty old replica (Chunk), that is, the Seal / Freeze Line.

[0102] 6. MetaServer returns the addresses of three new Chunk copies (i.e. Chunk4, which may be located on different ChunkServers) to the SDK.

[0103] 7. The SDK immediately writes to the three new ChunkServers and writes data d to the ChunkServers.

[0104] 8. The three new chunks return the result of successful writing to the SDK. If there is still failure at this time, repeat step 5 until success or the maximum number of failures is reached, and return writing failure.

[0105] 9. The SDK returns a successful write to the user, and then the background unfreezes the two old Chunks that were previously frozen, and recycles the old ChunkServer through the background GC thread.

[0106] It can be seen that steps 1 to 8 complete a complete data write operation. This process resists single-point replica failures. No matter what kind of error it is, such as network failure, disk failure, node downtime, process offline, etc., as long as the SDK receives a clear failure or does not receive a successful response within a certain timeout, it is considered a failure and needs to be failed over. At the same time, this design ensures that in the instant of fast switching of Chunks, if another SDK comes to read the data, there will be no swaying or inconsistent state. Such a design can effectively avoid the following problems: (1) Users and SDKs wait for a long time to handle replica failures; (2) When a write fails, a new Chunk is written, but the old data needs to be relocated; (3) Inconsistency between multiple Chunk copies.

[0107] In addition, it should be noted that frequent and rapid switching of chunks may cause problems such as system overload and space waste. To solve this problem, the following measures can be used:

[0108] (1) Use an exponential backoff strategy to adjust the timeout of write operations. For example, start from a shorter timeout and gradually increase to a longer timeout. This can avoid frequent switching and retries in a short period of time, reducing system load and space waste.

[0109] (2) Implement an effective background data cleanup and recycling mechanism to promptly release frozen or useless Chunk space and reduce space waste.

[0110] It can be seen that the fault replica switching method provided in the embodiment of the present application has the following technical advantages:

[0111] 1. Improve system availability: (1) Reduce service interruption time: Fast failover can quickly detect failures and switch to a backup system or replica, thereby reducing service interruption time. This is critical for applications that have extremely high service availability requirements, such as online trading systems and real-time data processing systems. (2) Quickly restore services: Even if a node or component fails, fast failover can quickly switch traffic to an available backup node or service to ensure service continuity and accessibility.

[0112] 2. Improve system stability: By introducing backup nodes or replicas into the system, fast failover can effectively reduce the impact of single point failures on the entire system. Even if a node fails, the system can continue to work and the entire system will not crash or fail to respond to requests due to a failed node.

[0113] 3. Enhance data persistence and consistency: (1) Data redundancy and backup: Fast failover is usually accompanied by redundant data storage and backup strategies to ensure that data can still be safely stored and accessed even in the event of hardware or software failures; (2) Data consistency maintenance: By synchronizing data between failed nodes, fast failover can ensure data consistency during the switching process. Even when a failure occurs, users can access the latest data status to avoid data loss or inconsistency.

[0114] 4. Improve user experience: (1) Reduce service unavailability time: Fast failover can significantly reduce the service interruption time faced by users, improving user experience and satisfaction; (2) Increase system response speed: Quickly switch to a backup system or replica after a failure occurs, which can ensure that the system responds quickly to user requests and reduce delays caused by failures.

[0115] An embodiment of the present application provides a fault replica switching device.

[0116] Please refer to FIG. 3 , which is a schematic diagram of the structure of a fault replica switching device provided by the present application. The fault replica switching device may include:

[0117] Execution module 1 is used to determine a target replica and use a preset number of replica service threads to perform a write backup operation on the target replica; wherein the replica length of the target replica is variable;

[0118] Monitoring module 2, used for determining the last written data and abnormal data in the target copy if abnormal copy writing is detected during the execution of the write backup operation;

[0119] A freezing module 3 is used to determine a normal replica service thread and freeze the written data after the last written data corresponding to the normal replica service thread;

[0120] A creation module 4 is used to create a preset number of new replica service threads, and use each new replica service thread to perform a write backup operation on the abnormal data and the data to be written after the abnormal data;

[0121] The switching module 5 is used to connect the newly written data corresponding to each new copy service thread to the frozen position to achieve the failed copy switching.

[0122] It can be seen that the fault copy switching device provided by the embodiment of the present application can monitor in real time whether a copy write anomaly occurs in the process of using the copy service thread to write and back up the copy data. When a copy write anomaly is detected, the data that was last successfully written before the anomaly occurred (i.e., the last written data mentioned above) and the data that failed to be written due to the anomaly (i.e., the abnormal data mentioned above) can be determined. Thus, the written data after the last written data corresponding to the copy service thread that is still in a normal state can be frozen, that is, only the last written data and the data written before it are retained. At this time, the same number of new copy service threads are created to re-backup the write abnormal data and the data after it, and this part of the newly written data is connected to the corresponding frozen positions respectively, so as to realize the fault copy switching. Obviously, the technical solution does not need to copy the data on the old copy to the new copy, which effectively reduces unnecessary time consumption, greatly improves the efficiency of fault copy switching, and further improves system performance.

[0123] In one embodiment of the present application, the freezing module 3 can be specifically used to determine metadata of abnormal data; determine the last written data corresponding to the normal copy service thread according to the metadata, and freeze the written data after the last written data.

[0124] In one embodiment of the present application, the fault copy switching device may also include a determination module for determining that a copy write abnormality is detected when it is detected that the amount of data written in the target copy exceeds the maximum capacity of the target copy, or when an abnormality is detected in the copy service thread.

[0125] In one embodiment of the present application, the switching module 5 may include:

[0126] A judging unit, used to judge whether a copy writing anomaly is detected during the process of executing the write backup operation using the new copy service thread;

[0127] The first switching unit is used to return to the step of determining the last written data and abnormal data in the target replica if a replica writing anomaly is detected, until the write backup operation of the target replica is completed, and connect the new written data corresponding to each new replica service thread to the frozen position to implement the failed replica switching;

[0128] The second switching unit is used to connect the newly written data corresponding to each new replica service thread to the frozen position to achieve the failed replica switching if no replica writing anomaly is detected.

[0129] In one embodiment of the present application, the above-mentioned first switching unit can be specifically used to determine whether the current number of backups has reached a preset number; if it has not reached the preset number, return to the step of determining the last written data and abnormal data in the target copy until the write backup operation of the target copy is completed; if it reaches the preset number, output a backup failure prompt.

[0130] In one embodiment of the present application, the faulty copy switching device may also include a first post-processing module for connecting the newly written data corresponding to each new copy service thread to the frozen position to implement the faulty copy switching, determining the frozen data, and thawing and cleaning the frozen data; and recovering each normal copy service thread.

[0131] In one embodiment of the present application, the faulty copy switching device may also include a second post-processing module, which is used to determine the abnormal copy service thread after determining the last written data and abnormal data in the target copy if a copy write abnormality is detected during the execution of a write backup operation; and output an abnormal prompt about the abnormal copy service thread and thread information of the abnormal copy service thread.

[0132] For an introduction to the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.

[0133] An embodiment of the present application provides an electronic device.

[0134] Please refer to FIG. 4 , which is a schematic diagram of the structure of an electronic device provided by the present application. The electronic device may include:

[0135] A memory 11, used for storing computer programs;

[0136] The processor 10 can implement the steps of any one of the above-mentioned fault replica switching methods when executing a computer program.

[0137] As shown in Fig. 4, it is a schematic diagram of the composition structure of an electronic device, which may include: a processor 10, a memory 11, a communication interface 12 and a communication bus 13. The processor 10, the memory 11 and the communication interface 12 all communicate with each other through the communication bus 13.

[0138] In the embodiment of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic devices, etc.

[0139] The processor 10 may call a program stored in the memory 11. Specifically, the processor 10 may execute operations in an embodiment of the method for switching a failed replica.

[0140] The memory 11 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions. In the embodiment of the present application, the memory 11 at least stores programs for implementing the following functions:

[0141] Determine a target copy, and use a preset number of copy service threads to perform a write backup operation on the target copy; wherein the copy length of the target copy is variable;

[0142] During the write backup operation, if a copy write anomaly is detected, the last written data and the abnormal data in the target copy are determined;

[0143] Determine a normal replica service thread, and freeze the written data after the last written data corresponding to the normal replica service thread;

[0144] Create a preset number of new replica service threads, and use each new replica service thread to perform a write backup operation on the abnormal data and the data to be written after the abnormal data;

[0145] Connect the newly written data corresponding to each new replica service thread to the frozen position to achieve failed replica switching.

[0146] In a possible implementation, the memory 11 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

[0147] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0148] The communication interface 12 may be an interface of a communication module, and is used to connect to other devices or systems.

[0149] Of course, it should be noted that the structure shown in FIG. 4 does not constitute a limitation on the electronic device in the embodiment of the present application. In actual applications, the electronic device may include more or fewer components than those shown in FIG. 4 , or combine certain components.

[0150] An embodiment of the present application provides a computer-readable storage medium.

[0151] The computer-readable storage medium provided in the embodiment of the present application stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned fault replica switching methods can be implemented.

[0152] The computer-readable storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0153] For an introduction to the computer-readable storage medium provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate on them here.

[0154] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.

[0155] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0156] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0157] The technical solution provided by the present application is described in detail above. The principle and implementation method of the present application are described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the method and core idea of ​​the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the present application.

Claims

1. A method for switching a faulty replica, characterized in that: include: Determine a target copy, and use a preset number of copy service threads to perform a write backup operation on the target copy; wherein the copy length of the target copy is variable; During the execution of the write backup operation, if a copy write abnormality is detected, then the last written data and the abnormal data in the target copy are determined; Determine a normal copy service thread, and freeze the written data after the last written data corresponding to the normal copy service thread; Creating the preset number of new replica service threads, and using each of the new replica service threads to perform a write backup operation on the abnormal data and the data to be written after the abnormal data; The newly written data corresponding to each of the new replica service threads is connected to the frozen position to implement the failed replica switching.

2. The method for switching a failed replica according to claim 1, characterized in that: Freezing the written data after the last written data corresponding to the normal copy service thread, including: Determining metadata of the abnormal data; The last written data corresponding to the normal copy service thread is determined according to the metadata, and the written data after the last written data is frozen.

3. The method for switching a failed replica according to claim 1, characterized in that: Also includes: When it is monitored that the amount of data written into the target replica exceeds the maximum capacity of the target replica, or when it is monitored that the replica service thread is abnormal, it is determined that the replica write abnormality is monitored.

4. The method for switching a failed replica according to claim 1, characterized in that: Connecting the newly written data corresponding to each of the new replica service threads to the frozen position to implement the failed replica switching includes: In the process of executing the write backup operation by using the new copy service thread, determining whether an abnormality in writing the copy is detected; If the write abnormality of the replica is detected, return to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed, and connect the newly written data corresponding to each new replica service thread to the frozen position to achieve the failed replica switching; If no abnormality in writing to the replica is detected, the newly written data corresponding to each new replica service thread is connected to the frozen position to implement the failed replica switching.

5. The method for switching a failed copy according to claim 4, characterized in that: Returning to the step of determining the last written data and abnormal data in the target replica until the write backup operation of the target replica is completed, comprising: Determine whether the current number of backups reaches the preset number; If the preset number of times is not reached, returning to the step of determining the last written data and abnormal data in the target copy until the write backup operation of the target copy is completed; If the preset number of times is reached, a backup failure prompt is output.

6. The method for switching a failed replica according to claim 1, characterized in that: After connecting the newly written data corresponding to each of the new replica service threads to the frozen position to implement the failed replica switching, the method further includes: Determine frozen data, and unfreeze and clean up the frozen data; Recycle each of the normal replica service threads.

7. The method for switching a failed replica according to claim 1, characterized in that: During the execution of the write backup operation, if a copy write exception is detected, after determining the last written data and the abnormal data in the target copy, the method further includes: Determine the abnormal replica service thread; Output an abnormal prompt about the abnormal replica service thread and thread information of the abnormal replica service thread.

8. A fault replica switching device, characterized in that: include: An execution module, used for determining a target copy, and performing a write backup operation on the target copy using a preset number of copy service threads; wherein the copy length of the target copy is variable; A monitoring module, used for determining the last written data and abnormal data in the target copy if abnormal copy writing is detected during the execution of the write backup operation; A freezing module, used to determine a normal copy service thread, and freeze the written data after the last written data corresponding to the normal copy service thread; A creation module, used to create the preset number of new replica service threads, and use each of the new replica service threads to perform a write backup operation on the abnormal data and the data to be written after the abnormal data; The switching module is used to connect the newly written data corresponding to each new copy service thread to the frozen position to achieve the failed copy switching.

9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the fault replica switching method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the fault replica switching method according to any one of claims 1 to 7 are implemented.