A breaker breaking method and module for a raft consensus algorithm

By introducing a Breaker circuit breaker into the Raft consensus algorithm and using retention time and ProbeRequest to determine the state of the Raft group, the problem of long recovery time and service interruption caused by data accumulation in the Leader node is solved, thus improving the availability of the distributed system.

CN115567373BActive Publication Date: 2026-02-10上海沄熹科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211077362.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-05
Publication Date
2026-02-10
Estimated Expiration
2042-09-05

AI Technical Summary

Technical Problem

In the Raft consensus algorithm, the failure of a Follower node causes the Leader node to accumulate a large amount of data, resulting in a long recovery time or service interruption for the Raft group, which affects the availability of the distributed system.

Method used

A Breaker circuit breaker is introduced into the Raft module. By calculating the retention time of the information to be sent, the Breaker circuit breaker is triggered or closed to refuse or allow the Leader node to receive data information. The ProbeRequest is used to determine the recovery status of the Raft group, thereby reducing the probability of long recovery time and service interruption.

Benefits of technology

This reduces the probability of Raft groups experiencing long recovery times and service interruptions, thus improving the availability of distributed systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115567373B_ABST
    Figure CN115567373B_ABST
Patent Text Reader

Abstract

The application discloses a Breaker breaker method for a Raft consensus algorithm, and relates to the technical field of the Raft consensus algorithm.The implementation of the method needs to set a Breaker breaker in a Raft module; when the Raft module cannot complete a consensus operation, the survival time of the first piece of to-be-sent information is calculated, whether the survival time of the to-be-sent information is less than a set threshold is detected, and the Breaker breaker is triggered when the survival time is not less than the set threshold, thereby rejecting a Leader node from receiving other data information; when the Raft module can complete the consensus operation, the Breaker breaker is closed, thereby prompting the Leader node to start sending the data information received by the Leader node.The application further discloses a Breaker breaker module for the Raft consensus algorithm, which implements the aforementioned Breaker breaker method through a judging unit, a calculation and detection unit and a Breaker breaker unit arranged in the Raft module, can reduce the probability of long-time recovery of a Raft group and interruption of service of the Raft group, and improve the availability of a distributed system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Raft consensus algorithm technology, specifically a Breaker disconnection method and module for the Raft consensus algorithm. Background Technology

[0002] In distributed systems, distributed consistency is a crucial concept, referring to the fact that all servers in a distributed system maintain a unified state (data). However, in distributed systems, due to network issues, system conditions, or other factors, some services may become unavailable or unreliable. This necessitates a consensus algorithm to ensure that the system remains overall available even when some services fail.

[0003] Raft is a consensus algorithm that ensures data consistency across multiple server nodes. It was influenced by Paxos. Compared to Paxos, Raft is simpler and easier to understand. In Raft, Leader and Follower are two common roles: the Leader handles all client interactions, log replication, etc., while the Follower passively receives data. In a Raft group, there can only be one Leader node, which is elected by a vote from multiple Follower nodes.

[0004] In a real-world production environment, a situation may arise where all Follower nodes in a Raft group fail, leaving only the Leader node alive. In this case, the Leader node will still receive data that requires consensus. However, if the Follower nodes remain down for an extended period, the Leader node will accumulate a large amount of information, causing the Raft group to require a significant amount of time to recover. In more severe cases, this can lead to a complete service interruption of the Raft group, rendering it unusable.

[0005] Currently, in the Raft consensus algorithm, data is sent to the Raft module to complete the consensus process. This can lead to situations where the leader node accumulates a large amount of data, requiring a lengthy recovery time for the Raft group or causing the Raft group to experience service interruption. In a real-world production environment, the unavailability of the Raft module will severely impact the normal operation of the distributed system. Summary of the Invention

[0006] This invention addresses the needs and shortcomings of current technological development by providing a Breaker circuit breaker method and module for the Raft consensus algorithm. This reduces the probability of long recovery times for Raft groups or Raft group service interruptions, thereby improving the availability of distributed systems.

[0007] First, this invention provides a Breaker circuit breaking method for the Raft consensus algorithm. The technical solution adopted to solve the above-mentioned technical problem is as follows:

[0008] A Breaker circuit breaker method for the Raft consensus algorithm, the implementation of which requires setting a Breaker circuit breaker in the Raft module;

[0009] If the Raft module fails to complete the consensus operation, the retention time of the first message to be sent is calculated. It is then checked whether the retention time is less than a set threshold. If the retention time is not less than the set threshold, the Breaker circuit breaker is triggered, preventing the Leader node from receiving other data.

[0010] When the Raft module is able to complete the consensus operation, the Breaker circuit breaker is turned off, prompting the Leader node to start sending the data it has received.

