Database cluster arbitration method and apparatus, and device

By generating election guidance information through the management node, the data nodes in the database cluster are guided to re-elect the master node, which solves the problem of insufficient high availability in complex failure scenarios and achieves rapid recovery and high-quality service.

WO2026081482A1PCT designated stage Publication Date: 2026-04-23HUAWEI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2025-05-26
Publication Date
2026-04-23

AI Technical Summary

Technical Problem

In database clusters, existing technologies have insufficient high availability when some data nodes fail, especially in complex failure scenarios where it is difficult to quickly elect a new master node, leading to service interruption.

Method used

By acquiring service information from multiple data nodes through the management node, election guidance information is generated to guide the data nodes to re-elect the master node based on the arbitration protocol, thereby optimizing the election process and ensuring that the most suitable master node is quickly selected in complex failure scenarios.

Benefits of technology

It enables the rapid and seamless selection of healthy master nodes in complex fault scenarios, ensuring high availability and service continuity of the database cluster and improving recovery capabilities in fault scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025097219_23042026_PF_FP_ABST
    Figure CN2025097219_23042026_PF_FP_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of databases. Disclosed are a database cluster arbitration method and apparatus, and a device. The method comprises: acquiring service information of a plurality of data nodes in a database cluster, wherein the service information is used for representing database services that the data nodes can provide, and the plurality of data nodes comprise a master node; if it is determined, on the basis of the service information of the plurality of data nodes, that the master node cannot fully provide a database service, generating election guidance information, which is used for guiding the plurality of data nodes to re-elect a master node from among the plurality of data nodes on the basis of an arbitration protocol; and sending the election guidance information to the plurality of data nodes. In this way, election guidance information is generated, such that each data node can re-elect the most suitable master node from among a plurality of data nodes with reference to service information of the plurality of data nodes. The method is applicable to various complex fault scenarios, thereby meeting the requirement of achieving high availability in the complex fault scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Database cluster arbitration methods, devices and equipment

[0001] This application claims priority to Chinese Patent Application No. 202411444003.4, filed on October 15, 2024, entitled “Database Cluster Arbitration Method, Apparatus and Device”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of database technology, and in particular to a database cluster arbitration method, apparatus and equipment. Background Technology

[0003] A database cluster refers to a group of multiple data nodes that work together to provide highly available, high-performance, and scalable database services. Therefore, even if some data nodes in the database cluster fail, the cluster can still continue to provide services to users. For example, a database cluster may consist of a primary node and multiple secondary nodes. The secondary nodes back up the data on the primary node, and the data on the secondary nodes changes as the data on the primary node changes. If the primary node fails, a new primary node is elected from among the secondary nodes to ensure that the database cluster continues to provide services to users.

[0004] Therefore, one database cluster arbitration method involves multiple backup nodes, in the event of a master node failure, initiating election requests to other backup nodes to obtain votes if none of them receive a heartbeat signal from the master node within a specified time. For example, if backup node 1 does not receive a heartbeat signal from the master node within a specified time, it sends election requests to the other backup nodes. The other backup nodes decide whether to vote for backup node 1 based on these requests. If backup node 1 receives more than half the number of votes in the database cluster, it is elected as the new master node. It is evident that each backup node needs to initiate an election request to the other backup nodes, which can lead to insufficient high availability in complex failure scenarios. Summary of the Invention

[0005] This application provides a database cluster arbitration method, apparatus, and device, which can reselect the most suitable master node by referring to the service information of multiple data nodes, adapting to various complex fault scenarios, thereby meeting the requirement of high availability under complex fault scenarios. The technical solution is as follows:

[0006] Firstly, a database cluster arbitration method is provided. This method is applied to a management node and includes: obtaining service information from multiple data nodes in the database cluster, where the service information characterizes the database services that each data node can provide, including a master node; if, based on the service information of the multiple data nodes, it is determined that the master node cannot fully provide database services, then election guidance information is generated. This election guidance information guides the multiple data nodes to re-elect a master node from among the multiple data nodes based on an arbitration protocol, where the arbitration protocol is a negotiation among the multiple data nodes to re-elect a master node; and finally, the election guidance information is sent to the multiple data nodes. In this way, by generating election guidance information, each data node can refer to the service information of the multiple data nodes to re-elect the most suitable master node from among the multiple data nodes, adapting to various complex fault scenarios and thus achieving high availability under complex fault conditions.

[0007] In this context, the master node's inability to fully provide database services can be understood as the master node's operating state not being optimal. For example, the master node may fail or be in a sub-healthy state. A node failure can include, but is not limited to, power outages or process termination. A sub-healthy state can be understood as the master node being able to provide services but only providing partial, not full, services. For example, a sub-healthy state may include process lag on the master node, intermittent network outages, or disk failure. Conversely, a healthy state at least does not include failures or sub-healthy states.

[0008] In one possible implementation, if it is determined based on the service information of multiple data nodes that the master node cannot fully provide database services, election guidance information is generated. This includes: if it is determined based on the service information of the master node that it can provide partial database services, then election guidance information is generated based on the service information of multiple data nodes. The election guidance information indicates which data node among the multiple data nodes can fully provide database services. Thus, if the master node can provide partial database services, it means the master node is in a sub-healthy state, i.e., its service quality is poor. Therefore, in order to provide high-quality services, election guidance information (such as a candidate list) is automatically generated based on the service information of multiple data nodes obtained by the management node. This instructs other healthy nodes to re-elect a master node, so that subsequent multiple data nodes can select a healthy node based on the election guidance information. This achieves seamless automatic master switching, thereby ensuring the provision of high-quality services.

[0009] In one possible implementation, the number of data nodes is even. If, based on the service information of multiple data nodes, it is determined that the master node cannot fully provide database services, election guidance information is generated. This includes: if, based on the service information of multiple data nodes, it is determined that half of the data nodes have failed, then, based on the service information of the data nodes that have not failed, election guidance information is generated, indicating the number of votes required to elect a new master node and the available data nodes for voting. Therefore, in a scenario where the number of data nodes in the database cluster is even and half of the nodes have failed, the service information of multiple data nodes obtained by the management node can quickly identify nodes that can provide complete database services. A new master node can then be re-elected from these unfailed nodes to continue providing database services, thus improving high availability in failure scenarios.

[0010] In one possible implementation, the method further includes deleting failed data nodes from the database cluster. This allows the management node to also delete failed nodes in the database cluster, degrading the database cluster replicas without data loss.

[0011] In one possible implementation, the method further includes adding the deleted data nodes back to the database cluster if they recover. That is, when a failed data node is deleted and then recovers, the management node adds it back to the database cluster, achieving dynamic adjustment of data nodes in the database cluster. This ensures continued service provision under various failure scenarios and improves high availability during failures.

