Distributed system node dynamic change method, device, equipment and storage medium

By judging the latestness of the node list and the consensus of operation requests in the distributed system, it solves the inconsistency problem caused by the Paxos algorithm when nodes change, realizes asynchronous operation execution, and improves system performance and data consistency.

CN113157709BActive Publication Date: 2024-09-13BIGO TECH PTE LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110130843.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-29
Publication Date
2024-09-13
Estimated Expiration
2041-01-29

AI Technical Summary

Technical Problem

In a distributed system, when nodes are dynamically changed, using the Paxos algorithm may lead to inconsistency in the node list, resulting in a failure to reach consensus on the execution order of operation requests, affecting system performance and user experience.

Method used

By determining whether the node is in the latest node list, we obtain the operation requests that have not reached consensus and execute them sequentially according to the sequence number to ensure that all nodes reach a consensus on the operation request and its sequence number. The asynchronous consistency algorithm and request execution phase avoid Set the leading step size.

Benefits of technology

It improves the throughput and performance of distributed systems, improves user experience, and ensures the consistency of data obtained by each node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113157709B
    Figure CN113157709B
Patent Text Reader

Abstract

The present application provides a method, device, equipment and storage medium for dynamically changing nodes in a distributed system, the method comprising: any node in the distributed system can determine whether the node is in the latest node list in the distributed system; if so, obtain the operation request that has not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, the operation request includes a data operation request and a node change request; according to the sequence number, the corresponding operation request is executed in sequence, wherein if the executed operation request is a data operation request, the node data is updated, and if the executed operation request is a node change request, the node list is updated. In this way, the consistency algorithm stage and the request execution stage are asynchronous, and there is no need to set a leading step length, and the execution of the node change request does not need to be delayed, which can improve the system throughput, thereby improving the performance of the distributed system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of distributed systems, and in particular to a method, device, equipment and storage medium for dynamically changing nodes in a distributed system. Background Art

[0002] In order to improve the availability of services, a distributed system can be used for data storage. In a distributed system, multiple nodes are included, and each node needs to perform the same operations in the same order to keep the data of each node consistent.

[0003] Among them, the Paxos algorithm can be used to determine the execution order of each operation in the distributed system to ensure that the order in which each node executes each operation is consistent. The Paxos algorithm is a consistency algorithm with high fault tolerance proposed by Leslie Lamport in 1990. Specifically, each node can broadcast an operation request, and each node in the distributed system decides the execution order of the operation request, so that each operation request and its serial number can reach a consensus among all nodes in the distributed system. After reaching a consensus, each node can execute each operation request in sequence according to the serial number of each operation request, so that the data status obtained by each node will be consistent in the end.

[0004] In some cases, the nodes in the distributed system may change. For example, new nodes may be added to the distributed system, or nodes may be deleted from the distributed system. However, in a distributed system, the time when each node executes each operation request may not be synchronized. When a node changes, the time when each node updates its node list may also be asynchronous. In this case, when each node reaches a consensus on the operation request using the Paxos algorithm, the list of nodes that will participate in the decision may be different, causing errors in the Paxos algorithm and failure to reach a consensus on the execution order of each operation request in each node.

[0005] In the existing paxos algorithm, operation requests can be divided into data operation requests and member change operation requests, and a leading step length L is set. For each operation request, the paxos algorithm running phase shall not lead the execution operation phase by L steps. For example, assuming that the sequence number of the latest executed operation request is i, then the sequence number of the operation request running the paxos algorithm shall not exceed i+L, and the member change operation takes effect after L steps. For example, assuming that the sequence number of a member change operation to add a node is j, then when the operation request is executed, the node list will not be updated immediately, but the new node will not be added to the node list until the j+L-1 operation is executed.

