A method and apparatus for determining an election procedure in a distributed database

CN116049308BActive Publication Date: 2026-08-07JINZHUAN INFORMATION TECHNOLOGY CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JINZHUAN INFORMATION TECHNOLOGY CO LTD
Filing Date
2022-12-30
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0005]本申请实施例的目的在于提供一种分布式数据库中的选举流程确定方法和装置,以解决自选举无法满足主节点能力的问题

Benefits of technology

[0038] This application provides a method for determining the election process in a distributed database. When a conflict arises between self-selection and other-selection of distributed nodes, the method can determine which selection method to use based on the current selection status of nodes within a service group. If a node is in a pre-election or election state of self-election, or if a node is already in an other-election state, the other-election method is prioritized to ensure that the other-election receives a response immediately and is not interfered with by self-election.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116049308B_ABST
    Figure CN116049308B_ABST
Patent Text Reader

Abstract

The application provides an election process determination method and device in a distributed database. The method comprises the following steps: determining a current selection state of a node in a service group; if the node is in a pre-election state or an election state of self-election, when a control node sends a self-election request to each node, the node is controlled to enter a self-election process; if the node is in a self-election state, when a disconnection node which is disconnected with a master node initiates a self-election request, the node is controlled to continue the self-election process. The application gives priority to a self-election mode, ensures that the self-election can be responded in the first time, and is not disturbed by self-election.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of distributed database technology, and in particular to a method and apparatus for determining the election process in a distributed database. Background Technology

[0002] In large-scale distributed database products, distributed nodes typically possess high availability characteristics. This means that multiple nodes form a service group, and when some nodes fail, others can take over the service. A service group generally includes a master node and multiple slave nodes. The master node provides basic external service functions, while the slave nodes act as backups to take over the master node's functions when it fails. While providing functional services, the master node transmits data, status, and other information generated during this process to the slave nodes. Information received and agreed upon by a majority of slave nodes is permanently saved as service information for the entire service group, thus forming distributed consistency across the distributed database.

[0003] The master node in the service group is elected. Common distributed consensus protocols (such as Paxos and Raft) have implemented self-election capabilities, but the election results are often random and difficult to be manipulated manually. In some special scenarios, they cannot meet the requirement of specifying a master node.

[0004] There is currently no good solution to the problem that the current self-elected system cannot meet the requirements of the master node. Summary of the Invention

[0005] The purpose of this application is to provide a method and apparatus for determining the election process in a distributed database, so as to solve the problem that self-election cannot meet the capabilities of the master node. The specific technical solution is as follows:

[0006] In a first aspect, a method for determining the election process in a distributed database is provided, characterized in that the method includes:

[0007] Determine the current selection status of nodes within the service group;

[0008] If the node is in a pre-election or election state of self-election, when the control node sends a request for other elections to each node, it controls the node to enter the other election process.

[0009] If the node is in a state of other-election, and a node that has lost contact with the master node initiates a self-election request, the node is controlled to continue the other-election process.

[0010] Optionally, after determining the current selection status of nodes within the service group, the method further includes:

[0011] If the node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, it controls the node to continue the self-election process.

[0012] Optionally, the pre-election state includes: if the target slave node detects an anomaly in the master node, the target slave node enters the self-election pre-election state and sends a self-election request to other slave nodes in the service group, so that the other slave nodes enter the pre-election state;

[0013] The election process includes: each slave node sending its own node information to other slave nodes and receiving node information sent by other slave nodes, and electing a new master node based on the node information and the preset election rules;

[0014] The service reconstruction status includes: the new master node sends master node election information to other slave nodes, and the other slave nodes update the saved master node election information and update their own status to slave node.

[0015] Optionally, if the node is in a pre-election or election state of self-election, when the control node sends a request for other nodes to participate in the election process, controlling the node to enter the election process includes:

[0016] If the node is in a pre-election state or an election state of self-election, when the control node sends a request for other election to each node, each node switches from the pre-election state or the election state to the pre-election state of other election.

[0017] Each node sends a successful response to the control node;

[0018] After the control node receives a preset proportion of successful responses from the nodes, each node enters the selection process.

[0019] Optionally, if the node is in a service reconstruction state of self-election, and the controlling node sends a self-election request to each node, controlling the node to continue the self-election process includes:

