A method and apparatus for executing a distributed transaction

By dividing transactions into sub-transactions in a distributed system and executing them using remote direct memory access and network communication, the problem of low execution efficiency in distributed transactions is solved, achieving more efficient distributed transaction processing.

CN115033350BActive Publication Date: 2026-03-31BEIJING OCEANBASE TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-07
Publication Date
2026-03-31

AI Technical Summary

Technical Problem

In distributed systems, existing technologies suffer from low efficiency in distributed transaction execution, especially in shared-nothing architectures where network communication latency is high, while shared-memory architectures are limited in network scale when applied on a large scale.

Method used

After receiving a transaction request, it is divided into several sub-transactions. The local sub-transactions are executed in the local data center using remote direct memory access. The remote sub-transactions are sent to other data centers for execution using network communication. Finally, the transaction result is determined based on the operation results.

Benefits of technology

It improves the execution efficiency of large-scale distributed transactions, reduces network communication latency and memory contention, and expands the application scope of network scale.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033350B_ABST
    Figure CN115033350B_ABST
Patent Text Reader

Abstract

The specification discloses a distributed transaction execution method and device, which comprises the following steps: first, receiving a transaction request containing a plurality of data operations; then, dividing the transaction into a plurality of sub-transactions according to data centers; in the local data center, executing the data operations contained in the local sub-transactions by using a remote direct memory access mode to determine a first operation result; sending each remote sub-transactions to the corresponding other data center by using a network communication mode; making each other data center execute the data operations contained in the received remote sub-transactions by using a remote direct memory access mode; receiving the second operation result returned by each other data center; and finally determining the execution result of the transaction according to the first operation result and the second operation result. By using the network communication mode to execute access between data centers and the remote direct memory access mode to execute access in each data center, the execution efficiency of large-scale distributed transactions is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for executing distributed transactions. Background Technology

[0002] Currently, with the rapid development of the Internet, the application of distributed systems has also developed. In distributed systems, after a user initiates a transaction request on the client, multiple server nodes typically need to collaborate to complete the transaction request. Because multiple server nodes need to collaborate, the execution efficiency of distributed transactions is a key issue that needs to be considered.

[0003] This specification provides a method for executing distributed transactions to improve the execution efficiency of large-scale distributed transactions. Summary of the Invention

[0004] This specification provides a method and apparatus for executing distributed transactions, which at least partially solves the problems existing in the prior art.

[0005] The following technical solution is adopted in this specification:

[0006] This specification provides a method for executing distributed transactions, including:

[0007] Receive transaction requests that include several data operations;

[0008] Based on the data center corresponding to each data operation, the transaction is divided into several sub-transactions, and the data center for executing each sub-transaction is determined.

[0009] Determine a local sub-transaction to be executed by the local data center, execute the data operations contained in the local sub-transaction in the local data center via remote direct memory access, and determine the first operation result;

[0010] Remote sub-transactions executed by other data centers are sent to the corresponding other data centers via network communication, so that each other data center executes the data operations contained in the received remote sub-transactions via remote direct memory access, and receives the second operation results returned by each other data center;

[0011] The execution result of the transaction is determined based on the results of the first and second operations.

[0012] This specification provides a distributed transaction execution apparatus, including:

[0013] The request receiving module is used to receive transaction requests that include several data operations;

[0014] The sub-transaction distribution module is used to divide the transaction into several sub-transactions according to the data center corresponding to each data operation, and to determine the data center to execute each sub-transaction;

[0015] The first determining module is used to determine a local sub-transaction executed by the local data center, execute the data operations contained in the local sub-transaction in the local data center via remote direct memory access, and determine the first operation result;

[0016] The second determining module is used to send remote sub-transactions executed by other data centers to the corresponding other data centers via network communication, so that each other data center executes the data operations contained in the received remote sub-transactions via remote direct memory access, and receives the second operation results returned by each other data center;

[0017] An execution module is used to determine the execution result of the transaction based on the first operation result and the second operation result.

[0018] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described distributed transaction execution method.

[0019] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the above-described distributed transaction execution method.

[0020] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects:

[0021] The distributed transaction execution method provided in this specification first receives a transaction request containing several data operations. Then, based on data centers, the transaction is divided into several sub-transactions. Within the local data center, the data operations contained in the local sub-transaction are executed using remote direct memory access (RDM) to determine the first operation result. Each remote sub-transaction is then sent to its corresponding other data centers via network communication. Each other data center executes the received data operations contained in the remote sub-transactions using RDM and receives the second operation result returned by each other data center. Finally, the transaction execution result is determined based on the first and second operation results. By using network communication between data centers and RDM within each data center, the execution efficiency of large-scale distributed transactions is improved. Attached Figure Description

[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0023] Figure 1 This document provides a schematic diagram of the execution flow of a distributed transaction.

[0024] Figure 2 This document provides a schematic diagram illustrating the execution of a distributed transaction.

[0025] Figure 3 This document provides a schematic diagram illustrating the execution of a distributed transaction.