[0011] Specifically, the implementation process of this method is as follows:

[0012] S1. Start a Raft group and initialize a Breaker circuit breaker in each Raft role;

[0013] S2, the Leader node adds a reception time ts to each received message.

[0014] If the Raft group is in a normal state, then proceed with the consensus operation.

[0015] If the Leader node is alive in the Raft group and more than half of the Follower nodes are down, then continue to execute step S3;

[0016] S3. During the process of the Leader node attempting to send a message, first calculate the retention time t of the first message to be sent, that is, the retention time t is equal to the current time tn minus the receiving time ts. Then check the retention time t. If the retention time t is less than the set threshold K, continue to wait for the next round of message sending; otherwise, execute step S4.

[0017] S4. If the dwell time t is greater than or equal to the set threshold K, the Breaker circuit breaker is triggered first, Breaker_isOpen is marked as true, the Leader node is prevented from receiving other data information, and then a ProbeRequest is created and an attempt is made to send the ProbeRequest to other nodes in the Raft group.

[0018] S5. If the ProbeRequest message fails to reach consensus within the Raft group, it means that the Raft group has not yet recovered. At this time, no action is taken, and we wait for the Leader node to try to send the message again.

[0019] If the ProbeRequest message can reach a consensus within the Raft group, it means that the Raft group has returned to normal. At this time, the Breaker circuit breaker is closed, Breaker_isOpen is marked as false, and the Leader node begins to send the data it has received to complete the consensus and allows the Leader to receive new data.

[0020] More specifically, when executing step S4, the created ProbeRequest is used as a special type of information to determine whether consensus has been reached within the Raft group.

[0021] Preferably, the set threshold K is a multiple of the retention time t.

[0022] Secondly, this invention provides a Breaker circuit breaker module for the Raft consensus algorithm, and the technical solution adopted to solve the above-mentioned technical problems is as follows:

[0023] A Breaker module for the Raft consensus algorithm, whose structure includes components deployed within the Raft module:

[0024] The judgment unit is used to determine whether the Raft module can complete the consensus operation, and to start the computation detection unit when the Raft module cannot complete the consensus operation.

[0025] The calculation and detection unit is used to calculate the retention time of the first message to be sent, detect whether the retention time of the message to be sent is less than a set threshold, and trigger the Breaker disconnect unit when the retention time is not less than the set threshold, and put the Breaker disconnect unit in the closed state when the retention time is less than the set threshold.

[0026] The Breaker unit, in the triggered state, prevents the Leader node from receiving other data information, and in the closed state, prompts the Leader node to start sending the data information it has received.

[0027] Specifically, while the Leader node in the Raft group is alive, the decision-making unit uses the ProbeRequest information to determine whether the Raft module can complete the consensus operation.

[0028] If the ProbeRequest information can reach a consensus within the Raft group, then the Raft module is deemed capable of completing the consensus operation.

[0029] If the ProbeRequest information fails to reach a consensus within the Raft group, the Raft module is deemed unable to complete the consensus operation, and the computation detection unit is activated.

[0030] More specifically, the Leader node adds a reception time ts to each received message;

[0031] The calculation and detection unit uses the current time tn to subtract the receiving time ts to obtain the retention time t of the first message to be sent. Then it checks whether the retention time t is less than the set threshold K, and triggers the Breaker disconnect unit when the retention time t is not less than the set threshold K.

[0032] After the Breaker circuit breaker unit is triggered, the judgment unit creates a ProbeRequest and sends it to other Follower nodes in the Raft group. If the ProbeRequest information fails to reach consensus within the Raft group, it means that the Raft group has not yet recovered. At this time, no operation is performed, and the system waits for the Leader node to try to send a message again. If the ProbeRequest information can reach consensus within the Raft group, it means that the Raft group has recovered. At this time, the computation detection unit closes the Breaker circuit breaker unit.

[0033] Preferably, the threshold K is a multiple of the retention time t.

[0034] The Breaker circuit breaking method and module for the Raft consensus algorithm of the present invention have the following advantages compared with the prior art:

[0035] This invention can reduce the probability of long recovery times and Raft group service interruptions, thereby improving the availability of distributed systems. Attached Figure Description

[0036] Appendix Figure 1 This is a flowchart of the method according to Embodiment 1 of the present invention;

[0037] Appendix Figure 2 This is a connection block diagram of Embodiment 2 of the present invention.

[0038] The information indicated by the labels in the attached diagram is as follows:

[0039] 1. Judgment unit, 2. Calculation and detection unit, 3. Breaker circuit breaker unit. Detailed Implementation

[0040] To make the technical solution, the technical problem solved, and the technical effect of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with specific embodiments.