[0020] If the node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, each node returns a failure response to the control node and continues the self-election process.

[0021] Once the control node receives a failure response from a preset proportion of nodes, it terminates the selection process.

[0022] Optionally, he selects the following states:

[0023] The control node sends an election request to the nodes in the service group, and each node returns an entry status response to the control node.

[0024] The control node sends a request to collect information to the nodes, and each node returns its own node information to the control node. The control node selects a new master node based on the node information and the set selection rules, and notifies the new master node.

[0025] The new master node sends the master node election information to other nodes, and the other nodes update the master node election information and adjust their own status to slave node.

[0026] Optionally, if the node is in a state of other-election and a disconnected node that has lost contact with the master node initiates a self-election request, controlling the node to continue the other-election process includes:

[0027] If the node is in the other election state, when the disconnected node that has lost contact with the master node initiates a self-election request, the node that has entered the other election state will send a failure response to the disconnected node.

[0028] The disconnected node exited the self-election state.

[0029] Secondly, an election process determination device in a distributed database is provided, the device comprising:

[0030] The determination module is used to determine the current selection status of nodes within the service group;

[0031] The first control module is used to control the node to enter the other election process when the control node sends an other election request to each node if the node is in the pre-election state or election state of self-election.

[0032] The second control module is used to control the node to continue the election process when the node is in the election state and a disconnected node that has lost contact with the master node initiates a self-election request.

[0033] Thirdly, an electronic device is provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0034] Memory, used to store computer programs;

[0035] When a processor executes a program stored in memory, it implements the election process determination method steps in any of the aforementioned distributed databases.

[0036] Fourthly, a computer-readable storage medium is provided, wherein a computer program is stored therein, and when executed by a processor, the computer program implements the election process determination method steps in any of the aforementioned distributed databases.

[0037] Beneficial effects of the embodiments in this application:

[0038] This application provides a method for determining the election process in a distributed database. When a conflict arises between self-selection and other-selection of distributed nodes, the method can determine which selection method to use based on the current selection status of nodes within a service group. If a node is in a pre-election or election state of self-election, or if a node is already in an other-election state, the other-election method is prioritized to ensure that the other-election receives a response immediately and is not interfered with by self-election.

[0039] Of course, implementing any product or method of this application does not necessarily require achieving all of the above advantages at the same time. Attached Figure Description

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

[0041] Figure 1 A flowchart illustrating a method for determining the election process in a distributed database, as provided in this application embodiment;

[0042] Figure 2 This is a schematic diagram of self-elected signaling provided for an embodiment of this application;

[0043] Figure 3 This is a schematic diagram of the signaling for the election of another person, provided as an embodiment of this application.

[0044] Figure 4 A schematic diagram of signaling transitioning from a self-elected pre-election state or election state to a self-elected election state, provided for an embodiment of this application;

[0045] Figure 5 A signaling diagram illustrating the maintenance of the other's election state provided in this application embodiment;

[0046] Figure 6 A signaling diagram illustrating the self-election state provided in this application embodiment;

[0047] Figure 7 A schematic diagram of the structure of an election process determination device in a distributed database provided in an embodiment of this application;

[0048] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0049] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0050] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustration and has no specific meaning in itself. Therefore, "module" and "part" may be used interchangeably.

[0051] To address the problems mentioned in the background art, according to one aspect of the embodiments of this application, an embodiment of a method for determining the election process in a distributed database is provided.

[0052] This application provides a method for determining the election process in a distributed database, which can be applied.

[0053] The following will describe in detail, with reference to specific implementation methods, a method for determining the election process in a distributed database provided in this application embodiment, such as... Figure 1 As shown, the specific steps are as follows:

[0054] Step 101: Determine the current selection status of nodes within the service group.

[0055] The master node in the service group is elected, which can be divided into self-election and external election. Self-election is initiated by the nodes within the service group. After a majority of nodes reach a consensus, the master node is generated, and other nodes automatically become slave nodes. External election is controlled by other types of components independent of the service group. Each node in the service group passively receives information and adjusts its own role.

