A database cluster brain split prevention method, device, equipment, medium and product

By introducing a detector confirmation mechanism into the database cluster, the primary database only performs fault handling after receiving the detector's confirmation result, thus avoiding split-brain scenarios, ensuring data consistency, and resolving the data inconsistency issue after the standby database automatically takes over in the database cluster.

CN118819733BActive Publication Date: 2025-11-25WUHAN DAMENG DATABASE
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410919113.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-10
Publication Date
2025-11-25
Estimated Expiration
2044-07-10

AI Technical Summary

Technical Problem

In database clusters, existing technologies may still result in split-brain scenarios after the standby database automatically takes over as the new primary database. This can lead to data inconsistencies between the failed primary database and the new primary database after the failure is resolved, making it impossible for the primary database to rejoin the cluster.

Method used

When the primary database detects a faulty node, it switches the active node to a fault handling waiting state and transmits the status to the detector. After the detector confirms whether the fault handling conditions are met, the primary database decides whether to perform fault handling based on the confirmation result, avoiding directly entering the fault handling state. If the conditions are not met, the standby database takes over as the new primary database.

Benefits of technology

This ensures that the data in the database cluster is consistent with the data in the new primary database after the primary database recovers from the failure, thus preventing split-brain scenarios in the database cluster and maintaining the high availability of the database cluster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819733B_ABST
    Figure CN118819733B_ABST
Patent Text Reader

Abstract

The application discloses a database cluster brain split prevention method, device, equipment, medium and product. The method is applied to a database cluster, the database cluster comprises a master library, a detector and at least one backup library, and the method comprises the following steps: in the case that it is determined that there is a fault node, switching an active node in the master library to a fault processing waiting state through the master library, and transmitting the fault processing waiting state of the active node to the detector; in the case that it is detected that there is an active node in the master library in the fault processing waiting state, confirming whether a fault processing condition is met through the detector, and transmitting a confirmation result to the master library; and through the master library, if the confirmation result indicates that the fault processing condition is met, entering a fault processing state to perform fault processing, otherwise, exiting the active node to make the backup library take over as a new master library. The above technical scheme can avoid the brain split in the database cluster.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of database, and particularly relate to a database cluster brain split prevention method, device, equipment, medium and product. BACKGROUND

[0002] In a database cluster, when a certain instance in a master library fails, the remaining instances in the master library automatically perform fault handling; when all instances in the master library fail and cannot be recovered in a short time, a standby library automatically takes over to become a new master library, and the standby library keeps data consistent with the master library by redoing the redo logs generated by each instance node of the master library.

[0003] At present, in order to prevent the brain split from occurring in the database cluster, the detector of a third party can be used to confirm that all instances in the master library are indeed faulty and the data of the standby library is consistent with the data of the faulty master library, and then allow the standby library to automatically take over as a new master library.

[0004] However, the above method may still cause brain split after allowing the standby library to automatically take over, for example, the master library includes node 1 and node 2, node 1 network card fails, node 1 with smaller node identifier is selected as the control node according to the fault handling rule, node 2 is forcibly exited by identifying node 2 as faulty, and node 1 performs fault handling to update the redo logs corresponding to node 1; the detector cannot communicate with node 1 and node 2, and the detector misjudges that all instances in the master library are indeed faulty; the detector cannot obtain the information of the redo logs corresponding to node 1 in time, and the detector misjudges that the data of the standby library is consistent with the data of the faulty master library; the standby library automatically takes over as a new master library, resulting in that the faulty master library cannot join the database cluster again after recovery because the data of the faulty master library is inconsistent with the data of the new master library. SUMMARY

[0005] The present application provides a database cluster brain split prevention method, device, equipment, medium and product, which can avoid the brain split in the database cluster.

[0006] In a first aspect, the embodiments of the present application provide a database cluster brain split prevention method applied to a database cluster, wherein the database cluster includes a master library, a detector and at least one standby library, and the method includes:

[0007] switching an active node in the master library to a fault handling waiting state when it is determined that there is a faulty node, and transmitting the fault handling waiting state of the active node to the detector by the master library;

[0008] confirming whether a fault handling condition is met when it is detected that there is an active node in the master library in the fault handling waiting state, and transmitting the confirmation result to the master library by the detector;

[0009] If the confirmation result indicates that the fault processing condition is met, the master library enters a fault processing state to perform fault processing, otherwise the active node is exited to make the backup library take over as a new master library.

[0010] In a second aspect, an embodiment of the present application provides a database cluster anti-split brain device, configured in a database cluster, the database cluster comprising a master library, a detector and at least one backup library, the device comprising:

[0011] A fault processing waiting module is configured to switch an active node in the master library to a fault processing waiting state and transmit the fault processing waiting state of the active node to the detector by the master library when it is determined that there is a fault node.

[0012] A confirmation module is configured to confirm whether a fault processing condition is met and transmit a confirmation result to the master library by the detector when it is detected that there is an active node in the master library in the fault processing waiting state.

[0013] A fault processing module is configured to enter a fault processing state to perform fault processing by the master library if the confirmation result indicates that the fault processing condition is met, otherwise the active node is exited to make the backup library take over as a new master library.

[0014] In a third aspect, an embodiment of the present application provides a database cluster anti-split brain device, comprising:

[0015] A database cluster, a memory and at least one processor.

[0016] The database cluster comprises a master library, a detector and at least one backup library.

[0017] The memory is in communication connection with the at least one processor; wherein,

[0018] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the method of the first aspect.

[0019] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to enable a processor to execute the method of the first aspect when executed.

[0020] In a fifth aspect, an embodiment of the present application provides a computer program product, which comprises a computer program, and the computer program is used to enable a processor to execute the method of the first aspect when executed.

[0021] The technical scheme of the embodiment of the present application provides a confirmation mechanism for a detector when a fault handling needs to be performed in a database cluster in a fault condition, the master library performs the fault handling only after receiving the confirmation result transmitted by the detector and indicating that the fault handling condition is met, and if the confirmation result indicates that the fault handling condition is not met, the active node in the master library exits and is taken over by the standby library as a new master library, ensuring that the data of the fault master library after the fault recovery is consistent with that of the new master library, and avoiding the brain split in the database cluster.

[0022] It should be understood that the content described in this part is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS

[0023] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0024] Figure 1 is a flow chart of a database cluster brain split prevention method according to the first embodiment of the present application;

[0025] Figure 2 is a structural schematic diagram of a database cluster brain split prevention device according to the second embodiment of the present application;

[0026] Figure 3 is a structural schematic diagram of a database cluster brain split prevention device according to the second embodiment of the present application; DETAILED DESCRIPTION

[0027] In order to make the person skilled in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor should be within the scope of protection of the present application.

[0028] It is to be understood that the terms "first", "second", and the like, used in the description and in the claims, are used to differentiate between similar objects, and are not necessarily used to describe a particular sequential or chronological order. It is to be understood that the use of such terms as "data", "information", and the like, are used in the description and in the claims to refer to the content of the data and information, and not to the medium or the like, unless specifically stated otherwise. It is to be understood that the use of such terms as "including", "having", and the like, are used in the description and in the claims to mean "comprising" and not to exclude other steps, elements, or the like, unless specifically stated otherwise.

[0029] Before the database cluster anti-split-brain method provided by the embodiments of the present application is described, the application background of the embodiments of the present application is introduced as follows:

[0030] A data shared cluster (DSC) is a multi-instance, single-database system. Multiple database instances can simultaneously access and modify the data of the same database. A user can log in to any database instance in the DSC to obtain complete database services. There is only one copy of the data file and the control file in the DSC system, and these files are used equally by several nodes. These files are stored on shared storage. Each node has its own independent online log and archive log, and the online log and the archive log are also stored on shared storage.