[0041] Example 1:

[0042] This embodiment proposes a Breaker circuit breaker method for the Raft consensus algorithm. The implementation of this method requires setting a Breaker circuit breaker in the Raft module.

[0043] If the Raft module fails to complete the consensus operation, the retention time of the first message to be sent is calculated. It is then checked whether the retention time is less than a set threshold. If the retention time is not less than the set threshold, the Breaker circuit breaker is triggered, preventing the Leader node from receiving other data.

[0044] When the Raft module is able to complete the consensus operation, the Breaker circuit breaker is turned off, prompting the Leader node to start sending the data it has received.

[0045] Combined with appendix Figure 1 The Breaker circuit breaker method in this embodiment is implemented as follows:

[0046] S1. Start a Raft group and initialize a Breaker circuit breaker in each Raft role;

[0047] S2, the Leader node adds a reception time ts to each received message.

[0048] If the Raft group is in a normal state, then proceed with the consensus operation.

[0049] If the Leader node is alive in the Raft group and more than half of the Follower nodes are down, then continue to execute step S3;

[0050] S3. During the process of the Leader node attempting to send a message, first calculate the retention time t of the first message to be sent, that is, the retention time t is equal to the current time tn minus the receiving time ts. Then check the retention time t. If the retention time t is less than the set threshold K, continue to wait for the next round of message sending; otherwise, execute step S4.

[0051] S4. If the dwell time t is greater than or equal to the set threshold K, the Breaker circuit breaker is triggered first, the Breaker_isOpen is marked as true, and the Leader node is prevented from receiving other data information. Then, a ProbeRequest is created and an attempt is made to send the ProbeRequest to other nodes in the Raft group. The created ProbeRequest is a special kind of information that is used to operate within the Raft group in a way that determines whether consensus has been reached.

[0052] S5. If the ProbeRequest message fails to reach consensus within the Raft group, it means that the Raft group has not yet recovered. At this time, no action is taken, and we wait for the Leader node to try to send the message again.

[0053] If the ProbeRequest message can reach a consensus within the Raft group, it means that the Raft group has returned to normal. At this time, the Breaker circuit breaker is closed, Breaker_isOpen is marked as false, and the Leader node begins to send the data it has received to complete the consensus and allows the Leader to receive new data.

[0054] In this implementation process, the threshold K is set as a multiple of the retention time t.

[0055] Example 2:

[0056] Combined with appendix Figure 2 This embodiment proposes a Breaker module for the Raft consensus algorithm, the structure of which includes the following components deployed in the Raft module:

[0057] Judgment unit 1 is used to determine whether the Raft module can complete the consensus operation, and to start the computation detection unit 2 when the Raft module cannot complete the consensus operation;

[0058] The calculation and detection unit 2 is used to calculate the retention time of the first message to be sent, detect whether the retention time of the message to be sent is less than a set threshold, and trigger the Breaker circuit breaker unit when the retention time is not less than the set threshold, and put the Breaker circuit breaker unit in the closed state when the retention time is less than the set threshold.

[0059] Breaker unit 3, in the triggered state, prevents the Leader node from receiving other data information, and in the closed state, prompts the Leader node to start sending the data information it has received.

[0060] In this embodiment, when the Leader node in the Raft group is alive, the determination unit 1 uses the ProbeRequest information to determine whether the Raft module can complete the consensus operation.

[0061] If the ProbeRequest information can reach a consensus within the Raft group, then the Raft module is deemed capable of completing the consensus operation.

[0062] If the ProbeRequest information fails to reach a consensus within the Raft group, the Raft module is deemed unable to complete the consensus operation, and the computation detection unit is activated.

[0063] In this embodiment, the Leader node adds a reception time ts to each received message;

[0064] The calculation and detection unit 2 calculates the retention time t of the first message to be sent by subtracting the receiving time ts from the current time tn. Then it checks whether the retention time t is less than the set threshold K, and triggers the Breaker disconnection unit 3 when the retention time t is not less than the set threshold K.

[0065] After triggering Breaker circuit breaker unit 3, the judgment unit creates a ProbeRequest and sends it to other Follower nodes in the Raft group. If the ProbeRequest information fails to reach consensus within the Raft group, it means that the Raft group has not yet recovered. At this time, no operation is performed, and the system waits for the Leader node to try to send a message again. If the ProbeRequest information can reach consensus within the Raft group, it means that the Raft group has recovered. At this time, the computation detection unit 2 closes Breaker circuit breaker unit 3.

[0066] In this embodiment, the threshold K is a multiple of the retention time t.

