Log replication decoupling consensus method using erasure codes and storage medium
By introducing erasure coding and decoupling logs into the Raft algorithm, the log replication task is dispersed and the leader node load is reduced, which solves the performance bottleneck problem of the Raft algorithm in the Internet of Things scenario, processes non-transactional data, and ensures system consistency and resource efficiency. .
Patent Information
- Application Number
- CN202410704840.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-06-03
AI Technical Summary
In the Internet of Things scenario, the Raft algorithm relies on a single leader node to manage log replication and maintain consistency, which results in limited system performance. Especially in the case of high network latency and packet loss rate, it leads to data retransmission and system performance degradation. Existing improvement solutions fail to fundamentally solve the leader performance bottleneck problem, especially the lack of optimization solutions for large amounts of non-transactional data processing.
The log replication decoupling consensus method using erasure coding is used to divide the data into encoded data fragments through the dynamic erasure coding protocol, which is distributed and copied to the follower nodes, reducing the load of the leader node, and introducing decoupled logs and adaptive encoding strategies. , ensuring that the system reduces network and storage resource consumption when the number of healthy nodes decreases.
It effectively reduces the load on the leader node, solves the system performance bottleneck problem, processes a large amount of non-transactional data, ensures the consistency and reliability of the system log, and reduces the consumption of network and storage resources.
Smart Images