[0012] In one possible implementation, if it is determined based on the service information of multiple data nodes that the master node cannot fully provide database services, election guidance information is generated. This includes: if it is determined based on the master node's service information that the master node has failed, election guidance information is generated, and the election guidance information is also used to indicate that the master node has failed. It is evident that in related technologies, the standby node initiates the election request only after the election timeout period has elapsed. However, in this application, by obtaining the service information of multiple data nodes from the management node, a master node failure is detected, and election guidance information is immediately generated to guide the standby node to re-elect the master node according to the election guidance information, without waiting for the election timeout period to arrive. This allows the database cluster to quickly elect a new master node, optimizing the recovery time objective.

[0013] In one possible implementation, election guidance information is sent to multiple data nodes. This includes sending the information within a first duration after the master node fails, where the first duration is shorter than a second duration. The second duration refers to the time between the moment when multiple data nodes do not receive the master node's heartbeat signal and the moment when the re-election of the master node begins. In this way, when the master node fails, the backup node can initiate a re-election of the master node before the election timeout expires. Compared to waiting for the election timeout to occur before initiating a re-election, this is more timely and allows for a faster election of a new master node, thus optimizing the recovery time objective.

[0014] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0015] Secondly, a database cluster arbitration method is provided. The database cluster includes multiple data nodes, including a master node. The method is applied to any one of the data nodes and includes: receiving election guidance information sent by a management node. This election guidance information is generated based on the service information of multiple data nodes, indicating that the master node cannot fully provide database services. The service information characterizes the database services that a data node can provide, and the election guidance information guides the re-election of a master node from among the multiple data nodes. Based on the election guidance information and an arbitration protocol, a new master node is re-elected from among the multiple data nodes. The arbitration protocol is a negotiation among the multiple data nodes to re-elect the master node. In this way, according to the election guidance information generated by the management node, each data node can refer to the service information of multiple data nodes to re-elect the most suitable master node from among the multiple data nodes, adapting to various complex failure scenarios and thus achieving high availability under complex failure scenarios.

[0016] In one possible implementation, election guidance information directs data nodes among multiple data nodes that can fully provide database services. Based on the election guidance information and an arbitration protocol, a new master node is elected from among the multiple data nodes, including re-electing a master node from among the data nodes that can fully provide database services. Thus, if the master node can only provide partial database services, meaning it is in a sub-healthy state with poor service quality, then to provide high-quality service, election guidance information is automatically generated using service information from multiple data nodes obtained by the management node. This information instructs other healthy nodes to re-elect a master node, allowing subsequent data nodes to select a healthy node based on the election guidance information. This achieves seamless automatic master node switching, ensuring high-quality service is provided externally.

[0017] In one possible implementation, the number of data nodes is even, and election guidance information indicates the number of votes for an eligible master node and the number of data nodes with available votes. Based on the election guidance information and the arbitration protocol, a new master node is elected from among the multiple data nodes, including: based on the number of votes for an eligible master node and the number of data nodes with available votes, and from among the data nodes that have not experienced failures. Therefore, in scenarios where the number of data nodes in the database cluster is even and half of the nodes fail, the majority election rule of the arbitration protocol cannot be satisfied, and thus service cannot continue. The technical solution provided in this application, however, can quickly identify nodes capable of providing complete database services by obtaining service information from multiple data nodes through the management node. A new master node is then re-elected from these nodes to continue providing database services, improving high availability in failure scenarios.

[0018] In one possible implementation, the election guidance information is also used to indicate that the master node has failed. Based on the election guidance information and the arbitration protocol, a new master node is elected from multiple data nodes, including: starting the re-election of the master node from multiple data nodes after receiving the election guidance information. It is evident that in related technologies, the standby node initiates the election request only after the election timeout period has elapsed. However, in this application, in the event of a master node failure, the management node detects the failure and immediately generates election guidance information to guide the standby node in re-electing the master node, without waiting for the election timeout period. This allows the database cluster to quickly elect a new master node, optimizing the recovery time objective.

[0019] In one possible implementation, receiving election guidance information from the management node includes: receiving the election guidance information from the management node within a first time period after the master node fails, where the first time period is shorter than a second time period. The second time period refers to the duration from the moment when multiple data nodes fail to receive the master node's heartbeat signal to the moment when the re-election of the master node begins. In this way, when the master node fails, the backup node can initiate a re-election of the master node before the election timeout expires. Compared to waiting for the election timeout to arrive before initiating a re-election, this is more timely and allows for a faster election of a new master node, thus optimizing the recovery time objective.

[0020] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0021] Thirdly, a database cluster arbitration device is provided. The device is applied to a management node and includes: an acquisition module for acquiring service information of multiple data nodes in the database cluster, the service information being used to characterize the database services that the data nodes can provide, the multiple data nodes including a master node; a generation module for generating election guidance information if it is determined based on the service information of the multiple data nodes that the master node cannot fully provide database services, the election guidance information being used to guide the multiple data nodes to re-elect a master node from among the multiple data nodes based on an arbitration protocol, the arbitration protocol being a protocol for the multiple data nodes to negotiate and re-elect a master node; and a sending module for sending the election guidance information to the multiple data nodes.

[0022] In one possible implementation, a generation module is used to generate election guidance information based on the service information of multiple data nodes if it is determined from the service information of the master node that the master node can provide partial database services. The election guidance information indicates the data nodes among the multiple data nodes that can provide complete database services.

[0023] In one possible implementation, the number of multiple data nodes is even; the generation module is used to generate election guidance information based on the service information of the data nodes that have not failed, if it is determined from the service information of the multiple data nodes that half of the data nodes have failed. The election guidance information indicates the number of votes for the elected master node and the data nodes available for voting.

[0024] In one possible implementation, the apparatus further includes a deletion module for deleting data nodes that have failed in the database cluster.

[0025] In one possible implementation, the apparatus further includes an adding module for adding deleted data nodes back to the database cluster if the deleted data nodes in the database cluster recover.

[0026] In one possible implementation, a generation module is used to generate election guidance information if it is determined from the service information of the master node that the master node has failed. The election guidance information is also used to indicate that the master node has failed.

[0027] In one possible implementation, a sending module is used to send election guidance information to multiple data nodes within a first duration after the master node fails. The first duration is shorter than a second duration, which refers to the duration between the moment when multiple data nodes do not receive the heartbeat signal from the master node and the moment when the re-election of the master node begins.

[0028] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0029] Fourthly, a database cluster arbitration device is provided. The database cluster includes multiple data nodes, including a master node. The device is applied to any one of the multiple data nodes. The device includes: a receiving module for receiving election guidance information sent by a management node. The election guidance information is generated based on the service information of the multiple data nodes, which indicates that the master node cannot fully provide database services. The service information is used to characterize the database services that the data nodes can provide, and the election guidance information is used to guide the re-election of a master node from the multiple data nodes; and a selection module for re-electing a master node from the multiple data nodes based on the election guidance information and an arbitration protocol. The arbitration protocol is a protocol for the multiple data nodes to negotiate and re-elect a master node.

[0030] In one possible implementation, election guidance information indicates which of the multiple data nodes can fully provide database services; the selection module is used to re-elect the master node from among the multiple data nodes that can fully provide database services.