[0026] Figure 4 This document provides a schematic diagram of a distributed transaction execution system.

[0027] Figure 5 This document provides a schematic diagram illustrating the execution of a distributed transaction.

[0028] Figure 6 This is a schematic diagram of a distributed transaction execution device provided in this specification;

[0029] Figure 7 This is a schematic diagram of an electronic device that implements a method for executing distributed transactions, as provided in this specification. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments in this specification without creative effort are within the scope of protection of this application.

[0031] Currently, in distributed systems, distributed systems using a shared-nothing architecture have good scalability because each server node is independent. However, data exchange between server nodes requires network communication (e.g., TCP / IP), and the high latency of network communication limits the execution efficiency of distributed transactions.

[0032] Distributed systems using a shared memory architecture utilize Remote Direct Memory Access (RDMA) technology to make memory access on server nodes within the same data center (e.g., the same RDMA-enabled LAN) equivalent to accessing the same memory. This results in high efficiency for distributed transactions within the same data center. However, RDMA technology places high demands on the network, requiring support for lossless Ethernet transmission and corresponding hardware that supports RDMA. Furthermore, within the same data center, shared memory architectures face memory and bandwidth contention. Therefore, to ensure the efficiency of distributed transactions, there is an upper limit to the number of server nodes in the data center, limiting the network scale of RDMA and making it difficult to achieve widespread application.

[0033] The technical solutions provided by the various embodiments of this application are described in detail below with reference to the accompanying drawings.

[0034] Figure 1 This is a schematic diagram of the execution flow of a distributed transaction in this specification, which specifically includes the following steps:

[0035] S100: Receive a transaction request that includes several data operations.

[0036] Generally, a distributed system typically comprises multiple data centers, each containing several server nodes. Each server node can function as a storage node in the distributed system, storing data for access by itself or other nodes as a transaction participant. It can also receive transaction requests from clients and act as a transaction manager, coordinating all transaction participants to execute distributed transactions. All transaction participants can reside in the same data center or in different data centers.

[0037] Based on this, in one or more embodiments of this specification, when a user sends a transaction request to a server node of the business platform through a client, the server node of the business platform can receive the transaction request containing several data operations, and act as a transaction coordinator to distribute the several data operations contained in the transaction to other transaction participants, thereby completing the execution of this distributed transaction.

[0038] The server mentioned in this manual can be a server set up on a business platform, or a device such as a desktop computer or laptop computer capable of executing the solution described in this manual. For ease of explanation, the following description will only focus on the server node acting as the transaction coordinator, and will be referred to as the coordinator from now on.

[0039] S102: Based on the data center corresponding to each data operation, the transaction is divided into several sub-transactions, and the data center for executing each sub-transaction is determined.

[0040] After obtaining a transaction containing several data operations, the coordinator can divide the transaction into several sub-transactions based on the data center corresponding to each data operation, and determine the data center to execute each sub-transaction. Subsequently, each sub-transaction can be distributed to the corresponding data center to complete the transaction execution.

[0041] Specifically, when at least some of the data operations have a strict execution order, the coordinator can first determine the data items corresponding to each data operation, then determine the data center corresponding to each data operation based on the data items corresponding to each data operation, and finally, based on the data center corresponding to each data operation and the execution order of each data operation, divide the transaction into several sub-transactions by dividing the data operations executed by the same data center and executed consecutively into the same sub-transaction, and determine the data center to execute each sub-transaction based on the correspondence between each data center and each sub-transaction during the division process.

[0042] A strict execution order means that the execution of at least some data operations depends on the results of other data operations. For example, in read-write operations, if a subsequent write operation needs to determine the data to be written based on an earlier read operation, then these two read-write operations must be executed sequentially in a strict order. The data items corresponding to each data operation include, but are not limited to, transaction identifiers, the type of data operation (e.g., read or write), the storage location of the data operation, and the data itself. The data center corresponding to each data operation refers to the data center of the server node to which the storage location of that data operation falls. For example, the data center of the server node to which the target address of a read operation falls is the data center corresponding to that read operation.

[0043] Considering the potential dependencies between data operations, the coordinator can divide the data operations sequentially according to their execution order. If a data operation requires a data item to be determined based on the results of previous data operations, the coordinator can first coordinate the execution of the previously divided sub-transactions. After obtaining the required operation results, the coordinator continues to divide the sub-transactions and coordinate their execution.

[0044] For example, suppose a transaction contains 6 data operations. Following the execution order of these operations, the first two operations correspond to data center 1, the third and fourth operations to data center 2, and the last two operations to data center 1. Then, this transaction is sequentially divided into 3 sub-transactions. The data center executing the first and third sub-transactions is data center 1, and the data center executing the second sub-transaction is data center 2.

[0045] S104: Determine the local sub-transaction to be executed by the local data center, execute the data operations contained in the local sub-transaction in the local data center via remote direct memory access, and determine the first operation result.