[0031] A redo log (also referred to as a REDO log) is used to record the modification operations performed on the data in the DSC. Each time a data modification generates a REDO log, a new log sequence number (LSN) is used to identify the REDO log. The LSN can be an increasing positive integer, and the LSN value is automatically incremented by 1 each time a REDO log is written. An LSN value represents a data modification operation.

[0032] The DSC internally includes multiple database instances, and a user can connect to any database instance to modify data and generate a REDO log. Each database instance independently maintains log information, and the LSN inside each database instance also has the characteristics of being incremental and unique. From the perspective of the entire DSC, in order to distinguish the order of data modifications and also to ensure that the LSN values generated by different database instances modifying the same data page are incremental, the LSN inside each database instance in the DSC is not necessarily continuous, and the LSN in the DSC does not have uniqueness between the database instances. An example is as follows:

[0033] 1. Suppose there are two nodes in the DSC, DSC01 and DSC02, and the LSN of each node is independently maintained and starts from 0.

[0034] 2. DSC01 modifies the 0th data page of the 0th file, and the LSN of DSC01 increases to 1000.

[0035] 3. DSC02 modifies the 1st data page of the 0th file, and the LSN of DSC02 also increases to 1000, although the LSN of DSC01 is also 1000 at this time, but the two LSNs do not represent the same modification of the data page.

[0036] 4. DSC02 continues to modify the 0th data page of the 0th file, and the LSN of DSC02 increases to 1001.

[0037] 5. DSC01 modifies the 0th data page of the 0th file again, which has just been modified by DSC02, in order to distinguish the order of modification, the LSN of DSC01 will directly increase from 1000 to 1002, not 1001.

[0038] DSC has high availability features. When a failure occurs in one of the instances, the remaining instances will automatically start the failure handling, the active transactions on the failed instance will be rolled back, the history records of the committed transactions in the rollback segment will be cleaned up, and the user connections of the failed instance will be automatically switched to the active instance. After the failure handling is completed, the failed instance will be kicked out of the cluster to ensure that the cluster can continue to provide services to the outside.

[0039] The DSC as a whole can also be used as a master database, and a single-instance database or another DSC can be used as a standby database, combined with a third-party detector, to form a data daemon cluster. Among them, the master database can be understood as a database in the cluster that allows data modification operations such as addition, deletion, and modification, and generates redo logs accordingly. The standby database can be understood as a database in the cluster that only allows read-only operations, receives redo logs synchronized by the master database, and then replays the redo logs to keep the data synchronized with the master database. The detector is a key component that detects the running status of the cluster, including the status of the master and standby databases, the status of the daemon process, and the synchronization status of the master and standby databases.

[0040] In the data daemon cluster, if all instances within the DSC as the master database fail and cannot be recovered in a short period of time, i.e., cannot provide normal database services, the standby database can automatically take over as the new master database to continue providing services to the outside. After the failure of the master database is recovered, it can be used as a new standby database to join the data daemon cluster again.

[0041] In the prior art, in order to ensure the data consistency of the data daemon cluster, the detector can be used to confirm that all instances in the master library are indeed faulty, the data of the standby library and the data of the faulty master library are consistent, and then the standby library is allowed to automatically take over as a new master library, so as to avoid the occurrence of double master and inconsistent data. However, in the following scenarios, after the standby library is allowed to automatically take over, the master-standby data inconsistency (split-brain) may still occur:

[0042] 1. It is assumed that the master library is a DSC, including two nodes DSC01 (node number 0) and DSC02 (node number 1), wherein DSC01 is deployed on machine A, DSC02 is deployed on machine B, and DSC01 is the control node in the master library; the standby library EP03 is a single-instance database, deployed on machine C; and the detector is deployed on machine D.

[0043] 2. The master library and the standby library maintain normal log synchronization, and at this time, the LSNs of the two nodes of the master library are 10000 and 12000 respectively, and the LSNs of the standby library are also normally replayed to the positions of 10000 and 12000.

