A cluster exception recovery method based on a PBFT algorithm

By introducing a cluster anomaly recovery process into the PBFT algorithm, the problem of cluster nodes being unable to recover after crashing or the network being paralyzed is solved, enabling rapid cluster recovery and improving system availability.

CN115632933BActive Publication Date: 2026-04-21HANGZHOU QULIAN TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU QULIAN TECHNOLOGY CO LTD
Filing Date
2019-12-24
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

The existing PBFT algorithm cannot complete the cluster self-recovery in a timely manner after the cluster node crashes and restarts or the network is paralyzed, causing the system to malfunction.

Method used

After the view change times out, the abnormal node enters a recovery state and sends a recovery request until it receives 2f+1 recovery requests with the same view value. Then, a new master node is elected, and the cluster is restored using the PBFT algorithm.

Benefits of technology

It improves the cluster's recovery efficiency under abnormal conditions, enhances the availability of the PBFT algorithm, and ensures that the system can quickly return to normal operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115632933B_ABST
    Figure CN115632933B_ABST
Patent Text Reader

Abstract

The application discloses a cluster abnormal recovery method based on a PBFT algorithm. In a cluster network composed of 3f+1 nodes, the PBFT algorithm can only tolerate at most f abnormal nodes at the same time, but in an actual deployment network, the whole cluster often enters an abnormal state due to reasons such as network delay, network disconnection or node restart. The abnormal node will try to initiate a view change request, and the view change request will eventually time out before the cluster network recovers, at which time the abnormal node will enter a recovery state and initiate a recovery request until more than 2f+1 nodes in the recovery state can select a consistent view value, determine a new master node, wait for a new view start message of the master node, and thus complete the abnormal recovery of the cluster. The method solves the problem that the cluster cannot autonomously recover after a failure in the PBFT algorithm, and greatly improves the availability of the PBFT algorithm.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of patent application No. 201911349305.2, filed on December 24, 2019, entitled "A Cluster Anomaly Recovery Method Based on PBFT Algorithm". Technical Field

[0002] This invention relates to the PBFT algorithm, and more particularly to a cluster anomaly recovery method based on the PBFT algorithm. Background Technology

[0003] PBFT is an abbreviation for Practical Byzantine Fault Tolerance. Proposed by Miguel Castro and Barbara Liskov in 1999, this algorithm addresses the problem of theoretical feasibility but practical inefficiency in the original Byzantine fault-tolerant algorithm. It truly solves the Byzantine attack problem in distributed asynchronous consensus systems, greatly promoting the application of Byzantine fault-tolerant algorithms in real-world systems. To tolerate the existence of f Byzantine nodes, PBFT requires at least 3f+1 nodes in the entire network.

[0004] PBFT is essentially a state machine replication algorithm that solves the Byzantine problem. Each node is a state machine that guarantees consistent service states across the entire network, enabling consistent operations. The PBFT algorithm has two main protocols:

[0005] (1) The three-phase consensus protocol ensures that the blocks packaged by the master node complete the consistency confirmation of the packaging result through the three-phase consensus, and ensures the system activity in response to Byzantine attacks.

[0006] (2) The view change protocol ensures that in the event of a master node acting maliciously, the system can elect a new master node to reach a consensus without disrupting its original consensus state.

[0007] Meanwhile, in order to ensure that the confirmed consistent state of each node is persisted and that the amount of garbage in memory is kept within a certain limit, PBFT also designed a checkpoint mechanism.

[0008] However, the current PBFT algorithm still has the following problems when applied to real-world scenarios: when cluster nodes need to crash and restart or the cluster network suffers severe paralysis or partitioning, the PBFT algorithm itself cannot complete the cluster's self-recovery in a timely manner. Therefore, a method for recovering from cluster anomalies needs to be designed. Summary of the Invention

[0009] To address the shortcomings of existing technologies, this invention proposes a cluster anomaly recovery method based on the PBFT algorithm, which can quickly restore the cluster in the event of a cluster restart or cluster network failure.

[0010] The first aspect of this application provides a cluster anomaly recovery method based on the PBFT algorithm, including:

[0011] (1) The cluster enters an abnormal state due to restart or network failure, and all nodes in the cluster become abnormal nodes.

[0012] (2) Each abnormal node sends a view change request to all nodes in the network, and then waits for view change requests from other nodes within a specified time and counts them. If 2f+1 view change requests containing the same view value are not received within the specified time, the view change timeout occurs. The view change request contains the ID of this node and the target view value of this node.