[0006] In the above node change method, if L is set too small, the sequence number of the paxos algorithm phase can only lead the smaller step size of the execution phase, thereby reducing the throughput efficiency of the distributed system. If L is set too large, the node list will be updated for a long time, thereby increasing the complexity of the system, which will reduce the performance of the distributed system and affect the user experience. Summary of the invention

[0007] To solve the above technical problems, the present application shows a method, device, equipment and storage medium for dynamically changing nodes in a distributed system.

[0008] In a first aspect, the present application shows a method for dynamically changing a node in a distributed system, which is applied to any node in a distributed system, and the method includes:

[0009] Determine whether the node is in the latest node list in the distributed system;

[0010] If yes, obtaining operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, wherein the operation request includes a data operation request and a node change request;

[0011] According to the sequence number, the corresponding operation request is executed in sequence, wherein if the executed operation request is a data operation request, the node data is updated, and if the executed operation request is a node change request, the node list is updated.

[0012] In a second aspect, the present application shows a distributed system node dynamic change device, which is applied to any node in the distributed system, and the device includes:

[0013] A determination module, used to determine whether the node is in the latest node list in the distributed system;

[0014] A consistency module, for, if yes, obtaining operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, wherein the operation request includes a data operation request and a node change request;

[0015] An execution module is used to execute corresponding operation requests in sequence according to the serial number, wherein if the executed operation request is a data operation request, the node data is updated; if the executed operation request is a node change request, the node list is updated.

[0016] In a third aspect, the present application illustrates an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for dynamically changing nodes in a distributed system as described in any one of the above items are implemented.

[0017] In a fourth aspect, the present application illustrates a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the method for dynamically changing nodes in a distributed system are implemented in any one of the above-mentioned items.

[0018] Compared with the prior art, this application has the following advantages:

[0019] In the present application, any node in a distributed system can determine whether the node is in the latest node list in the distributed system; if so, operation requests that have not reached consensus are obtained in the distributed system so that each node in the distributed system can reach a consensus on each operation request and its corresponding serial number, and the operation request includes a data operation request and a node change request; according to the serial number, the corresponding operation request is executed in sequence, wherein if the executed operation request is a data operation request, the node data is updated, and if the executed operation request is a node change request, the node list is updated.

[0020] In this way, before reaching a consensus on each operation request and its corresponding serial number, each node in the distributed system needs to determine whether the node is in the latest node list in the distributed system. That is to say, before executing the consistency algorithm, each node believes that the list of nodes that will participate in the resolution is the same. In this way, the operation request reaches a consensus on the serial number of each node, and the data obtained by each node is consistent. In other words, in this application, the consistency algorithm stage and the request execution stage are asynchronous, and there is no need to set a leading step size, and the execution of the node change request does not need to be delayed, which can improve the system throughput, thereby improving the performance of the distributed system and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0022] Figure 1 It is a flowchart of the steps of a distributed system node dynamic change method of the present application;

[0023] Figure 2 It is a schematic diagram of a distributed system node dynamic change method of the present application;

[0024] Figure 3 It is a structural block diagram of a distributed system node dynamic change device of the present application;

[0025] Figure 4 It is a structural block diagram of an electronic device of the present application. DETAILED DESCRIPTION

[0026] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0027] The following will describe in detail the method for dynamically changing nodes in a distributed system provided by an embodiment of the present invention through specific embodiments.

[0028] Reference Figure 1 , shows a flowchart of the steps of a distributed system node dynamic change method of the present application, the method is applied to any node in the distributed system, and specifically may include the following steps:

[0029] S101: Determine whether the node is in the latest node list in the distributed system. If yes, execute S102.

[0030] In this step, if the node is in the latest node list, it means that the node is an online node in the distributed system and can continue to execute other operation requests that have reached consensus in the distributed system. On the contrary, if the node is not in the latest node list, it means that the node has been offline from the distributed system and the node can be stopped without executing subsequent operation requests.