[0044] 3. DSC01 has a network card failure, and the connection with DSC02, EP03 and the detector is disconnected.

[0045] 4. Due to the communication abnormality between DSC01 and DSC02, the DSC automatically starts the fault handling.

[0046] The specific content of the fault handling in the DSC: according to the fault handling rule, DSC01 with a smaller node identifier is selected as the control node, DSC02 is forcibly exited, and DSC01 starts the fault handling.

[0047] The specific content of the fault handling of DSC01: roll back the active transactions of the fault node, and clean up the committed transactions of the fault node, both of which involve the modification of the roll back segment data page, so that DSC01 generates REDO log during this period, and the LSN corresponding to DSC01 becomes 11000. At this time, the LSNs of the two nodes in the DSC are 11000 and 12000 respectively, and only one surviving node DSC01 exists.

[0048] 5. Since the connection between DSC01 and the detector is disconnected, DSC02 is forcibly exited and cannot connect to the detector, and the detector determines that the DSC master library as a whole has failed after a certain waiting time, and needs the standby library EP03 to take over as a new master library, so as to continue to provide services to the outside.

[0049] 6. Before takeover, the replay positions of the LSNs corresponding to the two nodes in DSC 01 are 10000 and 12000. Although the LSN corresponding to DSC 01 becomes 11000 in step 4, since the communication links between the parties are disconnected, the detector and EP 03 cannot obtain the LSN update information of DSC 01 in time, so the detector determines that the data of the standby database and the data of the failed primary database are consistent, and needs the standby database EP 03 to take over as the new primary database to continue to provide services to the outside. EP 03 performs automatic takeover based on the LSNs 10000 and 12000, and becomes the new primary database.

[0050] 7. After the network card of DSC 01 is restored to normal, the communication with the new primary database EP 03 is restored. Since DSC 01 has more data between 10000 and 11000 than the new primary database EP 03, the data inconsistency (brain split) occurs, which causes DSC 01 to be unable to rejoin the cluster.

[0051] The database cluster brain split prevention method provided by the embodiment of the present application can solve the above problems, ensure that the data of the failed primary database after recovery is consistent with that of the new primary database, and avoid the brain split in the database cluster.

[0052] In the above scenario, if the method provided by the embodiment of the present application is used, the DSC will not directly start the fault handling in step 4, but needs to wait for the confirmation result transmitted by the detector, and judges whether to start the fault handling according to the confirmation result. However, since the network card of DSC 01 is faulty and cannot communicate with the detector, the DSC 01 cannot receive the confirmation result transmitted by the detector, so the DSC 01 will consider the confirmation to be failed after waiting for a period of time, and actively exits the fault handling, and EP 03 automatically takes over to become the new primary database. After the DSC is automatically pulled up and the network card is restored to normal, the data in the DSC is consistent with that in the new primary database EP 03, and the DSC can rejoin the cluster as a new standby database, and the brain split phenomenon will not occur again.

[0053] Embodiment one

[0054] Figure 1 is a flowchart of a database cluster brain split prevention method provided by the embodiment one of the present application. The embodiment can be applied to avoid the brain split when performing fault handling in the database cluster. The method can be executed by a database cluster brain split prevention device. The device can be realized in the form of software and / or hardware, and integrated in a database cluster brain split prevention equipment.

[0055] It should be noted that the database cluster brain split prevention method provided by the embodiment of the present application is applied to a database cluster, and the database cluster includes a primary database, a detector and at least one standby database. Optionally, the primary database can be the DSC mentioned above, and the standby database can be a single-instance database or another set of DSC, which is not limited here.

[0056] As shown in Figure 1 , the method comprises:

[0057] S110, in the case of determining that there is a fault node, switching an active node in the master library to a fault handling waiting state, and transmitting the fault handling waiting state of the active node to the detector.