[0056] Both self-election and other-election involve three states: pre-election, election, and service reconstruction. The server determines the current selection state of a node, specifically whether the node is in the pre-election or election state of self-election, the service reconstruction state of self-election, or the other-election state.

[0057] Figure 2This is a signaling diagram illustrating self-election. When a slave node detects an anomaly in the master node, it enters a pre-election state and sends a self-election RPC (Remote Procedure Call) request to other nodes. Upon receiving this request, other nodes also enter a pre-election state and return a success response. Each node sends its own information to other nodes and receives information from other nodes. Each node elects a new master node according to preset rules. The new master node sends its election information to other nodes, and upon receiving this information, the other nodes update their master node election information and adjust their own state to slave node.

[0058] Pre-election state: If the target slave node detects an anomaly in the master node, the target slave node enters the pre-election state of self-election and sends a self-election request to other slave nodes in the service group so that other slave nodes can enter the pre-election state.

[0059] Election status: Each slave node sends its own node information to other slave nodes and receives node information sent by other slave nodes. Based on the node information and the preset election rules, a new master node is elected.

[0060] Service Reconstruction Status: The new master node sends the master node election information to other slave nodes. Other slave nodes update the saved master node election information and update their own status to slave node.

[0061] Figure 3 The signaling diagram for the election process illustrates this: the control node sends a pre-election request to all nodes in the service group. Nodes in the service group enter the pre-election state and return a success response. After receiving successful responses from a majority of nodes, the control node sends an information collection request to all nodes in the service group, and each node returns its own information. Once the control node receives information from a majority of nodes, it elects and notifies the new master node according to preset rules. The new master node sends its election information to the other nodes, who then update their master node election information and adjust their own status to slave node.

[0062] Pre-election state: The control node sends an election request to the nodes in the service group, and each node returns an entry state response to the control node;

[0063] Election status: The control node sends a request to collect information to the nodes. Each node returns its own node information to the control node. The control node selects a new master node based on the information of each node and the set selection rules, and notifies the new master node.

[0064] Service Reconstruction Status: The new master node sends the master node election information to other nodes, and the other nodes update the master node election information and adjust their own status to slave node.

[0065] Step 102: If a node is in the pre-election or election state of self-election, when the control node sends a self-election request to each node, each node enters the self-election process.

[0066] Figure 4 This diagram illustrates the signaling process of transitioning from a pre-election or election state in a self-election to a third-party election. When the master node in a service group malfunctions, each slave node initiates a self-election and is currently in a pre-election or election state. The control node sends a third-party election request to each node, and each node switches from its pre-election or election state to the pre-election state of the third-party election. Each node sends a successful response to the control node. Once the control node receives successful responses from a preset proportion of nodes (i.e., a majority of nodes), the third-party election process begins.

[0067] Step 103: If a node is in a self-election state, when a node that has lost contact with the master node initiates a self-election request, each node continues the self-election process.

[0068] Figure 5 The signaling diagram illustrates how to maintain the election process. The control node initiates an election for other nodes within the service group and receives a majority of successful responses, continuing the election process. Nodes in the service group that are out of contact with the master node but not participating in the election initiate a self-election request. If a majority of nodes in the service group are currently in the election process, these nodes send a failure response to the out-of-contact node, causing the out-of-contact node to exit the self-election state, terminating the self-election. The election process for other nodes then continues.

[0069] In this application, when a conflict arises between self-selection and other-selection of distributed nodes, the selection method can be determined based on the current selection status of nodes within the service group. If a node is in a pre-election or election state of self-election, or if a node is already in an other-election state, the other-election method is prioritized to ensure that the other-election receives a response immediately and is not interfered with by self-election.

[0070] Optionally, after determining the current selection status of nodes within the service group, the method further includes: if a node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, each node continues the self-election process.

[0071] Figure 6 The signaling diagram illustrates the self-election process. When the master node in the service group malfunctions, each slave node initiates a self-election, and the nodes are currently in a service reconstruction state. The control node sends a self-election request to the nodes in the service group. Each node returns a failure response to the control node and continues the self-election service reconstruction process. Once the control node receives failure responses from a preset proportion of nodes (i.e., a majority of failure responses), it terminates the self-election process.