[0031] In one implementation, it is possible to determine whether the node list stored in the node is the latest node list in the distributed system by determining whether the first sequence number is not less than the second sequence number. The first sequence number is the maximum sequence number corresponding to the operation request executed by the node, and the second sequence number is the maximum sequence number of the node change request that has reached consensus in the distributed system.

[0032] If the first sequence number is not less than the second sequence number, it means that the current node has executed the latest node change request that has reached consensus in the distributed system, then the node list in the current node is the latest node list in the distributed system.

[0033] If the first sequence number is less than the second sequence number, it means that this node has not yet executed the latest node change request that has reached consensus in the distributed system. Then, the node list in this node is not the latest node list in the distributed system. Then, this node can continue to execute the corresponding operation requests in sequence according to the sequence number and update the first sequence number until the first sequence number is not less than the second sequence number.

[0034] In this application, each node will maintain the first sequence number, second sequence number and node list of the node. Among them, the first sequence number can be expressed as max apply index, the second sequence number can be expressed as max chosen config index, and the node list can be expressed as config. In the node list, all online nodes in the distributed system are recorded. When a node change occurs in the distributed system, the node list will also be updated accordingly.

[0035] S102: Acquire operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system can reach a consensus on each operation request and its corresponding sequence number, the operation request including a data operation request and a node change request.

[0036] In this application, a consensus algorithm thread runs in each node, and the consensus algorithm thread can obtain operation requests that have not reached consensus in the distributed system, so that each node in the distributed system can reach a consensus on each operation request and its corresponding serial number.

[0037] Among them, operation requests can be divided into two types: data operation requests and node change requests.

[0038] Data operation refers to the operation on the data stored in the nodes of a distributed system. After any node performs data operation, the data state of the node will be changed. For example, if you want to build a distributed SQL system, the data operation may be a SQL command.

[0039] A node change request refers to a change operation on a node in a distributed system, which is used to add or delete nodes in a distributed system, for example, to add a node in a distributed system, or to delete a node in a distributed system. After any node executes a node change request, the node list will change. Usually, data operation requests come from the client of a distributed service; while node change requests come from operation and maintenance tools, and operation and maintenance personnel initiate node addition, deletion, and change operations to the system through operation and maintenance tools.

[0040] In one implementation, obtaining operation requests that have not reached a consensus in a distributed system so that each node in the distributed system reaches a consensus on a sequence number corresponding to each operation request may include the following steps:

[0041] First, the operation requests that have not reached a consensus in this node are obtained in turn as the target operation requests. Among them, each node in the distributed system can receive and store the operation requests input by the user. These operation requests that have not reached a consensus in the distributed system can be stored in the request queue according to the corresponding reception time. The operation requests in the request queue are all operation requests that have not reached a consensus. Only the operation requests that have reached a consensus will be executed by each node in the distributed system. In this way, the data in each node is consistent.

[0042] Then, the third sequence number is increased by 1 to be the target sequence number. In the nodes of the distributed system, the third sequence number can also be maintained. The third sequence number is the maximum sequence number of the operation request that the distributed system has reached consensus on, which can be represented by maxchosen index. The target sequence number is max chosen index+1. Among them, the operation request corresponding to the third sequence number may be a data operation request or a node change request, which is not specifically limited.

[0043] Furthermore, the target operation request and its target sequence number are broadcasted in the distributed system, so that each node in the distributed system can reach a consensus on the operation request corresponding to the target sequence number, and update the third sequence number.

[0044] Among them, if the consensus operation request corresponding to the target sequence number is not the target operation request, it means that in the distributed system, there are other consensus operation requests corresponding to the target sequence number. At this time, the maximum sequence number of the consensus operation requests in the distributed system, that is, the third sequence number, will also change. Then, after updating the third sequence number, return to the step of adding one to the third sequence number to obtain a new target sequence number.

[0045] If the consensus operation request corresponding to the target sequence number is the target operation request, it means that in the distributed system, each node has reached a consensus on the target operation request corresponding to the target sequence number. Then, the next operation request in the node that has not reached a consensus can be obtained as a new target operation request.