Figure CN118689884A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain, and in particular to a log replication decoupling consensus method and storage medium using erasure codes. Background Art
[0002] Blockchain is a revolutionary technology. It is essentially a traceable and growing distributed ledger database. It achieves decentralization and information traceability through the comprehensive use of cryptography, consensus algorithms and other technologies. This feature of blockchain brings new solutions to the trust and security of IoT devices. Currently, most blockchain technologies used in IoT scenarios use consortium chain technology. The consensus mechanism is an extremely important part of the consortium chain, affecting the performance, scalability and security of the consortium chain. Since the nodes in the consortium chain are all authenticated, in order to achieve higher efficiency, most consortium chains use the Raft algorithm. The Raft algorithm coordinates log replication in the distributed system by electing a stable leader node to ensure that the log status of all nodes remains consistent. The leader node is responsible for processing client requests, converting requests into log entries, and replicating them to other nodes. When most nodes have saved a log entry, the entry is submitted and applied to the state machine by the leader. At any time, if the leader fails or cannot communicate with most nodes, the system will automatically elect a new leader. This election and log replication process is repeated until the system reaches a consistent state. The design of the Raft algorithm focuses on easy understanding and implementation, while ensuring strong consistency and fault tolerance.
[0003] The consensus mechanism of the alliance chain determines the overall performance of the system. In the geographically distributed IoT scenario, there is a high network delay between nodes, and the IoT devices will have a high request volume. The Raft algorithm relies on a single leader node to manage log replication and maintain consistency. This design causes the system performance to be limited by the processing power of the leader node. In the geographically distributed IoT scenario, the leader node needs to process a large number of requests from IoT devices. However, due to high network delay and packet loss rate, a large amount of IoT data causes data retransmission when the leader performs log replication, which generates high traffic between nodes and causes system performance degradation. In response to the problems of the Raft algorithm, the academic community has also proposed many methods to solve them, such as: changing the leader election mechanism of the Raft algorithm to allow nodes with higher performance to serve as leader nodes, and introducing erasure codes to save the storage resources of the Raft algorithm's network resources. Existing work has made many improvements to the problems of the Raft algorithm, mainly focusing on improving the performance of the leader. This approach cannot fundamentally solve the problem of the leader performance bottleneck. There is a large amount of non-transactional data in the IoT scenario, and the academic community has not proposed an optimization solution for this feature of the IoT scenario. Summary of the invention
[0004] In order to solve the problems in the prior art, the present invention provides a log replication decoupling consensus method using erasure codes.
[0005] The present invention provides a method comprising the following steps:
[0006] Step 1: The client sends a request to the cluster;
[0007] Step 2: After receiving the client's request, the cluster starts to process the client's request. After receiving the data from the client, the leader node generates the corresponding Term and normal log Index for this request, assembles it into a normal log entry and adds it to its local normal log. Then, the log replication process is started, and the dynamic erasure code protocol is used to divide the data into several encoded data fragments. The encoded entries are copied to the follower nodes. After receiving the responses from the set number of follower nodes, the leader node submits the entry. After receiving the non-transactional data from the client, the follower node generates the corresponding ServerID and decoupled log Index for this request, assembles it into a decoupled log entry and adds it. To its local decoupling log, and then start the replication process of the decoupling log. The dynamic erasure code protocol is also used to divide the data into several encoded data fragments. The decoupling entries containing complete data are copied to other follower nodes, and the decoupling entries containing encoded data fragments are copied to the leader node. The follower node responsible for copying the decoupling log marks the corresponding decoupling entry as weakly committed after receiving a set number of replies and reports to the leader node. After receiving the report from the follower node, the leader node generates a marked entry for the corresponding decoupling entry, and then copies the marked entry to other follower nodes. After receiving the set number of replies, the leader node marks the decoupling entry corresponding to the marked entry as strongly committed;
[0008] Step 3: After completing the log submission, the cluster replies to the client, indicating that the client's request has been completed.
[0009] As a further improvement of the present invention, in the second step, when a decoupled entry is marked as a weak commit state, the follower node will update its weak commit index and pass this information to the leader node through the heartbeat mechanism of the leader node. After receiving the weak commit index of the follower node, the leader node will merge all the decoupled entries that have entered the weak commit state but have not yet been merged into the normal log.
[0010] As a further improvement of the present invention, in the second step, the marked entry generated by the leader node does not contain specific command data, but refers to the instruction data in the corresponding decoupling entry through a pointer. When the leader node copies the marked entry to the follower node, it will check whether there is a corresponding decoupling entry in the local log according to the pointer. If the corresponding decoupling entry is missing in the local decoupling log, the follower node will request the corresponding decoupling entry from the leader node.
[0011] As a further improvement of the present invention, in the second step, the leader node uses the same k, m erasure code encoding strategy for encoding normal entries and the follower node uses the same k, m erasure code encoding strategy for encoding decoupled entries, that is, the data is divided into k data blocks, and m redundant blocks are generated. The leader node records the specific encoding strategy used in its normal entry, and the follower node records the specific encoding strategy used in its decoupled entry. The leader node assigns Term and the Index of the normal log to the encoded data block, and combines the encoding strategy to form a normal entry. The follower node assigns ServerID and the Index of the decoupled log to the encoded data block, and combines the encoding strategy to form a decoupled entry.
[0012] As a further improvement of the present invention, in the second step, the leader node broadcasts the encoded normal entry to all follower nodes, and the follower node sends a confirmation to the leader node after successful reception. Once the leader node receives confirmation replies from F+k-1 follower nodes, the normal entry is submitted; the follower node sends the encoded decoupled entry to other follower nodes, and sends the decoupled entry with complete data to the leader node. When the follower node receives confirmation replies from the leader node and F+k-2 other follower nodes, the corresponding decoupled entry is marked as a weakly submitted state. At this time, the leader node can create a corresponding marked entry and push the decoupled entry into a strongly submitted state.
[0013] As a further improvement of the present invention, in the second step, assuming that the erasure code parameter currently used is k old ,m old The leader node detects the number of healthy nodes in the current system through the heartbeat mechanism. When the number of healthy nodes in the system is less than F+k old , the coding strategy change process is started. The leader node first increases its term, then sets the value of the next array to the largest index value in the submitted entries, and adjusts the coding strategy to meet the new system health status. The new erasure code parameters need to ensure F+k new is equal to the number of healthy nodes in the system, and k new +m new =Equal to the total number of nodes in the system. The coding strategy of the follower node must be synchronized with the leader node. After the leader node changes the coding strategy, it must notify the follower node. After receiving the new coding strategy, the follower node will reply to the leader node for confirmation. When the leader node receives F+k new After a confirmation reply, it is confirmed that the encoding strategy change is successful.
[0014] As a further improvement of the present invention, in the second step, when the original leader node encounters a crash or network partition, the cluster will start a new leader election process. The newly elected leader node contains two types of entries in its log: committed entries and uncommitted entries. These entries all contain encoded data fragments. To ensure the consistency of the log, the new leader node needs to use the follower nodes to recover these data fragments to reconstruct a complete data set.
[0015] As a further improvement of the present invention, in the second step, for the submitted normal entries, the new leader node obtains at least k encoded data fragments from F follower nodes to complete data recovery. For the submitted marked entries, the new leader node only needs to request the corresponding follower node to obtain the required data. If this acquisition process fails, the new leader node requests data fragments from other follower nodes. Similarly, the new leader node can obtain at least k encoded data fragments from F follower nodes to restore the decoupled entries corresponding to the marked entries. For entries that have not yet been submitted, the new leader node will perform data recovery. If an entry that cannot be recovered is encountered, the new leader node will take deletion measures to remove the entry and its subsequent entries.
[0016] As a further improvement of the present invention, in the log replication decoupling consensus method, the requests sent by the client include transactional data requests and non-transactional data requests, the leader node can process transactional data requests and non-transactional data requests, and the follower node only processes non-transactional data requests, the transactional data requests include activity records, plans, bills, payment records, invoices, and the non-transactional data requests include GPS data, consumer feedback, audio data, picture data, and machine-generated log data.
[0017] The present invention also discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps of the log replication decoupling consensus method described in the present invention when called by a processor.
[0018] The beneficial effects of the present invention are: 1. The log replication decoupling consensus method of the present invention can effectively reduce the load of the leader node and solve the system performance problem caused by the leader performance bottleneck; 2. The log replication decoupling consensus method of the present invention can handle a large amount of non-transactional data in the Internet of Things scenario; 3. The log replication decoupling consensus method of the present invention ensures that even when the number of healthy nodes is reduced, the system's network and storage resource consumption can be effectively reduced; 4. The log replication decoupling consensus method of the present invention maintains the consistency and reliability of the distributed system by ensuring the consistency of the system log. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 It is a flow chart of the log replication decoupling consensus method of the present invention;
[0020] Figure 2 This is the overall architecture diagram of the log replication decoupling consensus method of the present invention;
[0021] Figure 3 It is a flow chart of decoupling log replication of the present invention;
[0022] Figure 4 It is a weak submission state diagram of the replication decoupling consensus method of the present invention;
[0023] Figure 5 It is a state diagram of marking entry generation and replication of the present invention; DETAILED DESCRIPTION
[0024] like Figure 1-2 As shown, the present invention discloses a log replication decoupling consensus method using erasure codes, comprising the following steps:
[0025] Step 1: The client sends a request to the cluster; the requests sent by the client are divided into two types: transactional data requests (activity records, plans, bills, payment records, invoices, etc.) and non-transactional data requests (GPS data, consumer feedback, audio data, image data, machine-generated log data, etc.).
[0026] Step 2: After receiving the client's request, the cluster starts to process the client's request; the leader node can process both transactional and non-transactional data, and the follower node can only process non-transactional data. After receiving the data from the client, the leader node will generate the corresponding Term (the term of the cluster node, which is a variable that only increases) and the Index of the normal log for this request, assemble it into a normal log entry and add it to its own local normal log, and then start the log replication process, using the dynamic erasure code protocol to divide the data into several encoded data fragments, and copy the encoded entries to the follower nodes. After receiving the response from the set number of follower nodes, the leader node will submit the entry; after receiving the non-transactional data from the client, the follower node will generate the corresponding ServerID (node number, which uniquely identifies a node) and the Index of the decoupled log for this request, and assemble it into a decoupled log. The leader node reads the entries in the log and adds them to its local decoupling log. Then, the replication process of the decoupling log is started. The dynamic erasure code protocol is also used to divide the data into several encoded data fragments. The decoupling entries containing complete data are copied to other follower nodes, and the decoupling entries containing encoded data fragments are copied to the leader node. The follower node responsible for copying the decoupling log marks the corresponding decoupling entry as weakly committed after receiving a set number of replies and reports to the leader node. After receiving the report from the follower node, the leader node generates a marked entry for the corresponding decoupling entry, and then copies the marked entry to other follower nodes. After receiving the set number of replies, the leader node marks the decoupling entry corresponding to the marked entry as strongly committed.
[0027] Step 3: After completing the log submission, the cluster replies to the client, indicating that the client's request has been completed.
[0028] The log replication decoupling consensus method of the present invention mainly consists of two parts: a decoupled log and a dynamic erasure code protocol. The core mechanism of the consensus mechanism of log replication decoupling is that the protocol significantly improves the efficiency and reliability of the Raft consensus algorithm by introducing decoupled logs and adaptive fragmentation coding protocols. The design concept of the decoupled log is to disperse the log replication tasks to each follower node without weakening the authority of the leader node, thereby effectively reducing the load of the leader node and solving the system performance problem caused by the leader performance bottleneck. In addition, the adaptive fragmentation coding protocol proposes an innovative solution to the problem that other optimization schemes for Raft, in the process of applying erasure codes to reduce network and storage resource consumption, cause the protocol performance to degrade to full replication as the number of healthy nodes decreases, ensuring that even when the number of healthy nodes is reduced, the consensus mechanism of log replication decoupling can still effectively reduce the system's network and storage resource consumption. The present invention will be elaborated in detail from three aspects:
[0029] 1. How are decoupled logs generated and replicated to all nodes in the cluster?
[0030] 2. How does the leader node merge the entries in the decoupled log into the normal log and perform the commit operation?
[0031] 3.What is the specific operating mechanism of the adaptive fragmentation coding strategy protocol?
[0032] 1. Decoupling log replication
[0033] When discussing the replication mechanism of the decoupled log in the consensus mechanism of log replication decoupling, it is first noted that each follower node maintains an independent decoupled log, and the corresponding follower node is responsible for replicating the decoupled log entries between nodes, and realizing the submission of the log and the application of the state machine through the merge operation of the leader node. In order to distinguish, the present invention calls the log in the Raft protocol a normal log, its entries are called normal entries, and the entries in the decoupled log are called decoupled entries.
[0034] In this framework, when each follower node receives a non-transactional data request initiated by a client, it first creates a corresponding decoupling entry and appends it to the local decoupling log. Then, the follower node starts the decoupling log replication process.
[0035] like Figure 3As shown in the figure, the structure of the decoupled log consists of a series of continuous decoupled entries, each of which contains the ServerID of the follower node that generated the entry, the Index of the decoupled entry, and the corresponding non-transactional state machine command data. When a decoupled entry is copied by most nodes and copied to the leader node, the decoupled entry enters the weakly committed state. It is worth noting that, unlike the Raft commit mechanism, the weakly committed state only indicates that the decoupled entry is ready to be merged into the normal log by the leader node, and does not ensure its ultimate security. The weakly committed state is a necessary stage for the decoupled entry to reach the strongly committed state.
[0036] Follower nodes maintain a variable called weak commit index to track which entries in the local decoupled log have reached the weak commit state. Unlike the commit index in the Raft protocol, the weak commit index is not monotonically increasing; in the event of a leader node failure, the weak commit index may regress. Figure 4 As shown in the figure, at time T1, follower node S0 successfully copied the decoupled entry D to leader node S1 and another follower node S2, and marked the entry as weakly committed. However, at time T2, leader node S1 failed and S3 was elected as the new leader node. Since the decoupled entry D failed to meet the conditions for being copied to the new leader node, its weakly committed state was revoked. This mechanism can only ensure that the decoupled entry that enters the weakly committed state can be merged into the normal log by the leader node, but it cannot guarantee the security of the log.
[0037] Under the framework of the Raft algorithm, the leader node is responsible for broadcasting log entries to other nodes in the cluster to ensure the consistency of the system log, thereby maintaining the consistency and reliability of the distributed system.
[0038] In the consensus mechanism of log replication decoupling, the decoupled entries in the decoupled log will eventually be converted into marked entries in the normal log maintained by the leader node. These marked entries are generated and replicated by the leader node. It is worth noting that these marked entries do not carry actual data content, so almost no additional network resources are consumed during the replication process. This means that the decoupled entries in the decoupled log will eventually be integrated into the normal log and replicated and managed by the leader node, thereby ensuring that the authority of the leader node in the Raft framework of log replication decoupling is not weakened.
[0039] 2. Marking entries and two-phase commit
[0040] When a decoupled entry is marked as weakly committed, the follower node updates its weakly committed index and passes this information to the leader through the heartbeat mechanism of the leader node. After receiving the weakly committed index from the follower node, the leader node merges all the decoupled entries that have entered the weakly committed state but have not yet been merged into the normal log. The leader node does not directly copy the data content of the decoupled entry to the normal log, but creates a marked entry, which does not contain specific command data, but contains a pointer to the corresponding decoupled entry and identifies itself as a marked entry pointing to the decoupled entry. Therefore, there are two types of entries in the normal log maintained by the leader node: one is the normal entry generated by the leader node after receiving the client request, which contains instruction data; the other is the marked entry generated based on the decoupled log, which does not contain instruction data, but refers to the instruction data in the corresponding decoupled entry through a pointer. When the marked entry corresponding to a decoupled entry is committed by the leader node, the decoupled entry enters the strong committed state, ensuring the final consistency of its data.
[0041] During the log replication process, the leader node will copy the marked entry to the follower node. Since the marked log does not contain data, after receiving the marked entry, the follower node needs to check whether there is a corresponding decoupling entry locally based on the pointer in it. If the corresponding decoupling entry is missing in the local decoupling log, the follower node will request the corresponding decoupling entry from the leader node. The following example will illustrate this situation: Figure 5 As shown, at time T1, the leader node S0 receives non-transactional data A from the client and generates a normal entry, which is then propagated to other follower nodes through the log replication mechanism. At the same time, after receiving the non-transactional data from the client, the follower node S2 generates the corresponding decoupling entry and attempts to copy it to other nodes. However, due to network problems, the decoupling entry generated by S2 failed to be successfully copied to node S4. At this time, the decoupling entries B and C are marked as weakly committed. At time T2, the leader node generates corresponding marked entries for the decoupling entries B and C, and propagates these marked entries to other nodes through the log replication mechanism, so that these marked entries are marked as strongly committed. Since the follower node S4 fails to contain the decoupling entry corresponding to the marked entry copied by the leader node, it requests the required decoupling entry from the leader node. At time T3, the leader node S0 sends the missing decoupling entries B and C to the follower node S4 based on the feedback from the follower node S4.
[0042] 3. Adaptive Coding Fragmentation Protocol
[0043] In the Raft framework with log replication decoupling, the adaptive coding fragmentation protocol plays a crucial role. It is designed to optimize the network and storage resource consumption during log replication. The protocol consists of two main parts: the encoding of entries and the dynamic adjustment of the encoding strategy during log replication. First, the encoding phase involves the encoding of normal entries by the leader node and the encoding of decoupled entries by the follower node. Both use the same (k, m) erasure code encoding strategy to divide the data into k data blocks and generate m redundant blocks. Since the encoding strategy may change over time, the specific encoding strategy used needs to be recorded in the entry. The leader node is responsible for assigning Term and Index to the encoded data block, and combining the encoding strategy to form a normal entry. Correspondingly, the follower node assigns ServerID and Index to the encoded data block and records the encoding strategy to form a decoupled entry.
[0044] Assuming that the cluster contains 2F+1 nodes and adopts the (k, m) erasure code strategy, in the log replication phase, it can be discussed from two aspects: one is the replication of normal entries by the leader node; the other is the replication of decoupled entries by the follower nodes. The leader node broadcasts the encoded normal entry to all follower nodes, and the follower nodes send confirmation to the leader node after successful reception. Once the leader node receives confirmation replies from F+k-1 follower nodes, the normal entry is committed. Similarly, the follower node sends the encoded decoupled entry to other nodes and sends the decoupled entry with complete data to the leader node. When the follower node receives confirmation replies from the leader node and F+k-2 other follower nodes, the corresponding decoupled entry is marked as weakly committed. At this point, the leader node can create the corresponding marked entry and push the decoupled entry into the strong committed state.
[0045] When the number of healthy nodes in the system is not enough to meet F+k, the leader node will not be able to submit logs. At this time, the system enters the coding strategy adjustment stage. In the adaptive coding strategy adjustment part, assume that the current erasure code parameter is k old , m old The leader node detects the number of healthy nodes in the current system through the heartbeat mechanism. When the number of healthy nodes in the system is less than F+k old , the coding strategy change process is initiated. The leader node first increases its term, then sets the value of the next array to the largest index value among the submitted entries, and adjusts the coding strategy to meet the new system health. Specifically, the new erasure code parameters need to ensure that F+k new is equal to the number of healthy nodes in the system, and k new +m newEqual to the total number of nodes in the system. The coding strategy of the follower node must be synchronized with the leader node. After the leader node changes the coding strategy, it must notify the follower node. After receiving the new coding strategy, the follower node will reply to the leader node for confirmation. When the leader node receives F+k new After a confirmation reply, it is confirmed that the encoding strategy has been changed successfully.
[0046] The preparation phase for the new leader node
[0047] When the original leader node encounters a crash or network partition, the cluster will start a new leader election process. The newly elected leader node contains two types of entries in its log: committed entries and uncommitted entries. These entries contain encoded data fragments. To ensure the consistency of the log, the new leader node needs to use the follower nodes to recover these data fragments to reconstruct the complete data set.
[0048] To perform its duties, the new leader node must go through a phase called leader preparation before processing client requests, which aims to restore complete log information. For submitted entries, there are two forms: normal entries containing data and marked entries that do not contain data. For normal entries, the new leader node can ensure that at least k encoded data fragments are obtained from F follower nodes to complete data recovery. For marked entries, since they point to specific decoupled entries, and the follower node that generates the decoupled entry retains complete data, the leader node only needs to request the corresponding follower node to obtain the required data. If this process fails, the leader node can request data fragments from other follower nodes. Similarly, the leader node has the ability to obtain at least k encoded data fragments from F follower nodes to restore the decoupled entry corresponding to the marked entry.
[0049] For entries that have not been committed, the new leader node will do its best to recover the data. However, if it encounters an entry that cannot be recovered, the leader node will take deletion measures to remove the entry and its subsequent entries to avoid affecting the consistency of the data. This strategy ensures that the system can maintain data integrity and consistency in the face of leader changes, while also ensuring the robustness and reliability of the distributed system.
[0050] The present invention also discloses a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps of the log replication decoupling consensus method described in the present invention when called by a processor.
[0051] The beneficial effects of the present invention are: 1. The log replication decoupling consensus method of the present invention can effectively reduce the load of the leader node and solve the system performance problem caused by the leader performance bottleneck; 2. The log replication decoupling consensus method of the present invention can handle a large amount of non-transactional data in the Internet of Things scenario; 3. The log replication decoupling consensus method of the present invention ensures that even when the number of healthy nodes is reduced, the system's network and storage resource consumption can be effectively reduced; 4. The log replication decoupling consensus method of the present invention maintains the consistency and reliability of the distributed system by ensuring the consistency of the system log.
[0052] The above contents are further detailed descriptions of the present invention in combination with specific preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as falling within the protection scope of the present invention.
Claims
1. A log replication decoupling consensus method using erasure codes, characterized in that: The following steps are involved: Step 1: The client sends a request to the cluster; Step 2: After receiving the client's request, the cluster starts processing the client's request; After receiving the data from the client, the leader node will generate the corresponding Term and normal log Index for this request, assemble it into a normal log entry and add it to its local normal log, then start the log replication process, use the dynamic erasure code protocol to divide the data into several encoded data fragments, copy the encoded entries to the follower nodes, and after receiving the responses from the set number of follower nodes, the leader node will submit the entry; after receiving the non-transactional data from the client, the follower node will generate the corresponding ServerID and decoupled log Index for this request, assemble it into a decoupled log entry and add it to its local decoupled log, then Start the replication process of the decoupled log. Also use the dynamic erasure code protocol to divide the data into several encoded data fragments. Copy the decoupled entries containing complete data to other follower nodes, and copy the decoupled entries containing encoded data fragments to the leader node. After receiving the set number of replies, the follower node responsible for copying the decoupled log marks the corresponding decoupled entry as weakly committed and reports to the leader node. After receiving the report from the follower node, the leader node generates a marked entry for the corresponding decoupled entry, and then copies the marked entry to other follower nodes. After receiving the set number of replies, the leader node marks the decoupled entry corresponding to the marked entry as strongly committed. Step 3: After completing the log submission, the cluster replies to the client, indicating that the client's request has been completed.
2. The log replication decoupling consensus method according to claim 1 is characterized in that: In the second step, when a decoupled entry is marked as weakly committed, the follower node updates its weakly committed index and passes this information to the leader node through the heartbeat mechanism of the leader node. After receiving the weakly committed index from the follower node, the leader node merges all the decoupled entries that have entered the weakly committed state but have not yet been merged into the normal log.
3. The log replication decoupling consensus method according to claim 1 is characterized in that: In the second step, the marked entry generated by the leader node does not contain specific command data, but refers to the instruction data in the corresponding decoupling entry through a pointer. When the leader node copies the marked entry to the follower node, it will check whether there is a corresponding decoupling entry in the local log according to the pointer. If the corresponding decoupling entry is missing in the local decoupling log, the follower node will request the corresponding decoupling entry from the leader node.
4. The log replication decoupling consensus method according to claim 1 is characterized in that: In the second step, the leader node uses the same k, m erasure code encoding strategy for encoding normal entries and the follower node uses the same k, m erasure code encoding strategy for encoding decoupled entries, that is, the data is divided into k data blocks and m redundant blocks are generated. The leader node records the specific encoding strategy used in its normal entry, and the follower node records the specific encoding strategy used in its decoupled entry. The leader node assigns Term and the Index of the normal log to the encoded data block, and combines the encoding strategy to form a normal entry. The follower node assigns ServerID and the Index of the decoupled log to the encoded data block, and combines the encoding strategy to form a decoupled entry.
5. The log replication decoupling consensus method according to claim 4 is characterized in that: In the second step, the leader node broadcasts the encoded normal entry to all follower nodes. The follower nodes send confirmation to the leader node after successful reception. Once the leader node receives confirmation replies from F+k-1 follower nodes, the normal entry is submitted. The follower node sends the encoded decoupled entry to other follower nodes and sends the decoupled entry with complete data to the leader node. When the follower node receives confirmation replies from the leader node and F+k-2 other follower nodes, the corresponding decoupled entry is marked as weakly committed. At this time, the leader node can create the corresponding marked entry and push the decoupled entry into the strongly committed state.
6. The log replication decoupling consensus method according to claim 5 is characterized in that: In the second step, it is assumed that the erasure code parameter currently used is k old , m old The leader node detects the number of healthy nodes in the current system through the heartbeat mechanism. When the number of healthy nodes in the system is less than F+k old , the coding strategy change process is started. The leader node first increases its term, then sets the value of the next array to the largest index value in the submitted entries, and adjusts the coding strategy to meet the new system health status. The new erasure code parameters need to ensure F+k new is equal to the number of healthy nodes in the system, and k new +m new =Equal to the total number of nodes in the system. The coding strategy of the follower node must be synchronized with the leader node. After the leader node changes the coding strategy, it must notify the follower node. After receiving the new coding strategy, the follower node will reply to the leader node for confirmation. When the leader node receives F+k new After a confirmation reply, it is confirmed that the encoding strategy change is successful.
7. The log replication decoupling consensus method according to claim 1 is characterized in that: In the second step, when the original leader node encounters a crash or network partition, the cluster will start a new leader election process. The newly elected leader node contains two types of entries in its log: committed entries and uncommitted entries. These entries all contain encoded data fragments. To ensure the consistency of the log, the new leader node needs to use the follower nodes to recover these data fragments to reconstruct the complete data set.
8. The log replication decoupling consensus method according to claim 7 is characterized in that: In the second step, for the submitted normal entries, the new leader node obtains at least k encoded data fragments from F follower nodes to complete data recovery. For the submitted marked entries, the new leader node only needs to request the corresponding follower node to obtain the required data. If this acquisition process fails, the new leader node asks other follower nodes for data fragments. Similarly, the new leader node can obtain at least k encoded data fragments from F follower nodes to restore the decoupled entries corresponding to the marked entries. For entries that have not yet been submitted, the new leader node will perform data recovery. If an entry cannot be recovered, the new leader node will take deletion measures to remove the entry and its subsequent entries.
9. The log replication decoupling consensus method according to claim 2 is characterized in that: In the log replication decoupled consensus method, the requests sent by the client include transactional data requests and non-transactional data requests. The leader node can process transactional data requests and non-transactional data requests, and the follower node only processes non-transactional data requests. The transactional data requests include activity records, plans, bills, payment records, and invoices. The non-transactional data requests include GPS data, consumer feedback, audio data, picture data, and machine-generated log data.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is configured to implement the steps of the log replication decoupling consensus method described in claims 1-9 when called by a processor.
Citation Information
Patent Citations
quick log copying method and device in Fabric block chain
CN113609229A
Block chain consensus method, consensus node and electronic equipment
CN113873030A
Distributed consensus system based on federal learning and operation method thereof
CN116723192A
Resource management method, device and equipment and computer storage medium
CN116955367A
Consistency algorithm in rack-mounted server environment
CN117271228A