[0072] This application, while retaining the inherent election mechanism of the distributed consensus protocol, provides a compatible election method that allows for the designation of a master node, meeting the requirements for on-demand election in some scenarios and ensuring the continuous service capability of distributed nodes in the distributed database.

[0073] Based on the same technical concept, embodiments of this application also provide an election process determination device in a distributed database, such as... Figure 7 As shown, the device includes:

[0074] The determination module 701 is used to determine the current selection status of nodes within the service group;

[0075] The first control module 702 is used to control each node to enter the other election process when the control node sends an other election request to each node if the node is in the pre-election state or election state of self-election.

[0076] The second control module 703 is used to ensure that if a node is in a self-election state and a node that has lost contact with the master node initiates a self-election request, each node continues the self-election process.

[0077] Optionally, the device is also used for:

[0078] After determining the current selection status of nodes within the service group, the method also includes:

[0079] If a node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, the control node continues the self-election process.

[0080] Optional,

[0081] The pre-election state includes: if the target slave node detects an anomaly in the master node, the target slave node enters the self-election pre-election state and sends a self-election request to other slave nodes in the service group so that other slave nodes can enter the pre-election state.

[0082] The election process includes: each slave node sending its own node information to other slave nodes and receiving node information sent by other slave nodes, and electing a new master node based on the node information and the preset election rules;

[0083] The service rebuild status includes: the new master node sends the master node election information to other slave nodes, and the other slave nodes update the saved master node election information and update their own status to slave node.

[0084] Optionally, the first control module 702 is used for:

[0085] If a node is in a pre-election or election state of self-election, when the control node sends a request for other elections to each node, each node switches from the pre-election or election state to the pre-election state of other elections.

[0086] Each node sends a successful response to the control node;

[0087] After the control node receives a preset proportion of successful responses from the nodes, each node enters the selection process.

[0088] Optionally, the second control module 703 is used for:

[0089] If a node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, each node returns a failure response to the control node and continues the self-election process.

[0090] Once the control node receives a failure response from a preset proportion of nodes, it terminates the selection process.

[0091] Optionally, he can select the following states:

[0092] The control node sends an election request to the nodes in the service group, and each node returns an entry status response to the control node.

[0093] The control node sends information collection requests to the nodes, and each node returns its own node information to the control node. The control node selects a new master node based on the node information and the set selection rules, and notifies the new master node.

[0094] The new master node sends the master node election information to other nodes, and the other nodes update the master node election information and adjust their own status to slave node.

[0095] Optionally, the device is also used for:

[0096] If a node is in the other-election state, when a node that has lost contact with the master node initiates a self-election request, the node that has entered the other-election state will send a failure response to the lost node.

[0097] The disconnected node exits the self-election state.

[0098] According to another aspect of the embodiments of this application, this application provides an electronic device, such as... Figure 8 As shown, the system includes a memory 803, a processor 801, a communication interface 802, and a communication bus 804. The memory 803 stores a computer program that can run on the processor 801. The memory 803 and the processor 801 communicate through the communication interface 802 and the communication bus 804. When the processor 801 executes the computer program, it implements the steps of the above method.

[0099] The memory and processor in the aforementioned electronic devices communicate with each other via a communication bus and a communication interface. The communication bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc.

[0100] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0101] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0102] According to another aspect of the embodiments of this application, a computer-readable medium having processor-executable non-volatile program code is also provided.

[0103] Optionally, in embodiments of this application, the computer-readable medium is configured to store program code for the processor to execute the above-described method.

[0104] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments, and will not be repeated here.

[0105] In specific implementation, the embodiments of this application can be referred to the above embodiments and have corresponding technical effects.

[0106] It is understood that the embodiments described herein can be implemented in hardware, software, firmware, middleware, microcode, or a combination thereof. For hardware implementation, the processing unit can be implemented in one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers, microprocessors, other electronic units for performing the functions described herein, or combinations thereof.

[0107] For software implementation, the techniques described herein can be implemented by units that perform the functions described herein. The software code can be stored in memory and executed by a processor. The memory can be implemented in the processor or external to the processor.

[0108] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0109] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0110] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.