[0046] After dividing the received transaction into several sub-transactions as described above, the data center in this specification includes a network that supports RDMA technology among the server nodes. Based on this, in one or more embodiments of this specification, for local sub-transactions executed by the local data center where the coordinator is located, the coordinator can directly use remote direct memory access to execute the data operations contained in the local sub-transactions within the local data center and determine the first operation result.

[0047] Specifically, the coordinator can, within the local data center receiving the transaction request, first determine the server node corresponding to each data operation based on the data items included in the local sub-transaction. Then, based on the server node corresponding to each data operation, determine the memory access method corresponding to each data operation. Finally, based on the execution order of each data operation and its corresponding memory access method, execute each data operation and determine the result of the first operation.

[0048] The local data center refers to the data center where the coordinator is located. For local sub-transactions executed by the local data center, the coordinator can process them directly. During processing, if the storage address corresponding to the data item for the data operation is on the server node acting as the coordinator, the coordinator can use local memory access to directly access local memory and execute the data operation. If the storage address corresponding to the data item is on another server node within the local data center, the coordinator can use remote direct memory access (RDMA) technology to execute the corresponding data operation.

[0049] Of course, the execution of distributed transactions usually requires verification of data operation conflicts. Only after successful verification can the entire transaction be executed. Therefore, the coordinator can first execute each data operation based on the cache and record the timestamp of each data operation to generate a cached result for subsequent verification. After successful verification, the modifications made to the data in each data center during the transaction are then written to the corresponding storage location. The cached result can be a maintained read-write set. In this case, the first operation result is the cached result of executing each data operation, and this cached result must at least contain the timestamp corresponding to each data operation.

[0050] Taking a read operation as an example, the coordinator can generate a corresponding read record in the read set, recording the timestamp of the read operation, the transaction identifier of the read operation, the target address read, and the data read, etc., and use the recorded data as the operation result corresponding to the read operation. If it is a write operation, the coordinator can generate a corresponding write record in the write set, instead of directly writing the data to the corresponding target address. The specific type of data recorded can be determined as needed, and this specification does not impose any restrictions on it.

[0051] There are already mature technologies for using RDMA to perform data operations within a data center, so this manual will not elaborate on them further.

[0052] S106: The remote sub-transactions executed by each other data center are sent to the corresponding other data centers via network communication, so that each other data center executes the data operations contained in the received remote sub-transactions via remote direct memory access, and receives the second operation results returned by each other data center.

[0053] After dividing the received transaction into several sub-transactions in step S102, for each remote sub-transaction executed by a non-local data center, the coordinator can send each remote sub-transaction to the corresponding other data centers via network communication, so that each other data center can execute the data operations contained in the received remote sub-transaction via remote direct memory access and return the second operation result to the coordinator.

[0054] Generally, a data center typically contains multiple server nodes. Therefore, in one or more embodiments of this specification, for each remote sub-transaction, the coordinator can first determine the order of the data operations based on their execution order, and then determine a specific data operation from among the data operations based on this order. Then, based on the data item corresponding to the determined specific data operation, the server node executing the determined specific data operation is determined from the data center executing the remote sub-transaction. This determined server node is used as a proxy coordinator, and the remote sub-transaction is sent to the proxy coordinator via network communication. The proxy coordinator then completes the execution of the remote sub-transaction within the data center executing the remote sub-transaction. The network communication method includes at least TCP / IP-based network communication, and the designated data operation can be the first data operation executed.

[0055] Therefore, the agent coordinator can first determine the server node corresponding to each data operation based on the data items corresponding to each data operation contained in the received remote sub-transaction. Then, based on the server node corresponding to each data operation, it determines the memory access method corresponding to each data operation. Finally, based on the execution order of each data operation and the memory access method corresponding to each data operation, it executes each data operation and returns the second operation result to the coordinator via network communication.

[0056] Specifically, the process of each agent coordinator executing each sub-transaction within its corresponding data center is similar to the process of the coordinator executing it within its local data center. Refer to the corresponding explanation in step S104; it will not be repeated here. After each agent coordinator completes the data operations contained in each sub-transaction within its corresponding data center, it can return the operation results to the coordinator via network communication. The coordinator can receive the second operation results returned by other data centers. Similar to the coordinator executing local sub-transactions, when each agent coordinator executes each remote sub-transaction, it can first execute each data operation based on a cache, record the timestamp of each data operation, and generate cached results for subsequent verification. After successful verification, the modifications to the data in each data center within the transaction are then written to the corresponding storage location.

[0057] For example, suppose a remote sub-transaction contains two data operations: a read operation and a write operation, executed in the order of read first, followed by write. The data storage location for the read operation is Node 1 on server node 1 of data center 1, and the data storage location for the write operation is Node 2 on server node 2 of data center 1. The coordinator can first determine that the first data operation executed in the remote sub-transaction is the read operation. Then, it determines that Node 1, the server node storing the data corresponding to the read operation, is the proxy coordinator for that data center. The coordinator encapsulates the data required for the two read and write operations into a single remote sub-transaction request and sends it to the proxy coordinator via network communication. The proxy coordinator then executes the data operation contained in the remote sub-transaction within its own data center and returns the result of the second operation to the coordinator via network communication. The coordinator can then receive the second operation result of the remote sub-transaction returned by data center 1.