[0031] In one possible implementation, the number of multiple data nodes is even, and the election guidance information indicates the number of votes for the electable master node and the number of data nodes with available votes; the selection module is used to re-elect the master node from the data nodes that have not failed among the multiple data nodes based on the number of votes for the electable master node and the number of data nodes with available votes.

[0032] In one possible implementation, the election guidance information is also used to indicate that the master node has failed; the selection module is used to begin re-electing a master node from multiple data nodes after receiving the election guidance information.

[0033] In one possible implementation, the receiving module is used to receive election guidance information sent by the management node within a first duration after the master node fails. The first duration is shorter than a second duration, which refers to the duration between the moment when multiple data nodes fail to receive the heartbeat signal from the master node and the moment when the re-election of the master node begins.

[0034] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0035] Fifthly, a computer program (product) is provided, the computer program (product) comprising: computer program code, which, when executed by a computer, causes the computer to perform the methods described in the preceding aspects.

[0036] In a sixth aspect, a computer-readable storage medium is provided that stores a program or instructions, wherein when the program or instructions are run on a computer, the methods of the above aspects are performed.

[0037] In a seventh aspect, a chip is provided, including a processor for retrieving and executing instructions stored in a memory, causing a communication device on which the chip is mounted to perform the methods described in the preceding aspects.

[0038] Eighthly, another chip is provided, comprising: an input interface, an output interface, a processor, and a memory, wherein the input interface, the output interface, the processor, and the memory are connected via an internal connection path, and the processor is used to execute code in the memory, wherein when the code is executed, the processor is used to perform the methods in the above aspects.

[0039] It should be understood that the beneficial effects of the technical solutions and corresponding possible implementations of the third to eighth aspects of this application can be found in the above description of the technical effects of the first and second aspects and their corresponding possible implementations, and will not be repeated here. Attached Figure Description

[0040] Figure 1 illustrates the architectural intent of a database cluster arbitration provided in related technologies;

[0041] Figure 2 is a flowchart illustrating a database cluster arbitration method provided in related technologies;

[0042] Figure 3 is a schematic diagram of the architecture of a database cluster provided in an embodiment of this application;

[0043] Figure 4 is a flowchart illustrating a database cluster arbitration method provided in an embodiment of this application;

[0044] Figure 5 is a flowchart illustrating another database cluster arbitration method provided in the embodiments of this application;

[0045] Figure 6 is a flowchart illustrating another database cluster arbitration method provided in an embodiment of this application;

[0046] Figure 7 is a flowchart illustrating another database cluster arbitration method provided in the embodiments of this application;

[0047] Figure 8 is a block diagram of a database cluster arbitration device provided in an embodiment of this application;

[0048] Figure 9 is a block diagram of a database cluster arbitration device provided in an embodiment of this application;

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

[0050] The terminology used in the implementation section of this application is for the purpose of explaining specific embodiments of this application only, and is not intended to limit this application.

[0051] A database cluster refers to a group of multiple data nodes that work together to achieve high reliability and high availability of data, ensuring that the database cluster can still provide continuous service to users even if some data nodes fail. For example, Figure 1 shows a schematic diagram of a database cluster architecture provided in related technologies. As shown in Figure 1, assume that the database cluster can include one master node and at least one standby node. For example, master node DB1, standby node DB2, and standby node DB3. Step ① When master node DB1 fails, standby nodes DB2 and DB3 will not receive the heartbeat signal from master node DB1. Step ② Standby nodes DB2 and DB3 perform self-arbitration, such as sending election requests to each other according to the arbitration protocol. Step ③ Standby nodes DB2 and DB3 reach a consensus based on the received election requests and elect standby node DB3 as the new master node.

[0052] Figure 2 is a schematic diagram of the arbitration method for the database cluster architecture shown in Figure 1. As shown in Figure 2, in the event of a failure of the primary node DB1, a timeout mechanism is initiated. If no node receives a heartbeat signal from the primary node DB1 after the election timeout period, each node sends an election request to the other nodes. As shown in Figure 2, backup node DB2 issues an election request, which may include its log information; backup node DB3 issues an election request, which may also include its log information. Backup node DB2 decides whether to vote for backup node DB3 based on the received election requests, and backup node DB3 decides whether to vote for backup node DB2 based on the received election requests. Simulated backup node DB3 receives 2 votes, while primary node DB1 and backup node DB2 receive 0 votes. If the number of votes received by backup node DB3 exceeds half the number of nodes in the database cluster, then backup node DB3 is determined to be the new primary node. At this point, the primary node DB1, backup node DB2, and backup node DB3 reach an agreement. Backup node DB3, acting as the new primary node, sends a heartbeat signal. Backup node DB2 and the original primary node DB1 respond to the information sent by backup node DB3 (the new primary node). The term shown in Figure 2 represents the term of office of backup node DB3 as the primary node. It is evident that each data node needs to include its own information in the election request and send it to other data nodes. Other data nodes then need to combine their own information with the information of the initiator of the election request to decide whether to vote. This process of data nodes sending their own information to each other can lead to insufficient high availability in complex failure scenarios.

[0053] To address the aforementioned technical problems, this application provides a database cluster arbitration method applied to a management node. The method includes acquiring service information from multiple data nodes in a database cluster. This service information characterizes the database services that each data node can provide, and the multiple data nodes include a master node. If, based on the service information of the multiple data nodes, it is determined that the master node cannot fully provide database services, election guidance information is generated. This election guidance information guides the multiple data nodes to re-elect a master node from among the multiple data nodes based on an arbitration protocol. The election guidance information is then sent to the multiple data nodes. By generating election guidance information, each data node can refer to the service information of the multiple data nodes to re-select the most suitable master node from among the multiple data nodes, adapting to various complex fault scenarios and thus achieving high availability under complex fault conditions.

[0054] Figure 3 is a schematic diagram of a database cluster architecture provided in an embodiment of this application. As shown in Figure 3, the database cluster architecture shown in Figure 3 differs from that shown in Figure 1 in that it also includes a management node, such as a database cluster management component (CM). The management node is used to obtain service information from each data node and generate election guidance information based on this service information. The election guidance information guides multiple data nodes (nodes 1 to n in Figure 3, where n is a positive integer greater than 1) to re-elect a master node from among the multiple data nodes based on an arbitration protocol. The management node then sends the election guidance information to each data node. Each data node receives the election guidance information and re-elects a master node from among the multiple data nodes according to the election guidance information. In this way, each data node can refer to the service information of multiple data nodes to re-elect the most suitable master node from among the multiple data nodes, which can meet various complex fault scenarios.

[0055] The executing entity of the above-described database cluster arbitration method can be a single entity or multiple entities. If the executing entity of the above-described database cluster arbitration method is a single entity, then the entity may include a management node and multiple data nodes, and the entity may be an all-in-one machine, a computer, etc. If the executing entity of the above-described database cluster arbitration method is multiple entities, then the multiple entities may include a management node and multiple data nodes, and each node may be an all-in-one machine, a computer, etc., which are not specifically limited in this embodiment.