[0058] Wherein, the fault node can be a node in the master library that has failed, and the failure can be, for example, process failure, machine failure, or network failure, etc., which is not limited here. The active node can be a node in the master library that is in an active state, which can be understood as a node in the master library that is currently running, such as a node in the master library other than the fault node. The number of fault nodes or active nodes is not limited.

[0059] The control node in the master library can be a node responsible for coordinating and managing the health status of the entire cluster, including fault detection, fault recovery, resource scheduling, etc. If the fault node is a control node, i.e., the control node fails, a new node needs to be selected from the active nodes of the master library as the control node; if the fault node is not a control node, the control node is consistent with the control node in the master library before the fault, and is in an active state. Therefore, it can be understood that the control node in the embodiment of the application can be a special active node, i.e., the control node is one of the active nodes of the master library.

[0060] The fault handling waiting state can be understood as a state waiting to enter the fault handling state, i.e., preparing to start fault handling but not yet performing fault handling. The fault handling state can be a state of executing fault handling.

[0061] In this step, in the case of determining that there is a fault node, the master library switches the active node in the master library to a fault handling waiting state, so that the active node waits to enter the fault handling state, and transmits the fault handling waiting state of the active node to the detector, so that the detector judges whether the active node of the master library should perform fault handling.

[0062] In one embodiment, transmitting the fault handling waiting state of the active node to the detector comprises:

[0063] Broadcasting the fault handling waiting state of the active node to the daemon process of the master library, so that the daemon process of the master library transmits the fault handling waiting state of the active node to the detector.

[0064] The daemon can be a core tool in the database cluster system, responsible for monitoring the running state of the database instance and the data synchronization state of the primary and standby databases, and starting various processing plans when a fault occurs. The daemon of the primary database can act as a message relay station for data interaction between the primary database and other parts of the database cluster.

[0065] In the embodiment of the application, for each active node, the active node can broadcast its fault processing waiting state to the daemon, and the daemon can transmit the fault processing waiting state of the active node to the detector.

[0066] S120, through the detector, in the case where it is detected that an active node in the primary database is in the fault processing waiting state, it is determined whether a fault processing condition is met, and the determination result is transmitted to the primary database.

[0067] The fault processing condition can be a condition for determining whether the primary database should perform fault processing. The determination result can be a result indicating whether the primary database meets the fault processing condition. If the determination result indicates that the fault processing condition is met, it means that the primary database should perform fault processing; if the determination result indicates that the fault processing condition is not met, it means that the primary database should not perform fault processing.

[0068] In one embodiment, the fault processing condition comprises:

[0069] There is a control node in the primary database and the control node is in an active state, there is no other primary database in the database cluster except the primary database, and the data of the standby database is consistent with that of the primary database.

[0070] Wherein, there is a control node in the primary database and the control node is in an active state, which can be understood as that there is a control node capable of performing fault processing in the primary database and the control node is running. There is no other primary database in the database cluster except the primary database, which ensures that there is only one primary database in the database cluster at present. All standby databases are consistent with the data of the primary database, which can be understood as that the LSNs of the primary database and the standby database are kept synchronized, and the current primary database in the database cluster is the legal primary database in the cluster.

[0071] In this step, the detector starts the confirmation mechanism when it detects that an active node in the primary database is in the fault processing waiting state. When the primary database meets all the conditions included in the above fault processing condition, it is considered that the fault processing condition is met, otherwise the fault processing condition is not met. The determination result is transmitted to the primary database, so that the primary database determines whether to perform fault processing based on the determination result.

[0072] In one embodiment, transmitting the determination result to the primary database comprises:

[0073] broadcasting the confirmation result to a daemon of the master database, so that the daemon transmits the confirmation result to an active node in the master database.

[0074] That is, the detector can broadcast the confirmation result to the daemon of the master database, and the daemon can transmit the confirmation result to the active node in the master database. Optionally, the daemon can only transmit the confirmation result to a control node in the active node of the master database.

