Data system and data management method based on arbitration node
By introducing arbitration nodes into distributed databases and using distributed consensus protocols to realize automatic role allocation and switching between the main database and the standby database, the problem of manual operation dependence when the main database fails in the existing technology is solved, and the quality of data services and data are improved. Degree of automation.
Patent Information
- Application Number
- CN202410703915.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-23
AI Technical Summary
Existing distributed databases rely on manual operation for active/standby switching when the main database fails, which is inefficient and affects the quality of data services. Moreover, the automation of the main database election is low.
Arbitration nodes are introduced to automatically manage the allocation of role information between the main database and the standby database in the data system through a distributed consensus protocol. The arbitration nodes are used to form a distributed consensus protocol member group to realize automatic switching between the main database and the standby database.
It improves the efficiency of automated switching when the main database fails, avoids service suspension, and improves data service quality and automation.
Smart Images

Figure CN118535550A
Abstract
Description
Technical Field
[0001] One or more embodiments of the present specification relate to the field of database technology, and in particular, to a data system and data management method based on arbitration nodes. Background Art
[0002] With the rapid development of the Internet and informatization, the generation of data is growing explosively, so the requirements for databases and their management are getting higher and higher. At present, distributed databases often deal with temporary failures by setting up master and backup databases. That is, when the master database fails, the backup database can switch to the master database to continue providing services, thus avoiding the service stoppage when the database fails and affecting the service quality and efficiency.
[0003] In the related art, the method of determining the master database among multiple databases (generally two databases) in a distributed database has a low degree of automation, which results in the master-slave switching when the master database fails relying on manual operation, which is inefficient and directly affects the data service quality of the distributed database. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a data system and a data management method based on an arbitration node.
[0005] To achieve the above objectives, one or more embodiments of this specification provide the following technical solutions:
[0006] According to a first aspect of one or more embodiments of this specification, a data system is provided, including:
[0007] The first database is configured to send a first master database election request to the arbitration node and the second database respectively, and determine that the first database is the master database upon receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request;
[0008] The second database is used to send a second master database election request to the arbitration node and the first database respectively, and determine that the second database is the 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;
[0009] An arbitration node is used to receive a first master database election request sent by the first database and / or a second master database election request sent by the second database, and return a confirmation message for the first master database election request to the first database to make the first database become the master database, or return a confirmation message for the second master database election request to the second database to make the second database become the master database.
[0010] In one or more embodiments of the present specification, the first database serves as the main database of the data system;
[0011] The first database is used to send a first master database election request to the arbitration node and the second database respectively in response to the first database being in a normal state and satisfying a renewal condition between the first database and the master database lease at a current moment.
[0012] In one or more embodiments of the present specification, the first database is used to extend the lease of the master database for a first preset duration upon receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request.
[0013] In one or more embodiments of the present specification, the first database is used to respond to the first database being in an abnormal state and the lease with the primary database satisfying a renewal condition at a current moment, not sending a first primary database election request to the arbitration node and the second database.
[0014] In one or more embodiments of the present specification, the system partition in the first database is used to periodically send the main database lease to the 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 main database lease periodically sent by the user partition;
[0015] The user partition in the first database is used to periodically send a 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.
[0016] In one or more embodiments of the present specification, the first database is used to determine that the first database is in an abnormal state in response to a failure in executing a write operation to write data to the first database.
[0017] In one or more embodiments of the present specification, the first database is used to determine that the write operation is successful in response to successful writing on no less than a first preset number of replicas when writing data to the first database, and to determine that the write operation fails in response to not successfully writing on no less than the first preset number of replicas within a second preset time period.
[0018] In one or more embodiments of the present specification, the first database is configured to return a write-unable message to the client in response to the first database being in an abnormal state and receiving a data write request sent by a client.
[0019] In one or more embodiments of this specification, the second database serves as a backup database of the data system;
[0020] The second database is used to return a confirmation message for the first master database election request to the first database in response to the renewal condition being met between the current moment and the lease with the master database and receiving the first master database election request sent by the first database as the master database.
[0021] In one or more embodiments of the present specification, the second database serves as a backup database of the data system, and is configured to send a second master database election request to the arbitration node and the first database respectively in response to satisfying a renewal condition for the lease with the master database at a current moment and not receiving a first master database election request sent by the first database serving as the master database.
[0022] According to a second aspect of one or more embodiments of this specification, a data management method based on an arbitration node is provided, which is applied to a first database in a data system, wherein the data system further includes a second database and an arbitration node, and the method includes:
[0023] Sending a first master database election request to the arbitration node and the second database respectively;
[0024] 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, the first database is determined to be the master database.
[0025] In one or more embodiments of the present specification, after determining that the first database is a primary database, the method further includes:
[0026] In response to the first database being in a normal state and satisfying a renewal condition for the lease with the primary database at the current moment, sending a first primary database election request to the arbitration node and the second database respectively;
[0027] 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, the master database lease is extended by a first preset duration.
[0028] In one or more embodiments of the present specification, after determining that the first database is a primary database or extending the lease of the primary database for a first preset period of time, the method further includes:
[0029] In response to the first database being in an abnormal state and the renewal condition between the first database and the master database lease is satisfied at the current moment, the first master database election request is not sent to the arbitration node and the second database, so that the second database responds to the renewal condition between the first database and the master database lease being satisfied at the current moment and receiving the first master database election request sent by the first database as the master database, returns a confirmation message for the first master database election request to the first database, and determines that the second database is the master database in response to receiving the confirmation information returned by the arbitration node and / or the first database for the second master database election request.
[0030] In one or more embodiments of the present specification, the method further includes:
[0031] In response to the first database being in an abnormal state and receiving a data write request sent by a client, a write failure message is returned to the client.
[0032] In one or more embodiments of the present specification, the method further includes:
[0033] In response to a failure in executing a write operation to write data to the first database, it is determined that the first database is in an abnormal state.
[0034] In one or more embodiments of the present specification, when writing data to the first database, the method further includes:
[0035] Determining that the write operation is successfully performed in response to the write being successful on no less than a first preset number of replicas;
[0036] In response to failure to successfully write on no less than the first preset number of replicas within a second preset time period, it is determined that the write operation has failed.
[0037] In one or more embodiments of the present specification, the method further includes:
[0038] The system partition periodically sends the main database 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 main database lease periodically sent by the user partition;
[0039] The user partition is used to periodically send a 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.
[0040] According to a third aspect of one or more embodiments of this specification, a data management method based on an arbitration node is provided, which is applied to a second database in a data system, wherein the data system further includes a second database and an arbitration node, and the method includes:
[0041] In response to the current moment satisfying the renewal condition with the master database lease and receiving a first master database election request sent by the first database as the master database, a confirmation message for the first master database election request is returned to the first database, so that the first database extends the master database lease for a first preset period of time.
[0042] In one or more embodiments of the present specification, the method further includes:
[0043] In response to the renewal condition being met between the current moment and the lease of the primary database, and the first database as the primary database not receiving the first primary database election request sent by the first database, sending a second primary database election request to the arbitration node and the first database respectively;
[0044] 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, the second database is determined to be the master database.
[0045] According to a fourth aspect of one or more embodiments of this specification, a data management device based on an arbitration node is provided, which is applied to a first database in a data system, wherein the data system further includes a second database and an arbitration node, and the device includes:
[0046] A first sending module, used to send a first master database election request to the arbitration node and the second database respectively;
[0047] The first taking office module is configured to determine that the first database is the master database 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.
[0048] In one or more embodiments of the present specification, the device further includes a main library renewal module, which is used to:
[0049] After determining that the first database is the master database, in response to the first database being in a normal state and satisfying a renewal condition for the lease with the master database at the current moment, sending a first master database election request to the arbitration node and the second database respectively;
[0050] 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, the master database lease is extended by a first preset duration.
[0051] In one or more embodiments of the present specification, the device further includes a first active / standby switching module, configured to:
[0052] After determining that the first database is the master database or extending the master database lease for a first preset period of time, in response to the first database being in an abnormal state and satisfying a renewal condition between the current moment 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 responds to satisfying the renewal condition between the current moment and the master database lease and receiving the first master database election request sent by the first database as the master database, returns a confirmation message for the first master database election request to the first 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 for the second master database election request.
[0053] In one or more embodiments of the present specification, the device further includes a write rejection module, configured to:
[0054] In response to the first database being in an abnormal state and receiving a data write request sent by a client, a write failure message is returned to the client.
[0055] In one or more embodiments of the present specification, the device further includes an abnormality determination module, configured to:
[0056] In response to a failure in executing a write operation to write data to the first database, it is determined that the first database is in an abnormal state.
[0057] In one or more embodiments of the present specification, the device further includes a write status determination module, configured to:
[0058] When writing data to the first database, determining that the write operation is successfully executed in response to successful writing on no less than a first preset number of replicas;
[0059] In response to failure to successfully write on no less than the first preset number of replicas within a second preset time period, it is determined that the write operation has failed.
[0060] In one or more embodiments of the present specification, the device further includes a notification module, configured to:
[0061] The system partition periodically sends the main database 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 main database lease periodically sent by the user partition;
[0062] The user partition is used to periodically send a 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.
[0063] According to a fifth aspect of one or more embodiments of this specification, a data management device based on an arbitration node is provided, which is applied to a second database in a data system, wherein the data system further includes a first database and an arbitration node, and the device includes:
[0064] The master database renewal module is used to respond to the renewal condition between the current moment and the master database lease being met and receiving a first master database election request sent by the first database as the master database, and return a confirmation message for the first master database election request to the first database, so that the first database extends the master database lease for a first preset period of time.
[0065] In one or more embodiments of the present specification, the device further includes a second active / standby switching module, configured to:
[0066] In response to the renewal condition being met between the current moment and the lease of the primary database, and the first database as the primary database not receiving the first primary database election request sent by the first database, sending a second primary database election request to the arbitration node and the first database respectively;
[0067] 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, the second database is determined to be the master database.
[0068] According to a sixth aspect of one or more embodiments of the present specification, a computer program product is proposed, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method described in the second aspect or the third aspect.
[0069] According to a seventh aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0070] processor;
[0071] a memory for storing processor-executable instructions;
[0072] The processor implements the method as described in the second aspect or the third aspect by running the executable instructions.
[0073] According to an eighth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in the second aspect or the third aspect are implemented.
[0074] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0075] The data system provided in the embodiments of the present specification includes a first database, a second database and an arbitration node. The first database is used to send a first master database election request to the arbitration node and the second database respectively, and determine that the first database is the master database when receiving confirmation information returned by the arbitration node and / or the second database for the first master database election request; the second database is used to send a second master database election request to the arbitration node and the first database respectively, and determine that the second database is the master database when receiving confirmation information returned by the arbitration node and / or the first database for the second master database election request; the arbitration node is used 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 for the first master database election request to the first database to make the first database become the master database, or return a confirmation message for the second master database election request to the second database to make the second database become the master database. That is to say, the embodiments of the present specification add arbitration nodes to the distributed database so that each database and the arbitration node form a distributed consensus protocol member group, and then the member groups respectively run the distributed consensus protocol to complete the role information allocation of the main database and the backup database. The automation level is high, and when the main database fails, the backup database can rely on the distributed consensus protocol to automatically switch to the main database, thereby avoiding the main database failure affecting the data service quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0076] Figure 1 It is a structural diagram of a data system provided by an exemplary embodiment.
[0077] Figure 2 is a structural diagram of a first database provided by an exemplary embodiment.
[0078] Figure 3 is a structural diagram of a second database provided by an exemplary embodiment.
[0079] Figure 4 It is a flowchart of writing data into a first database serving as a main database provided by an exemplary embodiment.
[0080] Figure 5 It is a schematic diagram of the process of active / standby switching provided by an exemplary embodiment.
[0081] Figure 6 The flowchart of an arbitration node-based data management method applied to a first database is provided by an exemplary embodiment.
[0082] Figure 7is a block diagram of an electronic device provided by an exemplary embodiment.
[0083] Figure 8 It is a block diagram of a data management device based on arbitration nodes and applied to a first database provided by an exemplary embodiment. DETAILED DESCRIPTION
[0084] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0085] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0086] With the rapid development of the Internet and informatization, the generation of data is growing explosively, so the requirements for databases and their management are getting higher and higher. At present, distributed databases often deal with temporary failures by setting up master and backup databases. That is, when the master database fails, the backup database can switch to the master database to continue providing services, thus avoiding the service stoppage when the database fails and affecting the service quality and efficiency.
[0087] In the related art, the method of determining the master database among multiple databases (generally two databases) in a distributed database has a low degree of automation, which results in the master-slave switching when the master database fails relying on manual operation, which is inefficient and directly affects the data service quality of the distributed database.
[0088] Based on this, on the first aspect, at least one embodiment of the present specification provides a data system, which can be a distributed database that can automatically allocate and switch the main database and backup database of role information within the system. It has a high degree of automation and can avoid service suspension when the main database fails, thereby improving service quality.
[0089] The data system includes 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, such as the Paxos protocol, that is, the three form a distributed consensus protocol member group and serve as a member of the member group respectively. The main database, backup database and arbitration are three role information of the member group and are assumed by three members. Among them, the arbitration node always assumes the role information of arbitration, and the role information of the main database can only be assumed by one member at the same time. As for the role information of the backup database, it can be assumed by one of the first database and the second database, or both at the same time (that is, the main database has not yet been elected in the system, or the system has not yet appointed a new main database after the original main database resigns). For example, the attached Figure 1 In the data system shown, the first database A serves as the primary database, the second database B serves as the backup database, the arbitration node C serves as the arbitration, and the first database A, the second database B, and the arbitration node C respectively run the Paxos protocol. Then, the member group information of the Paxos member group formed by the data system is {[A, primary database], [B, backup database], [C, arbitration]}.
[0090] The first database may be in the form of a database cluster, which contains multiple partitions, each partition containing multiple replicas, namely, leader replicas and common replicas. Figure 2 The first database A shown has only one partition, and the partition includes three replicas, namely, replica R1, replica R2 and replica R3. The leader replica is replica R1. Then the member group information of the internal partition of the first database can be [A, primary database, (R1, R2, R3)]. Similarly, the second database can be in the form of a database cluster, which contains multiple partitions, and each partition contains multiple replicas, namely, leader replicas and ordinary replicas. Figure 3 The second database B shown has only one partition, and the partition includes three replicas, namely replica R1, replica R2 and replica R3, and the leader replica is replica R4. Then the member group information of the internal partition of the first database can be [B, standby database, (R4, R5, R6)]. As for the election method of the leader replica of each partition in each database, the present disclosure does not intend to limit this.
[0091] Next, three embodiments are used to introduce in detail the contents of the distributed consensus protocol run by the first database, the second database and the arbitration node in different scenarios. The scenarios corresponding to the three embodiments are the master database election scenario, the master database renewal scenario and the master-slave switching scenario.
[0092] Example 1
[0093] The scenario corresponding to this embodiment is a primary database election scenario, that is, when the data system is bootstrapped or recovers from a failure as a whole, no database in the data system serves as the primary database, that is, the first database and the second database both serve as standby databases.
[0094] The first database is used to send a first master database election request to the arbitration node and the second database respectively in this scenario, and determine that the first database is the 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.
[0095] For example, Figure 1 Taking the data system shown as an example, the first master database election request may request that the member group information of the Paxos member group be determined as {[A, master database], [B, backup database], [C, arbitration]}.
[0096] Among them, in the master database election scenario, the first database as a backup database in the data system can initiate a vote for the master database in the distributed consensus protocol member group, that is, send a first master database election request to other members in the member group respectively. If a certain number of other members return the vote, that is, return confirmation information for the first master database election request, then the first database can take over as the master database. It should be understood that if the data system has system partitions and user partitions, the content of the protocol can be executed by the system partition (specifically, the leader copy of the system partition), and after successfully taking over as the master database, notify the user partition to directly take over as the master database in the partition, or also be elected as the master database in the same way.
[0097] The second database is used to send a second master database election request to the arbitration node and the first database respectively in this scenario, and determine that the second database is the 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.
[0098] Among them, in the master database election scenario, the second database as a backup database in the data system can initiate a vote for the master database in the distributed consensus protocol member group, that is, send a second master database election request to other members in the member group respectively. If a certain number of other members return the vote, that is, return confirmation information for the second master database election request, then the second database can take over as the master database. It should be understood that if the data system has system partitions and user partitions, the content of the protocol can be executed by the system partition (specifically, the leader copy of the system partition), and after successfully taking over as the master database, notify the user partition to directly take over as the master database in the partition, or also be elected as the master database in the same way.
[0099] The arbitration node is used to receive a first master database election request sent by the first database and / or a second master database election request sent by the second database in this scenario, and return a confirmation message for the first master database election request to the first database to make the first database become the master database, or return a confirmation message for the second master database election request to the second database to make the second database become the master database.
[0100] The arbitration node is a special node that only participates in the allocation of the roles of the primary and backup databases within the distributed consensus protocol member group, and is not responsible for services such as data writing.
[0101] For example, in a master database election scenario, the arbitration node can decide which database to assign the master database role to based on the order of master database election requests received, that is, if the first master database election request is received first, only a confirmation message is returned to the first database to enable the first database to become the master database; if the second master database election request is received first, only a confirmation message is returned to the second database to enable the second database to become the master database.
[0102] For another example, in the master database election scenario, the arbitration node can decide which database to assign the role of the master database to based on the pre-configured priority, that is, if the priority of the first database is higher than that of the second database, only a confirmation message is returned to the first database to enable the first database to become the master database; if the priority of the first database is lower than that of the second database, only a confirmation message is returned to the second database to enable the second database to become the master database.
[0103] For another example, in a master database election scenario, the arbitration node may randomly decide which database to assign the role of the master database to, that is, randomly return a confirmation message to the first database or the second database to enable it to take over as the master database.
[0104] This embodiment can automatically select a master database after the data system is bootstrapped or recovers from a fault as a whole, so that the data system can provide external data services in a timely manner, avoiding the need for manual debugging of the data system before providing external services after bootstrapped or recovering from a fault.
[0105] Example 2
[0106] The scenario corresponding to this embodiment is the renewal scenario of the main database, that is, the first database or the second database in the data system is serving as the main database. The first database or the second database serving as the main database can renew the main database lease through the renewal mechanism to continuously maintain the role of the main database. The role information of the main database in the distributed consensus protocol member group formed by the data system is unique and has a main database lease (i.e., a certain duration, such as a first preset duration). Once the main database lease expires, the role information of the main database becomes invalid. Therefore, a reasonable renewal mechanism can be set to identify whether the database serving as the main database is normal, thereby ensuring that the anomalies of the database serving as the main database can be discovered in time to ensure that the database serving as the main database can provide services to the outside world. Preferably, once a database serves as the main database, if no anomalies occur, it can continue to serve as the main database through the renewal mechanism.
[0107] In this embodiment, a specific scenario in which the first database is used as the primary database and the second database is used as the backup database is taken as an example to introduce the details of the renewal mechanism.
[0108] The first database is used to send a first master database election request to the arbitration node and the second database respectively in response to the first database being in a normal state and satisfying a renewal condition between the first database and the master database lease at a current moment; and is used to extend the master database lease for a first preset duration upon receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request.
[0109] The second database is used to respond to the renewal condition between the lease with the primary database being met at the current moment and receiving a first primary database election request sent by the first database as the primary database, and return a confirmation message for the first primary database election request to the first database to make the first database become the primary database.
[0110] The arbitration node is used to respond to the renewal condition between the current moment and the lease of the master database being satisfied, and receiving a first master database election request sent by the first database as the master database, and return a confirmation message for the first master database election request to the first database to make the first database become the master database.
[0111] It should be understood that the above-mentioned renewal mechanism in this embodiment can be initiated and executed by the system partition of the data system, and after the renewal, the user partition can be notified to automatically renew (that is, continue to assume the role of the master database within the partition); or, the above-mentioned renewal mechanism in this embodiment can be initiated and executed by each partition of the data system (that is, the system partition and the user partition) within the partition respectively.
[0112] For example, Figure 1Taking the data system shown as an example, the first master database election request may request that the member group information of the Paxos member group be determined as {[A, master database], [B, backup database], [C, arbitration]}.
[0113] The renewal condition between the current time and the main database lease may be that there is a specific time interval between the current time and the expiration time of the main database lease, that is, the main database lease is about to expire.
[0114] If the first database is not determined to be in an abnormal state, it can be determined to be in a normal state. Exemplarily, the first database can determine whether the first database is in an abnormal state in the manner provided by any of the following optional examples:
[0115] Optional Example A
[0116] The first database determines that the first database is in an abnormal state in response to a write operation to write the target data in the first database failing to be executed.
[0117] For example, when writing data to the first database, the first database is used to determine that the write operation is successful in response to successful writing on no less than a first preset number of replicas, and to determine that the write operation fails in response to not successfully writing on no less than the first preset number of replicas within a second preset time period.
[0118] Please refer to the attached Figure 4 , the first database may write data to the first database in the following manner: first, write the target data indicated by the data write request in the leader copy of the first database, and generate a data write log; next, send the data write log to other copies of the first database, so that the other copies of the first database replay the data write log to write the target data. For example, the leader copy of the first database sends the data write log to other copies of the first database.
[0119] It should be understood that after the other replicas of the first database receive the data write log sent by the leader replica, they will write the target data into the replica by replaying the data write log, and return a write confirmation message to the leader replica after the write 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 have successfully written the data, and determine that the write is successful when the number of replicas reaches the first preset number, and determine that the write has failed when the number of replicas does not reach the first preset number. In other words, the first database has m replicas, and it is determined that the data is successfully written to the first database only when the data is successfully written in Q (m) replicas, that is, its internal member group information can be [A, primary database, (R1, R2, R3), m, Q (m)], for example, attached. Figure 2 It is shown that the first database A has 3 copies, Q(m) is 2, and its internal member group information can be [A, main database, (R1, R2, R3), 3, 2].
[0120] In this example, if a partition (eg, a system partition or a user partition) fails in executing a write operation to write target data in the first database, the partition determines that the first database is in an abnormal state.
[0121] Optional Example B
[0122] In response to the first database being in a normal state, the system partition in the first database periodically sends a main database lease to the user partition, and determines that the first database is in an abnormal state in response to not receiving the main database lease periodically sent by the user partition; in response to the first database being in a normal state, the user partition in the first database periodically sends a main database lease to the system partition, and determines that the first database is in an abnormal state in response to not receiving the main database lease periodically sent by the system partition.
[0123] In this example, the system partition and the user partition of the first database periodically send the master database lease to each other to notify each other that they are normal. The system partition and the user partition can confirm that the first database is in a normal state only when they are normal and confirm that the other party is normal through the above notification. Through this periodic mutual notification, the system partition and the user partition can be informed of each other's abnormalities in a timely manner. For example, the system partition has not selected a leader copy and is in an abnormal state. Without a leader copy, the main database lease cannot be sent to the user partition, so the user partition can promptly know that the system partition is abnormal and promptly 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 due to the failure of the write operation to write the target data (that is, the method provided by optional example A), then the main database lease will not be sent to the user partition, and then the user partition can promptly know that the system partition is abnormal and promptly confirm that the first database is in an abnormal state; for another example, the user partition has not selected a leader copy and is in an abnormal state, and without a leader copy, the main database lease cannot be sent to the system partition, and then the system partition can promptly know that the user partition is abnormal and promptly 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 due to the failure of the write operation to write the target data (that is, the method provided by optional example A), then the main database lease will not be sent to the system partition, and then the system partition can promptly know that the user partition is abnormal and promptly confirm that the first database is in an abnormal state.
[0124] Based on this, if the above-mentioned renewal mechanism in this embodiment is executed by the system partition of the data system, then the system partition of the first database can, through this example, promptly determine that the first database is in an abnormal state and not renew the lease when the system partition itself is abnormal or the user partition is abnormal; if the above-mentioned renewal mechanism in this embodiment is executed by each partition of the data system (i.e., the system partition and the user partition) respectively within the partition, then through this example, the system partition or the user partition of the first database can promptly know the abnormality of the other party and determine that the first database is in an abnormal state and not lease.
[0125] Example 3
[0126] The scenario corresponding to this embodiment is the active-standby switching scenario, that is, the first database or the second database in the data system is acting as the active database, and the first database or the second database as the active database is abnormal and cannot provide services, and needs to step down as the active database and the original standby database becomes the active database to provide services externally. Corresponding to the renewal mechanism, a active-standby database switching mechanism can also be set to make the active database step down as the active database when an abnormality occurs and make the original standby database become the active database.
[0127] In this embodiment, the first database is used as the primary database and the second database is used as the secondary database to introduce the details of the primary and secondary database switching mechanism. Figure 5 , which shows the process of the active-standby switching scenario in this embodiment.
[0128] The first database is used to respond to the first database being in an abnormal state and the renewal conditions between the current moment and the lease with the main database are met, and not to send a first main database election request to the arbitration node and the second database to notify the backup database to take over as the main database. Preferably, the first database can also be used to respond to the first database being in an abnormal state and receiving a data write request sent by the client, and return a write failure message to the client. That is, when the first database is abnormal, it will resign as the main database in time, switch the role information to the backup database, and no longer process the client's data write request to avoid affecting the service quality and data security.
[0129] The second database is used to send a second master database election request to the arbitration node and the first database respectively in response to the renewal condition between the lease with the master database being satisfied at the current moment and not receiving a first master database election request sent by the first database as the master database, and when receiving confirmation information returned by the first database and / or the arbitration node in response to the second master database election request, switch the role information of the second database to the master database.
[0130] The arbitration node is used for returning a confirmation message for the first master database election request to the second database to make the second database become the master database in response to the renewal condition being satisfied between the current moment and the lease with the master database, and receiving the first master database election request sent by the first database as the master database without receiving the first master database election request sent by the first database as the master database.
[0131] It should be understood that the above-mentioned master-slave database switching mechanism in this embodiment can be executed by the system partition of the data system (specifically, by the leader copy of the system partition), and after completing the master-slave database switching, the user partition is notified to directly perform the master-slave database switching within the partition; or, the above-mentioned master-slave database switching mechanism in this embodiment can be executed by each partition (i.e., the system partition and the user partition) separately within the partition to complete the master-slave database switching separately.
[0132] For example, Figure 1 Taking the data system shown as an example, the first master database election request can request to modify the member group information of the Paxos member group from {[A, master database], [B, backup database], [C, arbitration]} to {[A, backup database], [B, master database], [C, arbitration]}.
[0133] The renewal condition between the current time and the main database lease may be that there is a specific time interval between the current time and the expiration time of the main database lease, that is, the main database lease is about to expire.
[0134] If the first database is not determined to be in an abnormal state, it can be determined to be in a normal state. Exemplarily, the first database can determine whether the first database is in an abnormal state in the manner provided by any of the following optional examples:
[0135] Optional Example A
[0136] The first database determines that the first database is in an abnormal state in response to a write operation to write the target data in the first database failing to be executed.
[0137] For example, the first database is used to determine that the write operation is successful in response to successful writing on no less than a first preset number of replicas when writing data to the first database, and to determine that the write operation fails in response to not successfully writing on no less than the first preset number of replicas within a second preset time period.
[0138] The first database may write data to the first database in the following manner: first, write the target data indicated by the data write request in the leader copy of the first database, and generate a data write log; then, send the data write log to other copies of the first database, so that the other copies of the first database replay the data write log to write the target data. For example, the leader copy of the first database sends the data write log to other copies of the first database.
[0139] It should be understood that after the other replicas of the first database receive the data write log sent by the leader replica, they will write the target data into the replica by replaying the data write log, and return a write confirmation message to the leader replica after the write 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 have successfully written the data, and determine that the write is successful when the number of replicas reaches the first preset number, and determine that the write has 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 to the first database only when the data is successfully written in Q (m) replicas. For example, the attached Figure 2 It is shown that the first database A has 3 copies, Q(m) is 2, and its internal member group information can be [A, main database, (R1, R2, R3), 3, 2].
[0140] In this example, if a partition (eg, a system partition or a user partition) fails in executing a write operation to write target data in the first database, the partition determines that the first database is in an abnormal state.
[0141] Optional Example B
[0142] In response to the first database being in a normal state, the system partition in the first database periodically sends a main database lease to the user partition, and determines that the first database is in an abnormal state in response to not receiving the main database lease periodically sent by the user partition;
[0143] In response to the first database being in a normal state, the user partition in the first database periodically sends a master database lease to the system partition, and determines that the first database is in an abnormal state in response to not receiving the master database lease periodically sent by the system partition.
[0144] In this example, the system partition and the user partition of the first database periodically send the master database lease to each other to notify each other that they are normal. The system partition and the user partition can confirm that the first database is in a normal state only when they are normal and confirm that the other party is normal through the above notification. Through this periodic mutual notification, the system partition and the user partition can be informed of each other's abnormalities in a timely manner. For example, the system partition has not selected a leader copy and is in an abnormal state. Without a leader copy, the main database lease cannot be sent to the user partition, so the user partition can promptly know that the system partition is abnormal and promptly 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 due to the failure of the write operation to write the target data (that is, the method provided by optional example A), then the main database lease will not be sent to the user partition, and then the user partition can promptly know that the system partition is abnormal and promptly confirm that the first database is in an abnormal state; for another example, the user partition has not selected a leader copy and is in an abnormal state, and without a leader copy, the main database lease cannot be sent to the system partition, and then the system partition can promptly know that the user partition is abnormal and promptly 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 due to the failure of the write operation to write the target data (that is, the method provided by optional example A), then the main database lease will not be sent to the system partition, and then the system partition can promptly know that the user partition is abnormal and promptly confirm that the first database is in an abnormal state.
[0145] 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, then the first database can use this example to promptly determine that the first database is in an abnormal state when the system partition itself is abnormal or the user partition is abnormal, and then resign as the master database to execute the master-slave database switching mechanism to complete the master-slave database switching; if the above-mentioned master-slave database switching mechanism in this embodiment is executed by each partition (i.e., the system partition and the user partition) respectively in the partition, then the first database can use this example to enable the system partition or the user partition to promptly know the other party's abnormality and determine that the first database is in an abnormal state, and then resign as the master database in each partition to execute the master-slave database switching mechanism to complete the master-slave database switching.
[0146] In combination with the above-mentioned embodiments 2 and 3, it can be known that each time the main database lease is about to expire, if the database is in a normal state, it will send a first main database election request to the arbitration node and the database as the backup database respectively, that is, it claims to continue to serve as the main database. After receiving the first main database election request, the arbitration node and the backup database will return confirmation information to the database as the main database for the first main database election request, so that the main database lease of the database can be renewed and it can continue to serve as the main database. If the database as the main database is in an abnormal state, such as the failure of the write operation of writing data to a partition, the leader copy has not been elected in a partition, etc., it will resign as the main database, switch the role information to the backup database, and no longer process the data write request sent by the client; and when the main database lease is about to expire, it will not send the first main database election request to the arbitration node and the database as the backup database, so that the arbitration node and the database as the backup database will know that the main database is abnormal, and then the database as the backup database will initiate the main database election in the distributed consensus protocol member group according to the main-backup database switching mechanism and take over as the main database. It should be understood that the operation of initiating a master database election within the distributed consensus protocol member group by a database serving as a backup database and taking office as the master database can be executed by its system partition and broadcast to other partitions after taking office as the master database.
[0147] The database serving as the primary database in the above-mentioned embodiments 1, 2, and 3 may respond to the data write request sent by the client in the maximum protection mode, the maximum performance mode, or the maximum availability mode.
[0148] In summary, the embodiments of the present specification add arbitration nodes to the distributed database so that each database and the arbitration node form a distributed consensus protocol member group, and then the member groups respectively run the distributed consensus protocol to complete the role information allocation of the main database and the backup database. The automation level is high, and when the database serving as the main database fails, the database originally serving as the backup database can rely on the distributed consensus protocol to automatically switch the role information to the main database, thereby avoiding the failure of the database serving as the main database and affecting the data service quality.
[0149] Based on this, in a second aspect, at least one embodiment of this specification provides a data management method based on an arbitration node, which is applied to a first database in a data system, wherein the data system also includes a second database and an arbitration node, please refer to the attached Figure 6 , the method comprising:
[0150] Step S601: Send a first master database election request to the arbitration node and the second database respectively.
[0151] Step S602: 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, determine that the first database is the master database.
[0152] In one or more embodiments of the present specification, after determining that the first database is a primary database, the method further includes:
[0153] In response to the first database being in a normal state and satisfying a renewal condition for the lease with the primary database at the current moment, sending a first primary database election request to the arbitration node and the second database respectively;
[0154] 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, the master database lease is extended by a first preset duration.
[0155] In one or more embodiments of the present specification, after determining that the first database is a primary database or extending the lease of the primary database for a first preset period of time, the method further includes:
[0156] In response to the first database being in an abnormal state and the renewal condition between the first database and the master database lease is satisfied at the current moment, the first master database election request is not sent to the arbitration node and the second database, so that the second database responds to the renewal condition between the first database and the master database lease being satisfied at the current moment and receiving the first master database election request sent by the first database as the master database, returns a confirmation message for the first master database election request to the first database, and determines that the second database is the master database in response to receiving the confirmation information returned by the arbitration node and / or the first database for the second master database election request.
[0157] In one or more embodiments of the present specification, the method further includes:
[0158] In response to the first database being in an abnormal state and receiving a data write request sent by a client, a write failure message is returned to the client.
[0159] In one or more embodiments of the present specification, the method further includes:
[0160] In response to a failure in executing a write operation to write data to the first database, it is determined that the first database is in an abnormal state.
[0161] In one or more embodiments of the present specification, when writing data to the first database, the method further includes:
[0162] Determining that the write operation is successfully performed in response to the write being successful on no less than a first preset number of replicas;
[0163] In response to failure to successfully write on no less than the first preset number of replicas within a second preset time period, it is determined that the write operation has failed.
[0164] In one or more embodiments of the present specification, the method further includes:
[0165] The system partition periodically sends the main database 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 main database lease periodically sent by the user partition;
[0166] The user partition is used to periodically send a 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.
[0167] Based on this, in a second aspect, at least one embodiment of this specification provides a data management method based on an arbitration node, which is applied to a second database in a data system, wherein the data system further includes a second database and an arbitration node, and the method includes:
[0168] In response to the current moment satisfying the renewal condition with the master database lease and receiving a first master database election request sent by the first database as the master database, a confirmation message for the first master database election request is returned to the first database, so that the first database extends the master database lease for a first preset period of time.
[0169] In one or more embodiments of the present specification, the method further includes:
[0170] In response to the renewal condition being met between the current moment and the lease of the primary database, and the first database as the primary database not receiving the first primary database election request sent by the first database, sending a second primary database election request to the arbitration node and the first database respectively;
[0171] 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, the second database is determined to be the master database.
[0172] The specific details of the data management method applied to the first database and the second database have been introduced in detail when introducing the functions of the first database and the second database in the first aspect of the data system, and will not be repeated here.
[0173] Figure 7 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 7At the hardware level, the device includes a processor 702, an internal bus 704, a network interface 706, a memory 708, and a non-volatile memory 710, and may also include hardware required for other tasks. One or more embodiments of this specification may be implemented based on software, such as the processor 702 reading the corresponding computer program from the non-volatile memory 710 into the memory 707 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, 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 each logic unit, but can also be hardware or logic devices.
[0174] Please refer to Figure 8 The data management device based on arbitration node can be applied to Figure 7 The device shown in the figure is used to implement the technical solution of this specification. The device can be applied to a first database in a data system, the data system also includes a second database and an arbitration node, and the device includes:
[0175] A first sending module 801 is used to send a first master database election request to the arbitration node and the second database respectively;
[0176] The first taking office module 802 is configured to determine the first database as the master database 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.
[0177] In one or more embodiments of the present specification, the device further includes a main library renewal module, which is used to:
[0178] After determining that the first database is the master database, in response to the first database being in a normal state and satisfying a renewal condition for the lease with the master database at the current moment, sending a first master database election request to the arbitration node and the second database respectively;
[0179] 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, the master database lease is extended by a first preset duration.
[0180] In one or more embodiments of the present specification, the device further includes a first active / standby switching module, configured to:
[0181] After determining that the first database is the master database or extending the master database lease for a first preset period of time, in response to the first database being in an abnormal state and satisfying a renewal condition between the current moment 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 responds to satisfying the renewal condition between the current moment and the master database lease and receiving the first master database election request sent by the first database as the master database, returns a confirmation message for the first master database election request to the first 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 for the second master database election request.
[0182] In one or more embodiments of the present specification, the device further includes a write rejection module, configured to:
[0183] In response to the first database being in an abnormal state and receiving a data write request sent by a client, a write failure message is returned to the client.
[0184] In one or more embodiments of the present specification, the device further includes an abnormality determination module, configured to:
[0185] In response to a failure in executing a write operation to write data to the first database, it is determined that the first database is in an abnormal state.
[0186] In one or more embodiments of the present specification, the device further includes a write status determination module, configured to:
[0187] When writing data to the first database, determining that the write operation is successfully executed in response to successful writing on no less than a first preset number of replicas;
[0188] In response to failure to successfully write on no less than the first preset number of replicas within a second preset time period, it is determined that the write operation has failed.
[0189] In one or more embodiments of the present specification, the device further includes a notification module, configured to:
[0190] The system partition periodically sends the main database 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 main database lease periodically sent by the user partition;
[0191] The user partition is used to periodically send a 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.
[0192] The data management device based on arbitration node can be applied to Figure 8 The device shown in the figure is used to implement the technical solution of this specification. The device can be applied to a second database in a data system, the data system also includes a first database and an arbitration node, and the device includes:
[0193] The master database renewal module is used to respond to the renewal condition between the current moment and the master database lease being met and receiving a first master database election request sent by the first database as the master database, and return a confirmation message for the first master database election request to the first database, so that the first database extends the master database lease for a first preset period of time.
[0194] In one or more embodiments of the present specification, the device further includes a second active / standby switching module, configured to:
[0195] In response to the renewal condition being met between the current moment and the lease of the primary database, and the first database as the primary database not receiving the first primary database election request sent by the first database, sending a second primary database election request to the arbitration node and the first database respectively;
[0196] 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, the second database is determined to be the master database.
[0197] According to a sixth aspect of one or more embodiments of the present specification, a computer program product is proposed, comprising a computer program / instruction, which, when executed by a processor, implements the steps of the method described in the second aspect or the third aspect.
[0198] According to an eighth aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored. When the instructions are executed by a processor, the steps of the method described in the second aspect or the third aspect are implemented.
[0199] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer, which may be in the form of 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 email transceiver, a game console, a tablet computer, a wearable device or a combination of any of these devices.
[0200] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0201] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0202] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. 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 technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, disk storage, quantum memory, graphene-based storage media or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0203] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0204] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0205] The terms used in one or more embodiments of this specification are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of this specification. The singular forms of "a", "said" and "the" used in one or more embodiments of this specification and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0206] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0207] It should be understood that although the terms first, second, third, etc. may be used to describe various information in one or more embodiments of this specification, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0208] The above description is merely a preferred embodiment of one or more embodiments of the present specification and is not intended to limit one or more embodiments of the present specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of one or more embodiments of the present specification shall be included in the scope of protection of one or more embodiments of the present specification.
Claims
1. A data system based on an arbitration node, the data system comprising: The first database is configured to send a first master database election request to the arbitration node and the second database respectively, and determine that the first database is the master database upon 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 used to send a second master database election request to the arbitration node and the first database respectively, and determine that the second database is the 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; An arbitration node is used to receive a first master database election request sent by the first database and / or a second master database election request sent by the second database, and return a confirmation message for the first master database election request to the first database to make the first database become the master database, or return a confirmation message for the second master database election request to the second database to make the second database become the master database.
2. According to the arbitration node-based data system of claim 1, the first database serves as the main database of the data system; The first database is used to send a first master database election request to the arbitration node and the second database respectively in response to the first database being in a normal state and satisfying a renewal condition between the first database and the master database lease at a current moment.
3. According to the arbitration node-based data system of claim 2, the first database is used to extend the lease of the master database by a first preset duration when receiving confirmation information returned by the arbitration node and / or the second database in response to the first master database election request.
4. According to the arbitration node-based data system of claim 2, the first database is used to respond to the first database being in an abnormal state and the renewal conditions between the first database and the main database lease are met at the current moment, not sending a first main database election request to the arbitration node and the second database.
5. The arbitration node-based data system according to claim 4, wherein the system partition in the first database is used to periodically send the main database lease to the 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 main database lease periodically sent by the user partition; The user partition in the first database is used to periodically send a 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.
6. The arbitration node-based data system according to claim 4 or 5, wherein the first database is configured to determine that the first database is in an abnormal state in response to a failure in a write operation to write data to the first database.
7. According to the arbitration node-based data system of claim 6, the first database is used to determine that the write operation is successful in response to successful writing on no less than a first preset number of replicas when writing data to the first database, and to determine that the write operation fails in response to not successfully writing on no less than a first preset number of replicas within a second preset time period.
8. According to the arbitration node-based data system of claim 1, the first database is configured to return a write-unable message to the client in response to the first database being in an abnormal state and receiving a data write request sent by a client.
9. According to the arbitration node-based data system of claim 1, the second database serves as a backup database of the data system; The second database is used to return a confirmation message for the first master database election request to the first database in response to the renewal condition being met between the current moment and the lease with the master database and receiving the first master database election request sent by the first database as the master database.
10. According to the arbitration node-based data system of claim 1, the second database serves as a backup database of the data system, and is used to send a second master database election request to the arbitration node and the first database respectively in response to the renewal condition between the lease with the master database being met at the current moment and not receiving the first master database election request sent by the first database as the master database.
11. A data management method based on arbitration nodes, applied to a first database in a data system, wherein the data system further includes a second database and an arbitration node, the method comprising: Sending a first master database election request to the arbitration node and the second database respectively; 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, the first database is determined to be the master database.
12. The arbitration node-based data management method according to claim 11, after determining the first database as the primary database, the method further comprises: In response to the first database being in a normal state and satisfying a renewal condition for the lease with the primary database at the current moment, sending a first primary database election request to the arbitration node and the second database respectively; 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, the master database lease is extended by a first preset duration.
13. The arbitration node-based data management method according to claim 11, after determining that the first database is a primary database or extending the primary database lease for a first preset time, the method further comprises: In response to the first database being in an abnormal state and the renewal condition between the first database and the master database lease is satisfied at the current moment, the first master database election request is not sent to the arbitration node and the second database, so that the second database responds to the renewal condition between the first database and the master database lease being satisfied at the current moment and receiving the first master database election request sent by the first database as the master database, returns a confirmation message for the first master database election request to the first database, and determines that the second database is the master database in response to receiving the confirmation information returned by the arbitration node and / or the first database for the second master database election request.
14. The arbitration node-based data management method according to 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, a write failure message is returned to the client.
15. The arbitration node-based data management method according to any one of claims 11 to 14, the method further comprising: In response to a failure in executing a write operation to write data to the first database, it is determined that the first database is in an abnormal state.
16. The arbitration node-based data management method according to claim 15, when writing data to the first database, the method further comprises: Determining that the write operation is successfully performed in response to the write being successful on no less than a first preset number of replicas; In response to failure to successfully write on no less than the first preset number of replicas within a second preset time period, it is determined that the write operation has failed.
17. The arbitration node-based data management method according to any one of claims 11 to 14, the method further comprising: The system partition periodically sends the main database 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 main database lease periodically sent by the user partition; The user partition is used to periodically send a 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.
18. 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 satisfying the renewal condition between the current moment and the master database lease, and receiving a first master database election request sent by the first database as the master database, returning a confirmation message for the first master database election request to the first database, so that the first database extends the master database lease for a first preset period of time.
19. The arbitration node-based data management method according to claim 18, further comprising: In response to the renewal condition being met between the current moment and the lease of the primary database, and the first database as the primary database not receiving the first primary database election request sent by the first database, sending a second primary database election request to the arbitration node and the first database respectively; 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, the second database is determined to be the master database.
20. A data management device based on an arbitration node, applied to a first database in a data system, the data system also including a second database and an arbitration node, the device comprising: A first sending module, used to send a first master database election request to the arbitration node and the second database respectively; The first taking office module is configured to determine that the first database is the master database 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.
21. A data management device based on an arbitration node, applied to a second database in a data system, the data system also including a first database and an arbitration node, the device comprising: The master database renewal module is used to respond to the renewal condition between the current moment and the master database lease being met and receiving a first master database election request sent by the first database as the master database, and return a confirmation message for the first master database election request to the first database, so that the first database extends the master database lease for a first preset period of time.
22. A computer program product comprising a computer program / instructions, which when executed by a processor implement the steps of the method according to any one of claims 11 to 19.
23. An electronic device, comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to 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 according to any one of claims 11 to 19.
Citation Information
Cited By
Data system and data management method based on arbitration node
WO2025246815A1