[0058] It should be noted that there is no specific order of execution between steps S104 and S106. The order of execution depends on the data center corresponding to the sub-transaction obtained in step S102. That is, if the data center corresponding to the sub-transaction obtained in step S102 is the local data center, the coordinator executes step S104; if the data center corresponding to the sub-transaction obtained in step S102 is any other data center, the coordinator executes step S106.

[0059] S108: Determine the execution result of the transaction based on the first operation result and the second operation result.

[0060] After determining the results of each data operation of the local sub-transaction executed by the coordinator, and receiving the operation results returned by each agent coordinator, the coordinator can further determine the execution result of the transaction based on each operation result.

[0061] Taking the Optimistic Concurrency Optimization (SILO) algorithm as an example, the coordinator can verify each data operation based on the results of each operation to determine whether the data operations contained in the currently processed transaction conflict with those contained in other transactions. For example, if a data item corresponding to a read operation has been written to by another transaction before verification, it indicates a data operation conflict, meaning the data read by the read operation may not be the latest data, and a transaction rollback is required. If all data operations pass verification, the coordinator can commit each data operation, completing the execution of the transaction.

[0062] Based on this, in one or more embodiments of this specification, each data operation contained in the local sub-transaction executed by the coordinator can be directly verified by the coordinator after receiving the second operation result of all data operations. Specifically, the coordinator can determine whether there is a data operation conflict between the data operations contained in the local sub-transaction and the data operations of other transactions based on the timestamps of each data operation corresponding to the first operation result, and determine the first verification result.

[0063] Specifically, if the coordinator determines that any data operation among the data operations corresponding to the first operation result conflicts with data operations in other transactions, the first verification result is considered failed, and the coordinator needs to perform a transaction rollback. Only when all data operations are free from conflicts with data operations in other transactions will the first verification result be considered successful.

[0064] For remote sub-transactions handled by the coordinator through proxy coordinators, the coordinator needs to confirm that all data operations have been executed based on the cache. After completion, based on the second operation results returned by each proxy coordinator, the coordinator sends verification requests to each proxy coordinator via network communication. This allows each proxy coordinator to determine, based on the timestamps corresponding to the data operations within its respective remote sub-transaction, whether there are any data operation conflicts between the data operations within each remote sub-transaction and those of other transactions, and then return a second verification result via network communication. The specific verification process for each proxy coordinator is similar to the process by which the coordinator determines the first verification result; please refer to the aforementioned explanations, which will not be repeated here.

[0065] Therefore, the coordinator can receive the second verification result returned by each agent coordinator via network communication. Based on the first and second verification results, the coordinator determines whether the transaction execution has passed verification. If all data operations included in the transaction have passed verification, meaning there are no data operation conflicts between the transaction and other transactions, the coordinator can write the first operation result to the local data center storage, that is, write the cached result corresponding to the modification of data in the local data center in the local sub-transaction to the corresponding storage location. The coordinator can also send commit requests to other data centers receiving each remote sub-transaction via network communication, causing each other data center to write the second operation result to its corresponding storage, that is, write the cached result corresponding to the modification of data in other data centers in the remote sub-transaction to the corresponding storage location. The agent coordinator then returns commit results via network communication, and the coordinator can receive each commit result via network communication to confirm the completion of this transaction.

[0066] Figure 2 This document provides a schematic diagram illustrating the execution of a distributed transaction. Figure 2 The diagram illustrates two data centers, Data Center 1 and Data Center 2. Data Center 1 comprises two server nodes, Node 1 and Node 2, while Data Center 2 comprises two server nodes, Node 3 and Node 4. Node 1 is the server node that receives the transaction and acts as the coordinator, responsible for coordinating the execution of the transaction by other participants. Correspondingly, Data Center 1 is the local data center.

[0067] After dividing the transaction into sub-transactions corresponding to each data center through step S102, for the local sub-transaction executed by the local data center, i.e., data center 1, node 1 can execute it directly. When the server node corresponding to the data operation is coordinator node 1, node 1 can use local memory access to execute the corresponding data operation. When the server node corresponding to the data operation is node 2 in the local data center, node 1 can use RDMA technology to execute the corresponding data operation and determine the first operation result.

[0068] For remote sub-transactions executed by data center 2 outside the local data center, node 1 can send the remote sub-transaction to the server node in data center 2 via TCP / IP network communication. The specific node to which it is sent can be determined as needed. Here, we take sending it to node 3 in data center 2 as an example. After receiving the corresponding remote sub-transaction, node 3 can execute the corresponding data operation of node 3 via local memory access or execute the corresponding data operation of node 4 via RDMA technology. After node 3 completes the execution of each data operation contained in the received remote sub-transaction, it needs to return the second operation result to node 1 via TCP / IP network communication. When node 1 receives the second operation result returned by node 3 and confirms that all data operations have been completed, it can enter the verification stage.