[0046] In one implementation, each node can use the Paxos algorithm to reach a consensus on the operation request corresponding to the target sequence number. According to the Paxos algorithm, the nodes in the distributed system can be divided into two participating roles, namely Proposer and Acceptor. In the process of reaching a consensus on the operation request corresponding to the same target sequence number, each node can only play one role.

[0047] Among them, if there are operation requests that have not reached a consensus in this node, then the node can further calculate the target sequence number equal to max chosen index+1 and serve as the Proposer of the target sequence number. If there are no operation requests that have not reached a consensus in this node, then the node can serve as the Acceptor of the target sequence number.

[0048] The Paxos algorithm specifically consists of two phases:

[0049] In the first stage, the Proposer selects a proposal number Mn and then broadcasts the Prepare request numbered Mn to all Acceptors. In the Paxos algorithm, the proposal numbers selected by each Proposer will not be repeated, and for each Proposer, the new proposal number selected each time is greater than the previous proposal number.

[0050] After the Acceptor receives the Prepare request numbered Mn, if the number Mn is greater than the maximum proposal number the Acceptor has ever received, the Acceptor will feedback a Prepare response to the Proposer, in which the Prepare response carries the Acceptor's own approved proposal number and the corresponding approved proposal value.

[0051] In the second stage, if the Proposer receives Prepare responses from more than half of the Acceptors for the Prepare request numbered Mn issued by it, then the Proposer will broadcast an Accept request for the [Mn, Vn] proposal to all Acceptors, where the value of Vn is the approved proposal value corresponding to the largest approved proposal number in the received response. If the received response does not contain an approved proposal value, then the value of Vn is the value of the target operation request.

[0052] If the Proposer receives Prepare responses from no more than half of the Acceptors for its Prepare request numbered Mn, the Proposer returns to the first stage, selects a new proposal numbered Mn', and then broadcasts the Prepare request numbered Mn' to all Acceptors.

[0053] After the Acceptor receives the Accept request for the [Mn, Vn] proposal, if the number Mn is greater than or equal to the largest proposal number to which the Acceptor has made an Accept response, then it can use this proposal to feedback the Proposer with an Accept response for the [Mn, Vn] proposal, and at the same time, update its own approved proposal number to Mn and the corresponding approved proposal value to Vn.

[0054] If the Proposer receives Accept responses from more than half of the Acceptors to its Accept request for the [Mn, Vn] proposal, it means that the nodes in the distributed system have reached a consensus, and Vn is the value of the operation request corresponding to the current target sequence number.

[0055] If the Proposer receives no more than half of the Acceptors' Accept responses to its Accept request for the proposal [Mn, Vn], the Proposer returns to the first stage, selects a new proposal number Mn', and then sends a Prepare request numbered Mn' to all Acceptors.

[0056] In the above process, any node, as a Proposer, can broadcast Prepare request and Accept request to Acceptor, or, as an Acceptor, can receive Prepare request and Accept request broadcast by Proposer, and feedback Prepare response and Accept response accordingly. Prepare request, Accept request, Prepare response and Accept response can all be called consistency messages, and each consistency message can carry the third sequence number max chosen index and the second sequence number max chosen config index of the sending node. And, if the node receiving the consistency message finds that the third sequence number max chosen index of this node is less than the third sequence number maxchosen index in the consistency message, then the third sequence number max chosen index of this node is updated to the third sequence number max chosen index carried in the consistency message, and the second sequence number max chosen config index is processed in the same way.

[0057] In this way, the consistency of the second serial number and the third serial number stored in each node in the distributed system is maintained as much as possible, reducing the failure of the consistency algorithm caused by the error of a certain node itself, making the distributed system node dynamic change method provided by the present application more accurate.

[0058] In one implementation, if the nodes in the distributed system reach a consensus on the sequence number corresponding to any node change request, then the node can update the second sequence number.