[0075] S130, through the master database, if the confirmation result indicates that the fault handling condition is met, entering a fault handling state to perform fault handling, otherwise, exiting the active node to make the standby database take over as a new master database.

[0076] In this step, the control node in the active node of the master database can be used to determine whether the confirmation result indicates that the fault handling condition is met; if the fault handling condition is met, the control node performs fault handling, and the specific content of the fault handling includes but is not limited to rolling back the active transaction of the fault node, cleaning up the committed transaction of the fault node, and the current master database still provides services as the master database in the cluster after the fault handling is completed; if the fault handling condition is not met, all active nodes in the master database are exited, and the standby database takes over as a new master database.

[0077] The technical scheme of the embodiment of the application provides a confirmation mechanism for the detector when a fault occurs in the database cluster and fault handling needs to be performed, the master database performs fault handling only after receiving the confirmation result transmitted by the detector and indicating that the fault handling condition is met, if the confirmation result indicates that the fault handling condition is not met, the active node in the master database is exited, and the standby database takes over as a new master database, so that the data of the fault master database is consistent with that of the new master database after the fault master database is recovered, and the situation of brain split in the database cluster is avoided.

[0078] In one embodiment, the method further includes:

[0079] Through the master database, in a case where it is determined that the fault node is a control node in the master database, a node with the smallest node identifier is selected as a new control node from the active nodes of the master database.

[0080] In the database cluster, each node can be allocated a node identifier corresponding thereto only, and the node identifier is not limited, for example, different nodes can be identified by different numbers. In a case where it is determined that the control node is faulty, a node with the smallest node identifier is selected as a new control node from the active nodes of the master database. After the new control node is selected, the operation of switching the active nodes in the master database to a fault handling waiting state is performed.

[0081] In one embodiment, the method further includes:

[0082] After the active node is exited by the master library to make the backup library take over as a new master library, if a fault is recovered, the backup library re-joins the database cluster as a new backup library.

[0083] That is, in the case of the backup library taking over as a new master library, the failed master library is recovered from the fault and is consistent with the data of the new master library, and can re-join the database cluster as a new backup library, further ensuring the high-availability characteristics of the database cluster.

[0084] It should be noted that the database cluster brain split prevention method provided in the embodiments of the present application is applicable to the case of brain split prevention when the master library in the database cluster fails and needs to be handled. If the backup library is also a DSC, when the backup library DSC fails and needs to be handled, the brain split phenomenon does not occur, and the reasons are as follows: the backup library only provides read-only services, the backup library handling needs to redo the REDO log of the failed node and kick out the cluster, and during this process, no new REDO log is generated, so the backup library will not have a brain split phenomenon after the fault handling is completed, and there is no need for brain split prevention operation.

[0085] Embodiment two

[0086] Figure 2 is a structural schematic diagram of a database cluster brain split prevention device according to the second embodiment of the present application. The present embodiment can be applicable to the case of avoiding brain split when handling a fault in a database cluster. The device can be configured in a database cluster, and the database cluster includes a master library, a detector, and at least one backup library.

[0087] As shown in Figure 2 , the specific structure of the device includes:

[0088] A fault handling waiting module 21 is configured to switch an active node in the master library to a fault handling waiting state when it is determined that there is a failed node, and transmit the fault handling waiting state of the active node to the detector.

[0089] A confirmation module 22 is configured to confirm whether a fault handling condition is met when it is detected that there is an active node in the master library in the fault handling waiting state, and transmit the confirmation result to the master library.

[0090] A fault handling module 23 is configured to enter a fault handling state to perform fault handling if the confirmation result indicates that the fault handling condition is met, or exit the active node to make the backup library take over as a new master library if the fault handling condition is not met.