[0069] During the verification phase, Node 1 can directly verify the data operations contained in the local sub-transaction executed by Data Center 1 to determine the first verification result. For remote sub-transactions executed by Data Center 2, Node 1 needs to send a verification request to Node 3 via TCP / IP network communication. Upon receiving the verification request, Node 3 verifies the data operations of the remote sub-transaction executed by Data Center 2, determines the second verification result, and returns the second verification result to Node 1 via TCP / IP network communication. When Node 1 receives the second verification result returned by Node 3, it determines whether the transaction execution has passed verification based on the first and second verification results. If the verification passes, it proceeds to the commit phase.

[0070] Similar to the verification phase, in the commit phase, Node 1 can directly commit the data operations contained in the local sub-transaction executed by Data Center 1. For remote sub-transactions executed by Data Center 2, Node 1 needs to send a commit request to Node 3 via TCP / IP network communication. Upon receiving the commit request, Node 3 commits the data operations of the remote sub-transaction executed by Data Center 2 and returns the commit result to Node 1 via TCP / IP network communication. Node 1 can then confirm the completion of the distributed transaction based on the commit results.

[0071] based on Figure 1The distributed transaction execution method shown first receives a transaction request containing several data operations. Then, it divides the transaction into several sub-transactions based on data centers. Using remote direct memory access (RDM), the local sub-transactions are executed within the local data center, and a first operation result is determined. Simultaneously, each remote sub-transaction is sent to its corresponding data center via network communication. Other data centers then execute the received remote sub-transactions using RDM and receive second operation results from each data center. Finally, the transaction execution result is determined based on the first and second operation results. By using network communication between data centers and RDM within each data center, the execution efficiency of large-scale distributed transactions is improved.

[0072] Furthermore, in one or more embodiments of this specification, in step S106, when the coordinator sends each remote sub-transaction to its corresponding data center via network communication, to reduce direct remote access, the coordinator can also, for each remote sub-transaction, determine the number of data operations corresponding to each server node in the data center executing the remote sub-transaction based on the data items corresponding to the data operations contained in the remote sub-transaction. This allows the coordinator to determine the server node executing the remote sub-transaction based on the number of data operations corresponding to each server node. For example, the coordinator can determine the server node executing the most data operations from the data center executing the remote sub-transaction as the server node executing the remote sub-transaction, then use this determined server node as a proxy coordinator, and send the remote sub-transaction to this proxy coordinator via network communication. This ensures that most data operations in the remote sub-transaction are completed through the proxy coordinator using local memory access, further improving the execution efficiency of the sub-transaction and thus improving the execution efficiency of the distributed transaction.

[0073] Furthermore, in one or more embodiments of this specification, in step S102, when the data operations included in the transaction request received by the coordinator are independent of each other, there is no need to consider the execution order of the data operations. In this case, the coordinator can directly determine the data center corresponding to each data operation based on the data item corresponding to each data operation, and then divide the data operations executed by the same data center into the same sub-transaction based on the data center corresponding to each data operation. This reduces the division of sub-transactions and further improves the execution efficiency of distributed transactions. Here, "independent of each data operation" means that any two data operations are independent of each other, and there is no dependency between any two data operations.

[0074] For example, suppose a transaction contains 6 independent data operations. The first two data operations correspond to data center 1, the third and fourth data operations correspond to data center 2, and the last two data operations correspond to data center 1. Then, this transaction is sequentially divided into two sub-transactions. The data center executing the sub-transaction containing the first two data operations and the two data operations is data center 1, and the data center executing the sub-transaction containing the third and fourth data operations is data center 2.

[0075] Furthermore, since the data operations are independent of each other, in step S108, the coordinator does not need to complete all sub-transactions before verification. After the coordinator sends each sub-transaction to each agent coordinator via network communication, each agent coordinator can perform its own verification after completing the data operations contained in the received sub-transaction, and send the second verification result to the coordinator via network communication.

[0076] Therefore, the coordinator can receive the second verification result via network communication and, based on the first and second verification results, determine whether the transaction execution has passed verification. If so, the coordinator can adjust the data stored in the local data center according to the first operation result, and the coordinator can send commit requests to each of the other data centers receiving the remote sub-transactions via network communication. This causes each of the other data centers to adjust the data stored in its own data center according to the second operation result and return a commit result via network communication. The coordinator can then receive each commit result via network communication to confirm the completion of this transaction. The specific verification process can be found in the corresponding description in step S108, and will not be repeated here.

[0077] Figure 3 This document provides a schematic diagram illustrating the execution of a distributed transaction. Figure 3 The diagram illustrates two data centers, Data Center 1 and Data Center 2. Data Center 1 comprises two server nodes, Node 1 and Node 2, while Data Center 2 comprises two server nodes, Node 3 and Node 4. Node 1 is the server node that receives the transaction and acts as the coordinator, responsible for coordinating the execution of the transaction by other participants. Correspondingly, Data Center 1 is the local data center.