[0013] (3) Nodes that fail to update their view change requests immediately enter a pending recovery state and become pending recovery nodes;

[0014] (4) The node to be restored sends a recovery request to all nodes in the network. The recovery request includes the ID of the node and the target view value of the node.

[0015] (5) The node to be restored waits for the restoration requests of other nodes within a specified time and counts them. If 2f+1 restoration requests containing the same view value are received within the specified time, then proceed to step (6) to confirm the new view.

[0016] (6) Construct a new view based on the target view value. All nodes to be recovered that receive 2f+1 recovery requests containing the same view value within the specified time enter the new view and determine the new master node based on the view value of the new view. The rest are slave nodes. The master node in the new view first completes the abnormal recovery through the view change recovery method in the PBFT algorithm and constructs a new view start message based on the 2f+1 recovery requests received and broadcasts it to the entire network. The slave nodes in the new view wait for the new view start message from the master node within the specified time.

[0017] (7) If the slave node in the new view receives the new view start message from the master node within the specified time, it will proceed to step (8) to complete the view change; if it cannot receive the new view start message from the master node within the specified time, it will increment its own target view value by 1 and re-enter step (4).

[0018] (8) The slave nodes in the new view complete the abnormal recovery through the view change recovery method in the PBFT algorithm and update their own view value to the target view value; until all abnormal nodes are recovered and the entire cluster resumes normal operation.

[0019] Further, step (2) includes:

[0020] If 2f+1 view change requests containing the same view value are received within the specified time, the recovery is completed using the view change recovery method in the PBFT algorithm.

[0021] Further, step (5) includes:

[0022] If more than f+1 recovery requests with view values ​​greater than the target view value of this node are received within the specified time, the smallest view value among them is selected as the target view value of the node to be recovered and the process re-enters step (4).

[0023] Further, step (5) includes:

[0024] If 2f+1 recovery requests containing the same view value are not received within the specified time, return to step (4) and resend the recovery request, where the target view value remains unchanged.

[0025] Furthermore, the view change request in step (2) and the recovery request in step (4) also contain the node's digital signature information.

[0026] Furthermore, the counting rules in steps (2) and (5) state that a node ID can only be counted as one vote, and if multiple recovery requests are received from the same node, only that node can be counted as one vote.

[0027] Furthermore, the new view launch message in step (6) will contain an aggregate signature of 2f+1 nodes.

[0028] Furthermore, in step (6), the new master node is determined by polling. During polling, the view value is incremented by 1 each time, and the master node ID changes in turn.

[0029] Compared with the prior art, the embodiments of this application have the following advantages:

[0030] This application's embodiment adds a cluster anomaly recovery process to the PBFT algorithm. In actual PBFT deployment networks, cluster restarts or network paralysis frequently occur. In such cases, normal nodes enter an abnormal state and first attempt the PBFT view change method. Since network paralysis requires a certain amount of time to recover, view changes often time out and cannot be completed. The method of this invention allows the node in this situation to enter the anomaly recovery process, continuously sending anomaly recovery messages until more than 2f+1 nodes send recovery messages containing the same view value when the network recovers. At this point, the cluster anomaly recovery can be completed by electing a new node. The cluster anomaly recovery method based on the PBFT algorithm proposed in this invention improves the problem of the inability to recover after cluster paralysis in the classic PBFT algorithm, greatly improving the recovery efficiency after cluster anomalies and enhancing the usability of the PBFT algorithm. Attached Figure Description

[0031] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 This is a schematic diagram of a cluster anomaly recovery process provided in an embodiment of this application; Detailed Implementation

[0033] The present invention will be described in detail below with reference to the accompanying drawings and preferred embodiments. The objectives and effects of the present invention will become clearer as a result. The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0034] This invention proposes a cluster anomaly recovery method based on the PBFT algorithm. In a cluster network consisting of 3f+1 nodes, the PBFT algorithm can only tolerate a maximum of f nodes failing simultaneously. However, in actual network deployments, network latency, network disconnection, or node restarts often cause the entire cluster to enter an abnormal state. A node entering an abnormal state initially attempts to initiate a view change request; however, this request eventually times out before the cluster network recovers, preventing the cluster from recovering autonomously. By having the abnormal node enter a pending recovery state to initiate a recovery request, and then, after the cluster network recovers, more than 2f+1 pending recovery nodes can select a consistent view value, determine a new master node, and wait for the master node's new view startup message, the cluster anomaly recovery is completed. This method solves the problem of the PBFT algorithm's inability to autonomously recover after a cluster failure, significantly improving the availability of the PBFT algorithm.

