Distributed Transaction Processing Method, Apparatus and System Based on Programmable Switch

By using programmable switches to coordinate the transaction phase in distributed transaction processing, the problem of low distributed transaction performance is solved, achieving more efficient performance and throughput.

CN114860740BActive Publication Date: 2025-07-29TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110075634.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-20
Publication Date
2025-07-29
Estimated Expiration
2041-01-20

AI Technical Summary

Technical Problem

During distributed transaction processing, client nodes need to interact with multiple service nodes on multiple networks, resulting in increased latency and poor performance.

Method used

Programmable switches are used to coordinate distributed transaction processing, control the progress of the transaction processing phase by receiving and sending messages, and reduce network interactions between client nodes.

Benefits of technology

It improves the performance of distributed transaction processing, shortens latency, reduces transaction conflict probability, and improves system throughput and CPU resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860740B_ABST
    Figure CN114860740B_ABST
Patent Text Reader

Abstract

The present application provides a distributed transaction processing method, apparatus and system based on a programmable switch. The method includes: the programmable switch receives first messages sent by at least one service node participating in the current transaction processing stage of the distributed transaction. If the number of first messages received by the programmable switch for a non-final transaction processing stage is equal to the message number threshold and the type information in each first message indicates success, the programmable switch sends a second message to the target node. If the number of first messages received by the programmable switch for the final transaction processing stage is equal to the corresponding message number threshold and the type information in each first message indicates success, or if the type information in the first messages received by the programmable switch in the current transaction processing stage indicates failure, the programmable switch sends the distributed transaction processing result to the client node. Therefore, the performance of distributed transaction processing can be greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of distributed transactions, and in particular, to a distributed transaction processing method, apparatus, and system based on a programmable switch. Background Art

[0002] A transaction is an operation unit for users to concurrently access a database, and this operation unit has the characteristics of atomicity, consistency, isolation, and durability. As the amount of application data increases, data must be divided into different service nodes, and a transaction involving multiple service nodes is called a distributed transaction. A distributed transaction can ensure data consistency among multiple service nodes.

[0003] Currently, during the execution of a distributed transaction, multiple service nodes participating in the transaction need to directly perform network interactions in multiple transaction processing phases with the client node to complete. In the network interaction of each transaction processing phase, the client node needs to initiate the network interaction of the next transaction processing phase based on the network interaction result of the current transaction processing phase. Each transaction processing phase is initiated and ended by the client node, increasing the latency of distributed transaction processing and resulting in low performance of distributed transaction processing. Summary of the Invention

[0004] This application provides a distributed transaction processing method, apparatus, and system based on a programmable switch to solve the problem of low performance of distributed transaction processing.

[0005] In a first aspect, this application provides a distributed transaction processing method based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The method includes:

[0006] The programmable switch receives a first message sent by at least one service node participating in the current transaction processing phase of the distributed transaction. The current transaction processing phase is one of multiple sequentially processed transaction processing phases in the distributed transaction. The first message includes an identifier of the distributed transaction, a message count threshold, type information indicating whether the processing result of the current transaction processing phase is successful or failed, and an identifier of the target node.

[0007] If the number of first messages received by the programmable switch for a non-final transaction processing phase is equal to the message count threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing phase, then the programmable switch sends a second message to at least one service node participating in the next transaction processing phase according to the identifier of at least one service node participating in the next transaction processing phase. The second message is used to indicate to proceed to the next transaction processing phase.

[0008] If the number of first messages received by the programmable switch for the last transaction processing stage is equal to the corresponding message number threshold, and the type information in each first message indicates success, or, if the type information in the first message received by the programmable switch for the current transaction processing stage indicates failure, then the programmable switch sends a distributed transaction processing result to the client node.

[0009] Optionally, if the current transaction processing stage is the last transaction processing stage among multiple sequentially processed transaction processing stages, then the identifier of the target node in the first message is the identifier of the client node.

[0010] The programmable switch sends a distributed transaction processing result to the client node, including:

[0011] The programmable switch sends a distributed transaction processing result to the client node according to the identifier of the client node included in the first message.

[0012] Optionally, the distributed transaction processing method based on the programmable switch further includes:

[0013] If the type information in the first message received by the programmable switch indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing stage, then the programmable switch sends a third message to at least one service node participating in the rollback transaction processing stage, and the third message is used to indicate to perform the rollback transaction processing stage.

[0014] Optionally, the multiple sequentially processed transaction processing stages are a lock holding stage, a version check stage, and a data writing stage.

[0015] Optionally, the programmable switch includes multiple switching processing units, and at least one of the multiple switching processing units is respectively used to receive the first message sent by at least one service node participating in the current transaction processing stage.

[0016] In a second aspect, the present application provides a distributed transaction processing method based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The method includes:

[0017] The client node sends a fourth message to each service node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, the identifiers of at least one service node participating in each transaction processing stage, the message number threshold corresponding to each transaction processing stage, and the fourth message is further used to indicate to start processing the first transaction processing stage.

[0018] The client node receives the distributed transaction processing result sent by the programmable switch after the last transaction processing stage is completed, or when the type information in the first message of the current transaction processing stage indicates failure.

[0019] Optionally, the fourth message is further used to indicate at least one service node that needs to execute the rollback transaction processing stage after the processing result of each transaction processing stage is a failure.

[0020] In a third aspect, the present application provides a distributed transaction processing method based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The method includes:

[0021] The service node receives the fourth message sent by the client node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, the identifiers of at least one service node participating in each transaction processing stage, and the message count threshold corresponding to each transaction processing stage. The fourth message is further used to indicate the start of processing the first transaction processing stage.

[0022] The service node sequentially processes the current transaction processing stage according to the fourth message and sends a first message to the programmable switch. The current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes the identifier of the distributed transaction, the message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and the identifier of the target node.

[0023] Wherein, when the current transaction processing stage is not the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing stage.

[0024] When the current transaction processing stage is the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

[0025] Optionally, after sending the first message to the programmable switch, it further includes:

[0026] The service node receives the second message sent by the programmable switch. The second message is used to indicate to proceed to the next transaction processing stage; the service node processes the next transaction processing stage.

[0027] Optionally, the fourth message is further used to indicate at least one service node that needs to execute the rollback transaction processing stage after the processing result of each transaction processing stage is a failure.

[0028] When the type information in the first message indicates failure, the identifier of the target node is the identifier of at least one service node participating in the rollback transaction processing phase.

[0029] Optionally, the distributed transaction processing method based on a programmable switch further includes:

[0030] The service node receives a third message sent by the programmable switch, where the third message is used to indicate to perform the rollback transaction processing phase; the service node processes the rollback transaction processing phase.

[0031] In a fourth aspect, the present application provides a distributed transaction processing device based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device is included in the programmable switch, and the device includes:

[0032] A receiving module, configured to receive a first message sent by at least one service node participating in the current transaction processing phase of the distributed transaction. The current transaction processing phase is one of multiple sequentially processed transaction processing phases in the distributed transaction. The first message includes the identifier of the distributed transaction, the message number threshold, type information indicating whether the processing result of the current transaction processing phase is successful or failed, and the identifier of the target node.

[0033] A sending module, configured to, if the number of first messages received by the receiving module for a non-final transaction processing phase is equal to the message number threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing phase, then send a second message to at least one service node participating in the next transaction processing phase according to the identifier of at least one service node participating in the next transaction processing phase. The second message is used to indicate to perform the next transaction processing phase; and if the number of first messages received by the receiving module for the final transaction processing phase is equal to the corresponding message number threshold, and the type information in each first message indicates success, or if the type information in the first message received by the receiving module for the current transaction processing phase indicates failure, then send the distributed transaction processing result to the client node.

[0034] Optionally, if the current transaction processing phase is the final transaction processing phase among multiple sequentially processed transaction processing phases, then the identifier of the target node in the first message is the identifier of the client node.

[0035] The sending module is specifically configured to:

[0036] Send the distributed transaction processing result to the client node according to the identifier of the client node included in the first message.

[0037] Optionally, the sending module is further configured to:

[0038] If the type information in the first message received by the receiving module indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing phase, then send a third message to at least one service node participating in the rollback transaction processing phase, where the third message is used to indicate to perform the rollback transaction processing phase.