[0056] The following describes in detail a database cluster arbitration method provided by an embodiment of this application, with reference to the database cluster architecture shown in Figure 3. Figure 4 is a flowchart illustrating a database cluster arbitration method provided by an embodiment of this application. As shown in Figure 4, the method includes: S401-S406 (some steps are optional).

[0057] S401, The management node obtains service information from multiple data nodes in the database cluster, including the master node.

[0058] The management node is used to obtain and manage information about each data node in the database cluster. For example, the management node can be a cluster manager (CM) component, or simply the CM component. The CM component supports custom resource monitoring, provides status monitoring of each data node in the database, network communication failure monitoring, and file system failure monitoring. The CM component offers rich database management capabilities, such as starting and pausing nodes and instances, querying database instance status, log management, and cluster status management.

[0059] A database cluster includes multiple data nodes, which may include at least one primary node and at least one secondary node. For example, multiple data nodes may include one primary node and multiple secondary nodes. Alternatively, multiple data nodes may include one primary node and one secondary node. Furthermore, multiple data nodes may include multiple primary nodes and multiple secondary nodes. Of course, other combinations are possible, which will not be listed here. In this embodiment, the example of a database cluster including one primary node and multiple secondary nodes will be used for illustration.

[0060] Service information is used to characterize the database services that a data node can provide. For example, service information includes, but is not limited to, at least one of the following: data node log data, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures. Process failures may include, but are not limited to, process lag and process termination. Disk failures may include, but are not limited to, slow disk read / write speeds, unresponsive disks, damaged read / write heads, circuit board problems, lost chip information, motor not spinning, and burned-out chips. Network failures may include, but are not limited to, physical layer failures, data link layer failures, network layer failures, Ethernet network failures, WAN failures, TCP / IP failures, server failures, and other service failures. For example, a network layer failure might be a network intermittent outage.

[0061] S402. If it is determined based on the service information of multiple data nodes that the master node cannot fully provide database services, the management node generates election guidance information. The election guidance information is used to guide multiple data nodes to re-elect the master node from multiple data nodes based on the arbitration protocol.

[0062] In this context, the arbitration protocol can be understood as a protocol among multiple data nodes to negotiate and re-elect a master node. For example, the arbitration protocol may include, but is not limited to, the Paxos protocol, which is the Paxos algorithm. This algorithm is a message-passing-based consensus algorithm with high fault tolerance. It follows the majority rule, meaning that the data node that receives more than half the votes in the database cluster can become the new master node.

[0063] In this context, the master node's inability to fully provide database services can be understood as the master node's operating state not being optimal. For example, the master node may fail or be in a sub-healthy state. A node failure can include, but is not limited to, power outages or process termination. A sub-healthy state can be understood as the master node being able to provide services but only providing partial, not full, services. For example, a sub-healthy state may include process lag on the master node, intermittent network outages, or disk failure. Conversely, a healthy state at least does not include failures or sub-healthy states.

[0064] As mentioned above, the service information of each data node includes various information. Therefore, based on the service information of multiple data nodes, it can be determined whether the master node can provide complete database services. Thus, it can be determined that the master node cannot provide complete database services based on the service information of multiple data nodes. For example, if the master node's service information includes network intermittent interruptions, it can be determined that the master node is in a sub-optimal state, and in this case, it can be determined that the master node can provide partial database services. If the master node's service information includes process termination, it can be determined that the master node has malfunctioned, and in this case, it can be determined that the master node cannot provide complete database services. Furthermore, if the master node's service information includes disk head damage, it can be determined that the master node can only provide disk services, and in this case, it can be determined that the master node cannot provide complete database services.

[0065] The primary function of election guidance information is to instruct multiple data nodes to re-elect a master node from among themselves based on an arbitration protocol. However, the content of the election guidance information varies depending on the different service information of the data nodes, as described below.

[0066] In one possible implementation, S402 can be implemented as follows: If it is determined based on the service information of the master node that the master node can provide partial database services, then based on the service information of multiple data nodes, election guidance information is generated. This election guidance information indicates which data node among the multiple data nodes can fully provide database services. For example, the service information of the master node includes process lag, disk failure, or network interruptions. Therefore, it can be determined that the master node is in a sub-healthy state and can provide partial database services. At this time, the management node generates election guidance information, which can be in tabular form, such as a candidate list indicating a list of healthy nodes suitable to be the master node. For example, as shown in Figure 5, the multiple data nodes of the database cluster can include nodes 1 to n, where N is a positive integer greater than 1. Node 1 is the master node, and nodes 2 to n are backup nodes. The service information of node 1 includes process lag, disk failure, or network interruptions, indicating that node 1 is in a sub-healthy state. The service information of nodes 2 to n does not include process lag, disk failure, or network interruptions, indicating that nodes 2 to n are in a healthy state. So, if node 1 is determined to be in a sub-healthy state, while nodes 2 through n are all in a healthy state, the management node generates a candidate list. This candidate list does not include information about node 1, but includes information about nodes 2 through n. The candidate list can be represented as: Candidate: 2, 3…N. Thus, the master node can provide partial database services, meaning it is in a sub-healthy state, indicating poor service quality. Therefore, to provide high-quality service, the management node automatically generates election guidance information (such as the candidate list) based on the service information of multiple data nodes. This instructs other healthy nodes to re-elect a master node, allowing multiple data nodes to select a healthy node based on the election guidance information. This achieves seamless automatic master switching, ensuring high-quality service is provided.

[0067] In another possible implementation, the number of data nodes is even. S402 can be implemented as follows: if it is determined based on the service information of the multiple data nodes that half of the data nodes have failed, then based on the service information of the data nodes that have not failed, election guidance information is generated. The election guidance information indicates the number of votes for the elected master node and the data nodes with available votes. For example, as shown in Figure 6, the multiple data nodes of the database cluster may include nodes 1 to 4. Among them, node 1 is the master node, and nodes 2 to 4 are backup nodes. The service information of node 3 includes process termination, etc., which can determine that node 3 has failed. The service information of node 4 includes power failure, etc., which can determine that node 4 has failed. The service information of nodes 1 and 2 indicates that the nodes can provide complete database services, and it can be determined that nodes 1 and 2 are normal and available nodes. Then, when the management node detects that half of the nodes in the database cluster have failed, the management node generates election guidance information. This election guidance information can be in tabular form, such as a synchronization list, which indicates the number of votes for the elected master node and the data nodes with available votes. The synchronization list can be represented as `synclist:2; 1,2…`. The first element, '2', indicates that the node with two votes can become the master node. The subsequent '1' and '2' represent the two normally available nodes, node 1 and node 2. Therefore, in scenarios where the number of data nodes in a database cluster is even and half of the nodes fail, the service information of multiple data nodes obtained by the management node can quickly identify the nodes that can provide complete database services. A new master node can then be re-elected from these unaffected nodes to continue providing database services, thus improving high availability in failure scenarios.