[0035] The specific implementation process of this method is as follows:

[0036] (1) The cluster enters an abnormal state due to restart or network failure, and all nodes in the cluster become abnormal nodes.

[0037] (2) Each abnormal node sends a view change request to all nodes in the network, and then waits for other nodes' view change requests within a specified time and counts them. If 2f+1 view change requests containing the same view value are received within the specified time, the recovery is completed by the view change recovery method in the PBFT algorithm. However, if 2f+1 view change requests containing the same view value cannot be received within the specified time before the cluster network is restored, the view change will time out. The view change request contains the ID of this node, the target view value of this node, etc.

[0038] (3) Nodes that fail to update their view change requests immediately enter a pending recovery state and become pending recovery nodes;

[0039] (4) The node to be restored sends a recovery request to all nodes in the network. The recovery request includes the node's ID, the node's target view value, etc.

[0040] (5) The node to be restored waits for the restoration requests from other nodes within a specified time and counts them. If 2f+1 restoration requests containing the same view value are received within the specified time, the node proceeds to step (6) to confirm the new view. If more than f+1 restoration requests containing view values ​​greater than the target view value of the node are received within the specified time, the smallest view value is selected as the target view value of the node to be restored and the node re-enters step (4). If 2f+1 restoration requests containing the same view value are not received within the specified time due to cluster restart or cluster network paralysis, the node returns to step (4) and resends the restoration request, with the target view value remaining unchanged.

[0041] (6) Construct a new view based on the target view value. All nodes to be recovered that receive 2f+1 recovery requests containing the same view value within the specified time enter the new view, and a new master node is determined based on the view value of the new view. The rest are slave nodes. The abnormal recovery process for the master and slave nodes in the new view is as follows: Figure 1 As shown, the master node in the new view first completes the anomaly recovery through the view change recovery method in the PBFT algorithm and constructs a new view startup message based on the received 2f+1 recovery requests, which is then broadcast to the entire network; the slave nodes in the new view wait for the new view startup message from the master node within a specified time.

[0042] (7) If the slave node in the new view receives the new view start message from the master node within the specified time, it will proceed to step (8) to complete the view change; if it cannot receive the new view start message from the master node within the specified time, it will increment its own target view value by 1 and re-enter step (4).

[0043] (8) The slave nodes in the new view complete the abnormal recovery through the view change recovery method in the PBFT algorithm and update their own view value to the target view value; until all abnormal nodes are recovered and the entire cluster resumes normal operation.

[0044] In addition, as a preferred embodiment, the view change request in step (2) and the recovery request in step (4) both contain the node's digital signature information.

[0045] The counting rules in steps (2) and (5) state that each node ID can only be counted as one vote. If multiple recovery requests are received from the same node, only one vote can be counted for that node. This avoids duplicate vote counting.

[0046] The new view initiation message in step (6) will contain the aggregated signature of 2f+1 nodes. Compared to simply adding the signatures of 2f+1 nodes together, the aggregated signature can greatly reduce the size of the message body that needs to be transmitted.

[0047] In step (6), a new master node is determined by polling. The next master node is determined by polling. The master node ID is view mod N, where view is the view value and N is the number of nodes. During polling, the view value is incremented by 1 each time, and the master node ID changes in turn.

[0048] It will be understood by those skilled in the art that the above descriptions are merely preferred examples of the invention and are not intended to limit the invention. Although the invention has been described in detail with reference to the foregoing examples, those skilled in the art can still modify the technical solutions described in the foregoing examples or make equivalent substitutions for some of the technical features. All modifications and equivalent substitutions made within the spirit and principles of the invention should be included within the scope of protection of the invention.

Claims

1. A cluster abnormal recovery method based on a PBFT algorithm, the cluster consisting of 3f+1 nodes, wherein the PBFT algorithm can tolerate at most f nodes of Byzantine errors; characterized in that, The method includes: When the cluster enters an abnormal state, multiple nodes in the cluster become abnormal nodes; Each of the abnormal nodes sends a view change request to all other nodes in the cluster, the view change request including the target view value of the abnormal node that sent the view change request; If any of the abnormal nodes receives a view change request containing the same target view value within a preset change time, the first number of such requests is less than 2f+1, then the abnormal node becomes a node to be recovered. The node to be recovered sends a recovery request to all other nodes in the cluster, and the recovery request includes the target view value of the node to be recovered that sent the recovery request; If any of the nodes to be restored receives a second number of restoration requests containing the same target view value within a preset restoration time that is greater than or equal to 2f+1, then a new view is confirmed based on the number of the same target view values ​​that are greater than or equal to 2f+1, and a new master node is determined based on the view value of the new view; the rest are slave nodes. If a slave node in the new view receives a new view startup message from the master node within the preset new view startup time, the slave node completes the anomaly recovery using the view change recovery method in the PBFT algorithm and updates its node view value to the target view value. The slave node refers to any node in the cluster other than the master node. The new view startup message is constructed by the master node based on 2f+1 or more recovery requests containing the same target view value. If any of the slave nodes does not receive the new view startup message within the new view startup time, the target view value of the slave node is incremented by one, and the slave node resends the recovery request to all other nodes in the cluster.