[0039] Optionally, the multiple sequentially processed transaction processing phases are a lock holding phase, a version check phase, and a data writing phase.

[0040] Optionally, the programmable switch includes multiple switching processing units, and each switching processing unit includes a distributed transaction processing device based on the programmable switch.

[0041] In a fifth aspect, the present application provides a distributed transaction processing device based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device is included in the client node, and the device includes:

[0042] A sending module, configured to send a fourth message to each service node. The fourth message includes the identifier of the distributed transaction, the identifiers of the multiple sequentially processed transaction processing phases in the distributed transaction, the identifiers of at least one service node participating in each transaction processing phase, and the message number threshold corresponding to each transaction processing phase. The fourth message is further used to indicate to start processing the first transaction processing phase.

[0043] A receiving module, configured to receive the distributed transaction processing result sent by the programmable switch after the last transaction processing phase is completed, or when the type information in the first message in the current transaction processing phase indicates failure.

[0044] Optionally, the fourth message is further used to indicate at least one service node that needs to perform the rollback transaction processing phase after the processing result of each transaction processing phase is a failure.

[0045] In a sixth aspect, the present application provides a distributed transaction processing device based on a programmable switch, which is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device is included in the service node, and the device includes:

[0046] A receiving module, configured to receive a fourth message sent by a client node. The fourth message includes an identifier of a distributed transaction, identifiers of multiple sequentially processed transaction processing phases in the distributed transaction, identifiers of at least one service node participating in each transaction processing phase, and a message count threshold corresponding to each transaction processing phase. The fourth message is further configured to indicate the start of processing the first transaction processing phase.

[0047] A processing module, configured to sequentially process the current transaction processing phase according to the fourth message. The current transaction processing phase is one of the multiple sequentially processed transaction processing phases in the distributed transaction.

[0048] A sending module, configured to send a first message to a programmable switch. The first message includes an identifier of a distributed transaction, a message count threshold, type information indicating whether the processing result of the current transaction processing phase is successful or failed, and an identifier of a target node.

[0049] Wherein, when the current transaction processing phase is not the last transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing phase.

[0050] When the current transaction processing phase is the last transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

[0051] Optionally, the receiving module is further configured to:

[0052] After the sending module sends the first message to the programmable switch, receive a second message sent by the programmable switch. The second message is used to indicate the start of the next transaction processing phase.

[0053] The processing module is further configured to process the next transaction processing phase.

[0054] Optionally, the fourth message is further configured to indicate at least one service node that needs to perform a rollback transaction processing phase after the processing result of each transaction processing phase is failed.

[0055] When the type information in the first message indicates failure, the identifier of the target node is the identifier of at least one service node participating in the rollback transaction processing phase.

[0056] Optionally, the receiving module is further configured to:

[0057] Receive a third message sent by the programmable switch. The third message is used to indicate the start of the rollback transaction processing phase.

[0058] The processing module is further configured to process the rollback transaction processing phase.

[0059] In a seventh aspect, the present application provides a distributed transaction processing apparatus based on a programmable switch, including: a memory and a processor;

[0060] The memory is used for storing program instructions;

[0061] The processor is used for calling the program instructions in the memory to execute the distributed transaction processing method based on the programmable switch as described in the first aspect of the present application.

[0062] In an eighth aspect, the present application provides a distributed transaction processing apparatus based on a programmable switch, including: a memory and a processor;

[0063] The memory is used for storing program instructions;

[0064] The processor is used for calling the program instructions in the memory to execute the distributed transaction processing method based on the programmable switch as described in the second aspect of the present application.

[0065] In a ninth aspect, the present application provides a distributed transaction processing apparatus based on a programmable switch, including: a memory and a processor;

[0066] The memory is used for storing program instructions;

[0067] The processor is used for calling the program instructions in the memory to execute the distributed transaction processing method based on the programmable switch as described in the third aspect of the present application.

[0068] In a tenth aspect, the present application provides a distributed transaction processing system based on a programmable switch, including a programmable switch, a client node, and multiple service nodes.

[0069] Among them, the programmable switch is used for executing the method as described in the first aspect of the present application, the client node is used for executing the method as described in the second aspect of the present application, and the service node is used for executing the method as described in the third aspect of the present application.

[0070] Optionally, there may be multiple programmable switches, and the multiple programmable switches form a tree structure for executing the method as described in the first aspect of the present application.

[0071] In an eleventh aspect, the present application provides a computer-readable storage medium, in which computer program instructions are stored, and when the computer program instructions are executed, the method as described in the first aspect of the present application is implemented.

[0072] In a twelfth aspect, the present application provides a computer-readable storage medium, in which computer program instructions are stored, and when the computer program instructions are executed, the method as described in the second aspect of the present application is implemented.

[0073] In a thirteenth aspect, the present application provides a computer-readable storage medium storing computer program instructions, which, when executed, implement the method described in the third aspect of the present application.

[0074] In a fourteenth aspect, the present application provides a computer program product including a computer program, which, when executed by a processor, implements the method described in the first aspect of the present application.

[0075] In a fifteenth aspect, the present application provides a computer program product including a computer program, which, when executed by a processor, implements the method described in the second aspect of the present application.

[0076] In a sixteenth aspect, the present application provides a computer program product including a computer program, which, when executed by a processor, implements the method described in the third aspect of the present application.

[0077] The method, apparatus, and system for distributed transaction processing based on a programmable switch provided by the present application send a fourth message from a client node to each service node. Each service node processes the current transaction processing stage in sequence according to the received fourth message. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in a distributed transaction. The service node sends a first message to the programmable switch. The programmable switch receives the first messages sent by at least one service node. If the number of first messages received by the programmable switch for a non-final transaction processing stage is equal to the message number threshold and the type information in each first message indicates success, the programmable switch sends a second message to at least one service node participating in the next transaction processing stage. If the number of first messages received by the programmable switch for the final transaction processing stage is equal to the corresponding message number threshold and the type information in each first message indicates success, or if the type information in the first message received by the programmable switch for the current transaction processing stage indicates failure, the programmable switch sends the distributed transaction processing result to the client node, and the client node receives the distributed transaction processing result. Since the present application can make full use of the storage capacity and programmable ability of the programmable switch and use the programmable switch for distributed transaction processing, the performance of distributed transaction processing can be greatly improved, the latency of distributed transaction processing can be shortened, the probability of conflicts between transactions can be reduced, and the throughput of the entire system can be increased. Moreover, since the network interaction between the client and the server is reduced, the utilization rate of the central processing unit (CPU) resources of the client is improved. Description of the Drawings

[0078] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0079] Figure 1 Schematic diagram of an application scenario provided by an embodiment of the present application;

[0080] Figure 2 Flowchart of a distributed transaction processing method based on a programmable switch provided by an embodiment of the present application;

[0081] Figure 3 Schematic diagram of the successful submission process of a single read-write distributed transaction provided by an embodiment of the present application;

[0082] Figure 4 Schematic diagram of a first message provided by an embodiment of the present application;

[0083] Figure 5 Flowchart of a distributed transaction processing method based on a programmable switch provided by another embodiment of the present application;

[0084] Figure 6 Schematic diagram of multiple switching processing units of a programmable switch provided by an embodiment of the present application;

[0085] Figure 7 Schematic diagram of the internal processing logic of a programmable switch provided by an embodiment of the present application;

[0086] Figure 8 Schematic diagram of multiple programmable switches participating in the transaction submission process in parallel provided by an embodiment of the present application;

[0087] Figure 9 Schematic diagram of the structure of a distributed transaction processing device based on a programmable switch provided by an embodiment of the present application;

[0088] Figure 10 Schematic diagram of the structure of a distributed transaction processing device based on a programmable switch provided by another embodiment of the present application;

[0089] Figure 11 Schematic diagram of the structure of a distributed transaction processing device based on a programmable switch provided by another embodiment of the present application;

[0090] Figure 12 Schematic diagram of the structure of a distributed transaction processing device based on a programmable switch provided by another embodiment of the present application;

[0091] Figure 13 Schematic structural diagram of a distributed transaction processing apparatus based on a programmable switch according to another embodiment of the present application;