[0068] In some examples, the database cluster arbitration method provided in this application further includes: S403, the management node deletes the data nodes that have failed in the database cluster. This preserves the data nodes that can provide database services, completing automatic replication downgrading and ensuring no data loss. Thus, the management node can also delete failed nodes in the database cluster to downgrade the database cluster replicas without data loss. In other examples, after executing S403, the database cluster arbitration method provided in this application further includes: S404, if the deleted data nodes in the database cluster recover, the management node adds the deleted data nodes back to the database cluster. That is, when failed data nodes are deleted and then recover, the management node adds these data nodes back to the database cluster, achieving dynamic adjustment of data nodes in the database cluster to ensure continued service provision under various failure scenarios and improve high availability under failure scenarios.

[0069] In another possible implementation, S402 can be implemented as follows: If it is determined that the master node has failed based on the master node's service information, election guidance information is generated. This election guidance information also indicates that the master node has failed, or in other words, that other nodes can elect a new master node if their master nodes have failed. For example, as shown in Figure 7, the multiple data nodes in the database cluster can include nodes 1 to n, where n is a positive integer greater than 1. Node 1 is the master node, and nodes 2 to n are backup nodes. The service information of node 1 includes process termination or power failure, indicating that node 1 has failed. The service information of nodes 2 to n does not include process termination or power failure, indicating that nodes 2 to n are normally available nodes. At this time, the management node determines that the master node has failed and generates election guidance information. This election guidance information is an indication that other nodes can immediately elect a new master node if their master nodes have failed. The election guidance information can be in the form of a timeout message, for example, a timeout message. As can be seen, in related technologies, the standby node initiates the election request only after the election timeout period has expired. However, in this application, by obtaining service information from multiple data nodes through the management node, the failure of the master node is detected, and election guidance information is immediately generated to guide the standby node to re-elect the master node, so that the database cluster can quickly elect a new master node and optimize the recovery time target.

[0070] S405. The management node sends election guidance information to multiple data nodes, and correspondingly, the multiple data nodes receive the election guidance information.

[0071] The management node can send election guidance information to multiple data nodes in real time, at preset time intervals, or when it detects that the master node can provide partial database services. Of course, there are no specific limitations on when the management node can send election guidance information to multiple data nodes.

[0072] To quickly elect a new master node in the event of a master node failure, S405 can be implemented as follows: Within a first time interval after the master node failure, election guidance information is sent to multiple data nodes. This first time interval is shorter than a second time interval, where the second time interval refers to the period from when multiple data nodes do not receive the master node's heartbeat signal to when the re-election of the master node begins. In other words, after the master node failure, election guidance information is sent to multiple data nodes within the time interval between two heartbeat signals. For example, if the master node sends its first heartbeat signal at the first moment, and then fails at the second moment but before the third moment (when the master node sends its second heartbeat signal), then the second time interval is the period between the first and third moments, and the first moment is the period between the second moment and the fourth moment (when the election guidance information is sent), with the fourth moment earlier than the second moment. In this scenario, the management node sends the election guidance information to multiple data nodes at the fourth moment. In this way, if the master node fails, the backup node can initiate a re-election of the master node before the election timeout period expires. Compared with waiting for the election timeout period to expire before initiating a re-election, this is more timely and can elect a new master node more quickly, thus optimizing the recovery time objective (RTO).

[0073] The aforementioned management node sends election guidance information to multiple data nodes, and correspondingly, the multiple data nodes receive the election guidance information. Here, "multiple data nodes receiving election guidance information" can be understood as at least one data node receiving the election guidance information. For example, a node among the multiple data nodes capable of providing complete database services receives the election guidance information; or, nodes among the multiple data nodes capable of providing partial and complete services receive the election guidance information; or, each data node among the multiple data nodes is capable of receiving the election guidance information. Of course, other situations may exist, and specific limitations need to be considered in conjunction with the specific scenario; these will not be listed one by one in this embodiment.

[0074] S406. Based on election guidance information and arbitration agreement, multiple data nodes re-elect a master node from multiple data nodes.

[0075] As mentioned above, multiple data nodes receiving election guidance information can include various scenarios, which will be described in detail below.

[0076] Scenario 1: When the master node is in a sub-healthy state, both the master node and multiple backup nodes receive election guidance information.

[0077] As mentioned above, the master node being in a sub-healthy state means that it cannot provide complete database services. Based on this, in one possible implementation, the election guidance information instructs the data nodes among multiple data nodes that can fully provide database services. S406 can be implemented as follows: a new master node is elected from among the data nodes that can fully provide database services. That is, the master node receives the election guidance information and, based on the guidance information, is demoted to a backup node. Multiple backup nodes, based on the election guidance information and according to the arbitration protocol, re-elect a master node from among the multiple data nodes. Continuing with the above example, as shown in Figure 5, the election guidance information is a candidate list, where the candidate list is Candidate: 2, 3…N. After receiving the candidate list, node 1 parses the candidate list and matches the node information in the candidate list to determine that the candidate list does not contain node 1's information; therefore, node 1 is demoted to a backup node. Each of the multiple backup nodes (such as nodes 2 to n) receives the candidate list and parses it. Each backup node matches the node information in the candidate list to determine that the candidate list does not contain the master node's information; therefore, each backup node does not respond to messages sent by the master node. In addition, each backup node re-elects a master node from multiple data nodes based on the candidate list and the arbitration protocol, as shown in Figure 5 where node 3 is selected as the new master node. Thus, when the master node is in a sub-healthy state, meaning its service quality is poor, in order to provide high-quality service, the management node automatically generates election guidance information (such as a candidate list) based on the service information of multiple data nodes. This instructs other healthy nodes to re-elect a master node, automatically switching the sub-healthy node to a healthy one, achieving seamless automatic master switching and ensuring high-quality service.

[0078] Scenario 2: In the event of a failure of the primary node, multiple backup nodes receive election guidance information.

[0079] A failure of the primary node means that it cannot provide services. Therefore, in one possible implementation, the election guidance information is also used to indicate that the primary node has failed. S406 can be implemented as follows: after receiving the election guidance information, a new primary node is elected from multiple data nodes. That is, multiple backup nodes, based on the election guidance information and according to the arbitration protocol, re-elect a primary node from among the multiple data nodes. Continuing with the above example, as shown in Figure 7, the election guidance information is used to instruct multiple backup nodes (such as nodes 2 to n) to re-elect a new primary node. Multiple backup nodes receive the election guidance information and, based on the election guidance information, determine that node 1 has failed, and elect a new primary node from nodes 2 to n. Each backup node, based on the election guidance information and the arbitration protocol, re-elects a primary node from among the multiple data nodes, as shown in Figure 7 where node 2 is elected as the new primary node. As can be seen, in related technologies, the standby node initiates the election request only after the election timeout period has expired. However, in this application, when the master node fails, the management node detects the failure and immediately generates election guidance information to guide the standby node to re-elect the master node, enabling the database cluster to quickly elect a new master node and optimizing the recovery time target.