[0078] Compared to Figure 2 The difference is that, Figure 3 As shown, the data operations in the received transaction are independent of each other. Therefore, in step S102, when dividing the transaction into sub-transactions and in the data operation execution phase, there is no need to consider the execution order of each data operation.

[0079] After dividing the transaction into sub-transactions corresponding to each data center in step S102, for sub-transactions executed by the local data center (data center 1), node 1 can execute them directly and verify the first verification result upon completion. For sub-transactions executed by data center 2 (other than the local data center), node 1 can send the sub-transaction to node 3 in data center 2 via TCP / IP network communication. Upon receiving the corresponding sub-transaction, node 3 can execute the corresponding data operations using local memory access or RDMA technology. After completing all data operations within the received sub-transaction, node 3 can also directly verify the second verification result and return it to node 1 via TCP / IP network communication. Subsequent commit processes are similar to... Figure 2 The same applies, so I will not repeat it here.

[0080] It should be noted that, in one or more of the above embodiments, for ease of explanation, the data operations contained in the transaction are described as read and write operations. However, the specific data operations contained in the transaction can be determined as needed, and this specification does not limit this. For example, it can be data operations such as deletion, modification, and calculation.

[0081] The above describes one or more embodiments of a distributed transaction execution method provided in this specification. Based on the same idea, this specification also provides a corresponding distributed transaction execution system, such as... Figure 4 As shown.

[0082] Figure 4 This specification provides a schematic diagram of a distributed transaction execution system, which includes at least: a data center 200, and each data center 200 contains several server nodes 2001.

[0083] Access between data centers 200 is performed via network communication. For each data center 200, access between server nodes 2001 within that data center is performed via remote memory direct access.

[0084] The network communication method can be based on the TCP / IP protocol. The specific network communication method based on which protocol is used can be determined as needed, and this specification does not impose any restrictions on it.

[0085] Figure 5 This document provides a schematic diagram illustrating the execution of a distributed transaction. Figure 5 by Figure 4Based on the distributed transaction execution system shown, the diagram illustrates the processing of server node 2001 in data center 200 after receiving a transaction request. The "envelope" on the dotted line represents sub-transactions T2 and T3 obtained by dividing transaction T received by server node 2001.

[0086] After receiving a transaction request containing several data operations, server node 2001 can divide the transaction T into sub-transactions T1, T2, and T3 according to the data center corresponding to each data operation, and determine the data center to execute each sub-transaction. For the local sub-transaction T1 executed by the local data center where the node is located, the node can use remote direct memory access to execute the data operations contained in the local sub-transaction within the local data center that received the transaction request, and determine the first operation result. For remote sub-transactions T2 and T3 executed by other data centers, the node can send each remote sub-transaction to the corresponding other data center via network communication, so that each other data center can use remote direct memory access to execute the data operations contained in the received sub-transaction, and receive the second operation result returned by each other data center.

[0087] Of course, the execution of distributed transactions usually requires verification of data operation conflicts. Only after the verification is passed can the entire transaction be executed. Therefore, server node 2001 can first execute each data operation based on the cache and record the timestamp of each data operation to generate the cached results of each data operation for subsequent verification. After the verification is passed, the modifications to the data in each data center in the transaction are written to the corresponding storage location.

[0088] For local sub-transaction T1, server node 2001 can directly perform verification after confirming that all data operations have been executed based on the cache. That is, the node can determine whether there is a data operation conflict between the data operations contained in local sub-transaction T1 and the data operations of other transactions based on the timestamps of each data operation corresponding to the first operation result, and determine the first verification result.

[0089] For remote sub-transactions T2 and T3, after confirming that all data operations have been executed based on the cache, server node 2001 can send verification requests to other data centers via network communication based on the second operation results returned by other data centers. This allows other data centers to determine whether there are data operation conflicts between the data operations contained in each remote sub-transaction and the data operations of other transactions based on the timestamps corresponding to the data operations contained in their respective remote sub-transactions, and return the second verification result via network communication.

[0090] Therefore, server node 2001 can use network communication to receive the second verification result returned by other data centers. Based on the first verification result and the second verification result, it can determine whether the execution of the transaction has passed the verification. If all data operations contained in the transaction have passed the verification, that is, there is no data operation conflict between the transaction and other transactions, then the node can write the first operation result into the local data center storage. The node can also use network communication to send a commit request to each of the other data centers that received the remote sub-transactions, so that each of the other data centers writes the second operation result into its own storage and returns a commit result using network communication. The node can then use network communication to receive each commit result and confirm that the transaction has been completed.

[0091] Following the same line of thought, this specification also provides corresponding distributed transaction execution devices, such as... Figure 6 As shown.

[0092] Figure 6 A schematic diagram of a distributed transaction execution device provided in this specification includes:

[0093] The request receiving module 300 is used to receive transaction requests that include several data operations;