2. The cluster abnormal recovery method based on the PBFT algorithm according to claim 1, characterized in that, If any of the nodes to be restored receives a second number of restoration requests containing the same target view value within a preset restoration time that is greater than or equal to 2f+1, then a new view is confirmed based on the 2f+1 or more identical target view values, and the main node is determined based on the view value of the new view, including: The new view is constructed based on the target view value, and the new view includes the view value; The master node of the new view is determined based on the view value. The master node completes the anomaly recovery through the view change recovery method in the PBFT algorithm and sends a new view start message to all other nodes in the cluster.

3. The cluster anomaly recovery method based on the PBFT algorithm according to claim 1, characterized in that, After each of the abnormal nodes sends a view change request to all other nodes in the cluster, the process includes: If the first number is greater than or equal to 2f+1, then the abnormal node completes the abnormal recovery through the view change recovery method in the PBFT algorithm.

4. The cluster anomaly recovery method based on the PBFT algorithm according to claim 1, characterized in that, After the node to be recovered sends a recovery request to all other nodes in the cluster, the process also includes: If any node to be restored receives a third number greater than or equal to f+1 in the recovery time for a recovery request whose target view value is greater than its local view value, then the minimum view value is determined from the target view values ​​corresponding to all the recovery requests; the local view value is the target view value of any node to be restored that received the recovery request. Update the local view value of any node to be recovered to the minimum view value; Any node to be recovered resends the recovery request to all other nodes in the cluster. 5.The PBFT algorithm-based cluster exception recovery method according to claim 1, characterized in that, After the node to be recovered sends a recovery request to all other nodes in the cluster, the process also includes: If the second number is less than 2f+1, then the node to be recovered resends the recovery request to all other nodes in the cluster. 6.The PBFT algorithm-based cluster exception recovery method according to claim 1, characterized in that, The view change request also includes the ID and digital signature information of the abnormal node that sent the view change request; the recovery request also includes the ID and digital signature information of the node to be recovered that sent the recovery request.

7. The cluster abnormal recovery method based on the PBFT algorithm according to claim 6, characterized in that, The first number is the number of view change requests with different IDs but the same target view value; The second number is the number of recovery requests with different IDs but the same target view value. 8.The PBFT algorithm-based cluster exception recovery method according to claim 1, characterized in that, The new view initiation message includes the aggregate signature of 2f+1 nodes to be restored that contain the same target view value. 9.The cluster abnormal recovery method based on the PBFT algorithm of claim 2, wherein, Determining the main node of the new view based on the view value includes: The master node of the new view is determined by polling; the view value of the new view is incremented each time it is polled; the ID of the master node changes sequentially.

10. The cluster abnormal recovery method based on the PBFT algorithm according to any one of claims 1-9, characterized in that, When the cluster enters an abnormal state, it includes when the cluster enters an abnormal state due to a restart or network failure.

11. The cluster abnormal recovery method based on the PBFT algorithm according to any one of claims 1-9, characterized in that, If any of the abnormal nodes receives a view change request containing the same target view value within a preset change time, and the first number of such requests is less than 2f+1, then the abnormal node becomes a node to be recovered, including: The abnormal node enters a state of pending recovery and becomes the node to be recovered.

12. The cluster abnormal recovery method based on the PBFT algorithm according to any one of claims 1-9, characterized in that, If a slave node in the new view receives a new view launch message from the master node within a preset new view launch time, the slave node completes anomaly recovery using the view change recovery method in the PBFT algorithm, and updates its node view value to the target view value, including: If the fourth number of nodes that have completed anomaly recovery is less than 2f+1, then multiple nodes in the cluster repeat the cluster anomaly recovery method until the cluster returns to normal.

Citation Information

Patent Citations

  • Improved single-node abnormity active recovery method based on PBFT algorithm

    CN110460484A