[0080] Scenario 3: In a database cluster where the number of data nodes is even, all data nodes that have not failed will receive election guidance information, regardless of whether the master node has failed.

[0081] In one possible implementation, the number of data nodes is even. The election guidance information indicates the number of votes for the eligible master node and the number of data nodes with available votes. S406 can be implemented as follows: based on the number of votes for the eligible master node and the number of data nodes with available votes, a new master node is elected from the data nodes that have not failed. Continuing with the above example, as shown in Figure 6, the database cluster includes nodes 1 to 4. Among them, node 1 is the master node, and nodes 2 to 4 are backup nodes. When nodes 3 and 4 fail, the management node generates election guidance information, which is a synchronization list. The synchronization list can be synclist: 2; 1, 2… The management node sends the synchronization list to nodes 1 and 2, and nodes 1 and 2 receive and parse the synchronization list. Both nodes 1 and 2 match the node information in the synchronization list. After a successful match, both nodes 1 and 2 issue election requests. Node 1 receives 2 votes, and node 2 receives 0 votes. Therefore, node 1 becomes the new master node. Therefore, in scenarios where the number of data nodes in a database cluster is even and half of the nodes fail, the majority election rule of the arbitration protocol cannot be satisfied, and service cannot continue. The technical solution provided in this application, however, can quickly identify nodes capable of providing complete database services by obtaining service information from multiple data nodes through the management node. Furthermore, the management node can delete failed nodes in the database cluster to downgrade the database cluster replicas without data loss. In this way, a new master node is re-elected from among the unfailed nodes to continue providing database services, thus improving high availability in fault scenarios.

[0082] Figure 8 shows a block diagram of a database cluster arbitration device provided in this embodiment of the application. As shown in Figure 8, the device 800 is applied to a management node and includes: an acquisition module 801, used to acquire service information of multiple data nodes in a database cluster, the service information being used to characterize the database services that the data nodes can provide, the multiple data nodes including a master node; a generation module 802, used to generate election guidance information if it is determined based on the service information of multiple data nodes that the master node cannot fully provide database services, the election guidance information being used to guide multiple data nodes to re-elect a master node from among the multiple data nodes based on an arbitration protocol, the arbitration protocol being a protocol for multiple data nodes to negotiate and re-elect a master node; and a sending module 803, used to send the election guidance information to the multiple data nodes.

[0083] In one possible implementation, the generation module 802 is used to generate election guidance information based on the service information of multiple data nodes if it is determined from the service information of the master node that the master node can provide partial database services. The election guidance information indicates the data nodes among the multiple data nodes that can provide complete database services.

[0084] In one possible implementation, the number of multiple data nodes is even; the generation module 802 is used to generate election guidance information based on the service information of the data nodes that have not failed, if it is determined from the service information of the multiple data nodes that half of the data nodes have failed. The election guidance information indicates the number of votes for the elected master node and the data nodes available for voting.

[0085] In one possible implementation, the device 800 further includes a deletion module 804 for deleting data nodes that have failed in the database cluster.

[0086] In one possible implementation, the device 800 further includes an adding module 805, used to add the deleted data node to the database cluster if the deleted data node in the database cluster recovers to normal.

[0087] In one possible implementation, the generation module 802 is used to generate election guidance information if it is determined from the service information of the master node that the master node has failed. The election guidance information is also used to indicate that the master node has failed.

[0088] In one possible implementation, the sending module 803 is used to send election guidance information to multiple data nodes within a first duration after the master node fails. The first duration is shorter than a second duration, which refers to the duration between the moment when multiple data nodes do not receive the heartbeat signal from the master node and the moment when the re-election of the master node begins.

[0089] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0090] It should be understood that the device shown in Figure 8 is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, which will not be repeated here.

[0091] Figure 9 shows a block diagram of a database cluster arbitration device provided in this embodiment of the application. As shown in Figure 9, the database cluster includes multiple data nodes, including a master node. The device is applied to any one of the multiple data nodes. The device 900 includes: a receiving module 901, used to receive election guidance information sent by a management node. The election guidance information is generated based on the service information of multiple data nodes, which determines that the master node cannot fully provide database services. The service information is used to characterize the database services that the data nodes can provide, and the election guidance information is used to guide the re-election of a master node from multiple data nodes; and a selection module 902, used to re-elect a master node from multiple data nodes based on the election guidance information and an arbitration protocol. The arbitration protocol is a protocol for multiple data nodes to negotiate and re-elect a master node.

[0092] In one possible implementation, election guidance information indicates which of the multiple data nodes can fully provide database services; selection module 902 is used to re-elect the master node from the multiple data nodes that can fully provide database services.

[0093] In one possible implementation, the number of multiple data nodes is even, and the election guidance information indicates the number of votes for the electable master node and the number of data nodes with available votes; the selection module 902 is used to re-elect the master node from the data nodes that have not failed among the multiple data nodes based on the number of votes for the electable master node and the number of data nodes with available votes.

[0094] In one possible implementation, the election guidance information is also used to indicate that the master node has failed; the selection module 902 is used to begin re-electing a master node from multiple data nodes after receiving the election guidance information.

[0095] In one possible implementation, the receiving module 901 is used to receive election guidance information sent by the management node within a first duration after the master node fails. The first duration is shorter than a second duration, which refers to the duration between the moment when multiple data nodes fail to receive the heartbeat signal from the master node and the moment when the re-election of the master node begins.

[0096] In one possible implementation, the service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

[0097] It should be understood that the device shown in Figure 9 above is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.

[0098] Referring to FIG10, FIG10 shows a schematic diagram of the structure of an electronic device 1000 provided in an exemplary embodiment of this application. The electronic device 1000 shown in FIG10 is used to perform the operations involved in the database cluster arbitration method shown in FIG4 above. The electronic device 1000 can be implemented by a general bus architecture. As shown in FIG10, the electronic device 1000 includes at least one processor 1001, a memory 1003, and at least one communication interface 1004.

[0099] Processor 1001 may be, for example, a general-purpose central processing unit (CPU), a digital signal processor (DSP), a network processor (NP), a graphics processing unit (GPU), a neural-network processing unit (NPU), a data processing unit (DPU), a microprocessor, or one or more integrated circuits for implementing the solutions of this application. For example, processor 1001 includes application-specific integrated circuits (ASICs), programmable logic devices (PLDs), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. A PLD may be, for example, a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. It can implement or execute the various logic blocks, modules, and circuits described in connection with the embodiments of this application. A processor may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0100] Optionally, the electronic device 1000 also includes a bus. The bus is used to transmit information between the components of the electronic device 1000. The bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one thick line is used in Figure 10, but this does not indicate that there is only one bus or one type of bus.

[0101] Memory 1003 may be, for example, read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; electrically erasable programmable read-only memory (EEPROM); compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile optical discs, Blu-ray discs, etc.); magnetic disk storage media or other magnetic storage devices; or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but not limited thereto. Memory 1003 may exist independently and be connected to processor 1001 via a bus. Memory 1003 may also be integrated with processor 1001.

