Data system and data management method based on arbitration node
By introducing arbitration nodes and distributed consensus protocols into the distributed database, the roles of primary and backup databases are automatically determined, solving the problem of automatic failover when the primary database fails in the distributed database and improving service quality and efficiency.
Patent Information
- Application Number
- PCT/CN2025/092936
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-31
- Filing Date
- 2025-05-06
- Publication Date
- 2025-12-04
AI Technical Summary
Distributed databases rely on manual switching when the primary database fails, resulting in low automation and impacting data service quality and efficiency.
Arbitration nodes are introduced to form a distributed consensus protocol member group. The roles of primary and backup databases are automatically determined through negotiation between the arbitration nodes and the database, and the automatic switching between primary and backup databases is achieved using the distributed consensus protocol.
It improves the efficiency of automated failover in the event of a primary database failure, avoids manual intervention, and ensures the continuity and quality of data services.
Smart Images

Figure CN2025092936_04122025_PF_FP_ABST
Abstract
Description
Arbitration node-based data system and data management method TECHNICAL FIELD
[0001] One or more embodiments of the present disclosure relate to the technical field of database, and in particular to an arbitration node-based data system and data management method. BACKGROUND
[0002] In today's high-speed development of the Internet and informatization, the generation of data is growing explosively, so the requirements for databases and their management are becoming higher and higher. The current distributed database often faces temporary failures by setting up primary and backup databases, that is, when the primary database fails, the backup database can be switched to the primary database to continue to provide services, thereby avoiding the service stop when the database fails and affecting the service quality and efficiency.
[0003] In related technologies, the way of determining the primary database in multiple databases (generally two databases) of the distributed database has low automation degree, which leads to the primary- backup switching when the primary database fails to rely on manual operation, low efficiency, and direct impact on the data service quality of the distributed database. SUMMARY
[0004] Therefore, one or more embodiments of the present disclosure provide an arbitration node-based data system and data management method.
[0005] To achieve the above object, the technical solutions of one or more embodiments of the present disclosure are provided as follows.
[0006] According to a first aspect of one or more embodiments of the present disclosure, a data system is provided, comprising: a first database, configured to send a first primary database election request to the arbitration node and the second database respectively, and determine the first database as a primary database when receiving confirmation information returned by the arbitration node and / or the second database for the first primary database election request; a second database, configured to send a second primary database election request to the arbitration node and the first database respectively, and determine the second database as a primary database when receiving confirmation information returned by the arbitration node and / or the first database for the second primary database election request; and an arbitration node, configured to receive the first primary database election request sent by the first database and / or the second primary database election request sent by the second database, and return a confirmation message for the first primary database election request to the first database to make the first database become a primary database, or return a confirmation message for the second primary database election request to the second database to make the second database become a primary database.
[0007] In one or more embodiments of the present disclosure, the first database is a master database of the data system; and the first database is configured to send a first master database election request to the arbitration node and the second database in response to the first database being in a normal state and a renewal condition being met between a current time and a master database lease.
[0008] In one or more embodiments of the present disclosure, the first database is configured to extend the master database lease for a first preset time period upon receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request.
[0009] In one or more embodiments of the present disclosure, the first database is configured to not send a first master database election request to the arbitration node and the second database in response to the first database being in an abnormal state and a renewal condition being met between a current time and the master database lease.
[0010] In one or more embodiments of the present disclosure, a system partition in the first database is configured to periodically send the master database lease to a user partition in response to the first database being in a normal state, and determine that the first database is in an abnormal state in response to not receiving the master database lease periodically sent by the user partition; and a user partition in the first database is configured to periodically send the master database lease to the system partition in response to the first database being in a normal state, and determine that the first database is in an abnormal state in response to not receiving the master database lease periodically sent by the system partition.
[0011] In one or more embodiments of the present disclosure, the first database is configured to determine that the first database is in an abnormal state in response to a write operation execution failure when writing data to the first database.
[0012] In one or more embodiments of the present disclosure, the first database is configured to determine that a write operation is executed successfully in response to a write success on no less than a first preset number of replicas when writing data to the first database, and determine that the write operation is executed unsuccessfully in response to a write failure on no less than the first preset number of replicas within a second preset time period.
[0013] In one or more embodiments of the present disclosure, the first database is configured to return a write failure message to a client in response to the first database being in an abnormal state and receiving a data write request sent by the client.
[0014] In one or more embodiments of the present disclosure, the second database serves as a backup of the data system; the second database is configured to, in response to a renewal condition being met between a current time and a master lease, and receiving a first master election request sent by the first database serving as the master, return an acknowledgement message for the first master election request to the first database.
[0015] In one or more embodiments of the present disclosure, the second database serves as a backup of the data system, and is configured to, in response to a renewal condition being met between a current time and a master lease, and not receiving a first master election request sent by the first database serving as the master, send a second master election request to the arbitration node and the first database respectively.
[0016] According to a second aspect of one or more embodiments of the present disclosure, a data management method based on an arbitration node is provided, which is applied to a first database in a data system, the data system further comprising a second database and an arbitration node, and the method comprises: sending a first master election request to the arbitration node and the second database respectively; and determining the first database as a master in response to receiving an acknowledgement message returned by the arbitration node and / or the second database for the first master election request.
[0017] In one or more embodiments of the present disclosure, after the determination that the first database is the master, the method further comprises: in response to the first database being in a normal state, and a renewal condition being met between a current time and a master lease, sending a first master election request to the arbitration node and the second database respectively; and in response to receiving an acknowledgement message returned by the arbitration node and / or the second database for the first master election request, extending the master lease by a first preset time length.
[0018] In one or more embodiments of the present disclosure, after the determination that the first database is the master or the extension of the master lease by the first preset time length, the method further comprises: in response to the first database being in an abnormal state, and a renewal condition being met between a current time and the master lease, not sending a first master election request to the arbitration node and the second database, so that the second database, in response to a renewal condition being met between a current time and the master lease, and receiving a first master election request sent by the first database serving as the master, returns an acknowledgement message for the first master election request to the first database, and in response to receiving an acknowledgement message returned by the arbitration node and / or the first database for the second master election request, determines the second database as the master.
[0019] In one or more embodiments of the present disclosure, the method further comprises: in response to the first database being in an abnormal state and receiving a data write request sent by a client, returning a write failure message to the client.
[0020] In one or more embodiments of the present disclosure, the method further comprises: determining that the first database is in an abnormal state in response to a write operation for writing data to the first database failing to be executed.
[0021] In one or more embodiments of the present disclosure, when writing data to the first database, the method further comprises: determining that a write operation is executed successfully in response to being written successfully on no less than a first preset number of replicas; and determining that the write operation is executed unsuccessfully in response to being written unsuccessfully on no less than the first preset number of replicas within a second preset time length.
[0022] In one or more embodiments of the present disclosure, the method further comprises: the system partition periodically sending the master lease to the user partition in response to the first database being in a normal state, and determining that the first database is in an abnormal state in response to not receiving the master lease periodically sent by the user partition; and the user partition periodically sending the master lease to the system partition in response to the first database being in a normal state, and determining that the first database is in an abnormal state in response to not receiving the master lease periodically sent by the system partition.
[0023] According to a third aspect of one or more embodiments of the present disclosure, a data management method based on an arbitration node is proposed, applied to a second database in a data system, the data system further comprising a second database and an arbitration node, the method comprising: in response to a renewal condition being met between a current time and the master lease, and receiving a first master election request sent by the first database as a master, returning an acknowledgement message to the first database for the first master election request, so that the first database prolongs the master lease by a first preset time length.
[0024] In one or more embodiments of the present disclosure, the method further comprises: in response to a renewal condition being met between a current time and the master lease, and not receiving a first master election request sent by the first database as a master, sending a second master election request to the arbitration node and the first database respectively; and determining that the second database is a master in response to receiving acknowledgement information returned by the arbitration node and / or the first database for the second master election request.
[0025] According to a fourth aspect of one or more embodiments of the present disclosure, a data management apparatus based on an arbitration node is provided, which is applied to a first database in a data system, the data system further comprising a second database and an arbitration node, and the apparatus comprises: a first sending module configured to send a first master election request to the arbitration node and the second database respectively; and a first assuming module configured to determine the first database as a master in response to receiving confirmation information returned by the arbitration node and / or the second database in response to the first master election request.
[0026] In one or more embodiments of the present disclosure, the apparatus further comprises a master lease renewing module configured to: in response to the first database being in a normal state after determining the first database as a master, and a renewal condition being met between a current time and a master lease, send a first master election request to the arbitration node and the second database respectively; and in response to receiving confirmation information returned by the arbitration node and / or the second database in response to the first master election request, extend the master lease by a first preset time length.
[0027] In one or more embodiments of the present disclosure, the apparatus further comprises a first master-backup switching module configured to: in response to the first database being in an abnormal state after determining the first database as a master or extending the master lease by the first preset time length, and a renewal condition being met between a current time and the master lease, not send a first master election request to the arbitration node and the second database, so that the second database returns a confirmation message to the first master election request in response to a renewal condition being met between a current time and the master lease, and receiving the first master election request sent by the first database as a master, and determines the second database as a master in response to receiving confirmation information returned by the arbitration node and / or the first database in response to the second master election request.
[0028] In one or more embodiments of the present disclosure, the apparatus further comprises a write rejection module configured to: in response to the first database being in an abnormal state, and receiving a data write request sent by a client, return a write failure message to the client.
[0029] In one or more embodiments of the present disclosure, the apparatus further comprises an abnormality determining module configured to: determine the first database as being in an abnormal state in response to a write operation of writing data to the first database failing.
[0030] In one or more embodiments of the present disclosure, the apparatus further comprises a write state determining module configured to: determine that a write operation is successful in response to a successful write on no less than a first preset number of replicas when writing data to the first database; and determine that the write operation is unsuccessful in response to an unsuccessful write on no less than the first preset number of replicas within a second preset time period.
[0031] In one or more embodiments of the present disclosure, the apparatus further comprises a notifying module configured to: periodically send, by a system partition, the master database lease to a user partition in response to the first database being in a normal state, and determine that the first database is in an abnormal state in response to not receiving the master database lease periodically sent by the user partition; and configured to: periodically send, by the user partition, the master database lease to the system partition in response to the first database being in the normal state, and determine that the first database is in the abnormal state in response to not receiving the master database lease periodically sent by the system partition.
[0032] According to a fifth aspect of one or more embodiments of the present disclosure, a data management apparatus based on an arbitration node is provided, applied to a second database in a data system, the data system further comprising a first database and an arbitration node, the apparatus comprising: a master database lease module configured to, in response to a lease condition being met between a current time and the master database lease, and receiving a first master election request sent by the first database as a master database, return an acknowledgement message for the first master election request to the first database, so that the first database extends the master database lease for a first preset time period.
[0033] In one or more embodiments of the present disclosure, the apparatus further comprises a second master backup switching module configured to: in response to a lease condition being met between a current time and the master database lease, and not receiving the first master election request sent by the first database as a master database, send a second master election request to the arbitration node and the first database respectively; and determine that the second database is a master database in response to receiving acknowledgement information returned by the arbitration node and / or the first database for the second master election request.
[0034] According to a sixth aspect of one or more embodiments of the present disclosure, a computer program product is provided, comprising computer programs / instructions, which, when executed by a processor, implement the steps of the method according to the second aspect or the third aspect.
[0035] According to a seventh aspect of one or more embodiments of the present disclosure, an electronic device is provided, comprising: a processor;
[0036] a memory for storing processor-executable instructions; wherein the processor implements the method of the second or third aspect by running the executable instructions.
[0037] According to an eighth aspect of one or more embodiments of the present disclosure, a computer readable storage medium is provided, having stored thereon computer instructions which, when executed by a processor, implement the steps of the method of the second or third aspect.
[0038] The technical solution provided by the embodiments of the present disclosure can have the following beneficial effects: the data system provided by the embodiments of the present disclosure includes a first database, a second database, and an arbitration node, the first database is configured to send a first master database election request to the arbitration node and the second database respectively, and determine the first database as a master database when receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request; the second database is configured to send a second master database election request to the arbitration node and the first database respectively, and determine the second database as a master database when receiving confirmation information returned by the arbitration node and / or the first database in response to the second master database election request; the arbitration node is configured to receive the first master database election request sent by the first database and / or the second master database election request sent by the second database, and return a confirmation message in response to the first master database election request to the first database to make the first database a master database, or return a confirmation message in response to the second master database election request to the second database to make the second database a master database. That is, the embodiments of the present disclosure add an arbitration node in a distributed database to form a distributed consensus protocol member group with each database and the arbitration node, and then complete the role information distribution of the master database and the backup database by running the distributed consensus protocol in each member of the member group, which has a high degree of automation, and in the case of master database failure, the backup database can be automatically switched to a master database by relying on the distributed consensus protocol, thereby avoiding the influence of master database failure on data service quality. BRIEF DESCRIPTION OF DRAWINGS
[0039] FIG. 1 is a structural diagram of a data system according to an example embodiment.
[0040] FIG. 2 is a structural diagram of a first database according to an example embodiment.
[0041] FIG. 3 is a structural diagram of a second database according to an example embodiment.
[0042] FIG. 4 is a flowchart of data writing in a first database as a master database according to an example embodiment.
[0043] FIG. 5 is a process diagram of master-backup switching according to an example embodiment.
[0044] FIG. 6 is a flowchart of a method for managing data based on an arbitration node applied to a first database according to an example embodiment.
[0045] FIG. 7 is a block diagram of an electronic device according to an example embodiment.
[0046] FIG. 8 is a block diagram of an apparatus for managing data based on an arbitration node applied to a first database according to an example embodiment. DETAILED DESCRIPTION
[0047] The example embodiments will be described in detail herein with reference to the attached drawings. The following description is made with reference to the accompanying drawings in which like reference numerals refer to like elements, unless the context of use indicates otherwise. The following description of example embodiments is not representative of all embodiments consistent with one or more aspects of the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of one or more embodiments of the present disclosure as detailed in the appended claims.
[0048] It should be noted that the steps of the methods in other embodiments are not necessarily performed in the order shown and described in the present disclosure. In some other embodiments, the steps included in the methods can be more or less than those described in the present disclosure. Furthermore, a single step described in the present disclosure can be broken down into multiple steps in other embodiments; and multiple steps described in the present disclosure can be combined into a single step in other embodiments.
[0049] In today's high-speed development of the Internet and informatization, the generation of data is growing explosively, and therefore the requirements for databases and their management are becoming higher and higher. The current distributed database often faces temporary failures by setting up a primary and backup database, that is, when the primary database fails, the backup database can be switched to the primary database to continue to provide services, thereby avoiding the service stop when the database fails and affecting the service quality and efficiency.
[0050] In the related art, the way of determining the primary database in the distributed database in multiple databases (generally two data) has a low degree of automation, which leads to the primary- backup switching when the primary database fails to rely on manual operation, which is low in efficiency and directly affects the data service quality of the distributed database.
[0051] Therefore, in a first aspect, at least one embodiment of the present disclosure provides a data system, which can be a distributed database, capable of automatically allocating, switching, etc. the role information of the primary and backup databases in the system, with a high degree of automation, and capable of avoiding service suspension when the primary database fails, thereby improving the service quality.
[0052] The data system comprises a first database, a second database and an arbitration node, the first database, the second database and the arbitration node respectively run a distributed consensus protocol, for example, a Paxos (distributed consensus) protocol, that is, the three form a distributed consensus protocol member group, and respectively serve as a member in the member group, and the master database, the backup database and the arbitration are three role information of the member group and are assumed by the three members, wherein the arbitration node always assumes the arbitration role information, the master database role information can be assumed by only one member at the same time, and the backup database role information can be assumed by one of the first database and the second database or both (that is, the system has not yet elected a master database, or the original master database has resigned and the system has not yet appointed a new master database). For example, in the data system shown in FIG. 1, the first database A assumes the master database, the second database B assumes the backup database, and the arbitration node C assumes the arbitration, and the first database A, the second database B and the arbitration node C respectively run the Paxos protocol, so that the member group information of the Paxos member group formed by the data system is {[A, master database], [B, backup database], [C, arbitration]}.
[0053] The first database can be in the form of a database cluster, which internally contains multiple partitions, each of which contains multiple replicas, namely leader replicas and ordinary replicas. For example, as shown in FIG. 2, the first database A has only one partition, and the partition includes three replicas R1, R2 and R3, and the leader replica is replica R1, so that the member group information of the internal partition of the first database can be [A, master database, (R1, R2, R3)]. Similarly, the second database can be in the form of a database cluster, which internally contains multiple partitions, each of which contains multiple replicas, namely leader replicas and ordinary replicas. For example, as shown in FIG. 3, the second database B has only one partition, and the partition includes three replicas R1, R2 and R3, and the leader replica is replica R4, so that the member group information of the internal partition of the first database can be [B, backup database, (R4, R5, R6)]. The election method of the leader replica of each partition in each database is not limited in the present disclosure.
[0054] Next, the contents of the distributed consensus protocol run by the first database, the second database and the arbitration node in different scenarios will be described in detail through three embodiments, wherein the scenarios corresponding to the three embodiments are master database election scenario, master database renewal scenario and master-standby switching scenario. Embodiment 1
[0055] The scenario corresponding to this embodiment is the master database election scenario, that is, when the data system is self-booted or recovers from a fault as a whole, no database in the data system assumes the master database role, that is, the first database and the second database both serve as backup databases.
[0056] The first database is configured to send a first primary database election request to the arbitration node and the second database in the scenario, and determine the first database as a primary database upon receiving confirmation information returned by the arbitration node and / or the second database in response to the first primary database election request.
[0057] For example, in the data system shown in FIG. 1, the first primary database election request can request to determine the member group information of the Paxos member group as {[A, primary database], [B, backup database], [C, arbitration]}.
[0058] In the primary database election scenario, the first database as a backup database in the data system can initiate a vote for acting as a primary database in the distributed consensus protocol member group, i.e., send a first primary database election request to other members in the member group, and if a certain number of members in the other members return a vote, i.e., return confirmation information in response to the first primary database election request, the first database can act as a primary database. It should be understood that if the data system has a system partition and a user partition, the protocol content can be executed by the system partition (specifically, the leader copy of the system partition), and after successfully acting as a primary database, the user partition is notified to directly act as a primary database in the partition, or also elects a primary database in the same way.
[0059] The second database is configured to send a second primary database election request to the arbitration node and the first database in the scenario, and determine the second database as a primary database upon receiving confirmation information returned by the arbitration node and / or the first database in response to the second primary database election request.
[0060] In the primary database election scenario, the second database as a backup database in the data system can initiate a vote for acting as a primary database in the distributed consensus protocol member group, i.e., send a second primary database election request to other members in the member group, and if a certain number of members in the other members return a vote, i.e., return confirmation information in response to the second primary database election request, the second database can act as a primary database. It should be understood that if the data system has a system partition and a user partition, the protocol content can be executed by the system partition (specifically, the leader copy of the system partition), and after successfully acting as a primary database, the user partition is notified to directly act as a primary database in the partition, or also elects a primary database in the same way.
[0061] The arbitration node is configured to receive the first primary database election request sent by the first database and / or the second primary database election request sent by the second database in the scenario, and return confirmation information in response to the first primary database election request to the first database to make the first database a primary database, or return confirmation information in response to the second primary database election request to the second database to make the second database a primary database.
[0062] The arbitration node is a special node that only participates in the role assignment of the primary database and the backup database in the member group of the distributed consensus protocol, and does not perform service work such as data writing.
[0063] For example, in the primary database election scenario, the arbitration node can decide which database to assign the role of the primary database according to the order of the received primary database election requests, that is, if the first primary database election request is received first, only the first database is returned an acknowledgement message to make the first database assume the role of the primary database, and if the second primary database election request is received first, only the second database is returned an acknowledgement message to make the second database assume the role of the primary database.
[0064] For another example, in the primary database election scenario, the arbitration node can decide which database to assign the role of the primary database according to the preconfigured priority, that is, if the priority of the first database is higher than that of the second database, only the first database is returned an acknowledgement message to make the first database assume the role of the primary database, and if the priority of the first database is lower than that of the second database, only the second database is returned an acknowledgement message to make the second database assume the role of the primary database.
[0065] For yet another example, in the primary database election scenario, the arbitration node can randomly decide which database to assign the role of the primary database, that is, randomly return an acknowledgement message to the first database or the second database to make it assume the role of the primary database.
[0066] The embodiment can automatically elect a primary database after the data system is self-booted or the whole data system is recovered from a failure, so that the data system can provide data services in time, and the data system can provide services after self-booting or failure recovery without manual debugging. Embodiment 2
[0067] The embodiment corresponds to a primary database renewal scenario, that is, the first database or the second database in the data system is assuming the role of the primary database, and the first database or the second database as the primary database can renew the primary database lease through a renewal mechanism to continuously maintain the role of the primary database. The role information of the primary database in the member group of the distributed consensus protocol formed by the data system is unique and has a primary database lease (that is, a certain time length, for example, a first preset time length), and once the primary database lease expires, the role information of the primary database is invalid. Therefore, a reasonable renewal mechanism can be set to identify whether the database as the primary database is normal, so that the abnormality of the database as the primary database can be found in time, to ensure that the database as the primary database can provide services. Preferably, once a database assumes the role of the primary database, if no abnormality occurs, the database can continuously assume the role of the primary database through the renewal mechanism.
[0068] In the embodiment, the first database is taken as the primary database, and the second database is taken as the backup database, and the specific scenario is taken as an example to introduce the details of the renewal mechanism.
[0069] The first database is configured to send a first master election request to the arbitration node and the second database in response to the first database being in a normal state and a renewal condition being met between a current time and the master lease.
[0070] The second database is configured to return an acknowledgement message to the first database in response to a renewal condition being met between a current time and the master lease and receiving the first master election request sent by the first database as the master.
[0071] The arbitration node is configured to return an acknowledgement message to the first database in response to a renewal condition being met between a current time and the master lease and receiving the first master election request sent by the first database as the master.
[0072] It should be understood that the above renewal mechanism in the embodiment can be initiated and executed by a system partition of the data system, and the user partition is notified of the automatic renewal (i.e., continuing to assume the role of the master in the partition) after the renewal. Alternatively, the above renewal mechanism in the embodiment can be initiated and executed by each partition (i.e., the system partition and the user partition) of the data system.
[0073] For example, in the data system shown in FIG. 1, the first master election request can request to determine the member group information of the Paxos member group as {[A, master], [B, backup], [C, arbitration]}.
[0074] The renewal condition met between the current time and the master lease can be that the current time and the expiration time of the master lease are separated by a specific time interval, i.e., the master lease expiration period.
[0075] If the first database is not determined to be in an abnormal state, it can be determined to be in a normal state. For example, the first database can determine whether the first database is in an abnormal state in the following manner provided by any one of the optional examples. Optional Example A
[0076] The first database determines that the first database is in an abnormal state in response to a write operation for writing the target data in the first database failing.
[0077] For example, the first database is configured to determine that a write operation is successful in response to a successful write on no less than a first preset number of replicas when writing data to the first database, and to determine that the write operation is unsuccessful in response to an unsuccessful write on no less than the first preset number of replicas within a second preset time length.
[0078] Referring to FIG. 4, the first database can write data to the first database in the following manner: first, writing the target data indicated by the data write request in the leader replica of the first database, and generating a data write log; next, sending the data write log to other replicas of the first database, so that the other replicas of the first database replay the data write log to write the target data. For example, the leader replica of the first database sends the data write log to other replicas of the first database.
[0079] It should be understood that after receiving the data write log sent by the leader replica, the other replicas of the first database write the target data into the replicas by replaying the data write log, and return a write confirmation message to the leader replica after a successful write. Based on this, the leader replica can count the number of replicas that return the write confirmation message within the second preset time length, to determine the number of replicas that successfully write the data, and determine that the write is successful when the number of replicas reaches the first preset number, and determine that the write is unsuccessful when the number of replicas does not reach the first preset number. In other words, the first database has m replicas, and the data is determined to be successfully written to the first database only when the data is successfully written in Q(m) replicas, i.e., the internal member group information of the first database can be [A, leader, (R1, R2, R3), m, Q(m)], for example, as shown in FIG. 2, the first database A has 3 replicas, and Q(m) is 2, so the internal member group information of the first database A can be [A, leader, (R1, R2, R3), 3, 2].
[0080] In this example, if a partition (e.g., a system partition or a user partition) determines that a write operation for writing target data in the first database fails, the partition determines that the first database is in an abnormal state. Optional Example B
[0081] The system partition in the first database periodically sends a leader lease to the user partition in response to the first database being in a normal state, and determines that the first database is in an abnormal state in response to not receiving the leader lease periodically sent by the user partition; the user partition in the first database periodically sends a leader lease to the system partition in response to the first database being in a normal state, and determines that the first database is in an abnormal state in response to not receiving the leader lease periodically sent by the system partition.
[0082] In this example, the system partition and the user partition of the first database periodically send the master lease to each other to inform each other of their normality. The system partition and the user partition can confirm that the first database is in a normal state only when they are normal and the normality of the other partition is confirmed through the above-mentioned notification. Through the periodic mutual notification, the system partition and the user partition can timely learn the abnormality of the other partition. For example, the system partition is in an abnormal state because no leader replica is selected, and no leader replica can send the master lease to the user partition, so the user partition can timely learn the abnormality of the system partition and timely confirm that the first database is in an abnormal state. For another example, the system partition determines that the first database is in an abnormal state because the write operation of the target data fails (i.e., the manner provided in optional example A), and no master lease is sent to the user partition, so the user partition can timely learn the abnormality of the system partition and timely confirm that the first database is in an abnormal state. For another example, the user partition is in an abnormal state because no leader replica is selected, and no leader replica can send the master lease to the system partition, so the system partition can timely learn the abnormality of the user partition and timely confirm that the first database is in an abnormal state. For another example, the user partition determines that the first database is in an abnormal state because the write operation of the target data fails (i.e., the manner provided in optional example A), and no master lease is sent to the system partition, so the system partition can timely learn the abnormality of the user partition and timely confirm that the first database is in an abnormal state.
[0083] Based on this, if the above-mentioned lease renewal mechanism in this embodiment is executed by the system partition of the data system, the system partition of the first database can timely determine that the first database is in an abnormal state without lease renewal when the system partition itself or the user partition is abnormal. If the above-mentioned lease renewal mechanism in this embodiment is executed in each partition (i.e., the system partition and the user partition) of the data system, the system partition or the user partition of the first database can timely learn the abnormality of the other partition and determine that the first database is in an abnormal state without lease renewal.
[0084] This embodiment corresponds to a scenario of master-slave switching, that is, the first database or the second database in the data system is serving as a master, and the first database or the second database serving as the master is abnormal and cannot provide services, needs to be relieved of the duty of the master and be replaced by the original backup to serve as the master to provide services to the outside. Corresponding to the lease renewal mechanism, a master-slave switching mechanism can also be set to relieve the master from the duty when the master is abnormal and replace the original backup to serve as the master.
[0085] This embodiment takes the first database as the master and the second database as the backup as an example to introduce the detailed content of the master-slave switching mechanism. Referring to FIG. 5, the process of the master-slave switching scenario in this embodiment is shown.
[0086] The first database is configured to, in response to the first database being in an abnormal state and a renewal condition being met between a current time and the master library lease, not send a first master library election request to the arbitration node and the second database to inform the backup library to assume the role of the master library. Preferably, the first database can also be configured to, in response to the first database being in an abnormal state and receiving a data write request sent by a client, return a write failure message to the client. That is, when the first database is abnormal, the role information is switched to the backup library, and the data write request of the client is not processed, so as to avoid affecting the service quality and data security.
[0087] The second database is configured to, in response to a renewal condition being met between a current time and the master library lease and not receiving the first master library election request sent by the first database as the master library, send a second master library election request to the arbitration node and the first database respectively, and switch the role information of the second database to the master library when receiving the confirmation information returned by the first database and / or the arbitration node in response to the second master library election request.
[0088] The arbitration node is configured to, in response to a renewal condition being met between a current time and the master library lease and not receiving the first master library election request sent by the first database as the master library, receive the first master library election request sent by the first database as the master library, and return a confirmation message to the second database in response to the first master library election request to make the second database become the master library.
[0089] It should be understood that the above-mentioned master-slave library switching mechanism in the embodiment can be executed by the system partition of the data system (specifically, the leader copy of the system partition), and the user partition is notified after the master-slave library switching is completed to directly switch the master-slave library in the partition; or the above-mentioned master-slave library switching mechanism in the embodiment can be executed in each partition (i.e., the system partition and the user partition) to complete the master-slave library switching respectively.
[0090] For example, in the data system shown in FIG. 1, the first master library election request can request to modify the member group information of the Paxos member group from {[A, master library], [B, backup library], [C, arbitration]} to {[A, backup library], [B, master library], [C, arbitration]}.
[0091] The renewal condition met between the current time and the master library lease can be that the interval between the current time and the expiration time of the master library lease is a specific time length, i.e., the master library lease expiration period.
[0092] If the first database is determined to be in an abnormal state, the first database can be determined to be in a normal state. For example, the first database can determine whether the first database is in an abnormal state according to any of the following optional examples. Optional Example A
[0093] The first database determines that the first database is in an abnormal state in response to a failure of a write operation for writing the target data in the first database.
[0094] For example, the first database can determine that the write operation is successful in response to a success of writing in no less than a first preset number of replicas when writing data in the first database, and determine that the write operation is failed in response to a failure of writing in no less than a first preset number of replicas within a second preset time length.
[0095] The first database can write data in the first database in the following manner: first, write the target data indicated by the data write request in the leader replica of the first database, and generate a data write log; next, send the data write log to other replicas of the first database, so that other replicas of the first database replay the data write log to write the target data. For example, the leader replica of the first database sends the data write log to other replicas of the first database.
[0096] It should be understood that after receiving the data write log sent by the leader replica, the other replicas of the first database write the target data in the replicas by replaying the data write log, and return a write confirmation message to the leader replica after the writing is successful. Based on this, the leader replica can count the replicas that return the write confirmation message within the second preset time length to determine the number of replicas that successfully write the data, and determine that the writing is successful when the number of replicas reaches the first preset number, and determine that the writing is failed when the number of replicas does not reach the first preset number. In other words, the first database has m replicas, and the data is determined to be successfully written in the first database when the data is successfully written in Q(m) replicas. For example, as shown in FIG. 2, the first database A has 3 replicas, and Q(m) is 2, so the internal member group information of the first database A can be [A, leader, (R1, R2, R3), 3, 2].
[0097] In this example, if a partition (for example, a system partition or a user partition) fails to perform a write operation for writing target data in the first database, the partition determines that the first database is in an abnormal state. Optional Example B
[0098] The system partition of the first database periodically sends a master lease to the user partition in response to the first database being in a normal state, and determines that the first database is in an abnormal state in response to not receiving the master lease periodically sent by the user partition; the user partition of the first database periodically sends a master lease to the system partition in response to the first database being in a normal state, and determines that the first database is in an abnormal state in response to not receiving the master lease periodically sent by the system partition.
[0099] In this example, the system partition and the user partition of the first database periodically send master leases to each other to inform each other that they are normal. The system partition and the user partition can determine that the first database is in a normal state only when they are normal and the normal state of the other partition is confirmed through the above-mentioned notification. Through this periodic mutual notification, the system partition and the user partition can timely learn of the abnormality of the other partition. For example, the system partition is in an abnormal state because it has not selected a leader replica, and the system partition cannot send a master lease to the user partition because there is no leader replica. In this way, the user partition can timely learn of the abnormality of the system partition and timely determine that the first database is in an abnormal state. For another example, the system partition determines that the first database is in an abnormal state because a write operation for writing target data fails (i.e., the method provided in optional example A), and the system partition does not send a master lease to the user partition. In this way, the user partition can timely learn of the abnormality of the system partition and timely determine that the first database is in an abnormal state. For another example, the user partition is in an abnormal state because it has not selected a leader replica, and the user partition cannot send a master lease to the system partition because there is no leader replica. In this way, the system partition can timely learn of the abnormality of the user partition and timely determine that the first database is in an abnormal state. For another example, the user partition determines that the first database is in an abnormal state because a write operation for writing target data fails (i.e., the method provided in optional example A), and the user partition does not send a master lease to the system partition. In this way, the system partition can timely learn of the abnormality of the user partition and timely determine that the first database is in an abnormal state.
[0100] Based on this, if the above-mentioned master-slave database switching mechanism in this embodiment is executed by the system partition of the data system, the first database can timely determine that the first database is in an abnormal state when the system partition or the user partition is abnormal, and then the master-slave database switching mechanism is executed to complete the master-slave database switching by demoting the master database in each partition. If the above-mentioned master-slave database switching mechanism in this embodiment is executed in each partition (i.e., the system partition and the user partition) respectively, the system partition or the user partition can timely learn of the abnormality of the other partition and determine that the first database is in an abnormal state, and then the master-slave database switching mechanism is executed to complete the master-slave database switching by demoting the master database in each partition.
[0101] In combination with the above-mentioned embodiments 2 and 3, as the master database, each time when the master database lease expires, if the master database is in a normal state, the master database sends a first master election request to the arbitration node and the database serving as the backup database, i.e., claims to continue to serve as the master database. After receiving the first master election request, the arbitration node and the backup database return confirmation information to the database serving as the master database in response to the first master election request, so that the master database lease of the database is renewed and the database continues to serve as the master database. If the database serving as the master database is in an abnormal state, for example, a write operation of a partition fails, a leader replica is not elected in a partition, etc., the database resigns as the master database, switches the role information to the backup database, and does not process the data write request sent by the client, and does not send the first master election request to the arbitration node and the database serving as the backup database when the master database lease expires, so that the arbitration node and the database serving as the backup database know that the master database is abnormal, and then the database serving as the backup database initiates master election in the distributed consensus protocol member group according to the master- backup switching mechanism and takes office as the master database. It should be understood that the operation of the database serving as the backup database to initiate master election in the distributed consensus protocol member group and take office as the master database can be performed by a system partition of the database, and the database broadcasts to other partitions after taking office as the master database.
[0102] The database serving as the master database in the above-mentioned embodiments 1, 2 and 3 can respond to the data write request sent by the client according to the maximum protection mode, the maximum performance mode or the maximum availability mode.
[0103] In summary, the embodiments of the present disclosure add an arbitration node in the distributed database to form a distributed consensus protocol member group with the arbitration node and each database, and then each member in the member group runs a distributed consensus protocol to complete the role information distribution of the master database and the backup database, which has a high degree of automation. In addition, when the database serving as the master database fails, the database originally serving as the backup database can automatically switch the role information to the master database by relying on the distributed consensus protocol, thereby avoiding the influence of the failure of the database serving as the master database on the quality of data service.
[0104] Based on this, in a second aspect, at least one embodiment of the present disclosure provides a data management method based on an arbitration node, applied to a first database in a data system, the data system further comprising a second database and an arbitration node, please refer to FIG. 6, the method comprises the following steps.
[0105] Step S601, a first master election request is sent to the arbitration node and the second database, respectively.
[0106] Step S602, in response to receiving the confirmation information returned by the arbitration node and / or the second database in response to the first master election request, determining that the first database is a master database.
[0107] In one or more embodiments of the present disclosure, after determining that the first database is the master database, the method further comprises: in response to the first database being in a normal state and a renewal condition being met between a current time and the master database lease, sending a first master database election request to the arbitration node and the second database respectively; and in response to receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request, extending the master database lease by a first preset time length.
[0108] In one or more embodiments of the present disclosure, after determining that the first database is the master database or extending the master database lease by the first preset time length, the method further comprises: in response to the first database being in an abnormal state and a renewal condition being met between a current time and the master database lease, not sending a first master database election request to the arbitration node and the second database, so that the second database returns a confirmation message for the first master database election request to the first database in response to a renewal condition being met between a current time and the master database lease and receiving the first master database election request sent by the first database as the master database, and determines the second database as the master database in response to receiving confirmation information returned by the arbitration node and / or the first database in response to the second master database election request.
[0109] In one or more embodiments of the present disclosure, the method further comprises: in response to the first database being in an abnormal state and receiving a data write request sent by a client, returning a write failure message to the client.
[0110] In one or more embodiments of the present disclosure, the method further comprises: determining that the first database is in an abnormal state in response to a write operation for writing data to the first database failing.
[0111] In one or more embodiments of the present disclosure, when writing data to the first database, the method further comprises: determining that a write operation is executed successfully in response to being written successfully on no less than a first preset number of replicas; and determining that a write operation is executed unsuccessfully in response to not being written successfully on no less than a first preset number of replicas within a second preset time length.
[0112] In one or more embodiments of the present disclosure, the method further comprises: the system partition periodically sending the master library lease to the user partition in response to the first database being in a normal state, and determining that the first database is in an abnormal state in response to not receiving the master library lease periodically sent by the user partition; the user partition is configured to periodically send a master library lease to the system partition in response to the first database being in a normal state, and determine that the first database is in an abnormal state in response to not receiving the master library lease periodically sent by the system partition.
[0113] Based on this, in a second aspect, at least one embodiment of the present disclosure provides a data management method based on an arbitration node, applied to a second database in a data system, the data system further comprising a second database and an arbitration node, the method comprising: in response to the renewal condition being met between the current time and the master library lease, and receiving a first master election request sent by the first database as the master, returning an acknowledgement message to the first database for the first master election request, so that the first database extends the master library lease by a first preset time length.
[0114] In one or more embodiments of the present disclosure, the method further comprises: in response to the renewal condition being met between the current time and the master library lease, and not receiving a first master election request sent by the first database as the master, sending a second master election request to the arbitration node and the first database respectively; in response to receiving the acknowledgement information returned by the arbitration node and / or the first database for the second master election request, determining that the second database is the master.
[0115] For specific details of the above-mentioned data management methods applied to the first database and the second database, the functions of the first database and the second database have been introduced in the first aspect when introducing the data system, which will not be repeated here.
[0116] FIG. 7 is a schematic structural diagram of an apparatus according to an example embodiment. Referring to FIG. 7, at the hardware level, the apparatus comprises a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710, and can further comprise other hardware required by tasks. One or more embodiments of the present disclosure can be implemented in a software manner, for example, by the processor 702 reading a corresponding computer program from the non-volatile memory 710 into the memory 707 and then running. Of course, in addition to the software implementation, one or more embodiments of the present disclosure do not exclude other implementation manners, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to the logical units, but can also be hardware or logic devices.
[0117] Referring to FIG. 8, the arbitration node-based data management apparatus can be applied to the device shown in FIG. 7 to implement the technical solutions of the present disclosure. The apparatus can be applied to a first database in a data system, the data system further comprising a second database and an arbitration node, and the apparatus comprising: a first sending module 801 configured to send a first master election request to the arbitration node and the second database respectively; and a first assuming module 802 configured to determine the first database as a master in response to receiving confirmation information returned by the arbitration node and / or the second database in response to the first master election request.
[0118] In one or more embodiments of the present disclosure, the apparatus further comprises a master lease renewal module configured to: after determining the first database as a master, in response to the first database being in a normal state and a renewal condition being met between a current time and a master lease, send a first master election request to the arbitration node and the second database respectively; and in response to receiving confirmation information returned by the arbitration node and / or the second database in response to the first master election request, extend the master lease by a first preset time length.
[0119] In one or more embodiments of the present disclosure, the apparatus further comprises a first master-backup switching module configured to: after determining the first database as a master or extending the master lease by a first preset time length, in response to the first database being in an abnormal state and a renewal condition being met between a current time and the master lease, not send a first master election request to the arbitration node and the second database, so that the second database returns a confirmation message to the first master election request in response to a renewal condition being met between a current time and the master lease and receiving the first master election request sent by the first database as a master, and determines the second database as a master in response to receiving confirmation information returned by the arbitration node and / or the first database in response to the second master election request.
[0120] In one or more embodiments of the present disclosure, the apparatus further comprises a write rejection module configured to: in response to the first database being in an abnormal state and receiving a data write request sent by a client, return a write failure message to the client.
[0121] In one or more embodiments of the present disclosure, the apparatus further comprises an abnormality determination module configured to: in response to a write operation for writing data to the first database failing, determine that the first database is in an abnormal state.
[0122] In one or more embodiments of the present disclosure, the apparatus further comprises a write state determining module configured to: determine that the write operation is successfully performed in response to a successful write on no less than a first preset number of replicas when writing data to the first database; and determine that the write operation is unsuccessfully performed in response to a failure to write on no less than the first preset number of replicas within a second preset time period.
[0123] In one or more embodiments of the present disclosure, the apparatus further comprises a notifying module configured to: periodically send, by a system partition, the master database lease to a user partition in response to the first database being in a normal state, and determine that the first database is in an abnormal state in response to a failure to receive the master database lease periodically sent by the user partition; and periodically send, by the user partition, the master database lease to the system partition in response to the first database being in the normal state, and determine that the first database is in the abnormal state in response to a failure to receive the master database lease periodically sent by the system partition.
[0124] The arbitration node-based data management apparatus can be applied to the device as shown in FIG. 8 to implement the technical solution of the present disclosure. The apparatus can be applied to a second database in a data system, the data system further comprising a first database and an arbitration node, and the apparatus comprising: a master database lease module configured to return, to the first database, an acknowledgement message for a first master database election request sent by the first database as a master database in response to a lease condition being met between a current time and the master database lease, and to cause the first database to extend the master database lease for a first preset time period.
[0125] In one or more embodiments of the present disclosure, the apparatus further comprises a second master-standby switching module configured to: send, to the arbitration node and the first database respectively, a second master database election request in response to a lease condition being met between a current time and the master database lease, and a failure to receive the first master database election request sent by the first database as the master database; and determine that the second database is the master database in response to receiving acknowledgement information returned by the arbitration node and / or the first database for the second master database election request.
[0126] According to a sixth aspect of one or more embodiments of the present disclosure, a computer program product is provided, comprising computer programs / instructions, which, when executed by a processor, implement the steps of the method according to the second aspect or the third aspect.
[0127] According to an eighth aspect of one or more embodiments of the present disclosure, a computer readable storage medium is provided, which stores computer instructions, which, when executed by a processor, implement the steps of the method according to the second aspect or the third aspect.
[0128] The systems, apparatuses, modules, or units illustrated in the above embodiments can be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, and the specific form of the computer can be a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an e-mail device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0129] In one typical configuration, a computer includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.
[0130] The memory can include non-persistent memory, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or Flash memory, among others. The memory is an example of computer-readable media.
[0131] Computer-readable media includes permanent and non-permanent, movable and non-movable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, disk storage, quantum memory, graphene-based storage medium, or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device. According to the definition herein, computer-readable media does not include transitory media, such as modulated data signals and carriers.
[0132] It should also be noted that the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles, or devices including a series of elements not only include those elements, but also include other elements not explicitly listed, or inherent to such processes, methods, articles, or devices. Without more limitations, the element defined by the statement "including a" does not exclude the presence of additional identical elements in the process, method, article, or device including the element.
[0133] The above describes particular embodiments of the present disclosure. Other embodiments are within the scope of the claims. In some cases, the actions or steps recited in the claims can be performed in a different order and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order to achieve desirable results. In certain implementations, multitasking and parallel processing can be advantageous.
[0134] The terminology used in this disclosure of one or more embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of one or more embodiments of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0135] The user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0136] It should be understood that although the terms first, second, third, etc. can be employed in this disclosure of one or more embodiments to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one piece of information from another piece of information of the same type. For example, a first information can also be referred to as a second information, and similarly, a second information can also be referred to as a first information, without departing from the scope of one or more embodiments of the present disclosure. Depending on the context, the word "if' as used herein can be interpreted as "when" or "upon" or "in response to determining".
[0137] The above descriptions are only preferred embodiments of one or more embodiments of the present disclosure and are not intended to limit one or more embodiments of the present disclosure. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of the present disclosure should be included in the scope of protection of one or more embodiments of the present disclosure.
Claims
1. A data system based on an arbitration node, the data system comprising: a first database configured to send a first master election request to the arbitration node and a second database respectively, and determine the first database as a master when receiving an acknowledgement returned by the arbitration node and / or the second database in response to the first master election request; the second database configured to send a second master election request to the arbitration node and the first database respectively, and determine the second database as a master when receiving an acknowledgement returned by the arbitration node and / or the first database in response to the second master election request; the arbitration node configured to receive the first master election request sent by the first database and / or the second master election request sent by the second database, and return an acknowledgement message to the first database in response to the first master election request to make the first database as a master, or return an acknowledgement message to the second database in response to the second master election request to make the second database as a master. 2.The data system based on the arbitration node according to claim 1, wherein the first database is a master of the data system. The first database is configured to send a first master election request to the arbitration node and the second database respectively in response to the first database being in a normal state and a renewal condition being met between a current time and a master lease. 3.The data system based on the arbitration node according to claim 2, wherein the first database is configured to extend the master lease for a first preset time length when receiving the acknowledgement returned by the arbitration node and / or the second database in response to the first master election request. 4.The data system based on the arbitration node according to claim 2, wherein the first database is configured to not send a first master election request to the arbitration node and the second database in response to the first database being in an abnormal state and the renewal condition being met between the current time and the master lease. 5.The data system based on the arbitration node according to claim 4, wherein a system partition in the first database is configured to periodically send the master lease to a user partition in response to the first database being in a normal state, and determine the first database as being in an abnormal state in response to not receiving the master lease periodically sent by the user partition. A user partition in the first database is configured to periodically send a master lease to the system partition in response to the first database being in a normal state, and determine the first database as being in an abnormal state in response to not receiving the master lease periodically sent by the system partition. 6.The data system based on the arbitration node according to claim 4 or 5, wherein the first database is configured to determine the first database as being in an abnormal state in response to a write operation for writing data to the first database failing. 7.The arbitration node-based data system of claim 6, wherein the first database is configured to determine that a write operation is successful in response to a successful write on no less than a first preset number of replicas when writing data to the first database, and determine that the write operation is unsuccessful in response to an unsuccessful write on no less than the first preset number of replicas within a second preset time period. 8.The arbitration node-based data system of claim 1, wherein the first database is configured to return a write failure message to a client in response to the first database being in an abnormal state and receiving a data write request sent by the client. 9.The arbitration node-based data system of claim 1, wherein the second database is a backup of the data system. 10.The arbitration node-based data system of claim 1, wherein the second database is a backup of the data system, and is configured to send a second master election request to the arbitration node and the first database in response to a renewal condition being met between a current time and a master lease and in response to not receiving a first master election request sent by the first database as a master. 11.A method for arbitration node-based data management, applied to a first database in a data system, the data system further comprising a second database and an arbitration node, the method comprising: sending a first master election request to the arbitration node and the second database, respectively; and determining that the first database is a master in response to receiving an acknowledgement message returned by the arbitration node and / or the second database in response to the first master election request. 12.The arbitration node-based data management method of claim 11, wherein after the determination that the first database is a master, the method further comprises: sending a first master election request to the arbitration node and the second database, respectively, in response to the first database being in a normal state and a renewal condition being met between a current time and a master lease; and extending the master lease by a first preset time period in response to receiving an acknowledgement message returned by the arbitration node and / or the second database in response to the first master election request. 13.The arbitration node-based data management method of claim 12, wherein after the determination that the first database is a master or the extension of the master lease by the first preset time period, the method further comprises: in response to the first database being in an abnormal state and a renewal condition being met between the current time and the master library lease, not sending a first master library election request to the arbitration node and the second database, so that the second database returns an acknowledgement message to the first master library election request to the first database in response to a renewal condition being met between the current time and the master library lease and receiving the first master library election request sent by the first database as the master library, and determines the second database as the master library in response to receiving the acknowledgement information returned by the arbitration node and / or the first database to the second master library election request.
14. The arbitration node-based data management method of claim 11, further comprising: in response to the first database being in an abnormal state and receiving a data write request sent by a client, returning a write failure message to the client.
15. The arbitration node-based data management method of any one of claims 11 to 14, further comprising: in response to a write operation for writing data to the first database failing, determining that the first database is in an abnormal state.
16. The arbitration node-based data management method of claim 15, when writing data to the first database, further comprising: in response to a write operation being successful in being written to no less than a first preset number of replicas, determining that the write operation is successful; in response to a write operation failing in not being written to no less than a first preset number of replicas within a second preset time length, determining that the write operation is unsuccessful.
17. The arbitration node-based data management method of any one of claims 11 to 14, further comprising: a system partition periodically sending the master library lease to a user partition in response to the first database being in a normal state, and determining that the first database is in an abnormal state in response to not receiving the master library lease periodically sent by the user partition; the user partition periodically sending a master library lease to the system partition in response to the first database being in a normal state, and determining that the first database is in an abnormal state in response to not receiving the master library lease periodically sent by the system partition.
18. An arbitration node-based data management method applied to a second database in a data system, the data system further comprising a second database and an arbitration node, the method comprising: in response to a renewal condition being met between the current time and a master library lease and receiving a first master library election request sent by a first database as the master library, returning an acknowledgement message to the first master library election request to the first database, so that the first database extends the master library lease by a first preset time length.
19. The arbitration node-based data management method of claim 18, further comprising: in response to a renewal condition being met between the current time and a master library lease and not receiving a first master library election request sent by the first database as the master library, sending a second master library election request to the arbitration node and the first database, respectively. In response to receiving the confirmation information returned by the arbitration node and / or the second database in response to the second primary database election request, the second database is determined as the primary database.
20. An arbitration node-based data management apparatus applied to a first database in a data system, the data system further comprising a second database and an arbitration node, the apparatus comprising: a first sending module configured to send a first primary database election request to the arbitration node and the second database respectively; a first assuming module configured to determine the first database as the primary database in response to receiving the confirmation information returned by the arbitration node and / or the second database in response to the first primary database election request.
21. An arbitration node-based data management apparatus applied to a second database in a data system, the data system further comprising a first database and an arbitration node, the apparatus comprising: a primary database renewal module configured to return a confirmation message to the first database in response to the current time and the primary database lease satisfying a renewal condition, and receiving the first primary database election request sent by the first database as the primary database, so as to make the first database prolong the primary database lease by a first preset time length.
22. A computer program product comprising computer programs / instructions, which, when executed by a processor, implement the steps of the method of any one of claims 11 to 19.
23. An electronic device comprising: a processor; a memory for storing processor-executable instructions; wherein the processor implements the method of any one of claims 11 to 19 by running the executable instructions.
24. A computer-readable storage medium having computer instructions stored thereon, which, when executed by a processor, implement the steps of the method of any one of claims 11 to 19.
Citation Information
Patent Citations
Raft distributed system leader election method, related equipment and system
CN108616566A
Main node switching method and computer readable storage medium
CN112822238A
Database system and main library election method and device
CN115168322A
Main-standby switching method and device of equipment gateway and computer readable storage medium
CN116743551A
Data system and data management method based on arbitration node
CN118535550A