[0094] The sub-transaction distribution module 302 is used to divide the transaction into several sub-transactions according to the data center corresponding to each data operation, and to determine the data center to execute each sub-transaction;

[0095] The first determining module 304 is used to determine a local sub-transaction executed by the local data center, execute the data operations contained in the local sub-transaction in the local data center via remote direct memory access, and determine the first operation result;

[0096] The second determining module 306 is used to send the remote sub-transactions executed by each other data center to the corresponding other data center via network communication, so that each other data center executes the data operation contained in the received remote sub-transaction via remote direct memory access, and receives the second operation result returned by each other data center;

[0097] The execution module 308 is used to determine the execution result of the transaction based on the first operation result and the second operation result.

[0098] Optionally, the sub-transaction distribution module 302 determines the data center corresponding to each data operation based on the data items corresponding to each data operation, and divides the transaction into several sub-transactions by dividing data operations executed by the same data center and the execution order of each data operation into the same sub-transaction.

[0099] Optionally, the first determining module 304 determines a local sub-transaction executed by the local data center, determines the server node corresponding to each data operation in the local data center according to the data items corresponding to each data operation contained in the local sub-transaction, determines the memory access method corresponding to each data operation according to the server node corresponding to each data operation, executes each data operation according to the execution order of each data operation and its corresponding memory access method, and determines the first operation result. When the determined server node is the server node that receives the transaction request, the corresponding data operation is executed using the local memory access method. When the determined server node is another server node in the local data center, the corresponding data operation is executed using the remote direct memory access method.

[0100] Optionally, the second determining module 306, for each remote sub-transaction, determines a specified data operation from each data operation according to the execution order of the data operations contained in the remote sub-transaction, determines the server node that executes the specified data operation from the data center executing the remote sub-transaction according to the data item corresponding to the determined specified data operation, and sends the remote sub-transaction to the server node that executes the specified data operation using network communication.

[0101] Optionally, the second determining module 306, for each remote sub-transaction, determines the number of data operations corresponding to each server node in the data center executing the remote sub-transaction based on the data items corresponding to the data operations contained in the remote sub-transaction, determines the server node executing the remote sub-transaction based on the number of data operations corresponding to each server node, and sends the remote sub-transaction to the determined server node using network communication.

[0102] Optionally, the first operation result and the second operation result are cached results of the data operations included in the corresponding sub-transactions executed by each data center, and the cached results include at least the timestamps of the data operations performed.

[0103] The execution module 308 determines whether there is a data operation conflict between the data operations contained in the local sub-transaction and the data operations of other transactions based on the timestamps of the data operations corresponding to the first operation result, determines a first verification result, and sends verification requests to other data centers that receive each remote sub-transaction. Each other data center then determines whether there is a data operation conflict between the data operations contained in each remote sub-transaction and the data operations of other transactions based on the timestamps of the data operations corresponding to the second operation result and returns a second verification result. The module receives the second verification result and, based on the first and second verification results, determines whether the execution of the transaction passes verification. If so, it writes the first operation result to the local data center storage and sends a commit request to each other data center that receives each remote sub-transaction. This causes each other data center to write the second operation result to its corresponding other data center storage and receives the commit result returned by each other data center. The different data centers communicate via network communication.

[0104] Optionally, the data operations contained in the transaction are independent of each other;

[0105] The sub-transaction distribution module 302 determines the data center corresponding to each data operation based on the data items corresponding to each data operation, and divides the data operations executed by the same data center into the same sub-transaction based on the data center corresponding to each data operation.

[0106] This specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described... Figure 1 Provides methods for executing distributed transactions.

[0107] This instruction manual also provides Figure 7 The diagram shows the structure of the electronic device. Figure 7 At the hardware level, the electronic device includes a processor, internal bus, network interface, memory, and non-volatile memory, and may also include other hardware required for the business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to achieve the above-mentioned functions. Figure 1 Provides methods for executing distributed transactions.

[0108] Of course, in addition to the software implementation method, this specification does not exclude other implementation methods, such as the combination of hardware and software XOR logic devices, etc. In other words, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0109] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0110] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, ASICs, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0111] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0112] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.

[0113] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0114] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0115] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0116] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0117] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0118] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0119] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0120] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0121] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0122] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0123] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0124] The above description is merely an embodiment of this specification and is not intended to limit this specification. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.

Claims