[0102] The communication interface 1004 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), or Wireless Local Area Network (WLAN). The communication interface 1004 may include wired and wireless communication interfaces. Specifically, the communication interface 1004 may be an Ethernet interface, a Fast Ethernet (FE) interface, a Gigabit Ethernet (GE) interface, an Asynchronous Transfer Mode (ATM) interface, a WLAN interface, a cellular network communication interface, or a combination thereof. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. In this embodiment, the communication interface 1004 can be used by the electronic device 1000 to communicate with other devices.

[0103] In a specific implementation, as one embodiment, processor 1001 may include one or more CPUs, such as CPU0 and CPU1 shown in FIG10. Each of these processors may be a single-core processor or a multi-core processor. Here, processor may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., computer program instructions).

[0104] In a specific implementation, as one embodiment, the electronic device 1000 may include multiple processors, such as processor 1001 and processor 1005 as shown in FIG10. Each of these processors may be a single-core processor (single-CPU) or a multi-core processor (multi-CPU). Here, a processor may refer to one or more devices, circuits, and / or processing cores used for processing data (such as computer program instructions).

[0105] In a specific implementation, as one embodiment, the electronic device 1000 may further include an output device and an input device. The output device communicates with the processor 1001 and can display information in various ways. For example, the output device may be a liquid crystal display (LCD), a light-emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector, etc. The input device communicates with the processor 1001 and can receive user input in various ways. For example, the input device may be a mouse, a keyboard, a touchscreen device, or a sensing device, etc.

[0106] In some embodiments, the memory 1003 stores program code 1010 for executing the solution of this application, and the processor 1001 can execute the program code 1010 stored in the memory 1003. That is, the electronic device 1000 can implement the database cluster arbitration method provided in the method embodiment through the processor 1001 and the program code 1010 in the memory 1003. The program code 1010 may include one or more software modules. Optionally, the processor 1001 itself may also store program code or instructions for executing the solution of this application.

[0107] In specific embodiments, the electronic device 1000 of this application embodiment may correspond to the computing device in the above-described method embodiments.

[0108] In the database cluster arbitration method shown in Figure 4, each step is completed through the integrated logic circuitry of the processor in the electronic device 1000 or through software instructions. The steps of the method disclosed in this application can be directly implemented by the hardware processor, or by a combination of hardware and software modules within the processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. Since this storage medium is located in memory, the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above method; to avoid repetition, these will not be described in detail here.

[0109] This application also provides a database cluster arbitration device. The device includes a processor for loading and executing at least one instruction to enable the database cluster arbitration device to implement the database cluster arbitration method provided in this application. Optionally, the device further includes a memory coupled to the processor for storing at least one instruction.

[0110] This application also provides a computer-readable storage medium storing at least one instruction, which is loaded and executed by a processor to enable the computer to implement the database cluster arbitration method as described above.

[0111] This application also provides a computer program (product) that, when executed by a computer, causes the processor or computer to perform the corresponding steps and / or processes in the above method embodiments.

[0112] This application also provides a chip including a processor for calling and executing instructions stored in a memory, causing a device equipped with the chip to perform any of the database cluster arbitration methods described above.

[0113] This application embodiment also provides another chip, including: an input interface, an output interface, a processor, and a memory. The input interface, the output interface, the processor, and the memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute any of the database cluster arbitration methods described above.

[0114] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk).

[0115] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the setting results involved in this application were obtained with full authorization.

[0116] Those skilled in the art will recognize that the method steps and modules described in conjunction with the embodiments disclosed herein can be implemented in software, hardware, firmware, or any combination thereof. To clearly illustrate the interchangeability of hardware and software, the steps and components of each embodiment have been generally described in terms of functionality in the foregoing description. 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.

[0117] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.

[0118] When implemented using software, it can be implemented wholly or partially as a computer program product. This computer program product includes one or more computer program instructions. As an example, the methods of this application embodiment can be described in the context of machine-executable instructions, such as program modules that execute on a device on a real or virtual processor of the target. Generally, program modules include routines, programs, libraries, objects, classes, components, data structures, etc., which perform specific tasks or implement specific abstract data structures. In various embodiments, the functionality of program modules can be combined or divided among the described program modules. The machine-executable instructions for the program modules can execute within a local or distributed device. In a distributed device, the program modules can reside on both local and remote storage media.

[0119] Computer program code used to implement the methods of the embodiments of this application may be written in one or more programming languages. This computer program code may be provided to the processor of a general-purpose computer, a special-purpose computer, or other programmable database cluster arbitration device, such that when executed by the computer or other programmable database cluster arbitration device, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a computer, partially on a computer, as a standalone software package, partially on a computer and partially on a remote computer, or entirely on a remote computer or server.

[0120] In the context of the embodiments of this application, computer program code or related data may be carried by any suitable carrier to enable a device, apparatus, or processor to perform the various processes and operations described above. Examples of carriers include signals, computer-readable media, etc.

[0121] Examples of signals may include electrical, optical, radio, sound, or other forms of propagation signals, such as carrier waves, infrared signals, etc.

[0122] A machine-readable medium can be any tangible medium that contains or stores programs for or relating to an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination thereof. More detailed examples of machine-readable storage media include electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical storage devices, magnetic storage devices, or any suitable combination thereof.

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

[0124] In the embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device 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 couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections through some interfaces, devices, or modules, or they may be electrical, mechanical, or other forms of connection.

[0125] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of the embodiments of this application, depending on actual needs.

[0126] Furthermore, the functional modules in the various embodiments of this application can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.

[0127] If the integrated module is implemented as a software functional module 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 this application, in essence, or the part that contributes to the prior art, or all or 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 electronic device, etc.) to execute all or part of the steps of the methods 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, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0128] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have substantially the same function and purpose. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or order of execution. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another. For example, without departing from the various examples described, a first image can be referred to as a second image, and similarly, a second image can be referred to as a first image. Both the first image and the second image can be images, and in some cases, they can be separate and distinct images.

[0129] It should also be understood that, in the various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0130] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple second messages refer to two or more second messages. The terms "system" and "network" are often used interchangeably in this document.

[0131] It should be understood that the terminology used in the description of the various examples herein is for the purpose of describing particular examples only and is not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms “a” and “the” are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0132] It should also be understood that the term "and / or" as used herein refers to and covers any and all possible combinations of one or more of the associated listed items. The term "and / or" describes an association between related objects, indicating that three relationships can exist; for example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " in this application generally indicates that the preceding and following related objects are in an "or" relationship.

[0133] It should also be understood that the term “comprising” (also referred to as “includes”, “including”, “comprises” and / or “comprising”) as used in this specification specifies the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0134] It should also be understood that the terms “if” and “if” can be interpreted as meaning “when” or “upon”, or “in response to determination” or “in response to detection”. Similarly, depending on the context, the phrases “if determination…” or “if detection [the stated condition or event]” can be interpreted as meaning “when determination…”, or “in response to determination…”, or “when detection [the stated condition or event]” or “in response to detection [the stated condition or event]”.