[0092] Figure 14 Schematic structural diagram of a distributed transaction processing apparatus based on a programmable switch according to another embodiment of the present application;

[0093] Figure 15 Schematic diagram of a distributed transaction processing system based on a programmable switch according to an embodiment of the present application;

[0094] Figure 16 Schematic structural diagram of a distributed transaction processing apparatus based on a programmable switch according to another embodiment of the present application. Detailed implementation manners

[0095] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some but not all of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts based on the embodiments in the present application belong to the scope of protection of the present application.

[0096] With the increase in the amount of various application data, data must be divided into different service nodes, and a transaction involving multiple service nodes is called a distributed transaction. A distributed transaction can ensure data consistency among multiple service nodes. Currently, during the execution of a distributed transaction, multiple service nodes participating in the transaction need to directly perform network interactions in multiple transaction processing phases with the client node to complete. In the network interaction in each transaction processing phase, the client node needs to initiate the network interaction in the next transaction processing phase based on the network interaction result in the current transaction processing phase. Each transaction processing phase is initiated and ended by the client node, increasing the latency of distributed transaction processing and resulting in low performance of distributed transaction processing.

[0097] A programmable switch (Programable Switch) is a network switch with programming capabilities. With the development of network hardware, programmable switches with programmable capabilities have been introduced. Compared with traditional switches, intelligent network hardware can not only accelerate network protocol processing (such as load balancing, traffic control), but also provide the ability to support specific calculations and limited memory storage capabilities. The control of the programmable switch can be completed through a data plane programming language (such as the P4 language), and the processing of the network (modification, forwarding, discarding, etc.) can be completed according to the programming logic, and new network protocols can be customized.

[0098] Therefore, the present application provides a distributed transaction processing method, apparatus, and system based on a programmable switch. By initiating the submission of a distributed transaction by a client, network interactions in multiple transaction processing stages are carried out between the programmable switch and multiple service nodes participating in the transaction to complete the submission of the distributed transaction. Since the programmable switch is used for the processing of distributed transactions, the performance of distributed transaction processing can be greatly improved, the latency of distributed transaction processing can be shortened, the probability of conflicts between transactions can be reduced, the throughput of the entire system can be increased, and the expandability of a data center with multiple switches and multiple servers is also provided.

[0099] Figure 1 FIG. is a schematic diagram of an application scenario provided by an embodiment of the present application. As Figure 1 shown, the client 110 initiates the submission of a distributed transaction. After receiving the request for the submission of the distributed transaction initiated by the client 110, multiple service nodes 120 respectively perform network interactions in corresponding multiple transaction processing stages with the programmable switch 130 to complete the submission of the distributed transaction. The specific implementation process of the submission of the distributed transaction can refer to the solutions of the following embodiments. It should be noted that the application scenarios of the solutions of the present application are not limited to Figure 1 shown.

[0100] Figure 2 FIG. is a flowchart of a distributed transaction processing method based on a programmable switch provided by an embodiment of the present application. As Figure 2 shown, the method of this embodiment includes:

[0101] S201. The client node sends a fourth message to each service node. Correspondingly, the service node receives the fourth message sent by the client node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, the identifiers of at least one service node participating in each transaction processing stage, the message number threshold corresponding to each transaction processing stage, and the fourth message is also used to indicate the start of processing the first transaction processing stage.

[0102] Optionally, the multiple sequentially processed transaction processing stages are a lock holding stage, a version check stage, and a data writing stage.

[0103] S202. The service node sequentially processes the current transaction processing stage according to the fourth message. The current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction.

[0104] S203. The service node sends a first message to the programmable switch. Correspondingly, the programmable switch receives the first message sent by at least one service node participating in the current transaction processing stage of the distributed transaction. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes the identifier of the distributed transaction, the message count threshold, the type information indicating whether the processing result of the current transaction processing stage is successful or failed, and the identifier of the target node.

[0105] Wherein, when the current transaction processing stage is not the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing stage.

[0106] When the current transaction processing stage is the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

[0107] Wherein, Figure 2 Taking the example that service node 1, service node 2, and service node 3 all participate in the current transaction processing stage for illustration, this embodiment is not limited thereto.

[0108] S204. If the number of first messages received by the programmable switch for a non-last transaction processing stage is equal to the message count threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing stage, then the programmable switch sends a second message to at least one service node participating in the next transaction processing stage according to the identifier of at least one service node participating in the next transaction processing stage. The second message is used to indicate to proceed to the next transaction processing stage.

[0109] Wherein, Figure 2 Taking the example that service node 1, service node 2, and service node 3 all participate in the next transaction processing stage for illustration, this embodiment is not limited thereto.

[0110] S205. If the number of first messages received by the programmable switch for the last transaction processing stage is equal to the corresponding message count threshold, and the type information in each first message indicates success, or if the type information in the first message received by the programmable switch for the current transaction processing stage indicates failure, then the programmable switch sends the distributed transaction processing result to the client node. Correspondingly, the client node receives the distributed transaction processing result sent by the programmable switch after the processing in the last transaction processing stage is completed, or when the type information in the first message for the current transaction processing stage indicates failure.

[0111] Optionally, if the current transaction processing stage is the last transaction processing stage among multiple sequentially processed transaction processing stages, the identifier of the target node in the first message is the identifier of the client node. The programmable switch sends the distributed transaction processing result to the client node according to the identifier of the client node included in the first message.

[0112] In this embodiment, Figure 3 FIG. is a schematic diagram of the successful submission process of a single read-write distributed transaction provided by an embodiment of the present application. Taking multiple service nodes as service node 1, service node 2, and service node 3 as examples, and the transaction processing stages including: a lock holding stage, a version check stage, and a data writing stage as examples, refer to Figure 3 , and the solution of this embodiment will be illustrated by examples. As Figure 3 shown, the read-write distributed transaction is initiated by the client node. The service nodes where the read set of this transaction is located are service node 1 and service node 3, and the service nodes where the write set of this transaction is located are service node 1 and service node 2. Some service nodes only process one transaction processing stage, and some service nodes will process multiple transaction processing stages. For example, corresponding to Figure 3 , among them, the transaction processing stages sequentially processed by service node 1 include: a lock holding stage, a version check stage, and a data writing stage. The transaction processing stages sequentially processed by service node 2 include: a lock holding stage and a data writing stage. The transaction processing stages sequentially processed by service node 3 include: a version check stage. After the execution stage of this transaction is completed, the client node initiates the submission of this transaction. The client node sends a data message to each service node. This data message can refer to the above-mentioned fourth message. Specifically, the fourth message includes the identifier of the distributed transaction, the transaction processing stages sequentially processed by the above 3 service nodes respectively, and the message number threshold corresponding to each transaction processing stage (2 for the lock holding stage, 2 for the version check stage, and 2 for the data writing stage). The fourth message also includes the specific read and write data of the transaction. For example, the write data is the address and data of the write data set, and the read data is the address and its version information of the read data set. The fourth message is also used to indicate the start of processing the first transaction processing stage. After the service nodes where the write set is located (i.e., service node 1 and service node 2) receive the fourth message sent by the client node, they start processing the first transaction processing stage, that is, enter the lock holding stage. The service nodes where the write set is located (i.e., service node 1 and service node 2) acquire the locks of all write sets and send a coordination operation message indicating successful lock holding to the programmable switch. This coordination operation message can refer to the above-mentioned first message.

[0113] Figure 4 FIG. is a schematic diagram of the first message provided by an embodiment of the present application. The specific message format of the first message is as Figure 4As shown, the network protocol (Ethereal, EHT) header and the Internet Protocol (IP) header represent the packet headers of the ordinary Ethernet protocol and the IP protocol. The source port of the User Datagram Protocol (UDP) network packet header represents the identifier of the distributed transaction commit mechanism network protocol. The destination port of the UDP network packet header represents the thread identifier corresponding to the service node (the thread corresponding to the service node participates in the processing of the distributed transaction). The unique identifier (Identity, ID) of the distributed transaction is used to identify the transaction and handle network out-of-order and packet loss. The type is the type information indicating whether the processing result of the current transaction processing stage is successful or failed. The threshold is the threshold of the number of messages, and this threshold is equal to the number of service nodes participating in the current processing stage of the transaction. The participating nodes are the identifiers of the target nodes. For example, corresponding to Figure 3 , the first message that is successful in the lock-holding stage, its type information is successful in the lock-holding stage, the threshold of the number of messages is 2, and the identifiers of the target nodes are service node 1 and service node 3 that participate in the next transaction processing stage.