[0067] In summary, the Breaker circuit breaking method and module for the Raft consensus algorithm of this invention can reduce the probability of long recovery time for Raft groups and Raft group service interruption, and improve the availability of distributed systems.

[0068] The above specific examples illustrate the principles and implementation methods of the present invention in detail. These embodiments are merely for the purpose of helping to understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made to the present invention by those skilled in the art without departing from the principles of the present invention should fall within the patent protection scope of the present invention.

Claims

1. A Breaker circuit breaking method for the Raft consensus algorithm, characterized in that... This method requires setting a Breaker circuit breaker in the Raft module. If the Raft module fails to complete the consensus operation, the retention time of the first message to be sent is calculated. It is then checked whether the retention time is less than a set threshold. If the retention time is not less than the set threshold, the Breaker circuit breaker is triggered, preventing the Leader node from receiving other data. When the Raft module is able to complete the consensus operation, the Breaker circuit breaker is turned off, prompting the Leader node to start sending the data it has received. The specific process of implementing this method is as follows: S1. Start a Raft group and initialize a Breaker circuit breaker in each Raft role; S2, the Leader node adds a reception time ts to each received message. If the Raft group is in a normal state, then proceed with the consensus operation. If the Leader node is alive in the Raft group and more than half of the Follower nodes are down, then continue to execute step S3; S3. During the process of the Leader node attempting to send a message, first calculate the retention time t of the first message to be sent, that is, the retention time t is equal to the current time tn minus the receiving time ts. Then check the retention time t. If the retention time t is less than the set threshold K, continue to wait for the next round of message sending; otherwise, execute step S4. S4. If the dwell time t is greater than or equal to the set threshold K, the Breaker circuit breaker is triggered first, Breaker_isOpen is marked as true, the Leader node is prevented from receiving other data information, and then a ProbeRequest is created and an attempt is made to send the ProbeRequest to other nodes in the Raft group. S5. If the ProbeRequest message fails to reach consensus within the Raft group, it means that the Raft group has not yet recovered. At this time, no action is taken, and we wait for the Leader node to try to send the message again. If the ProbeRequest message can reach a consensus within the Raft group, it means that the Raft group has returned to normal. At this time, the Breaker circuit breaker is closed, Breaker_isOpen is marked as false, and the Leader node begins to send the data it has received to complete the consensus and allows the Leader to receive new data.

2. The Breaker circuit breaking method for the Raft consensus algorithm according to claim 1, characterized in that, When executing step S4, the created ProbeRequest is used as a special type of information to determine whether consensus has been reached within the Raft group.

3. The Breaker circuit breaking method for the Raft consensus algorithm according to claim 1, characterized in that, The set threshold K is a multiple of the retention time t.

4. A Breaker circuit breaker module for the Raft consensus algorithm, characterized in that, Its structure includes deployments within the Raft module: The judgment unit is used to determine whether the Raft module can complete the consensus operation by using the ProbeRequest information while the Leader node in the Raft group is alive: if the ProbeRequest information can reach a consensus within the Raft group, it is determined that the Raft module can complete the consensus operation; if the ProbeRequest information cannot reach a consensus within the Raft group, it is determined that the Raft module cannot complete the consensus operation, and the computation detection unit is started. The calculation and detection unit is used to calculate the retention time of the first message to be sent, detect whether the retention time is less than a set threshold, and trigger the Breaker unit if the retention time is not less than the set threshold. If the retention time is less than the set threshold, the Breaker unit is turned off. Specifically: the Leader node adds a reception time ts to each received message; the calculation and detection unit subtracts the reception time ts from the current time tn to obtain the retention time t of the first message to be sent, then detects whether the retention time t is less than a set threshold K, and triggers the Breaker unit if the retention time t is not less than the set threshold K. The Breaker unit; after the Breaker unit is triggered, the judgment unit creates a ProbeRequest and sends the ProbeRequest to other Follower nodes in the Raft group. If the ProbeRequest information fails to reach consensus in the Raft group, it means that the Raft group has not yet recovered. At this time, no operation is performed, and the system waits for the Leader node to try to send a message again. If the ProbeRequest information can reach consensus in the Raft group, it means that the Raft group has recovered. At this time, the computation detection unit closes the Breaker unit. The Breaker unit, in the triggered state, prevents the Leader node from receiving other data information, and in the closed state, prompts the Leader node to start sending the data information it has received.

5. A Breaker circuit breaker module for the Raft consensus algorithm according to claim 4, characterized in that, The threshold K is a multiple of the residence time t.

Citation Information

Patent Citations

  • Adaptive blockchain node fault tolerance improvement method and device, and storage medium

    CN113783947A

  • Method and apparatus for implementing data consistency, and server and terminal

    WO2020134199A1