[0135] It should be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0136] It should also be understood that the phrases "an embodiment," "an embodiment," and "a possible implementation" used throughout the specification mean that a specific feature, structure, or characteristic related to an embodiment or implementation is included in at least one embodiment of this application. Therefore, the phrases "in an embodiment," "an embodiment," or "a possible implementation" appearing throughout the specification do not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments.

Claims

1. A method of database cluster arbitration, the method comprising: The method is applied to a management node, and the method includes: Obtain service information of multiple data nodes in the database cluster. The service information is used to characterize the database services that the data nodes can provide. The multiple data nodes include the master node. If it is determined based on the service information of the multiple data nodes that the master node cannot fully provide database services, then election guidance information is generated. The election guidance information is used to guide the multiple data nodes to re-elect the master node from among the multiple data nodes based on an arbitration protocol. The arbitration protocol is an agreement among the multiple data nodes to negotiate and re-elect the master node. The election guidance information is sent to the multiple data nodes.

2. The method of claim 1, wherein, If, based on the service information of the multiple data nodes, it is determined that the master node cannot fully provide database services, election guidance information is generated, including: If it is determined based on the service information of the master node that the master node can provide partial database services, then based on the service information of the multiple data nodes, the election guidance information is generated, and the election guidance information indicates the data node among the multiple data nodes that can provide complete database services.

3. The method of claim 1, wherein, The number of the plurality of data nodes is even; If, based on the service information of the multiple data nodes, it is determined that the master node cannot fully provide database services, election guidance information is generated, including: If it is determined based on the service information of the multiple data nodes that half of the data nodes have failed, then the election guidance information is generated based on the service information of the data nodes that have not failed. The election guidance information indicates the number of votes for the elected master node and the data nodes available for voting.

4. The method of claim 3, wherein, The method further includes: Delete the data nodes that have failed in the database cluster.

5. The method of claim 4, wherein, The method further includes: If the deleted data node in the database cluster recovers, then the deleted data node is added back to the database cluster.

6. The method of claim 1, wherein, If, based on the service information of the multiple data nodes, it is determined that the master node cannot fully provide database services, election guidance information is generated, including: If it is determined that the master node has failed based on the service information of the master node, then the election guidance information is generated, and the election guidance information is also used to indicate that the master node has failed.

7. The method of claim 6, wherein, Sending the election guidance information to the plurality of data nodes includes: Within a first duration after the master node fails, the election guidance information is sent to the plurality of data nodes. The first duration is shorter than a second duration, which refers to the duration from the moment when the plurality of data nodes do not receive the heartbeat signal from the master node to the moment when the re-election of the master node begins.

8. The method according to any one of claims 1-7, characterized in that, The service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

9. A database cluster arbitration method, characterized by, The database cluster includes multiple data nodes, including a master node. The method is applied to any one of the multiple data nodes. The method includes: The system receives election guidance information sent by the management node. This election guidance information is generated based on the service information of the multiple data nodes, which determines that the master node cannot fully provide database services. The service information is used to characterize the database services that the data nodes can provide, and the election guidance information is used to guide the re-election of the master node from the multiple data nodes. Based on the election guidance information and the arbitration agreement, a new master node is elected from the plurality of data nodes. The arbitration agreement is a protocol for the plurality of data nodes to negotiate and re-elect the master node.

10. The method of claim 9, wherein, The election guidance information indicates which of the plurality of data nodes can provide complete database services; The process of re-electing a master node from the plurality of data nodes based on the election guidance information and arbitration agreement includes: A new master node is selected from among the data nodes that can fully provide database services.

11. The method of claim 9, wherein, The number of the plurality of data nodes is even, and the election guidance information indicates the number of votes for the elected master node and the number of data nodes available for voting; The process of re-electing a master node from the plurality of data nodes based on the election guidance information and arbitration agreement includes: Based on the number of votes for the eligible master node and the number of data nodes with available votes, a new master node is selected from the data nodes that have not experienced any failures.

12. The method of claim 9, wherein, The election guidance information is also used to indicate that the master node has failed; The process of re-electing a master node from the plurality of data nodes based on the election guidance information and arbitration agreement includes: Upon receiving the election guidance information, the process begins to re-elect a master node from the plurality of data nodes.

13. The method of claim 12, wherein, The election guidance information sent by the receiving management node includes: Within a first duration after the master node fails, the election guidance information sent by the management node is received. The first duration is less than a second duration, which refers to the duration from the moment when the multiple data nodes do not receive the heartbeat signal from the master node to the moment when the re-election of the master node begins.

14. The method according to any one of claims 9-13, characterized in that, The service information includes, but is not limited to, at least one of the following: log data of the data node, whether the data node has process failures, whether the data node has disk failures, and whether the data node has network failures.

15. A database cluster arbitration apparatus, characterized by, The device is used in a management node, and the device includes: The acquisition module is used to acquire service information of multiple data nodes in the database cluster. The service information is used to characterize the database services that the data nodes can provide. The multiple data nodes include the master node. The generation module is used to generate election guidance information if it is determined based on the service information of the multiple data nodes that the master node cannot fully provide database services. The election guidance information is used to guide the multiple data nodes to re-elect the master node from the multiple data nodes based on an arbitration protocol. The arbitration protocol is an agreement among the multiple data nodes to negotiate and re-elect the master node. The sending module is used to send the election guidance information to the multiple data nodes.

16. A database cluster arbitration apparatus, characterized by, The database cluster includes multiple data nodes, including a master node. The device is applied to any one of the multiple data nodes, and the device includes: The receiving module is used to receive election guidance information sent by the management node. The election guidance information is generated based on the service information of the multiple data nodes when it is determined that the master node cannot fully provide database services. The service information is used to characterize the database services that the data nodes can provide, and the election guidance information is used to guide the re-election of the master node from the multiple data nodes. The selection module is used to re-elect a master node from the plurality of data nodes based on the election guidance information and the arbitration agreement, wherein the arbitration agreement is an agreement among the plurality of data nodes to negotiate and re-elect a master node.

17. An electronic device, comprising: The electronic device includes a memory and a processor; the memory stores at least one instruction, which is loaded and executed by the processor to enable the electronic device to implement the method described in any one of claims 1-14.

18. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one instruction, which is loaded and executed by a processor to implement the method as described in any one of claims 1-14.

19. A computer program product, characterised in that, The computer program product includes a computer program / instruction that is executed by a processor to enable a computer to perform the method described in any one of claims 1-14.

20. A chip, characterized by The chip includes a processor for calling and executing instructions stored in a memory, such that a device having the chip installed performs the method of any one of claims 1-14.

Citation Information

Patent Citations

  • Host node election method and node

    CN103118084A

  • Method for constructing large-scale redis cluster

    CN113259188A

  • Cluster arbitration method, network device and system

    CN116367202A

  • Autonomous primary node election within a virtual input / output server cluster

    US20120179798A1

  • System and method for augmenting consensus election in a distributed database

    US20170032010A1