[0091] The technical scheme provided by the embodiment comprises the following steps: in the case that it is determined that there is a fault node, a fault handling waiting module switches an active node in the master library to a fault handling waiting state through the master library, and transmits the fault handling waiting state of the active node to a detector; in the case that it is detected that there is an active node in the master library in the fault handling waiting state through the detector, a confirmation module confirms whether a fault handling condition is met, and transmits a confirmation result to the master library; and in the case that the confirmation result indicates that the fault handling condition is met, a fault handling module enters a fault handling state to perform fault handling, otherwise, the active node is exited to make the backup library take over as a new master library. When fault handling needs to be performed in the case of a fault in the database cluster, the scheme provides a confirmation mechanism for the detector, the master library performs fault handling only after receiving the confirmation result indicating that the fault handling condition is met which is transmitted by the detector, and in the case that the confirmation result indicates that the fault handling condition is not met, the active node in the master library is exited to be taken over by the backup library as a new master library, so that the data of the fault master library after fault recovery is consistent with that of the new master library, and the situation of brain split in the database cluster is avoided.

[0092] Further, the fault handling condition comprises:

[0093] the master library has a control node in an active state, there is no other master library in the database cluster except the master library, and the data of the backup library is consistent with that of the master library.

[0094] Further, the fault handling waiting module 21 is specifically configured to:

[0095] broadcast the fault handling waiting state of the active node to a daemon process of the master library, so that the daemon process of the master library transmits the fault handling waiting state of the active node to the detector.

[0096] Further, the confirmation module 22 is specifically configured to:

[0097] broadcast the confirmation result to a daemon process of the master library, so that the daemon process of the master library transmits the confirmation result to the active node in the master library.

[0098] Further, the device further comprises a control node selection module configured to:

[0099] in the case that it is determined that the fault node is a control node in the master library, selecting a node with the smallest node identifier as a new control node from the active nodes of the master library.

[0100] Further, the device further comprises a fault recovery module configured to:

[0101] After the active node is exited to make the standby library take over as a new master library, if a fault is recovered, the master library re-joins the database cluster as a new standby library.

[0102] The database cluster split-brain prevention apparatus provided by the embodiments of the present application can execute the database cluster split-brain prevention method provided by any of the embodiments of the present application, and has the corresponding function modules and beneficial effects of executing the method.

[0103] Embodiment three

[0104] Figure 3 is a structural schematic diagram of a database cluster split-brain prevention apparatus for implementing the embodiments of the present application. The database cluster split-brain prevention apparatus is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframes, and other suitable computers. The components shown here, their connections and relationships, and their functions, are merely examples, and are not intended to limit the implementation of the present application described and / or claimed herein.

[0105] The database cluster split-brain prevention apparatus of the embodiments of the present application comprises:

[0106] a database cluster, a memory, and at least one processor;

[0107] The database cluster comprises a master library, a detector, and at least one standby library;

[0108] The memory is in communication connection with the at least one processor; wherein,

[0109] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the database cluster split-brain prevention method provided by the embodiments of the present application.

[0110] As Figure 3As shown, the database cluster anti-split-brain device 10 includes at least one processor 11, and memories, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected to the at least one processor 11 in communication. The memories store computer programs executable by the at least one processor 11, and the processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the database cluster anti-split-brain device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14. A database cluster included in the database cluster anti-split-brain device 10 can also be connected to the bus 14, and the database cluster is not shown in the figure. The database cluster includes a primary database, a detector, and at least one standby database. Figure 3

[0111] Various components in the database cluster anti-split-brain device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, speakers, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the database cluster anti-split-brain device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.

[0112] The processor 11 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the database cluster anti-split-brain method.

[0113] ​In some embodiments, the database cluster anti-split-brain method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, portions or all of the computer program can be loaded and / or installed onto database cluster anti-split-brain device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of the above-described database cluster anti-split-brain method can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the database cluster anti-split-brain method by other means, e.g., with the aid of firmware.

[0114] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.

[0115] Computer programs used to implement the methods of the application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program running on the processor implements the functions / operations specified in the flowcharts and / or the block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.

[0116] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0117] To provide for interaction with a user, the systems and techniques described here can be implemented on a database cluster anti-split brain device having a display device for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the database cluster anti-split brain device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.