[0059] S103: Execute corresponding operation requests in sequence according to the sequence numbers. If the executed operation request is a data operation request, update the node data; if the executed operation request is a node change request, update the node list.

[0060] In this application, each node also runs an execution operation thread, which can continuously take out and execute corresponding operation requests from the operation request queue that has reached consensus in the order of sequence numbers from small to large. The execution operation thread and the consensus algorithm thread are two independent threads.

[0061] If the executed operation request is a data operation request, the data stored in the node is updated; if the executed operation request is a node change request, the node list stored in the node is updated; at the same time, the first sequence number max apply index of the node can also be updated.

[0062] In this step, the node change request can be divided into a node addition request or a node deletion request. If the node change request is a node addition request, the changed node is added to the node list stored in this node; if the node change request is a node deletion request, the changed node is deleted from the node list stored in this node.

[0063] For example, if you want to add a new node A in a distributed system, you can use the operation and maintenance tool to send a node addition request to any node in the distributed system. The node addition request is used to indicate the addition of a new node A in the distributed system. When the node addition request is agreed upon by the nodes in the distributed system, each node will execute the operation and update its node list. After the update is completed, the latest node list will include node A. For node A, you can input and store the latest node list of the distributed system, then start node A and add it to the distributed system. After node A joins the system, it will automatically catch up with other nodes and execute all operation requests in sequence.

[0064] If you want to delete node B in the distributed system, you can use the operation and maintenance tool to send a node deletion request to any node in the distributed system. The node deletion request is used to instruct to delete node B in the distributed system. When the node deletion request is agreed upon by the nodes in the distributed system, each node will execute the operation and update its node list. After the update is completed, the latest node list will no longer contain node B. For node B, after it completes this operation, it will find that it is no longer included in the node list, so it will automatically exit the distributed system.

[0065] From the above, it can be seen that in this application, each node in the distributed system needs to determine whether the node is in the latest node list in the distributed system before reaching a consensus on each operation request and its corresponding serial number. That is to say, before executing the consistency algorithm, each node believes that the list of nodes that will participate in the resolution is the same. In this way, the operation request reaches a consensus on the serial number of each node, and the data obtained by each node is consistent. In other words, in this application, the consistency algorithm stage and the request execution stage are asynchronous, and there is no need to set a leading step size, and the execution of the node change request does not need to be delayed, which can improve the system throughput, thereby improving the performance of the distributed system and enhancing the user experience.

[0066] Reference Figure 2 , showing a schematic diagram of a distributed system node dynamic change method of the present application. The service client sends a data operation request, and the operation and maintenance tool sends a member change operation request. Node A in the distributed system stores the received operation request in a queue, and takes out the operation request from the request operation queue in turn. Then, the Paxos algorithm is used to reach a consensus on the taken operation request in the distributed system including multiple nodes such as node B and node C, and then, the corresponding operations are executed in turn according to the execution sequence number. If the executed operation request is a data operation request, the data in the database DB is updated. If the operation request is a member change operation request, the node list in node A is updated.

[0067] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the order of the actions described, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the present application.

[0068] Reference Figure 3 , shows a structural block diagram of a distributed system node dynamic change device of the present application, and the device may specifically include the following modules:

[0069] A determination module 201 is used to determine whether the node is in the latest node list in the distributed system;

[0070] A consistency module 202 is used for, if yes, obtaining operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, wherein the operation request includes a data operation request and a node change request;

[0071] The execution module 203 is used to execute the corresponding operation requests in sequence according to the serial number, wherein if the executed operation request is a data operation request, the node data is updated; if the executed operation request is a node change request, the node list is updated.

[0072] In one implementation, the determination module 201 is specifically configured to:

[0073] Determine whether the first sequence number is not less than the second sequence number, where the first sequence number is the maximum sequence number corresponding to the operation request executed by the node, and the second sequence number is the maximum sequence number of the node change request that has reached consensus in the distributed system;