[0114] The programmable switch receives the first message for the lock-holding stage, records the number of the received first messages, determines whether the number of the received first messages is equal to the threshold of the number of messages, and determines whether the type information in each first message indicates success. Compared with the prior art, this first message is processed by the programmable switch instead of by the client node, that is, the coordination operation in the distributed transaction commit process is offloaded to the programmable switch (such as Figure 3The operation in () is unloaded. After the programmable switch receives the first message with the last successful lock holding (i.e., the coordination operation message sent by service node 2), at this time, the number of the first messages received by the programmable switch is equal to the message number threshold (i.e., 2), and the type information in each first message (i.e., the first messages sent by service node 1 and service node 2 respectively) indicates success in the lock holding phase. Then the programmable switch broadcasts the last coordination operation message with successful lock holding in the lock holding phase to all service nodes where the read set is located (i.e., service node 1 and service node 3) according to the identifier of the target node. This coordination operation message can refer to the above-mentioned second message, and the second message is used to indicate the next transaction processing phase. After the service nodes where the read set is located (i.e., service node 1 and service node 3) receive the second message broadcast by the programmable switch, they enter the version check phase, confirm that the data in the read set has not been changed by other parallel transactions from the execution phase to the version check phase, and send the coordination operation message with successful version check to the programmable switch. This coordination operation message can refer to the above-mentioned first message. Among them, for the first message corresponding to the successful version check phase, its type information is successful in the version check phase, the message number threshold is 2, and the identifier of the target node is service node 1 and service node 2 participating in the next transaction processing phase.

[0115] The programmable switch receives the first message for the version check phase, records the number of the first messages received, determines whether the number of the first messages received is equal to the message number threshold, and determines whether the type information in each first message indicates success. After the programmable switch receives the last first message with successful version check (i.e., the coordination operation message sent by service node 3), at this time, the number of the first messages received by the programmable switch is equal to the message number threshold (i.e., 2), and the type information in each first message (i.e., the first messages sent by service node 1 and service node 3 respectively) indicates success in the version check phase. Then the programmable switch broadcasts the last coordination operation message with successful version check in the version check phase to all service nodes where the write set is located (i.e., service node 1 and service node 2) according to the identifier of the target node. This coordination operation message can refer to the above-mentioned second message, and the second message is used to indicate the next transaction processing phase. After the service nodes where the write set is located (i.e., service node 1 and service node 2) receive the second message broadcast by the programmable switch, they enter the write data phase. The service nodes where the write set is located (i.e., service node 1 and service node 2) first perform the unlock operation, then update the data in the transaction write set to the local storage, and finally send the coordination operation message with successful write data to the programmable switch. This coordination operation message can refer to the above-mentioned first message. Among them, for the first message corresponding to the write data phase, its type information is successful in the write data phase, the message number threshold is 2, and since the write data phase is the last transaction processing phase, the identifier of the target node is the identifier of the client node.

[0116] The programmable switch receives a first message for the write data phase, records the number of received first messages, determines whether the number of received first messages is equal to the message number threshold, and determines whether the type information in each first message indicates success. After the programmable switch receives the last first message with successful write data (i.e., the coordination operation message sent by service node 2), at this time, the number of first messages received by the programmable switch is equal to the message number threshold (i.e., 2), and the type information in each first message (i.e., the first messages sent by service node 1 and service node 2 respectively) indicates success in the write data phase. Then, the programmable switch forwards the last coordination operation message with successful write data in the write data phase to the client node according to the identifier of the client node, and this coordination operation message is the above-mentioned distributed transaction processing result. After the client node receives this distributed transaction processing result, it indicates that the distributed transaction is successfully committed.

[0117] For Figure 3 the general read-write distributed transaction in, compared with the prior art, the method of this embodiment shortens the time of the commit process to two-thirds, at the same time shortens the lock-holding time to one-half, shortens the time interval between two read read-set versions to three-fourths, and except for the start and end of the commit, the client node's thread is not required to participate in the distributed transaction commit process, reducing the CPU resource consumption of the client node's thread.

[0118] Based on the above embodiment, if the type information in the first message received by the programmable switch in the lock-holding phase or the version check phase indicates failure, and the identifier of the target node in this first message is the identifier of the client node, then the programmable switch sends a distributed transaction processing result to the client node, and this result indicates that the distributed transaction commit fails. When the client node receives that the distributed transaction processing result is a failure, it performs corresponding processing, such as: re-initiating the commit of this distributed transaction.

[0119] Optionally, the client node may include multiple threads, and these multiple threads may simultaneously initiate the commit of multiple distributed transactions. The multiple service nodes participating in the distributed transaction commit may include multiple threads, and these multiple threads may process multiple distributed transactions in parallel. The specific processing process of each service node refers to the above embodiment.

[0120] The distributed transaction processing method based on a programmable switch provided by this application sends a fourth message from a client node to each service node. The service node processes the current transaction processing stage in sequence according to the received fourth message. The current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction; the service node sends a first message to the programmable switch. The programmable switch receives the first messages sent by at least one service node. If the number of first messages received by the programmable switch for a non-final transaction processing stage is equal to the message number threshold, and the type information in each first message indicates success, the programmable switch sends a second message to at least one service node participating in the next transaction processing stage; if the number of first messages received by the programmable switch for the final transaction processing stage is equal to the corresponding message number threshold, and the type information in each first message indicates success, or if the type information in the first message received by the programmable switch for the current transaction processing stage indicates failure, the programmable switch sends the distributed transaction processing result to the client node, and the client node receives the distributed transaction processing result. Since this application can make full use of the storage capacity and programmable ability of the programmable switch and use the programmable switch for the processing of distributed transactions, it can greatly improve the performance of distributed transaction processing, shorten the latency of distributed transaction processing, reduce the probability of conflicts between transactions, and improve the throughput of the entire system. Moreover, because the network interaction between the client and the server is reduced, the CPU resource utilization rate of the client is improved.

[0121] Based on the embodiments shown in Figure 2 In some embodiments, Figure 5 is a flowchart of the distributed transaction processing method based on a programmable switch provided by another embodiment of this application. As Figure 5 shown, the method of this embodiment includes:

[0122] S501. The client node sends a fourth message to each service node. Correspondingly, the service node receives the fourth message sent by the client node. The fourth message includes the identifier of the distributed transaction, the identifiers of the multiple sequentially processed transaction processing stages in the distributed transaction, the identifiers of at least one service node participating in each transaction processing stage, the message number threshold corresponding to each transaction processing stage, and the fourth message is further used to indicate the start of processing the first transaction processing stage.

[0123] S502. The service node processes the current transaction processing stage in sequence according to the fourth message. The current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction.

[0124] S503. The service node sends a first message to the programmable switch. Correspondingly, the programmable switch receives the first message sent by at least one service node participating in the current transaction processing stage of the distributed transaction. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes the identifier of the distributed transaction, the message number threshold, the type information indicating whether the processing result of the current transaction processing stage is successful or failed, and the identifier of the target node.

[0125] In this embodiment, the specific implementation processes of S501, S502, and S503 can refer to Figure 2 the relevant descriptions of the illustrated embodiments, which will not be elaborated here.

[0126] S504. If the number of first messages received by the programmable switch for a non-final transaction processing stage is equal to the message number threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing stage, then the programmable switch sends a second message to at least one service node participating in the next transaction processing stage according to the identifier of at least one service node participating in the next transaction processing stage. Correspondingly, the service node receives the second message sent by the programmable switch. The second message is used to indicate to proceed to the next transaction processing stage. The service node processes the next transaction processing stage.

[0127] In this embodiment, on the basis of Figure 2 the illustrated embodiment, since some service nodes may only process one transaction processing stage and some service nodes may process multiple transaction processing stages, therefore, the service nodes participating in the next transaction processing stage need to receive the second message sent by the programmable switch and process the next transaction processing stage according to the second message. For example: Figure 3 in, service node 3 only processes one transaction processing stage, i.e., version check; after service node 1 receives the second message broadcast by the programmable switch for successful lock holding, it enters the next transaction processing stage, i.e., the version check stage, and processes the version check stage, that is, to confirm that the data in the read set has not been changed by other parallel transactions from the execution stage to the version check stage.

[0128] S505. If the type information in the first message received by the programmable switch indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing stage, then the programmable switch sends a third message to at least one service node participating in the rollback transaction processing stage. Correspondingly, the service node receives the third message sent by the programmable switch. The third message is used to indicate to proceed to the rollback transaction processing stage.

[0129] Optionally, the fourth message is further used to indicate at least one service node that needs to execute a rollback transaction processing phase after the processing result in each transaction processing phase fails.

[0130] Optionally, when the type information in the first message indicates failure, the identifier of the target node is the identifier of at least one service node participating in the rollback transaction processing phase.

[0131] Optionally, when the type information in the first message indicates failure, the programmable switch filters and discards other first messages received after this first message to reduce network overhead.

[0132] In this embodiment, the fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing phases in the distributed transaction, and the identifiers of at least one service node participating in each transaction processing phase. Therefore, according to the fourth message, at least one service node that needs to execute a rollback transaction processing phase after the processing result in each transaction processing phase fails can be obtained. For example: Figure 3 In, the service nodes where the distributed transaction write set is located in the fourth message are service node 1 and service node 2. When the service nodes where the write set is located fail to execute in the current transaction processing phase, a rollback transaction processing needs to be performed. If the type information in the first message received by the programmable switch in the lock holding phase or the version check phase indicates failure, and the identifier of the target node is service node 1 and service node 2 participating in the rollback transaction processing phase, the programmable switch sends a third message to service node 1 and service node 2 participating in the rollback transaction processing phase. Correspondingly, service node 1 and service node 2 respectively receive the third message sent by the programmable switch. The third message is used to indicate to perform the rollback transaction processing phase.

[0133] S506. The service node processes the rollback transaction processing phase.

[0134] In this embodiment, after receiving the third message sent by the programmable switch, the service node processes the rollback transaction processing phase. Among them, Figure 5 In, service node 1, service node 2, and service node 3 all participating in the rollback transaction processing phase are taken as an example for illustration, and this embodiment is not limited thereto.

[0135] For example, referring to Figure 3 In, after service node 1 and service node 2 respectively receive the third message sent by the programmable switch, they respectively execute a lock release operation, and the lock release operation is the rollback transaction processing phase.

[0136] S507. If the number of first messages for the last transaction processing stage received by the programmable switch is equal to the corresponding message number threshold, and the type information in each first message indicates success, or if the type information in the first message for the current transaction processing stage received by the programmable switch indicates failure, then the programmable switch sends a distributed transaction processing result to the client node. Correspondingly, the client node receives the distributed transaction processing result sent by the programmable switch after the processing in the last transaction processing stage is completed, or when the type information in the first message for the current transaction processing stage indicates failure.

[0137] In this embodiment, for the specific implementation process of S507, reference can be made to Figure 2 the relevant descriptions in the illustrated embodiment, which will not be elaborated here.

[0138] Optionally, the programmable switch includes multiple switching processing units, and at least one switching processing unit among the multiple switching processing units is respectively used to receive the first messages sent by at least one service node participating in the current transaction processing stage.

[0139] In this embodiment, the physical ports of the programmable switch are statically divided into multiple different computing units, and this computing unit is the switching processing unit. Multiple computing units jointly complete the processing of different transaction processing stages of distributed transactions for packets across different physical ports. Multiple computing units perform parallel processing and communicate through the internal mechanism of the programmable switch, which can avoid single-point bottlenecks. Figure 6 It is a schematic diagram of multiple switching processing units of the programmable switch provided in an embodiment of the present application. As Figure 6 shown, multiple physical ports are mapped to different switching processing units, which can also be called computing units. Each computing unit consists of two parts: an ingress and an egress. The network messages processed by the ingress can be forwarded to the egress of other computing units, thereby completing the communication tasks of different physical ports. The network messages processed by the egress can be retransmitted to the ingress, thereby completing the loop processing of network packets. Taking the transaction initiated from the client node where computing unit 1 is located as an example, the distributed transaction requires other computing units (such as computing unit N-1 , computing unit N)'s service nodes. Messages from the service nodes of each other computing unit can directly reach the Egress of computing unit 1. The Egress of computing unit 1 receives the first message sent by at least one service node participating in the current transaction processing stage, and retransmits this first message to the Ingress of computing unit 1. The service nodes (computing unit 1) located in the same computing unit receive the first message sent by at least one service node participating in the current transaction processing stage and send this first message to the Ingress of computing unit 1. The Ingress of computing unit 1 aggregates the first messages sent by the service nodes of computing unit 1 and the first messages retransmitted by the Egress of computing unit 1, and performs the processing of the corresponding transaction processing stage. The second message or the third message is forwarded by the Ingress of computing unit 1 to the Egress of the corresponding computing unit according to the identifier of the target node. For the specific processing method, refer to S504 or S505. By making full use of the processing capabilities of multiple computing units, the message aggregation operation is completed in advance within each computing unit, thereby reducing the message transmission between different computing units.

[0140] Since the present application can make full use of the storage capacity and programmable ability of the programmable switch, and use the programmable switch for the processing of distributed transactions, multiple switching processing units of the programmable switch process distributed transactions in parallel. Therefore, it can greatly improve the performance of distributed transaction processing, shorten the latency of distributed transaction processing, reduce the probability of conflicts between transactions, and improve the throughput of the entire system. During the process of distributed transaction processing, the correctness and consistency of distributed transaction processing are ensured by rolling back the transaction processing stage. Also, because the network interaction between the client and the server is reduced, the CPU resource utilization rate of the client is improved.

[0141] Based on the above embodiments, different priorities can be assigned to the network messages in the submission process of different distributed transactions, and the scheduling and processing can be performed according to the priorities in both the programmable switch and the service nodes. The programmable switch sets different processing queues for different priorities and preferentially processes messages with high priorities. When the service node receives a batch of network requests simultaneously, after sorting according to the network priority, it preferentially processes messages with high priorities. Specifically, when distributed transactions initiated by different client nodes perform operations on the same data, during the submission of the distributed transaction, through the priority scheduling in the programmable switch and the service node, the critical path can be made as short as possible. This critical path includes, for example, the critical path of holding locks, which is from the lock-holding operation in the lock-holding stage to the lock-release operation in the rollback transaction processing stage or the write data stage (such as Figure 3The critical path from the lock-holding operation in the slave lock-holding stage of the middle service node 2 to the lock-release operation in the data-writing stage. This critical path may also include, for example, the critical path for data version validity, which is the version-checking operation from reading data during the execution process to the version-checking stage during the distributed transaction commit process (such as Figure 3 The critical path of the middle service node 3). Therefore, network requests that end the critical path have a higher priority. The order of network request priorities from high to low is: ① Network requests for releasing locks, ② Network requests for version checking, ③ Network requests for reading data, ④ Network requests for holding locks.

[0142] Based on the above embodiments, Figure 7 This is a schematic diagram of the internal processing logic of a programmable switch provided by an embodiment of the present application. As Figure 7 shown, the filtering message enables the programmable switch to complete the forwarding of other network requests to ensure that the normal forwarding of other network requests in the network is not affected during the distributed transaction commit process. Handling packet loss means that the programmable switch first determines whether the state of the distributed transaction is legal by the ID of the network message (i.e., the first message) to handle the situations of network packet loss and network out-of-order. The specific judgment logic is: if the ID of the network message is different from the ID recorded in the programmable switch, the current network message is discarded. State transition means that if the programmable switch determines whether the state of the current distributed transaction has started the rollback transaction processing stage. If the current distributed transaction is in the rollback transaction processing stage, network messages sent by other service nodes of the transaction are discarded to avoid repeated rollback. If the programmable switch meets the judgment conditions for the next transaction processing stage in S204, the programmable switch enables the participating service nodes in the next stage to perform the processing of the next transaction processing stage through broadcasting. Priority scheduling means that the programmable switch completes the priority scheduling processing of network messages during the distributed transaction commit process through the priority queue in the programmable switch. Broadcasting is the broadcast operation in the network, and unicasting is the unicast operation in the network. The forwarding table is used to complete the basic function of network forwarding of the programmable switch.

[0143] Based on the above embodiments, some programmable switches can be selected from multiple programmable switches to form a tree structure. The service nodes and client nodes participating in the distributed transaction processing can perform network communication through the programmable switches of this tree structure. Each switch parallelly completes the relevant processing of the distributed transaction, improving the performance of the distributed transaction processing. For example: Figure 8 This is a schematic diagram of multiple programmable switches participating in the transaction commit process in parallel provided by an embodiment of the present application. As Figure 8As shown in the figure, first, a group of programmable switches are selected in the programmable switch to form a tree structure, which can connect all service nodes and client nodes participating in the current distributed transaction processing, that is, the programmable switch tree completes the submission process of the current distributed transaction. The highest-level programmable switch in the tree structure serves as the root node of the tree structure. Taking the write data phase in the distributed transaction submission process as an example, as Figure 8 shown, the service nodes where the three write sets are located are directly connected to the programmable switch S1, the service node where one write set is located is directly connected to the programmable switch S2, the client node is directly connected to the programmable switch S3, and the programmable switches S1, S2, and S3 are directly connected to S0. S0, S1, S2, and S3 together form a group of programmable switch tree structures for completing the submission of distributed transactions, where S0 is the root node of the tree structure. The three service nodes directly connected to the programmable switch S1 complete the write data phase of the transaction, send the message of successful write data to the programmable switch S1, and the programmable switch S1 waits for all three service nodes to send messages, and sends the last received message of successful write data to the programmable switch S0. And so on, the programmable switch S2 sends the messages of the service nodes directly connected to it to S0. The programmable switch S0 waits for the messages of S1 and S2. When S0 receives the messages of successful write data from S1 and S2, the write data phase of the distributed transaction is successful, and the programmable switch S0 sends the last received message of successful write data phase to the client node through S3.

[0144] Based on the above embodiments, for different distributed transactions and different transaction processing phases of the same distributed transaction, the programmable switch can recycle limited storage resources to serve subsequent distributed transactions. Specifically, during the process of distributed transaction processing, the lock holding phase, version check phase, write data phase, and rollback transaction processing phase of commit failure are abstracted into the same operation, that is, the processing corresponding to S204 and S205, and the same state machine is reused for this same operation to make full use of the storage resources in the programmable switch. Different distributed transactions use the low bits of the ID in their network messages to represent their storage spaces in the programmable switch, and these storage spaces are reused by different distributed transactions, ensuring that no multiple distributed transactions share the same storage space at the same time, thus ensuring correctness.

[0145] Figure 9 It is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided by an embodiment of the present application. As Figure 9As shown in the figure, the distributed transaction processing device 900 based on a programmable switch according to this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device 900 based on a programmable switch is included in the programmable switch. The distributed transaction processing device 900 based on a programmable switch according to this embodiment includes: a receiving module 901 and a sending module 902.

[0146] The receiving module 901 is configured to receive a first message sent by at least one service node participating in the current transaction processing stage of the distributed transaction. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes an identifier of the distributed transaction, a message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and an identifier of the target node.

[0147] The sending module 902 is configured to, if the number of first messages received by the receiving module 901 for a non-final transaction processing stage is equal to the message count threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing stage, then send a second message to at least one service node participating in the next transaction processing stage according to the identifier of at least one service node participating in the next transaction processing stage. The second message is used to indicate to proceed to the next transaction processing stage; and if the number of first messages received by the receiving module 901 for the final transaction processing stage is equal to the corresponding message count threshold, and the type information in each first message indicates success, or if the type information in the first message received by the receiving module 901 for the current transaction processing stage indicates failure, then send the distributed transaction processing result to the client node.

[0148] Based on any of the above-described embodiments, if the current transaction processing stage is the final transaction processing stage among multiple sequentially processed transaction processing stages, then the identifier of the target node in the first message is the identifier of the client node.

[0149] The sending module 902 is specifically configured to:

[0150] Send the distributed transaction processing result to the client node according to the identifier of the client node included in the first message.

[0151] Based on any of the above-described embodiments, the sending module 902 is further configured to:

[0152] If the type information in the first message received by the receiving module 901 indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing phase, then a third message is sent to at least one service node participating in the rollback transaction processing phase, and the third message is used to indicate to perform the rollback transaction processing phase.

[0153] Based on any of the above-described embodiments, the multiple sequentially processed transaction processing phases are the lock holding phase, the version check phase, and the data writing phase.

[0154] Based on any of the above-described embodiments, the programmable switch includes a plurality of switching processing units, and each switching processing unit includes a distributed transaction processing device based on the programmable switch.

[0155] The device of this embodiment can be used to execute the solution of the programmable switch in any of the above method embodiments. The implementation principle and technical effects are similar and will not be elaborated here.

[0156] Figure 10 This is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided in another embodiment of the present application. As Figure 10 shown, the distributed transaction processing device 1000 based on the programmable switch of this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and a plurality of service nodes. The distributed transaction processing device 1000 based on the programmable switch is included in the client node. The distributed transaction processing device 1000 based on the programmable switch of this embodiment includes: a sending module 1001 and a receiving module 1002.

[0157] The sending module 1001 is configured to send a fourth message to each service node. The fourth message includes the identifier of the distributed transaction, the identifiers of the multiple sequentially processed transaction processing phases in the distributed transaction, and the identifiers of at least one service node participating in each transaction processing phase. The threshold of the number of messages corresponding to each transaction processing phase. The fourth message is further used to indicate to start processing the first transaction processing phase.

[0158] The receiving module 1002 is configured to receive the distributed transaction processing result sent by the programmable switch after the last transaction processing phase is completed, or when the type information in the first message of the current transaction processing phase indicates failure.

[0159] Based on any of the above-described embodiments, the fourth message is further used to indicate at least one service node that needs to perform the rollback transaction processing phase after the processing result of each transaction processing phase is a failure.

[0160] The device of this embodiment can be used to execute the solution of the client node in any of the above method embodiments. The implementation principle and technical effects are similar, and will not be elaborated here.

[0161] Figure 11 FIG. is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided in another embodiment of the present application. As Figure 11 shown, the distributed transaction processing device 1100 based on a programmable switch in this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device 1100 based on a programmable switch is included in the service nodes. The distributed transaction processing device 1100 based on a programmable switch in this embodiment includes: a receiving module 1101, a processing module 1102, and a sending module 1103.

[0162] The receiving module 1101 is configured to receive a fourth message sent by the client node. The fourth message includes an identifier of a distributed transaction, identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, identifiers of at least one service node participating in each transaction processing stage, and a message count threshold corresponding to each transaction processing stage. The fourth message is further used to indicate the start of processing the first transaction processing stage.

[0163] The processing module 1102 is configured to sequentially process the current transaction processing stage according to the fourth message. The current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction.

[0164] The sending module 1103 is configured to send a first message to the programmable switch. The first message includes an identifier of a distributed transaction, a message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and an identifier of a target node.

[0165] Wherein, when the current transaction processing stage is a non-final transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing stage.

[0166] When the current transaction processing stage is a final transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

[0167] Based on any of the above embodiments shown, the receiving module 1101 is further configured to:

[0168] After the sending module 1103 sends the first message to the programmable switch, receive a second message sent by the programmable switch. The second message is used to indicate the start of the next transaction processing stage.

[0169] The processing module 1102 is further configured to process the next transaction processing stage.

[0170] Based on any of the above-described embodiments, the fourth message is further used to indicate at least one service node that needs to execute a rollback transaction processing stage after the processing result in each transaction processing stage fails.

[0171] When the type information in the first message indicates failure, the identifier of the target node is the identifier of at least one service node participating in the rollback transaction processing stage.

[0172] Based on any of the above-described embodiments, the receiving module 1101 is further configured to:

[0173] Receive a third message sent by the programmable switch, where the third message is used to indicate to perform a rollback transaction processing stage.

[0174] The processing module 1102 is further configured to process the rollback transaction processing stage.

[0175] The device in this embodiment can be used to execute the solution of the service node in any of the above method embodiments, and its implementation principle and technical effects are similar, which will not be elaborated here.

[0176] Figure 12 This is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided in another embodiment of the present application. As Figure 12 shown, the distributed transaction processing device 1200 based on a programmable switch in this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device 1200 based on a programmable switch is included in the programmable switch. The distributed transaction processing device 1200 based on a programmable switch in this embodiment includes: a memory 1201 and a processor 1202. Among them, the memory 1201 and the processor 1202 are connected through a bus.

[0177] The memory 1201 is used to store program instructions.

[0178] The processor 1202 is used to call the program instructions in the memory to execute:

[0179] Receives a first message sent by at least one service node participating in the current transaction processing stage of a distributed transaction. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes an identifier of the distributed transaction, a message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and an identifier of a target node. If the number of first messages received by the processor 1202 for a non-final transaction processing stage is equal to the message count threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing stage, then according to the identifier of at least one service node participating in the next transaction processing stage, a second message is sent to at least one service node participating in the next transaction processing stage. The second message is used to indicate to proceed to the next transaction processing stage. And if the number of first messages received by the processor 1202 for the final transaction processing stage is equal to the corresponding message count threshold, and the type information in each first message indicates success, or if the type information in the first message received by the processor 1202 for the current transaction processing stage indicates failure, then a distributed transaction processing result is sent to the client node.

[0180] Based on any of the above-described embodiments, if the current transaction processing stage is the final transaction processing stage among multiple sequentially processed transaction processing stages, then the identifier of the target node in the first message is the identifier of the client node.

[0181] The processor 1202 is specifically configured to:

[0182] According to the identifier of the client node included in the first message, send a distributed transaction processing result to the client node.

[0183] Based on any of the above-described embodiments, the processor 1202 is further configured to:

[0184] If the type information in the first message received by the processor 1202 indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing stage, then a third message is sent to at least one service node participating in the rollback transaction processing stage. The third message is used to indicate to proceed to the rollback transaction processing stage.

[0185] Based on any of the above-described embodiments, the multiple sequentially processed transaction processing stages are a lock holding stage, a version check stage, and a data writing stage.

[0186] Based on any of the above-described embodiments, the programmable switch includes multiple switching processing units, and each switching processing unit includes a distributed transaction processing device based on the programmable switch.

[0187] The device of this embodiment can be used to execute the programmable switch solution in any of the above method embodiments. The implementation principle and technical effects are similar and will not be elaborated here.

[0188] Figure 13 FIG. is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided in another embodiment of the present application. As Figure 13 shown, the distributed transaction processing device 1300 based on a programmable switch in this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, client nodes, and multiple service nodes. The distributed transaction processing device 1300 based on a programmable switch is included in the client nodes. The distributed transaction processing device 1300 based on a programmable switch in this embodiment includes: a memory 1301 and a processor 1302. Among them, the memory 1301 and the processor 1302 are connected through a bus.

[0189] The memory 1301 is used to store program instructions.

[0190] The processor 1302 is used to call the program instructions in the memory to execute:

[0191] Send a fourth message to each service node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, and the identifiers of at least one service node participating in each transaction processing stage, the threshold of the number of messages corresponding to each transaction processing stage. The fourth message is also used to indicate the start of processing the first transaction processing stage; receive the distributed transaction processing result sent by the programmable switch after the last transaction processing stage is processed, or when the type information in the first message of the current transaction processing stage indicates failure.

[0192] Based on any of the above embodiments shown, the fourth message is also used to indicate at least one service node that needs to execute a rollback transaction processing stage after the processing result of each transaction processing stage fails.

[0193] The device of this embodiment can be used to execute the client node solution in any of the above method embodiments. The implementation principle and technical effects are similar and will not be elaborated here.

[0194] Figure 14 FIG. is a schematic structural diagram of a distributed transaction processing device based on a programmable switch provided in another embodiment of the present application. As Figure 14As shown in the figure, the distributed transaction processing device 1400 based on a programmable switch in this embodiment is applied to a distributed transaction processing system. The distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device 1400 based on a programmable switch is included in the service node. The distributed transaction processing device 1400 based on a programmable switch in this embodiment includes: a memory 1401 and a processor 1402. Among them, the memory 1401 and the processor 1402 are connected through a bus.

[0195] The memory 1401 is used to store program instructions.

[0196] The processor 1402 is used to call the program instructions in the memory to execute:

[0197] Receive a fourth message sent by the client node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing stages in the distributed transaction, the identifiers of at least one service node participating in each transaction processing stage, and the message count threshold corresponding to each transaction processing stage. The fourth message is also used to indicate the start of processing the first transaction processing stage; according to the fourth message, sequentially process the current transaction processing stage, where the current transaction processing stage is one of the multiple sequentially processed transaction processing stages in the distributed transaction; send a first message to the programmable switch. The first message includes the identifier of the distributed transaction, the message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and the identifier of the target node. Among them, when the current transaction processing stage is not the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing stage. When the current transaction processing stage is the last transaction processing stage and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

[0198] Based on any of the above - shown embodiments, the processor 1402 is further used for:

[0199] After the processor 1402 sends the first message to the programmable switch, receive a second message sent by the programmable switch. The second message is used to indicate the start of the next transaction processing stage.

[0200] The processor 1402 is also used to process the next transaction processing stage.

[0201] Based on any of the above - shown embodiments, the fourth message is further used to indicate at least one service node that needs to execute a rollback transaction processing stage after the processing result of each transaction processing stage is a failure.

[0202] When the type information in the first message indicates failure, the identifier of the target node is the identifier of at least one service node participating in the rollback transaction processing phase.

[0203] Based on any of the above-described embodiments, the processor 1402 is further configured to:

[0204] Receive a third message sent by the programmable switch, where the third message is used to indicate to perform the rollback transaction processing phase.

[0205] The processor 1402 is further configured to process the rollback transaction processing phase.

[0206] The apparatus of this embodiment can be used to execute the solution of the service node in any of the above method embodiments. The implementation principles and technical effects are similar and will not be elaborated here.

[0207] Figure 15 FIG. is a schematic diagram of a distributed transaction processing system based on a programmable switch provided by an embodiment of the present application. As Figure 15 shown, the distributed transaction processing system 1500 based on a programmable switch includes a programmable switch 1501, a client node 1502, and a plurality of service nodes 1503. Among them, the programmable switch 1501 can adopt Figure 9 or Figure 12 the structure of the apparatus embodiment, and correspondingly, it can execute Figure 2 or Figure 5 the technical solutions of the embodiments. The implementation principles and technical effects are similar and will not be elaborated here. The client node 1502 can adopt Figure 10 or Figure 13 the structure of the apparatus embodiment, and correspondingly, it can execute Figure 2 or Figure 5 the technical solutions of the embodiments. The implementation principles and technical effects are similar and will not be elaborated here. The service node 1503 can adopt Figure 11 or Figure 14 the structure of the apparatus embodiment, and correspondingly, it can execute Figure 2 or Figure 5 the technical solutions of the embodiments. The implementation principles and technical effects are similar and will not be elaborated here.

[0208] It should be noted that Figure 15 the programmable switch in

[0209] Figure 16 can be one or multiple. If there are multiple programmable switches, these multiple programmable switches form a tree structure and jointly complete the solutions of the programmable switch in the above embodiments. Figure 16As shown, for example, the distributed transaction processing apparatus 1600 based on a programmable switch can be provided as a server or a computer. Referring to Figure 16 , the distributed transaction processing apparatus 1600 based on a programmable switch includes a processing component 1601, which further includes one or more processors, and memory resources represented by a memory 1602 for storing instructions executable by the processing component 1601, such as application programs. The application programs stored in the memory 1602 may include one or more modules each corresponding to a set of instructions. In addition, the processing component 1601 is configured to execute instructions to implement the solutions of the client node, service node, or programmable switch in any of the above method embodiments.

[0210] The distributed transaction processing apparatus 1600 based on a programmable switch may further include a power component 1603 configured to perform power management of the distributed transaction processing apparatus 1600 based on a programmable switch, a wired or wireless network interface 1604 configured to connect the distributed transaction processing apparatus 1600 based on a programmable switch to a network, and an input / output (I / O) interface 1605. The distributed transaction processing apparatus 1600 based on a programmable switch can operate based on an operating system stored in the memory 1602, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, or the like.

[0211] This application also provides a computer program product, including a computer program, which when executed by a processor implements the solution of the distributed transaction processing method based on a programmable switch as described above.

[0212] This application also provides a computer-readable storage medium storing computer-executable instructions, which when executed by a processor implement the solution of the distributed transaction processing method based on a programmable switch as described above.

[0213] The above computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk. The readable storage medium can be any available medium accessible by a general-purpose or special-purpose computer.

[0214] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an Application Specific Integrated Circuits (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in a distributed transaction processing device based on a programmable switch.

[0215] Those of ordinary skill in the art can understand that all or part of the steps for implementing the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps including the above method embodiments; and the foregoing storage medium includes: various media such as ROM, RAM, magnetic disk, or optical disc that can store program code.

[0216] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some or all of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A distributed transaction processing method based on a programmable switch, characterized in that, Applied to a distributed transaction processing system, the distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes, and the method includes: The programmable switch receives a first message sent by at least one service node participating in the current transaction processing stage of a distributed transaction. The current transaction processing stage is one of multiple sequentially processed transaction processing stages in the distributed transaction. The first message includes the identifier of the distributed transaction, the message count threshold, type information indicating whether the processing result of the current transaction processing stage is successful or failed, and the identifier of the target node. If the number of the first messages received by the programmable switch for a non-final transaction processing stage is equal to the message count threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing stage, then the programmable switch sends a second message to at least one service node participating in the next transaction processing stage according to the identifier of at least one service node participating in the next transaction processing stage. The second message is used to indicate to perform the next transaction processing stage. If the number of the first messages received by the programmable switch for the final transaction processing stage is equal to the corresponding message count threshold, and the type information in each first message indicates success, or if the type information in the first message received by the programmable switch for the current transaction processing stage indicates failure, then the programmable switch sends the distributed transaction processing result to the client node.

2. The method according to claim 1, characterized in that, If the current transaction processing stage is the final transaction processing stage among the multiple sequentially processed transaction processing stages, then the identifier of the target node in the first message is the identifier of the client node. The programmable switch sending the distributed transaction processing result to the client node includes: The programmable switch sends the distributed transaction processing result to the client node according to the identifier of the client node included in the first message.

3. The method according to claim 2, wherein The method further includes: If the type information in the first message received by the programmable switch indicates failure, and the identifier of the target node in the first message is the identifier of at least one service node participating in the rollback transaction processing stage, then the programmable switch sends a third message to at least one service node participating in the rollback transaction processing stage. The third message is used to indicate to perform the rollback transaction processing stage.

4. The method according to claim 1, wherein The multiple sequentially processed transaction processing stages are the lock holding stage, the version check stage, and the data writing stage.

5. The method according to any one of claims 1-4, characterized in that, The programmable switch includes multiple switching processing units, and at least one of the multiple switching processing units is respectively used to receive the first message sent by at least one service node participating in the current transaction processing stage.

6. The method according to claim 1, characterized in that, The method further includes: The client node sends a fourth message to each service node. The fourth message includes the identifier of the distributed transaction, the identifiers of multiple sequentially processed transaction processing phases in the distributed transaction, the identifiers of at least one service node participating in each transaction processing phase, and the message count threshold corresponding to each transaction processing phase. The fourth message is further used to indicate the start of processing the first transaction processing phase; The client node receives the distributed transaction processing result sent by the programmable switch after the last transaction processing phase is processed, or when the type information in the first message in the current transaction processing phase indicates failure.

7. The method according to claim 6, characterized in that The fourth message is further used to indicate at least one service node that needs to execute the rollback transaction processing phase after the processing result of each of the transaction processing phases is a failure.

8. The method according to claim 1, characterized in that, The method further includes: The service node receives the fourth message sent by the client node; The service node sequentially processes the current transaction processing phase according to the fourth message and sends a first message to the programmable switch, wherein, when the current transaction processing phase is not the last transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing phase; when the current transaction processing phase is the last transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

9. The method according to claim 8, wherein After sending the first message to the programmable switch, it further includes: The service node receives a second message sent by the programmable switch. The second message is used to indicate the execution of the next transaction processing phase; The service node processes the next transaction processing phase.

10. The method according to claim 8, characterized in that, The method further includes: The service node receives a third message sent by the programmable switch. The third message is used to indicate the execution of the rollback transaction processing phase; The service node processes the rollback transaction processing phase.

11. A distributed transaction processing device based on a programmable switch, characterized in that, Applying a distributed transaction processing system, the distributed transaction processing system includes a programmable switch, a client node, and multiple service nodes. The distributed transaction processing device is included in the programmable switch. The device includes: a receiving module, configured to receive a first message sent by at least one service node participating in the current transaction processing phase of a distributed transaction. The current transaction processing phase is one of multiple sequentially processed transaction processing phases in the distributed transaction. The first message includes the identifier of the distributed transaction, the message count threshold, type information indicating whether the processing result of the current transaction processing phase is successful or failed, and the identifier of the target node; A sending module, configured to, if the number of the first messages received by the receiving module for a non-final transaction processing phase is equal to the message number threshold, and the type information in each first message indicates success, and the identifier of the target node in the first message is the identifier of at least one service node participating in the next transaction processing phase, send a second message to at least one service node participating in the next transaction processing phase according to the identifier of at least one service node participating in the next transaction processing phase, where the second message is used to indicate to perform the next transaction processing phase; and if the number of the first messages received by the receiving module for the final transaction processing phase is equal to the corresponding message number threshold, and the type information in each first message indicates success, or if the type information in the first message received by the receiving module for the current transaction processing phase indicates failure, send a distributed transaction processing result to the client node.

12. The device according to claim 11, wherein, The apparatus further includes: A sending module, configured to send a fourth message to each service node, where the fourth message includes an identifier of a distributed transaction, identifiers of multiple sequentially processed transaction processing phases in the distributed transaction, identifiers of at least one service node participating in each transaction processing phase, and a message number threshold corresponding to each transaction processing phase, and the fourth message is further used to indicate to start processing the first transaction processing phase; A receiving module, configured to receive a distributed transaction processing result sent by the programmable switch after the final transaction processing phase is processed, or when the type information in the first message for the current transaction processing phase indicates failure.

13. The device according to claim 11, characterized in that, The apparatus further includes: A receiving module, configured to receive a fourth message sent by the client node; A processing module, configured to sequentially process the current transaction processing phase according to the fourth message, where the current transaction processing phase is one of the multiple sequentially processed transaction processing phases in the distributed transaction; A sending module, configured to send a first message to the programmable switch; Wherein, when the current transaction processing phase is a non-final transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of at least one service node participating in the next transaction processing phase; When the current transaction processing phase is the final transaction processing phase and the type information in the first message indicates success, the identifier of the target node is the identifier of the client node.

14. A distributed transaction processing device based on a programmable switch, characterized in that, It includes: A memory and a processor; The memory is used to store program instructions; The processor is used to call the program instructions in the memory to execute the method according to any one of claims 1-10.

15. A distributed transaction processing system based on a programmable switch, including a programmable switch, a client node, and multiple service nodes; Among them, The programmable switch is used to execute the method according to any one of claims 1-10.

16. A distributed transaction processing system based on a programmable switch, comprising a programmable switch, a client node, and multiple service nodes; there are multiple programmable switches, and the multiple programmable switches form a tree structure for executing the method according to any one of claims 1-5.

17. A computer-readable storage medium, characterized in that, Computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed, the method according to any one of claims 1-10 is implemented.

18. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, the method according to any one of claims 1-10 is implemented.

Citation Information

Patent Citations

  • Method of realizing heartbeat mechanism, apparatus and system thereof

    CN106936662A

  • Transcript selector based on programmable network equipment

    CN108900509A