[0118] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0119] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.

[0120] It should be understood that the various forms of flow shown above can be reordered, added to, or have steps deleted. For example, the steps described in the present application can be performed in parallel, in series, or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, and this is not limited herein.

[0121] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A database cluster anti-split-brain method, characterized in that, The method is applied to a database cluster comprising a master library, a detector and at least one backup library, and comprises the following steps: In the case where it is determined that there is a fault node, the active node in the master library is switched to a fault processing waiting state by the master library, and the fault processing waiting state of the active node is transmitted to the detector; In the case where it is detected that there is an active node in the master library in the fault processing waiting state, the detector confirms whether a fault processing condition is met, and transmits the confirmation result to the master library; If the confirmation result indicates that the fault processing condition is met, the master library enters a fault processing state to perform fault processing, otherwise, the active node is exited to enable the backup library to take over as a new master library; The fault processing condition comprises: There is a control node in the master library and the control node is in an active state, there is no other master library in the database cluster except the master library, and the backup library is consistent with the data of the master library; When the master library enters the fault processing state to perform fault processing, the content of the fault processing at least comprises rolling back the active transaction of the fault node and cleaning up the committed transaction of the fault node, and after the fault processing is completed, the master library still provides services as the master library in the database cluster.

2. The method of claim 1, wherein, The fault processing waiting state of the active node is transmitted to the detector, which comprises the following steps: The fault processing waiting state of the active node is broadcasted to the daemon process of the master library, so that the daemon process of the master library transmits the fault processing waiting state of the active node to the detector.

3. The method of claim 1, wherein, The confirmation result is transmitted to the master library, which comprises the following steps: The confirmation result is broadcasted to the daemon process of the master library, so that the daemon process of the master library transmits the confirmation result to the active node in the master library.

4. The method of claim 1, wherein, Further comprising the following steps: In the case where it is determined that the fault node is the control node in the master library, a node with the smallest node identifier is selected as a new control node from the active nodes of the master library.

5. The method of claim 1, wherein, Further comprising the following steps: After the active node is exited to enable the backup library to take over as a new master library, if the fault is recovered, the backup library re-joins the database cluster as a new backup library.

6. A database cluster anti-split brain apparatus, comprising: The device is configured in a database cluster comprising a master library, a detector and at least one backup library, and comprises the following modules: A fault processing waiting module is configured to switch an active node in the master library to a fault processing waiting state in the case where it is determined that there is a fault node, and transmit the fault processing waiting state of the active node to the detector; A confirmation module is configured to confirm whether a fault processing condition is met in the case where it is detected that there is an active node in the master library in the fault processing waiting state, and transmit the confirmation result to the master library; A fault processing module is configured to enter a fault processing state to perform fault processing in the case where the confirmation result indicates that the fault processing condition is met, otherwise, the active node is exited to enable the backup library to take over as a new master library; The fault processing condition comprises: There is a control node in the master library and the control node is in an active state, there is no other master library in the database cluster except the master library, and the backup library is consistent with the data of the master library; The master library has a control node and the control node is in an active state, there is no master library in the database cluster except the master library, and the standby library is consistent with the data of the master library; The content of the fault processing includes at least rolling back the active transactions of the fault node and cleaning up the committed transactions of the fault node, and after the fault processing is completed, the master library still provides services as the master library in the database cluster.

7. A database cluster anti-split brain device, comprising: Comprise: A database cluster, a memory, and at least one processor; The database cluster comprises a master library, a detector, and at least one standby library; The memory is in communication connection with the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the method of any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to execute the method of any one of claims 1-5.

9. A computer program product, characterised in that, The computer program product comprises a computer program which, when executed by a processor, implements the method of any one of claims 1-5.

Citation Information

Patent Citations

  • Method and system for preventing split brain of shared storage cluster and computer storage medium

    CN111651291A

  • Database cluster monitoring method and device, equipment and medium

    CN116089222A