[0111] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0112] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0113] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks. It should be noted that in this document, relational terms such as "first" and "second" are used only 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. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. In the absence of further restrictions, an element defined by the phrase "comprising a..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0114] The above description is merely a specific embodiment of this application, enabling those skilled in the art to understand or implement this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A method for determining the election process in a distributed database, characterized in that, The method includes: Determine the current selection status of nodes within the service group; If the node is in a pre-election or election state of self-election, when the control node sends a request for other elections to each node, it controls the node to enter the other election process. Among them, the self-election is initiated by the nodes within the service group. After a majority of nodes reach a consensus, the master node is generated and other nodes automatically become slave nodes. The other-election is controlled by other types of components independent of the service group. Each node in the service group passively receives information and adjusts its own role. The pre-election state is as follows: if the target slave node detects an anomaly in the master node, the target slave node enters the pre-election state of self-election and sends a self-election request to other slave nodes in the service group so that the other slave nodes can enter the pre-election state. The election process is as follows: each slave node sends its own node information to other slave nodes and receives node information sent by other slave nodes, and elects a new master node according to the node information and the preset election rules. If the node is in a state of other election, and a node that has lost contact with the master node initiates a self-election request, the control node controls the node to continue the other election process. After determining the current selection status of nodes within the service group, the method further includes: If the node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, it controls the node to continue the self-election process. The service reconstruction state is used to indicate that the new master node sends the master node election information to other slave nodes, and the other slave nodes update the saved master node election information and update their own state to slave node.

2. The method according to claim 1, characterized in that, If the node is in a pre-election or election state of self-election, when the control node sends a request for other nodes to participate in the election process, controlling the node to enter the election process includes: If the node is in a pre-election state or an election state of self-election, when the control node sends a request for other election to each node, each node switches from the pre-election state or the election state to the pre-election state of other election. Each node sends a successful response to the control node; After the control node receives a preset proportion of successful responses from the nodes, each node enters the selection process.

3. The method according to claim 1, characterized in that, If the node is in a service reconstruction state of self-election, when the controlling node sends a self-election request to each node, controlling the node to continue the self-election process includes: If the node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, each node returns a failure response to the control node and continues the self-election process. Once the control node receives a failure response from a preset proportion of nodes, it terminates the selection process.

4. The method according to claim 1, characterized in that, He selected the following states: The control node sends an election request to the nodes in the service group, and each node returns an entry status response to the control node. The control node sends a request to collect information to the nodes, and each node returns its own node information to the control node. The control node selects a new master node based on the node information and the set selection rules, and notifies the new master node. The new master node sends the master node election information to other nodes, and the other nodes update the master node election information and adjust their own status to slave node.

5. The method according to claim 1, characterized in that, If the node is in a state of other-election, and a node that has lost contact with the master node initiates a self-election request, controlling the node to continue the other-election process includes: If the node is in the other election state, when the disconnected node that has lost contact with the master node initiates a self-election request, the node that has entered the other election state will send a failure response to the disconnected node. The disconnected node exited the self-election state.

6. An election process determination device in a distributed database, characterized in that, The device includes: The determination module is used to determine the current selection status of nodes within the service group; The first control module is used to control the node to enter the other election process when the control node sends an other election request to each node if the node is in the self-election pre-election state or election state. Among them, the self-election is initiated by the nodes within the service group. After a majority of nodes reach a consensus, the master node is generated and other nodes automatically become slave nodes. The other-election is controlled by other types of components independent of the service group. Each node in the service group passively receives information and adjusts its own role. The pre-election state is as follows: if the target slave node detects an anomaly in the master node, the target slave node enters the pre-election state of self-election and sends a self-election request to other slave nodes in the service group so that the other slave nodes can enter the pre-election state. The election process is as follows: each slave node sends its own node information to other slave nodes and receives node information sent by other slave nodes, and elects a new master node according to the node information and the preset election rules. The second control module is used to control the node to continue the election process when the node is in the other election state and the disconnected node that has lost contact with the master node initiates a self-election request. The device is also used for: If the node is in a service reconstruction state of self-election, when the control node sends a self-election request to each node, it controls the node to continue the self-election process. The service reconstruction state is used to indicate that the new master node sends the master node election information to other slave nodes, and the other slave nodes update the saved master node election information and update their own state to slave node.

7. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Master-slave node election method and device, equipment and medium

    CN115102839A