[0074] If it is not less than, obtain the node list stored by the node as the latest node list in the distributed system;

[0075] If it is less, the corresponding operation requests are executed in sequence according to the sequence numbers, and the first sequence number is updated until the first sequence number is not less than the second sequence number.

[0076] In one implementation, the consistency module 202 is further configured to:

[0077] If a consensus is reached on the sequence number corresponding to any node change request, the second sequence number is updated.

[0078] In one implementation, the consistency module 202 is specifically configured to:

[0079] Sequentially obtain the operation requests that have not reached consensus in the nodes as the target operation requests;

[0080] The third sequence number is incremented by one to obtain the target sequence number. The third sequence number is the maximum sequence number of the operation request that has reached consensus in the distributed system.

[0081] Broadcasting the target operation request and the target sequence number in the distributed system so that each node in the distributed system reaches a consensus on the operation request corresponding to the target sequence number and updates the third sequence number;

[0082] If the consensus operation request corresponding to the target sequence number is not the target operation request, the process returns to the step of adding one to the third sequence number to obtain the target sequence number.

[0083] In one implementation, the consistency module 202 is specifically configured to:

[0084] A consistency message for the target sequence number is broadcasted in the distributed system, wherein the consistency message carries the second sequence number and the third sequence number stored in the node, so that each node in the distributed system updates the second sequence number and the third sequence number.

[0085] In one implementation, the consistency module 202 is specifically configured to:

[0086] Receiving consistency messages of operation requests that have not reached consensus and are broadcasted by other nodes in the distributed system, where the consistency messages carry the second sequence number and the third sequence number stored by the sending node;

[0087] According to the received consistency message, the second sequence number and the third sequence number stored in the node are updated.

[0088] In one implementation, the execution module 203 is specifically configured to:

[0089] If the node change request is a node addition request, then the corresponding node is added to the node list;

[0090] If the node change request is a node deletion request, the corresponding node is deleted from the node list.

[0091] From the above, it can be seen that in this application, each node in the distributed system needs to determine whether the node is in the latest node list in the distributed system before reaching a consensus on each operation request and its corresponding serial number. That is to say, before executing the consistency algorithm, each node believes that the list of nodes that will participate in the resolution is the same. In this way, the operation request reaches a consensus on the serial number of each node, and the data obtained by each node is consistent. In other words, in this application, the consistency algorithm stage and the request execution stage are asynchronous, and there is no need to set a leading step size, and the execution of the node change request does not need to be delayed, which can improve the system throughput, thereby improving the performance of the distributed system and enhancing the user experience.

[0092] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0093] The distributed system node dynamic change device provided in the embodiment of the present invention has the corresponding functional modules for executing the distributed system node dynamic change method, can execute the distributed system node dynamic change method provided in the embodiment of the present invention, and can achieve the same beneficial effects.

[0094] In another embodiment provided by the present invention, an electronic device is also provided, which may include: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, each process of the above-mentioned distributed system node dynamic change method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not described here. For example, Figure 4 As shown, the electronic device may specifically include: a processor 301, a storage device 302, a display screen 303 with a touch function, an input device 304, an output device 305, and a communication device 306. The number of processors 301 in the electronic device may be one or more. Figure 4 A processor 301 is taken as an example. The processor 301, storage device 302, display screen 303, input device 304, output device 305 and communication device 306 of the electronic device can be connected via a bus or other means.

[0095] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the method for dynamically changing nodes in a distributed system as described in any of the above embodiments.

[0096] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the method for dynamically changing nodes in a distributed system as described in any one of the above embodiments.