1.A method for executing a distributed transaction, comprising: receiving a transaction request containing a plurality of data operations; dividing the transaction into a plurality of sub-transactions according to data centers corresponding to the data operations, and determining data centers for executing the sub-transactions; determining a local sub-transaction executed by a local data center, executing data operations contained in the local sub-transaction in the local data center by a remote direct memory access mode, and determining a first operation result, wherein for each data operation contained in the local sub-transaction, when a storage address corresponding to the data operation is in a server node receiving the transaction request, the corresponding data operation is executed by a local memory access mode, and when the storage address is in another server node in the local data center, the corresponding data operation is executed by a remote direct memory access mode; sending remote sub-transactions executed by each other data center to corresponding other data centers by a network communication mode, so that each other data center executes data operations contained in the received remote sub-transactions by a remote direct memory access mode, and receiving second operation results returned by each other data center; determining an execution result of the transaction according to the first operation result and the second operation result. 2.The method of claim 1, wherein dividing the transaction into a plurality of sub-transactions according to data centers corresponding to the data operations comprises: determining data centers corresponding to the data operations according to data items corresponding to the data operations; dividing the transaction into a plurality of sub-transactions by dividing data operations executed by the same data center and executed continuously into the same sub-transaction according to data centers corresponding to the data operations and execution orders of the data operations. 3.The method of claim 1, wherein determining a local sub-transaction executed by a local data center, executing data operations contained in the local sub-transaction in the local data center by a remote direct memory access mode, and determining a first operation result comprises: determining a local sub-transaction executed by a local data center, determining storage addresses of the data operations according to data items corresponding to the data operations contained in the local sub-transaction, and determining server nodes corresponding to the data operations in the local data center according to the storage addresses of the data operations; determining memory access modes corresponding to the data operations according to the server nodes corresponding to the data operations; executing the data operations according to execution orders of the data operations and the memory access modes corresponding to the data operations, and determining the first operation result. 4.The method of claim 1, wherein sending remote sub-transactions executed by each other data center to corresponding other data centers by a network communication mode comprises: for each remote sub-transaction, determining specified data operations from the data operations according to execution orders of the data operations contained in the remote sub-transaction; determining server nodes executing the specified data operations from the data center executing the remote sub-transaction according to data items corresponding to the specified data operations; sending the remote sub-transaction to the server nodes executing the specified data operations by a network communication mode. 5.The method of claim 1, wherein the remote sub-transactions performed by each other data center are sent to the corresponding other data center via network communication, and specifically comprising: determining, for each remote sub-transaction, a number of data operations corresponding to each server node in the data center performing the remote sub-transaction according to data items corresponding to the data operations included in the remote sub-transaction; determining a server node performing the remote sub-transaction according to the number of data operations corresponding to each server node; and sending the remote sub-transaction to the determined server node via network communication. 6.The method of claim 1, wherein the first operation result and the second operation result are cache results of data operations included in corresponding sub-transactions performed by each data center, and the cache results at least include timestamps of the data operations; and determining an execution result of the transaction according to the first operation result and the second operation result, specifically comprising: determining a first verification result according to the timestamps of each data operation corresponding to the first operation result, and judging whether there is a data operation conflict between each data operation included in the local sub-transaction and data operations of other transactions; sending a verification request to each other data center receiving each remote sub-transaction, so that each other data center judges whether there is a data operation conflict between each data operation included in each remote sub-transaction and data operations of other transactions according to the timestamps of each data operation corresponding to the second operation result and returns a second verification result; receiving the second verification result, and judging whether the execution of the transaction passes the verification according to the first verification result and the second verification result; if yes, writing the first operation result into a storage of the local data center, sending a commit request to each other data center receiving each remote sub-transaction, so that each other data center writes the second operation result into a storage of the corresponding each other data center, and receives a commit result returned by each other data center; wherein the different data centers communicate via network communication. 7.The method of claim 1, wherein a plurality of data operations included in the transaction are independent of each other; and dividing the transaction into a plurality of sub-transactions according to data centers corresponding to each data operation, specifically comprising: determining the data center corresponding to each data operation according to data items corresponding to each data operation; and dividing data operations performed by the same data center into the same sub-transaction according to the data center corresponding to each data operation. 8.An apparatus for executing a distributed transaction, comprising: a receiving request module configured to receive a transaction request including a plurality of data operations; and a sub-transaction distribution module configured to divide the transaction into a plurality of sub-transactions according to data centers corresponding to each data operation, and determine data centers performing each sub-transaction. ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ The first determining module is configured to determine a local sub-transaction executed by the local data center, execute data operations contained in the local sub-transaction in the local data center by using a remote direct memory access mode, and determine a first operation result, wherein for each data operation contained in the local sub-transaction, if a storage address corresponding to the data operation is in a server node receiving the transaction request, the corresponding data operation is executed by using a local memory access mode; and if the storage address corresponding to the data operation is in another server node in the local data center, the corresponding data operation is executed by using a remote direct memory access mode; The second determining module is configured to send remote sub-transactions executed by each other data center to corresponding other data centers by using a network communication mode, so that each other data center executes data operations contained in the received remote sub-transactions by using a remote direct memory access mode, and receives a second operation result returned by each other data center; The executing module is configured to determine an execution result of the transaction according to the first operation result and the second operation result. 9.A computer readable storage medium, the storage medium storing a computer program, the computer program being executed by a processor to implement the method in any one of claims 1 to 7. 10.An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the method in any one of claims 1 to 7 when executing the program.

Citation Information

Patent Citations

  • Method for processing database affair, client, and server

    CN107577678A

  • Distributed transaction processing method and device and storage medium

    CN113392157A