Transaction processing method and device, electronic equipment and storage medium
By forming a consensus protocol group between multiple availability zones of a distributed database system and centrally processing consensus across partition transactions, the problem of low efficiency of distributed databases when executing cross-partition transactions is solved, improving processing efficiency and reducing latency.
Patent Information
- Application Number
- CN202411556683.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-03-14
AI Technical Summary
Distributed databases are less efficient when performing transactions across partitions, resulting in higher processing efficiency and latency.
By forming a consensus protocol group between multiple availability zones within the database system, such as a Paxos protocol group or a PBFT protocol group, consensus processing of cross-partition transactions is concentrated within the consensus protocol group of the control node, reducing consensus operations between each partition.
Improves the processing efficiency of cross-partition transactions, reduces latency, and reduces dependence on each partition consensus protocol group.
Smart Images

Figure CN119621841A_ABST
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 transaction processing method and apparatus, an electronic device, and a storage medium. Background Art
[0002] In recent years, database technology has developed rapidly, with more and more types, such as distributed databases. A distributed database is a database system that stores data on multiple computers in different geographical locations. These computers are connected together through a network, forming a logically single database system. The purpose of distributed database design is to improve the scalability, availability and performance of the system while reducing the risk of single point failure.
[0003] In the related art, when a distributed database executes cross-partition transactions, the efficiency is low due to the interactions between partitions and the consensus operations within the consensus protocol groups of each partition. Summary of the invention
[0004] In view of this, one or more embodiments of the present specification provide a transaction processing method and apparatus, an electronic device, and a storage medium.
[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 transaction processing method is proposed, which is applied to a control node of any one of multiple availability zones in a database system, each availability zone having a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple availability zones in the database system; the method includes:
[0007] Receive a transaction processing request sent by a client, and perform consensus processing on the transaction processing request within the consensus protocol group;
[0008] If the transaction processing request completes consensus within the consensus protocol group, the transaction processing request is sent to the corresponding partition node for execution.
[0009] In one or more embodiments of the present specification, before performing consensus processing on the transaction processing request within the consensus protocol group, the method further includes:
[0010] Sending the transaction processing request to the corresponding partition node for verification;
[0011] The step of performing consensus processing on the transaction processing request within the consensus protocol group includes:
[0012] When the transaction processing request passes the verification, the transaction processing request is processed by consensus within the consensus protocol group.
[0013] In one or more embodiments of the present specification, sending the transaction processing request to the corresponding partition node for verification includes:
[0014] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed;
[0015] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node directed to by the transaction processing request.
[0016] In one or more embodiments of the present specification, the partition node is used to add the received transaction processing request to the unverified transaction queue, and verify the transaction processing requests in the unverified transaction queue in sequence, and report the verification pass message of the verified transaction processing request to the control node.
[0017] In one or more embodiments of the present specification, the partition node is used to add the verified transaction processing requests to the verified transaction queue, and batch report the verification pass messages of the transaction processing requests in the verified transaction queue to the control node.
[0018] In one or more embodiments of the present specification, the partition node is used to report the hash value of the verified transaction processing request as a verification pass message to the control node.
[0019] In one or more embodiments of the present specification, a Paxos protocol group or a PBFT protocol group is formed between control nodes in multiple availability zones within the database system.
[0020] In one or more embodiments of the present specification, sending the transaction processing request to the corresponding partition node for execution includes:
[0021] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed, so that the partition node receiving the transaction processing request executes the transaction processing request in the partition node;
[0022] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node targeted by the transaction processing request, so that the transaction source node executes part of the content of the transaction processing request within the transaction source node, and executes the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request.
[0023] According to a second aspect of one or more embodiments of the present specification, a transaction processing method is proposed, which is applied to any partition node of any of multiple available zones in a database system, each available zone having a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system; the method includes:
[0024] Receive a transaction processing request sent by the control node that has reached consensus within the consensus protocol group, and execute the transaction processing request, wherein the transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
[0025] In one or more embodiments of this specification, executing the transaction processing request includes:
[0026] If the transaction processing request is for a partition node, executing the transaction processing request in the partition node executing the method;
[0027] If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node executing the method, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
[0028] In one or more embodiments of the present specification, executing part of the content of the transaction processing request in the partition node executing the method, and executing the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request, includes:
[0029] Executing relevant contents in the transaction processing request in the partition node executing the method;
[0030] Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message;
[0031] Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
[0032] In one or more embodiments of this specification, the method further includes:
[0033] Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
[0034] In one or more embodiments of the present specification, the verifying the transaction processing request in sequence includes:
[0035] The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
[0036] In one or more embodiments of the present specification, reporting a verification success message of the verified transaction processing request to the control node includes:
[0037] The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
[0038] According to a third aspect of one or more embodiments of the present specification, a transaction processing device is provided, which is applied to a control node of any one of multiple available zones in a database system, each available zone having a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system; the device includes:
[0039] A consensus module, used to receive a transaction processing request sent by a client, and perform consensus processing on the transaction processing request within the consensus protocol group;
[0040] An execution module is used to send the transaction processing request to a corresponding partition node for execution if the transaction processing request completes consensus within the consensus protocol group.
[0041] In one or more embodiments of the present specification, the device further includes a verification module, which is used to:
[0042] Before the transaction processing request is processed by consensus within the consensus protocol group, the transaction processing request is sent to a corresponding partition node for verification;
[0043] The consensus module is used to:
[0044] When the transaction processing request passes the verification, the transaction processing request is processed by consensus within the consensus protocol group.
[0045] In one or more embodiments of this specification, the verification module is used to:
[0046] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed;
[0047] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node directed to by the transaction processing request.
[0048] In one or more embodiments of the present specification, the partition node is used to add the received transaction processing request to the unverified transaction queue, and verify the transaction processing requests in the unverified transaction queue in sequence, and report the verification pass message of the verified transaction processing request to the control node.
[0049] In one or more embodiments of the present specification, the partition node is used to add the verified transaction processing requests to the verified transaction queue, and batch report the verification pass messages of the transaction processing requests in the verified transaction queue to the control node.
[0050] In one or more embodiments of the present specification, the partition node is used to report the hash value of the verified transaction processing request as a verification pass message to the control node.
[0051] In one or more embodiments of the present specification, a Paxos protocol group or a PBFT protocol group is formed between control nodes in multiple availability zones within the database system.
[0052] In one or more embodiments of the present specification, when the execution module is used to send the transaction processing request to the corresponding partition node for execution, it is used to:
[0053] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed, so that the partition node receiving the transaction processing request executes the transaction processing request in the partition node;
[0054] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node targeted by the transaction processing request, so that the transaction source node executes part of the content of the transaction processing request within the transaction source node, and executes the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request.
[0055] According to a fourth aspect of one or more embodiments of the present specification, a transaction processing device is provided, which is applied to any partition node of any of multiple available zones in a database system, each available zone having a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system; the device includes a receiving module, which is used to:
[0056] Receive a transaction processing request sent by the control node that has reached consensus within the consensus protocol group, and execute the transaction processing request, wherein the transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
[0057] In one or more embodiments of the present specification, when the receiving module is used to execute the transaction processing request, it is used to:
[0058] If the transaction processing request is for a partition node, executing the transaction processing request in the partition node running the transaction processing device;
[0059] If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node running the transaction processing device, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
[0060] In one or more embodiments of the present specification, when the receiving module is used to execute part of the content of the transaction processing request in the partition node running the transaction processing device and to execute the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request, it is used to:
[0061] Executing relevant content in the transaction processing request in a partition node running the transaction processing device;
[0062] Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message;
[0063] Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
[0064] In one or more embodiments of the present specification, the device further includes a verification module, which is used to:
[0065] Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
[0066] In one or more embodiments of this specification, the verification module is used to:
[0067] The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
[0068] In one or more embodiments of the present specification, when the verification module is used to report a verification success message of a verified transaction processing request to the control node, it is used to:
[0069] The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
[0070] According to a fifth aspect of one or more embodiments of this specification, a computer program product is proposed, comprising a computer program / instruction, which implements the steps of the method described in the first aspect or the second aspect when executed by a processor.
[0071] According to a sixth aspect of one or more embodiments of this specification, an electronic device is provided, including:
[0072] processor;
[0073] a memory for storing processor-executable instructions;
[0074] The processor implements the method as described in the first aspect or the second aspect by running the executable instructions.
[0075] According to a seventh aspect of one or more embodiments of the present specification, a computer-readable storage medium is provided, on which computer instructions are stored, and when the instructions are executed by a processor, the steps of the method described in the first aspect or the second aspect are implemented.
[0076] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:
[0077] The transaction processing method provided in the embodiments of this specification is applied to the control node of any one of the multiple available zones in the database system, each of which has a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system. The method first receives a transaction processing request sent by the client, and performs consensus processing on the transaction processing request in the consensus protocol group. If the transaction processing request completes consensus in the consensus protocol group, the transaction processing request is sent to the corresponding partition node for execution. Since the consensus protocol group formed between the control nodes of multiple available zones in the database system replaces the consensus protocol group formed between the same partition nodes of multiple available zones in the related technology, cross-partition transactions do not require the partitions involved to reach consensus in their respective consensus protocol groups, but the transaction is unified in the consensus protocol group of the control node for consensus, thereby improving the processing efficiency of cross-partition transactions. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 It is an architectural diagram of a distributed database in related technologies.
[0079] Figure 2 is a schematic diagram of a distributed database provided by an exemplary embodiment.
[0080] Figure 3 It is an architectural diagram of a distributed database provided by an exemplary embodiment.
[0081] Figure 4 It is a flowchart of a transaction processing method provided by an exemplary embodiment.
[0082] Figure 5 It is a logic diagram of a transaction processing method provided by an exemplary embodiment.
[0083] Figure 6 It is a logic diagram of transaction execution provided by an exemplary embodiment.
[0084] Figure 7 It is a structural schematic diagram of a device provided by an exemplary embodiment.
[0085] Figure 8 is a block diagram of a transaction processing device provided by an exemplary embodiment. DETAILED DESCRIPTION
[0086] 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.
[0087] 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.
[0088] In the related art, a consensus protocol group is formed between the partition nodes corresponding to the same data partition in multiple available zones in the database system, and operations within the data partition need to be completed in its consensus protocol group before being executed by the corresponding partition nodes. Therefore, if the database system executes cross-partition transactions, each data partition involved must complete consensus in its consensus protocol group before executing related operations. If there are many partitions involved, especially if operations between partitions need to be executed in a certain order, the transaction execution process requires multiple consensuses, which is time-consuming and inefficient.
[0089] For example, Figure 1In the database system shown, available zones zone1, zone2, zone3, and zone4 all include partition nodes P1, P2, P3, and a control node RS, wherein partition node P1 corresponds to data partition P1, partition node P2 corresponds to data partition P2, and partition node P3 corresponds to data partition P3. Consensus protocol group 1 is formed between P1 of zone1, P1 of zone2, P1 of zone3, and P1 of zone4. Consensus protocol group 2 is formed between P2 of zone1, P2 of zone2, P2 of zone3, and P2 of zone4. Consensus protocol group 3 is formed between P3 of zone1, P3 of zone2, P3 of zone3, and P3 of zone4. If the database system needs to execute a transaction, and account A in data partition P1 transfers X yuan to account B in data partition P2, the control node RS of available zone zone1 that receives the transaction sends the transaction to partition node P1, and P1 performs consensus processing on the "A account - X yuan" operation in consensus protocol group 1. After consensus is completed, partition nodes P1 in zone1, zone2, zone3, and zone4 all perform the "A account - X yuan" operation, and then partition node P1 in zone1 sends a call (Subcall) transaction message to partition node P2, and partition node P2 performs consensus on the "B account + X yuan" operation in the message in consensus protocol group 2. After consensus is completed, partition nodes P2 in zone1, zone2, zone3, and zone4 all perform the "B account + X yuan" operation, and partition node P2 in zone1 replies to the transaction message to partition node P1, and partition node P1 sends a transaction submission message to partition node P2. This process requires two consensus processes, and if the transaction is more complex, it will involve more consensus processes, which leads to low efficiency and high latency in cross-partition transaction processing.
[0090] Based on the above technical problems, at least one embodiment of this specification provides a transaction processing method, which is applied to any one of multiple availability zones in a database system, each availability zone has a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple availability zones in the database system, such as a Paxos protocol group or a PBFT (Practical Byzantine Fault Tolerance) protocol group. Figure 2 and attached Figure 3In the database system shown, available zones zone1, zone2, zone3, and zone4 all include partition nodes P1, P2, P3, and control node RS, wherein partition node P1 corresponds to data partition P1, partition node P2 corresponds to data partition P2, and partition node P3 corresponds to data partition P3, and a PBFT protocol group is formed between the RS of zone1, the RS of zone2, the RS of zone3, and the RS of zone4.
[0091] The database system implements a distributed partitioning strategy to divide the huge data table horizontally into multiple small partition units and distribute them among many servers. This strategy significantly improves the efficiency of data processing and query by horizontally cutting the data, while achieving load balancing and enhancing the overall performance of the system. It also has the ability to dynamically adjust the number of partitions and supports the horizontal expansion of the database, so that partitions can be flexibly added or reduced without downtime. Through data replication technology, the database system ensures high availability of data among servers. In addition, the database system supports the processing of cross-partition distributed transactions that follow the ACID principle and is completely transparent to the application layer. This refined partition management greatly optimizes the data storage and access process, making the database system particularly suitable for carrying large-scale online transaction processing (OLTP) and online analytical processing (OLAP) tasks.
[0092] The famous Paxos algorithm can overcome the problem of data consistency in distributed systems, thereby improving the overall reliability of the system. Through the Paxos protocol, the database system can ensure that even if some nodes fail, it can effectively reach consistent decisions between nodes. The core principle of the Paxos algorithm allows the system to operate normally in the face of up to f node failures, so at least 2f+1 nodes can be deployed; in other words, this strategy ensures that the system can achieve data consistency and high reliability when at least f+1 nodes remain in normal operation.
[0093] When faced with the challenge of Byzantine failures, the reliability and stability of distributed database systems are seriously threatened. Byzantine failures may cause nodes to exhibit inconsistent behavior, such as sending wrong information, deliberately destabilizing the system, or stopping responding. To deal with such problems, the Practical Byzantine Fault Tolerance (PBFT) algorithm is regarded as an effective solution to ensure that the system can resist Byzantine intervention and maintain data consistency and system availability even in the event of partial node failure. The advantage of the PBFT algorithm is that even if there are up to f Byzantine nodes in the system, as long as the system has 3f+1 nodes, the integrity and consistency of database operations can be guaranteed.
[0094] The method is completed by the cooperation of a control node and at least one partition node in the available zone that executes the method. Next, the details of the method are introduced from both sides of the control node and any partition node.
[0095] Please refer to the attached Figure 4 , which exemplarily shows a flowchart of a transaction processing method applied to a control node, including steps S301 to S303.
[0096] In step S401, a transaction processing request sent by a client is received, and the transaction processing request is processed by consensus within the consensus protocol group.
[0097] Exemplarily, before the transaction processing request is processed by consensus within the consensus protocol group, the method further includes: sending the transaction processing request to the corresponding partition node for verification. Specifically, if the transaction processing request is for one partition node, the transaction processing request is sent to the partition node targeted by the transaction processing request; if the transaction processing request is for multiple partition nodes, the transaction processing request is sent to the transaction source node targeted by the transaction processing request.
[0098] Attach Figure 2 , Attachment Figure 3 Taking the database system shown as an example, if the transaction processing request is for partition node P1, that is, the transaction content of the transaction processing request only involves data partition P1, then the control node RS can send the transaction processing request to partition node P1 for verification; if the transaction processing request is for partition nodes P1 and P2, and P1 is the transaction source node, for example, the transaction content of the transaction processing request is that account A in data partition P1 transfers X yuan to account B in data partition P2, then the control node RS can send the transaction processing request to partition node P1 for verification.
[0099] Optionally, the partition node is used to add the received transaction processing request to the unverified transaction queue, and to verify the transaction processing requests in the unverified transaction queue in sequence, and to report the verification pass message of the verified transaction processing request to the control node. For example, the partition node is used to add the verified transaction processing request to the verified transaction queue, and to report the verification pass message of the transaction processing request in the verified transaction queue to the control node in batches. For another example, the partition node is used to report the hash value of the verified transaction processing request as the verification pass message to the control node.
[0100] Based on the above content, in this step, if the transaction processing request passes the verification, the transaction processing request can be processed by consensus in the consensus protocol group. For example, after receiving the hash value of the verified transaction processing request reported by the partition node, it is compared with the hash value of each transaction processing request that has not been processed by consensus, so as to screen out the verified transaction processing request, and package it as a proposal for consensus processing in the consensus protocol group, and determine whether the consensus is completed by the reply of other members in the consensus protocol group, for example, when more than a preset proportion of members vote in favor of the proposal, it is considered that the consensus is completed. For example, if the consensus protocol group is a PBFT protocol group, the verified transaction processing request can be broadcast to the control nodes of other available zones first, and then the hash value of the verified transaction processing request can be packaged as a consensus proposal to start the consensus. After the consensus is completed, the control nodes of each available zone can screen the local transaction processing request (the transaction processing request sent by the client and / or the transaction processing request sent by the control nodes of other available zones) based on the hash value of the completed consensus to determine the transaction processing request that has completed the consensus.
[0101] In step S402, if the transaction processing request completes consensus within the consensus protocol group, the transaction processing request is sent to the corresponding partition node for execution.
[0102] It should be understood that the control nodes in other availability zones can also send the consensus-completed transaction processing request to the corresponding partition node for execution; or the corresponding partition in the availability zone directly executes the transaction processing request and then synchronizes it to the corresponding partitions in other availability zones.
[0103] Exemplarily, if the transaction processing request is for one partition node, the transaction processing request is sent to the partition node for which the transaction processing request is for, so that the partition node receiving the transaction processing request executes the transaction processing request in the partition node; if the transaction processing request is for multiple partition nodes, the transaction processing request is sent to the transaction source node for which the transaction processing request is for, so that the transaction source node executes part of the transaction processing request in the transaction source node, and executes the remaining content of the transaction processing request by mobilizing other partitions for which the transaction processing request is for. When a transaction processing request is executed, the data in the database is updated.
[0104] For example, when a transaction processing request is directed to multiple partition nodes, the transaction processing request may be executed in the following manner:
[0105] First, the relevant contents in the transaction processing request are executed in the partition node executing the method. Figure 2 , Attachment Figure 3Taking the database system shown as an example, if the transaction content of the transaction processing request is that account A in data partition P1 transfers X yuan to account B in data partition P2, P1 can execute the "A account - X yuan" operation.
[0106] Next, a call transaction message (requestsubcall) is sent to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message. Figure 2 , Attachment Figure 3 Taking the database system shown as an example, if the transaction content of the transaction processing request is that account A in data partition P1 transfers X yuan to account B in data partition P2, the transaction content carried in the call transaction message is the operation of "account B + X yuan".
[0107] Finally, a response transaction message (response subcall) returned by other partition nodes targeted by the transaction processing request is received, and a transaction commit message (commit subcall) is sent to other partition nodes targeted by the transaction processing request when the response transaction message indicates that the transaction content is executed successfully.
[0108] Please refer to the attached Figure 5 , which is attached Figure 3 Taking the database system shown executing cross-partition transactions as an example, the execution process of the method is shown, including steps ① to ⑥.
[0109] Step ①: Initiate cross-partition transactions (i.e. control nodes to receive cross-partition transactions).
[0110] Step ②: The transaction is routed to the correct partition (i.e. the transaction source node).
[0111] Step 3: Transaction verification.
[0112] Step ④: Broadcast the verified transaction to other zones.
[0113] Step 5: The transaction is packaged into a proposal and consensus is started.
[0114] Step ⑥: Transaction execution, database update.
[0115] Please refer to the attached Figure 6 , which is attached Figure 3 The database system shown executes a cross-partition transaction from P1 to P2 as an example, and illustrates the process of executing transactions on corresponding partitions in the method, including steps ① to ⑨.
[0116] Step 1: P1 initiates a consensus transaction set and starts execution.
[0117] Step ②: P1 executes the transaction.
[0118] Step 3: P1 writes the transaction log and updates the database.
[0119] Step 4: P1 sends a request subcall to P2.
[0120] Step ⑤: P2 executes the partition transaction message.
[0121] Step ⑥: P2 writes the transaction log and updates the database.
[0122] Step 7: P2 returns the response subcall to P1.
[0123] Step ⑧: P1 writes the transaction log and updates the database.
[0124] Step 9: Send commit subcall.
[0125] The transaction processing method provided in the embodiments of this specification is applied to the control node of any one of the multiple available zones in the database system, each of which has a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system. The method first receives a transaction processing request sent by the client, and performs consensus processing on the transaction processing request in the consensus protocol group. If the transaction processing request completes consensus in the consensus protocol group, the transaction processing request is sent to the corresponding partition node for execution. Since the consensus protocol group formed between the control nodes of multiple available zones in the database system replaces the consensus protocol group formed between the same partition nodes of multiple available zones in the related technology, cross-partition transactions do not require the partitions involved to reach consensus in their respective consensus protocol groups, but the transaction is unified in the consensus protocol group of the control node for consensus, thereby improving the processing efficiency of cross-partition transactions.
[0126] When executing cross-partition transactions, this method only needs to reach a consensus once within the consensus protocol group. In the subsequent transaction execution phase of each partition, there is no need to delay sending transaction messages, which greatly reduces the delay time of cross-partition transactions. Moreover, since each partition is in the same regional network, due to the mutual trust between nodes, there is no need to attach verification information when transmitting transaction messages. The received messages are assumed to be reliable by default, eliminating the correctness verification process. Furthermore, there is no need to persist transaction messages.
[0127] Take the transaction of transferring X yuan from account A in data partition P1 to account B in data partition P2 as an example. In the related technology, at least two consensus processes are required, while this method only needs one consensus process. It should be understood that this example is relatively simple, and in actual business scenarios, cross-partition transactions are more complex. Therefore, this method reduces the number of consensus processes more than the existing technology, and the effect is more significant.
[0128] In summary, this method reaches consensus on the consensus protocol group composed of the right control nodes after the cross-partition transactions are packaged, which significantly enhances the efficiency and performance of the distributed security database in processing cross-partition transactions. It perfectly meets the current cross-partition transaction needs and significantly improves the throughput capacity when processing such transactions, providing an effective way to improve transaction efficiency and performance.
[0129] Next, a transaction processing method applied to any partition node is introduced, which may include the following steps:
[0130] Receive a transaction processing request sent by the control node that has reached consensus within the consensus protocol group, and execute the transaction processing request, wherein the transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
[0131] Exemplarily, the executing the transaction processing request may include:
[0132] If the transaction processing request is for a partition node, executing the transaction processing request in the partition node executing the method;
[0133] If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node executing the method, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
[0134] Exemplarily, executing part of the transaction processing request in the partition node executing the method, and executing the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request, includes:
[0135] Executing relevant contents in the transaction processing request in the partition node executing the method;
[0136] Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message;
[0137] Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
[0138] Exemplarily, the method further includes:
[0139] Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
[0140] Exemplarily, the verifying the transaction processing request in sequence includes:
[0141] The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
[0142] Exemplarily, reporting a verification success message of the verified transaction processing request to the control node includes:
[0143] The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
[0144] The details involved in the above steps have been introduced in detail in the method introduction on the control node side, and will not be repeated here.
[0145] Figure 7 is a schematic structural diagram of a device provided by an exemplary embodiment. Figure 7 At 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 708 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.
[0146] This specification also provides a transaction processing device, which can be applied to a control node in any of a plurality of available zones in a database system, each of which has a control node and a plurality of partition nodes, and a consensus protocol group is formed between the control nodes in the plurality of available zones in the database system; for example, the control node where the device is located runs in Figure 7 For the equipment shown, please refer to the attached Figure 8 , the device comprises:
[0147] The consensus module 801 is used to receive a transaction processing request sent by a client, and perform consensus processing on the transaction processing request within the consensus protocol group;
[0148] The execution module 802 is used to send the transaction processing request to the corresponding partition node for execution if the transaction processing request completes consensus within the consensus protocol group.
[0149] In one or more embodiments of the present specification, the device further includes a verification module, which is used to:
[0150] Before the transaction processing request is processed by consensus within the consensus protocol group, the transaction processing request is sent to a corresponding partition node for verification;
[0151] The consensus module is used to:
[0152] When the transaction processing request passes the verification, the transaction processing request is processed by consensus within the consensus protocol group.
[0153] In one or more embodiments of this specification, the verification module is used to:
[0154] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed;
[0155] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node directed to by the transaction processing request.
[0156] In one or more embodiments of the present specification, the partition node is used to add the received transaction processing request to the unverified transaction queue, and verify the transaction processing requests in the unverified transaction queue in sequence, and report the verification pass message of the verified transaction processing request to the control node.
[0157] In one or more embodiments of the present specification, the partition node is used to add the verified transaction processing requests to the verified transaction queue, and batch report the verification pass messages of the transaction processing requests in the verified transaction queue to the control node.
[0158] In one or more embodiments of the present specification, the partition node is used to report the hash value of the verified transaction processing request as a verification pass message to the control node.
[0159] In one or more embodiments of the present specification, a Paxos protocol group or a PBFT protocol group is formed between control nodes in multiple availability zones within the database system.
[0160] In one or more embodiments of the present specification, when the execution module is used to send the transaction processing request to the corresponding partition node for execution, it is used to:
[0161] If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed, so that the partition node receiving the transaction processing request executes the transaction processing request in the partition node;
[0162] If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node targeted by the transaction processing request, so that the transaction source node executes part of the content of the transaction processing request within the transaction source node, and executes the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request.
[0163] This specification also provides a transaction processing device, which can be applied to any partition node in any of multiple available zones in a database system, each of which has a control node and multiple partition nodes, and a consensus protocol group is formed between the control nodes in the multiple available zones in the database system; for example, the control node where the device is located runs in Figure 7 In the device shown, the apparatus comprises a receiving module, which is used to:
[0164] Receive a transaction processing request sent by the control node that has reached consensus within the consensus protocol group, and execute the transaction processing request, wherein the transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
[0165] In one or more embodiments of the present specification, when the receiving module is used to execute the transaction processing request, it is used to:
[0166] If the transaction processing request is for a partition node, executing the transaction processing request in the partition node running the transaction processing device;
[0167] If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node running the transaction processing device, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
[0168] In one or more embodiments of the present specification, when the receiving module is used to execute part of the content of the transaction processing request in the partition node running the transaction processing device and to execute the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request, it is used to:
[0169] Executing relevant content in the transaction processing request in a partition node running the transaction processing device;
[0170] Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message;
[0171] Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
[0172] In one or more embodiments of the present specification, the device further includes a verification module, which is used to:
[0173] Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
[0174] In one or more embodiments of this specification, the verification module is used to:
[0175] The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
[0176] In one or more embodiments of the present specification, when the verification module is used to report a verification success message of a verified transaction processing request to the control node, it is used to:
[0177] The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
[0178] 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.
[0179] In a typical configuration, a computer includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0180] 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.
[0181] 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.
[0182] 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.
[0183] 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.
[0184] 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.
[0185] 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 manual 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.
[0186] 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".
[0187] 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 transaction processing method, applied to a control node of any one of a plurality of available zones in a database system, each of which has a control node and a plurality of partition nodes, wherein a consensus protocol group is formed between the control nodes in the plurality of available zones in the database system; the method comprising: Receive a transaction processing request sent by a client, and perform consensus processing on the transaction processing request within the consensus protocol group; If the transaction processing request completes consensus within the consensus protocol group, the transaction processing request is sent to the corresponding partition node for execution.
2. The transaction processing method according to claim 1, before the transaction processing request is subjected to consensus processing within the consensus protocol group, the method further comprises: Sending the transaction processing request to the corresponding partition node for verification; The step of performing consensus processing on the transaction processing request within the consensus protocol group includes: When the transaction processing request passes the verification, the transaction processing request is processed by consensus within the consensus protocol group.
3. The transaction processing method according to claim 2, wherein sending the transaction processing request to the corresponding partition node for verification comprises: If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed; If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node directed to by the transaction processing request.
4. According to the transaction processing method of claim 2, the partition node is used to add the received transaction processing request to the unverified transaction queue, and verify the transaction processing requests in the unverified transaction queue in turn, and report the verification pass message of the verified transaction processing request to the control node.
5. The transaction processing method according to claim 4, wherein the partition node is used to add the verified transaction processing requests to the verified transaction queue, and batch report the verification pass messages of the transaction processing requests in the verified transaction queue to the control node.
6. The transaction processing method according to claim 4, wherein the partition node is used to report the hash value of the verified transaction processing request as a verification pass message to the control node.
7. According to the transaction processing method according to claim 1, a Paxos protocol group or a PBFT protocol group is formed between the control nodes in multiple availability zones in the database system.
8. The transaction processing method according to claim 1, wherein sending the transaction processing request to the corresponding partition node for execution comprises: If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed, so that the partition node receiving the transaction processing request executes the transaction processing request in the partition node; If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node targeted by the transaction processing request, so that the transaction source node executes part of the content of the transaction processing request within the transaction source node, and executes the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request.
9. A transaction processing method, applied to any partition node of any of a plurality of available zones in a database system, each of which has a control node and a plurality of partition nodes, wherein a consensus protocol group is formed between the control nodes in the plurality of available zones in the database system; the method comprising: Receive a transaction processing request sent by the control node that has reached consensus within the consensus protocol group, and execute the transaction processing request, wherein the transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
10. The transaction processing method according to claim 9, wherein executing the transaction processing request comprises: If the transaction processing request is for a partition node, executing the transaction processing request in the partition node executing the method; If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node executing the method, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
11. The transaction processing method according to claim 10, wherein executing part of the transaction processing request in the partition node executing the method and executing the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request comprises: Executing relevant contents in the transaction processing request in the partition node executing the method; Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message; Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
12. The transaction processing method according to claim 9, further comprising: Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
13. The transaction processing method according to claim 12, wherein the verifying the transaction processing requests in sequence comprises: The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
14. The transaction processing method according to claim 13, wherein the step of reporting a verification success message of the verified transaction processing request to the control node comprises: The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
15. A transaction processing device, applied to a control node of any one of a plurality of available zones in a database system, each of which has a control node and a plurality of partition nodes, wherein a consensus protocol group is formed between the control nodes in the plurality of available zones in the database system; The device comprises: A consensus module, used to receive a transaction processing request sent by a client, and perform consensus processing on the transaction processing request within the consensus protocol group; An execution module is used to send the transaction processing request to a corresponding partition node for execution if the transaction processing request completes consensus within the consensus protocol group.
16. The transaction processing device according to claim 15, further comprising a verification module, configured to: Before the transaction processing request is processed by consensus within the consensus protocol group, the transaction processing request is sent to a corresponding partition node for verification; The consensus module is used to: When the transaction processing request passes the verification, the transaction processing request is processed by consensus within the consensus protocol group.
17. The transaction processing device according to claim 16, wherein the verification module is used for: If the transaction processing request is for a partition node, sending the transaction processing request to the partition node for which the transaction processing request is directed; If the transaction processing request is directed to multiple partition nodes, the transaction processing request is sent to the transaction source node directed to by the transaction processing request.
18. According to the transaction processing device of claim 15, a Paxos protocol group or a PBFT protocol group is formed between the control nodes in multiple availability zones in the database system.
19. A transaction processing device, applied to any partition node of any of a plurality of available zones in a database system, each of which has a control node and a plurality of partition nodes, wherein a consensus protocol group is formed between the control nodes in the plurality of available zones in the database system; the device comprises a receiving module, which is used to: receiving a transaction processing request sent by a control node that has reached consensus within the consensus protocol group, and executing the transaction processing request, wherein: The transaction processing request is sent by the client to the control node, and the control node performs consensus processing in the consensus protocol group.
20. The transaction processing device according to claim 19, wherein when the receiving module is used to execute the transaction processing request, it is used to: If the transaction processing request is for a partition node, executing the transaction processing request in the partition node running the transaction processing device; If the transaction processing request is directed to multiple partition nodes, part of the transaction processing request is executed in the partition node running the transaction processing device, and the remaining content of the transaction processing request is executed by mobilizing other partitions targeted by the transaction processing request.
21. The transaction processing device according to claim 20, wherein the receiving module is used to execute part of the content of the transaction processing request in the partition node running the transaction processing device, and execute the remaining content of the transaction processing request by mobilizing other partitions targeted by the transaction processing request, and is used to: Executing relevant content in the transaction processing request in a partition node running the transaction processing device; Sending a call transaction message to other partition nodes targeted by the transaction processing request, so that the partition nodes receiving the call transaction message execute the transaction content carried in the call transaction message; Receive a reply transaction message returned by other partition nodes targeted by the transaction processing request, and send a transaction commit message to other partition nodes targeted by the transaction processing request when the reply transaction message indicates that the transaction content is executed successfully.
22. The transaction processing device according to claim 19, further comprising a verification module, configured to: Receive a transaction processing request sent by a control node that has not been consensus processed within the consensus protocol group, verify the transaction processing request in turn, and report a verification success message of the transaction processing request to the control node if the transaction processing request successfully passes the verification.
23. The transaction processing device according to claim 22, wherein the verification module is used for: The transaction processing request is added to an unverified transaction queue, and the transaction processing requests in the unverified transaction queue are verified in sequence, and a verification success message of the verified transaction processing request is reported to the control node.
24. The transaction processing device according to claim 23, wherein when the verification module is used to report a verification success message of the verified transaction processing request to the control node, it is used to: The verified transaction processing requests are added to the verified transaction queue, and verification success messages of the transaction processing requests in the verified transaction queue are reported in batches to the control node.
25. 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 1 to 14.
26. An electronic device comprising: processor; a memory for storing processor-executable instructions; The processor implements the method according to any one of claims 1 to 14 by running the executable instructions.
27. 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 1 to 14.
Citation Information
Cited By
Write request processing method, database system, device, storage medium and product
CN120910045A