[0097] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0098] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0099] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for dynamically changing nodes in a distributed system, characterized in that: Applied to any node in a distributed system, each node in the distributed system needs to perform the same operation in the same order so that the data of each node remains consistent. The method includes: Determine whether the node is in the latest node list in the distributed system; If yes, obtaining operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, wherein the operation request includes a data operation request and a node change request; Execute the corresponding operation requests in sequence according to the sequence numbers, wherein if the executed operation request is a data operation request, update the node data, and if the executed operation request is a node change request, update the node list; The step of determining whether the node is in the latest node list in the distributed system includes: Determine whether the first sequence number is not less than the second sequence number, wherein the first sequence number is the maximum sequence number corresponding to the operation request executed by the node, and the second sequence number is the maximum sequence number of the node change request that has reached consensus in the distributed system; If it is not less than, obtaining the node list stored in the node as the latest node list in the distributed system; If it is less, the corresponding operation requests are executed in sequence according to the sequence numbers, and the first sequence number is updated until the first sequence number is not less than the second sequence number.

2. The method according to claim 1, characterized in that: After obtaining the operation request for which no consensus has been reached in the distributed system, the method further includes: If a consensus is reached on the sequence number corresponding to any node change request, the second sequence number is updated.

3. The method according to claim 1, characterized in that The obtaining of the operation request without consensus in the distributed system so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number includes: Sequentially obtain the operation requests that have not reached consensus in the nodes as target operation requests; Increasing the third sequence number by one to obtain the target sequence number, wherein the third sequence number is the maximum sequence number of the operation requests that have reached consensus in the distributed system; Broadcasting the target operation request and the target sequence number in the distributed system, so that each node in the distributed system reaches a consensus on the operation request corresponding to the target sequence number, and updates the third sequence number; If the consensus operation request corresponding to the target sequence number is not the target operation request, the process returns to the step of adding one to the third sequence number to obtain the target sequence number.

4. The method according to claim 3, characterized in that The broadcasting of the target operation request and the target sequence number in the distributed system includes: A consistency message for the target sequence number is broadcasted in the distributed system, wherein the consistency message carries the second sequence number and the third sequence number stored in the node, so that each node in the distributed system updates the second sequence number and the third sequence number.

5. The method according to claim 1, characterized in that The obtaining of the operation request without consensus in the distributed system so that each node in the distributed system reaches a consensus on the sequence number corresponding to each operation request includes: Receiving a consistency message of an operation request for which no consensus has been reached, broadcasted by other nodes in the distributed system, wherein the consistency message carries the second sequence number and the third sequence number stored by the sending node; According to the received consistency message, the second sequence number and the third sequence number stored in the node are updated.

6. The method according to claim 1, characterized in that The updating of the node list comprises: If the node change request is a node addition request, adding a corresponding node to the node list; If the node change request is a node deletion request, the corresponding node is deleted from the node list.

7. A distributed system node dynamic change device, characterized in that: Applied to any node in a distributed system, each node in the distributed system needs to perform the same operation in the same order so that the data of each node remains consistent. The device includes: A determination module, used to determine whether the node is in the latest node list in the distributed system; A consistency module, for, if yes, obtaining operation requests that have not reached a consensus in the distributed system, so that each node in the distributed system reaches a consensus on each operation request and its corresponding sequence number, wherein the operation request includes a data operation request and a node change request; an execution module, configured to execute the corresponding operation requests in sequence according to the sequence numbers, wherein if the executed operation request is a data operation request, the node data is updated, and if the executed operation request is a node change request, the node list is updated; The judgment module is specifically used for: Determine whether the first sequence number is not less than the second sequence number, where the first sequence number is the maximum sequence number corresponding to the operation request executed by the node, and the second sequence number is the maximum sequence number of the node change request that has reached consensus in the distributed system; If it is not less than, obtain the node list stored by the node as the latest node list in the distributed system; If it is less, the corresponding operation requests are executed in sequence according to the sequence numbers, and the first sequence number is updated until the first sequence number is not less than the second sequence number.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the distributed system node dynamic change method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for dynamically changing nodes in a distributed system according to any one of claims 1 to 6 are implemented.