Distributed transaction submission method and device

By asynchronously writing to the storage medium and selecting the participating node at the minimum ID as the target coordination point, the delay and fault blocking problems caused by the coordination point writing persistent status logs multiple times are solved, and an efficient transaction submission process is achieved.

CN115248827BActive Publication Date: 2025-09-05CHINA MOBILE GROUP SHAIHAI +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110468274.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-28
Publication Date
2025-09-05
Estimated Expiration
2041-04-28

AI Technical Summary

Technical Problem

In the prior art, the delay problem caused by the co-regulating point writing persistent status logs multiple times, especially when the co-regulating point fails, the entire transaction submission process is blocked.

Method used

After receiving the request message from the coordination point, the participating node writes asynchronously to the storage medium and feedbacks the preparation and completion status. The coordination point only continues the next operation after receiving the successful message, reducing the persistence log; when the coordination point fails, the participating node with the smallest ID is selected as the target coordination point to continue the process.

Benefits of technology

It effectively reduces the delay caused by co-regulating points writing persistent status logs, and avoids transaction commit process blockage when co-regulating points fail, ensuring the smooth execution of transaction commits.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115248827B_ABST
    Figure CN115248827B_ABST
Patent Text Reader

Abstract

The present invention provides a distributed transaction submission method and apparatus, applied to participating nodes. The method comprises: receiving a first request message sent by a coordinating node; writing data in the first request message to a storage medium, wherein the first request message carries transaction submission request information and metadata information of all participating nodes; if the data has been successfully written to the storage medium, sending a first request success message to the coordinating node; receiving a second request message sent by the coordinating node; executing the related transaction; after completing the related transaction, sending a second request success message to the coordinating node; and writing a transaction execution completion status log of the participating nodes to the storage medium. Embodiments of the present invention can effectively reduce the delay caused by the coordinating node writing a persistent status log.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a distributed transaction submission method and device. Background Art

[0002] Related technologies use a standard two-phase commit method to implement the transaction commit function of a distributed database. Figure 1 As shown, the standard two-phase commit method includes a preparation phase for a transaction commit request and an execution phase for the transaction commit request.

[0003] During the preparation phase of a transaction commit request, the coordinating node asks all participating nodes whether to commit the transaction. Based on the query, it writes a persistent state log and awaits responses from the participating nodes. The participating nodes execute the coordinating node's query for committing the transaction and write the data before the commit and the commit log. Each participating node then responds to the coordinating node's query. If the participating node succeeds, it sends a "transaction commit" message to the coordinating node. If the participating node fails, it sends a "transaction commit aborted" message to the coordinating node.

[0004] During the transaction commit request execution phase, the coordinating node writes a persistent state log based on the responses from each participating node. If the response is "Agree to execute transaction commit," the coordinating node issues a "Formally execute transaction commit" request to all participating nodes. After the participating nodes complete the transaction commit operation, they release the resources occupied during the entire transaction commit phase and send a "Transaction commit completed" message to the coordinating node. Upon receiving this message from all participating nodes, the coordinating node completes the transaction.

[0005] If the response is "Abort transaction commit," or if the coordinating node does not receive a response from all participating nodes, it sends a "Data Rollback" request to all participating nodes. The participating nodes then perform a rollback based on the data written before the transaction commit, releasing resources used during the entire transaction commit phase. After the execution is complete, the participating nodes send a "Data Rollback Completed" message to the coordinating node. Upon receiving this message from all participating nodes, the coordinating node cancels the transaction commit.

[0006] In summary, the coordination node's multiple writing of persistent state logs in related technologies has brought about many delay problems that need to be solved urgently. Summary of the Invention

[0007] The present invention provides a distributed transaction submission method and device, which are used to solve the problem in the related art that a coordinating node writes a persistent state log multiple times, which causes a lot of delay.

[0008] In a first aspect, the present invention provides a distributed transaction submission method, applied to participating nodes, comprising:

[0009] Receive a first request message sent by the coordinating node, and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0010] When the data has been successfully written into the storage medium, sending a first request success message to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0011] receiving a second request message sent by the coordinating node, and executing the relevant transaction, wherein the second request message is used to instruct the participating nodes to start executing the relevant transaction;

[0012] After the relevant transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0013] Writing the transaction execution completion status log of the participating nodes into the storage medium.

[0014] In one embodiment, the distributed transaction submission method further includes:

[0015] If the first request message is not received, or if an exception occurs in the processing of the first request message, a first request failure message is sent to the coordination node or no information is fed back. The first request failure message is used to indicate to the coordination node that the participating node is not ready to commit the transaction.

[0016] In one embodiment, after sending the first request failure message to the coordinating node, the method further includes:

[0017] receiving a third request message sent by the coordinating node to suspend transaction submission, wherein the third request message is used to instruct the participating nodes to suspend transaction submission;

[0018] After the transaction submission is aborted, a third request success message is sent to the coordinating node, where the third request success message is used to indicate to the coordinating node that the transaction abort of the participating node is complete.

[0019] In one embodiment, after receiving the first request message sent by the coordinating node, the method further includes:

[0020] Regularly query the status information of the coordinating node and all participating nodes;

[0021] If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node, and the target coordination node is used to perform relevant operations of the coordination node.

[0022] In a second aspect, the present invention provides a distributed transaction submission method, applied to a coordination node, comprising:

[0023] Receive transaction submission request information sent by the client;

[0024] Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0025] If a first request success message sent by all participating nodes is received within a preset time, a second request message is sent to all participating nodes;

[0026] Receive the second request success message sent by all the participating nodes, and send the transaction execution completion information of all the participating nodes to the client.

[0027] In one embodiment, after sending the first request message to all participating nodes, the method further includes:

[0028] If a first request failure message sent by the target participating node is received, or if the first request success message sent by all participating nodes is not received within a preset time, a third request message is sent to all participating nodes;

[0029] receiving third request success messages sent by all participating nodes, and sending transaction submission failure information of all participating nodes to the client;

[0030] The target participating node includes at least one participating node among all the participating nodes.

[0031] In a third aspect, the present invention provides a distributed transaction committing device, comprising:

[0032] A first writing unit is configured to receive a first request message sent by the coordinating node, and write data in the first request message into a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0033] A first sending unit is configured to send a first request success message to the coordinating node when the data has been successfully written into the storage medium, wherein the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0034] an execution unit, configured to receive a second request message sent by the coordinating node and execute a related transaction, wherein the second request message is used to instruct the participating nodes to start executing the related transaction;

[0035] A second sending unit is configured to send a second request success message to the coordinating node after completing the execution of the related transaction, wherein the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0036] The second writing unit is configured to write the transaction execution completion status log of the participating node into the storage medium.

[0037] In a fourth aspect, the present invention provides a distributed transaction committing device, comprising:

[0038] A receiving unit, configured to receive transaction submission request information sent by a client;

[0039] a third sending unit, configured to obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0040] A fourth sending unit is configured to send a second request message to all the participating nodes if a first request success message sent by all the participating nodes is received within a preset time;

[0041] The fifth sending unit is configured to receive the second request success messages sent by all the participating nodes, and send transaction execution completion information of all the participating nodes to the client.

[0042] In a fifth aspect, the present invention provides an electronic device comprising a memory and a memory storing a computer program, wherein when the processor executes the program, the steps of the distributed transaction submission method described in the first aspect or the second aspect are implemented.

[0043] In a sixth aspect, the present invention provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, and the computer program is used to enable the processor to execute the steps of the distributed transaction submission method described in the first aspect or the second aspect.

[0044] The distributed transaction submission method and device provided by the present invention facilitate the query of metadata information of other participating nodes and perform preparation operations for transaction submission by participating nodes by receiving a first request message sent by a coordinating node. The participating nodes execute related transactions by receiving a second request message sent by the coordinating node. In the two request stages, the coordinating node receives the first request success message and the second request success message respectively. There is no need to write status logs indicating that the participating nodes have made preparations for transaction submission and that the transaction has been executed. This can effectively reduce the delay caused by the coordinating node writing a persistent status log. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0046] Figure 1 This is a timing diagram of the standard two-phase commit method provided by related technologies;

[0047] Figure 2 This is one of the flow charts of the distributed transaction submission method provided by the present invention;

[0048] Figure 3 It is a flowchart of the preparation phase of a transaction submission request provided by the present invention;

[0049] Figure 4 This is one of the flow charts of the execution phase of the transaction submission request provided by the present invention;

[0050] Figure 5 This is the second flow chart of the execution phase of the transaction submission request provided by the present invention;

[0051] Figure 6 1 is a flow chart of a distributed transaction submission method provided by the present invention in the event of a coordination node failure;

[0052] Figure 7 This is the second flow chart of the distributed transaction submission method provided by the present invention;

[0053] Figure 8 It is a structural diagram of the distributed transaction submission device provided by the present invention;

[0054] Figure 9 It is a structural diagram of the distributed transaction submission device provided by the present invention;

[0055] Figure 10 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0056] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0057] In order to solve the problem in the related art that the coordination node writes the persistent state log multiple times, which causes a lot of delay, the embodiment of the present invention provides a distributed transaction submission method. Figure 2 This is one of the flow charts of the distributed transaction submission method provided by the embodiment of the present invention. Figure 2 The execution subject may be a participating node, and the method includes:

[0058] Step 200: Receive a first request message sent by a coordinating node, and write data in the first request message into a storage medium. The first request message carries transaction submission request information and metadata information of all participating nodes.

[0059] The first request message is used to indicate to the participating nodes whether to prepare to execute the transaction commit.

[0060] A transaction is used to indicate a database transaction. A database transaction includes one or more database operations, which together form a logical whole and implement operations on one or more current databases.

[0061] The metadata information of the participating nodes includes the unique code (Identity document, ID) of the participating nodes and status information, etc.

[0062] After receiving the first request message sent by the coordinating node, each participating node writes the transaction submission request information in the first request message and the metadata information of all participating nodes into the storage medium.

[0063] Step 201: When the data has been successfully written into the storage medium, a first request success message is sent to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction.

[0064] When the data in the first request message has been successfully written into the storage medium, each participating node immediately sends a first request success message to the coordination node, indicating that each participating node is ready to commit the transaction.

[0065] Step 202: Receive a second request message sent by the coordinating node and execute related transactions. The second request message is used to instruct the participating nodes to start executing related transactions.

[0066] After receiving the second request message sent by the coordinating node, each participating node starts to execute the transaction operation and modify information such as the transaction status.

[0067] Step 203: After the related transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed.

[0068] After each participating node completes the transaction operation and updates information such as the transaction status, it sends a second request success message to the coordination node, indicating that the transaction of each participating node has been completed.

[0069] Step 204: Write the transaction execution completion status log of the participating nodes into the storage medium.

[0070] All participating nodes asynchronously write the status log of the transaction execution completion to the storage medium.

[0071] The distributed transaction submission method provided by the embodiment of the present invention is that the participating nodes receive the first request message sent by the coordinating node, so as to query the metadata information of other participating nodes and perform preparation operations for transaction submission. The participating nodes receive the second request message sent by the coordinating node to execute related transactions. In the two request stages, the coordinating node receives the first request success message and the second request success message respectively. There is no need to write status logs indicating that the participating nodes have made preparations for transaction submission and that the transaction has been executed. The delay caused by the coordinating node writing the persistent status log can be effectively reduced. In the second request stage, the mode of writing the persistent status log by all participating nodes is adjusted from synchronous to asynchronous, further reducing the delay caused by the participating nodes writing the persistent status log.

[0072] Combine Figure 3 This section describes the process by which the coordinating node and participating nodes jointly implement the preparation phase of a transaction submission request. Figure 3 FIG. 1 is a flow chart of the preparation phase of a transaction submission request provided by an embodiment of the present invention. Figure 3 As shown, the preparation phase of a transaction commit request includes:

[0073] The client initiates a transaction submission request to the coordinating node.

[0074] The coordinating node queries the metadata information of the n participating nodes that are currently operating normally, generates a first request message based on the transaction submission request and the metadata information of the n participating nodes, and sends it to each participating node in parallel.

[0075] After receiving the first request message, each participating node writes the data in the first request message into the storage medium. After successful writing, it immediately sends a first request success message to the coordination node, indicating that the participating node is ready to commit the transaction.

[0076] Combine Figure 4 Describes the process of the execution phase in which the coordinating node and participating nodes jointly implement a transaction submission request. Figure 4 This is one of the flow charts of the execution phase of a transaction submission request provided by an embodiment of the present invention, such as Figure 4 As shown, the execution phase of a transaction commit request includes:

[0077] After the coordinating node receives the first request success message sent by n participating nodes within the preset time, it sends a second request message to the n participating nodes. After each participating node receives the second request message, it executes the transaction operation and updates the transaction status and other information. After the execution is completed, the second request success message is sent to the coordinating node, and the status log of the transaction execution completion is written to the storage medium.

[0078] After receiving the second request success message, the coordinating node sends transaction execution completion information of all participating nodes to the client.

[0079] Based on any of the above embodiments, the distributed transaction submission method further includes:

[0080] If the first request message is not received, or if an exception occurs in the processing of the first request message, a first request failure message is sent to the coordination node or no information is fed back. The first request failure message is used to indicate to the coordination node that the participating node is not ready to commit the transaction.

[0081] If the target participating node fails to successfully receive the first request message, or if an exception occurs in the processing of the first request message after receiving the first request message, it sends a first request failure message to the coordination node, or does not feedback any information, indicating that the target participating node is not ready to commit the transaction.

[0082] The target participating nodes include one or more participating nodes among all participating nodes.

[0083] The distributed transaction submission method provided by an embodiment of the present invention, if the target participating node does not receive the first request message, or an exception occurs in the processing of the first request message, then a first request failure message is sent to the coordination node or no information is fed back, so that the coordination node can respond in a timely manner. After the coordination node receives the first request failure message, it does not need to write a status log indicating that the participating node is not ready for transaction submission, which can effectively reduce the delay caused by the coordination node writing a persistent status log.

[0084] Based on any of the foregoing embodiments, after sending the first request failure message to the coordinating node, the method further includes:

[0085] receiving a third request message sent by the coordinating node to suspend transaction submission, wherein the third request message is used to instruct the participating nodes to suspend transaction submission;

[0086] After the transaction submission is aborted, a third request success message is sent to the coordinating node, where the third request success message is used to indicate to the coordinating node that the transaction abort of the participating node is complete.

[0087] Each participating node receives the third request message sent by the coordinating node, aborts the transaction submission, modifies the transaction status information, writes the status log of the aborted transaction submission into the storage medium, executes the rollback transaction operation, and after the execution is completed, sends the third request success message to the coordinating node, indicating that the transaction abort of each participating node is completed.

[0088] The distributed transaction submission method provided by an embodiment of the present invention, after each participating node receives the third request message, aborts the transaction submission and feeds back a third request success message to the coordination node, to ensure that the transaction submission is successfully aborted. After the coordination node receives the third request success message, it does not need to write a status log of the transaction abort completion of the participating node, which can effectively reduce the delay caused by the coordination node writing a persistent status log.

[0089] Combine Figure 5 Describes the process of the execution phase in which the coordinating node and participating nodes jointly implement a transaction submission request. Figure 5 This is the second flow chart of the execution phase of the transaction submission request provided by the embodiment of the present invention, such as Figure 5 As shown, the execution phase of the transaction commit request also includes:

[0090] If the coordinating node receives a first request failure message sent by the target participating node, or does not receive first request success messages sent by the n participating nodes within a preset time, the coordinating node sends a third request message to the n participating nodes.

[0091] After receiving the third request message, each participating node aborts the transaction submission, modifies the transaction status and other information, writes the status log of the aborted transaction submission into the storage medium, executes the rollback transaction operation, and after the execution is completed, feeds back the third request success message to the coordination node.

[0092] After receiving the third request success message, the coordinating node sends transaction submission failure information of n participating nodes to the client.

[0093] Based on any of the foregoing embodiments, the step of receiving the first request message sent by the coordinating node further includes:

[0094] Regularly query the status information of the coordinating node and all participating nodes;

[0095] If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node, and the target coordination node is used to perform relevant operations of the coordination node.

[0096] The standard two-phase commit method used in related technologies relies heavily on the coordination node. If the coordination node fails, the entire transaction commit process will be blocked.

[0097] In order to solve the problem that the entire transaction submission process will be blocked when the coordinating node fails, in one embodiment, each participating node periodically queries the status information of the coordinating node and all participating nodes. If the status information of the coordinating node is abnormal, all participating nodes are sorted based on their ID information, and the participating node with the smallest ID is obtained, and the participating node with the smallest ID is used as the target coordinating node.

[0098] Furthermore, the target coordination node receives the transaction submission request information sent by the client, obtains metadata information of all participating nodes, generates a first request message based on the transaction submission request information and the metadata information of all participating nodes, and sends the first request message to each participating node in parallel.

[0099] When each participating node receives the first request message, the target coordination node receives the first request success message sent by each participating node, sends a second request message to all participating nodes based on the first request success message, receives the second request success message sent by all participating nodes, and sends transaction execution completion information of all participating nodes to the client.

[0100] When the target participating node does not receive the first request message, or an exception occurs in the processing of the first request message, the target coordination node receives the first request failure message sent by the target participating node, and based on the first request failure message, or based on not receiving the first request success message sent by all participating nodes, sends a third request message to all participating nodes, receives the third request success message sent by all participating nodes, and sends transaction submission failure information of all participating nodes to the client.

[0101] The distributed transaction submission method provided by an embodiment of the present invention is that participating nodes periodically query the status information of the coordinating node and all participating nodes. In the event of a failure of the coordinating node, the participating node with the smallest ID is selected from all participating nodes as the target coordinating node, and any embodiment of the present invention is re-executed based on the target coordinating node. This effectively solves the problem in related technologies that the entire transaction submission process is blocked due to a failure of the coordinating node, and ensures that the transaction submission is executed smoothly and advances to the final state.

[0102] Combine Figure 6 This section describes how to resolve the issue where a coordination node failure blocks the entire transaction submission process. Figure 6 FIG is a flow chart of a distributed transaction submission method in the event of a coordination node failure provided by an embodiment of the present invention. Figure 6 As shown, in the case of a coordination node failure, the distributed transaction submission method further includes:

[0103] Based on the ID information of the n participating nodes, all participating nodes are sorted, and participating node 2 with the smallest ID is obtained, and participating node 2 is used as a temporary coordination node.

[0104] Participating node 2 receives the transaction submission request information sent by the client, obtains metadata information of n participating nodes, generates a first request message based on the transaction submission request information and the metadata information of n participating nodes, and sends the first request message to other participating nodes in parallel.

[0105] When other participating nodes receive the first request message, participating node 2 receives the first request success message sent by other participating nodes, sends a second request message to other participating nodes based on the first request success message, receives the second request success message sent by other participating nodes, and sends the transaction execution completion information of other participating nodes to the client.

[0106] Figure 7 This is the second flow chart of the distributed transaction submission method provided by the embodiment of the present invention. Figure 7 As shown, the execution subject may be a coordination node, and the method includes:

[0107] Step 700: Receive transaction submission request information sent by the client.

[0108] The transaction commit request information is used to instruct the coordinating node to execute transaction commit by the participating nodes.

[0109] The coordinating node receives the transaction submission request information sent by the client.

[0110] Step 701: Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes.

[0111] The coordinating node queries and obtains metadata information of all participating nodes that are currently operating normally, generates a first request message based on the transaction submission request information and the metadata information of all participating nodes, and sends the first request message to all participating nodes in parallel.

[0112] The coordinating node generates an operation record based on the received transaction submission request information, the obtained metadata information of all participating nodes, and the sent first request message information, and saves the operation record to the memory without writing the operation record to the storage medium.

[0113] Step 702: If the first request success message sent by all the participating nodes is received within the preset time, a second request message is sent to all the participating nodes.

[0114] When all participating nodes receive the first request message, the coordinating node receives the first request success message sent by all participating nodes.

[0115] After receiving the first request success messages sent by all participating nodes within a preset time, the coordinating node sends a second request message to all participating nodes.

[0116] Step 703: Receive the second request success message sent by all participating nodes, and send transaction execution completion information of all participating nodes to the client.

[0117] After receiving the second request success message sent by all participating nodes, the coordinating node sends the transaction execution completion information of all participating nodes to the client to end the transaction.

[0118] In a distributed transaction submission method provided by an embodiment of the present invention, a coordinating node generates a first request message based on the transaction submission request information sent by the client and the metadata information of all participating nodes obtained, and sends the first request message to all participating nodes, so that each participating node can query the metadata information of other participating nodes and make preparations for transaction submission. The coordinating node sends a second request message to all participating nodes, so that each participating node executes related transactions. In the two request stages, the coordinating node receives the first request success message and the second request success message respectively. There is no need to write status logs indicating that the participating nodes have made preparations for transaction submission and that the transaction has been executed, which can effectively reduce the delay caused by the coordinating node writing a persistent status log.

[0119] Based on any of the foregoing embodiments, after sending the first request message to all participating nodes, the method further includes:

[0120] If a first request failure message sent by the target participating node is received, or if the first request success message sent by all participating nodes is not received within a preset time, a third request message is sent to all participating nodes;

[0121] receiving third request success messages sent by all participating nodes, and sending transaction submission failure information of all participating nodes to the client;

[0122] The target participating node includes at least one participating node among all the participating nodes.

[0123] Among them, when the coordinating node receives the first request failure message sent by the target participating node, or does not receive the first request success message sent by all participating nodes within the preset time, it sends a third request message to all participating nodes. After the participating node receives the third request message and aborts the transaction submission, the coordinating node receives the third request success message sent by the participating node and sends the transaction submission failure information of all participating nodes to the client.

[0124] The distributed transaction submission method provided by an embodiment of the present invention sends a third request message to all participating nodes when the coordinating node receives a first request failure message sent by the target participating node, or does not receive a first request success message sent by all participating nodes. Each participating node aborts the transaction submission. After the coordinating node receives the third request success message, it does not need to write a status log of the transaction abort completion of the participating nodes, which can effectively reduce the delay caused by the coordinating node writing a persistent status log.

[0125] The distributed transaction committing device provided by the present invention is described below. The distributed transaction committing device described below and the distributed transaction committing method described above can be referenced to each other.

[0126] Figure 8 FIG. 1 is a schematic diagram of the structure of a distributed transaction submission device provided by an embodiment of the present invention. Figure 8 As shown, the execution subject may be a participating node, and the device includes: a first writing unit 800, a first sending unit 801, an execution unit 802, a second sending unit 803, and a second writing unit 804, wherein:

[0127] A first writing unit 800 is configured to receive a first request message sent by a coordinating node and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0128] A first sending unit 801 is configured to send a first request success message to the coordinating node when the data has been successfully written into the storage medium, wherein the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0129] An execution unit 802 is configured to receive a second request message sent by the coordinating node and execute a related transaction, wherein the second request message is used to instruct the participating nodes to start executing the related transaction;

[0130] A second sending unit 803 is configured to send a second request success message to the coordinating node after completing the execution of the related transaction, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0131] The second writing unit 804 is configured to write the transaction execution completion status log of the participating node into the storage medium.

[0132] The distributed transaction submission device provided by an embodiment of the present invention facilitates the query of metadata information of other participating nodes and performs preparation operations for transaction submission by participating nodes by receiving the first request message sent by the coordinating node. The participating nodes execute related transactions by receiving the second request message sent by the coordinating node. In the two request stages, the coordinating node receives the first request success message and the second request success message respectively. There is no need to write status logs indicating that the participating nodes have made preparations for transaction submission and that the transaction has been executed. This can effectively reduce the delay caused by the coordinating node writing a persistent status log.

[0133] Optionally, the device further comprises:

[0134] The sixth sending unit 805 is used to send a first request failure message to the coordination node or not feedback any information if the first request message is not received, or if an exception occurs in the processing of the first request message. The first request failure message is used to indicate to the coordination node that the participating node is not ready to commit the transaction.

[0135] Optionally, the sixth sending unit 805 is configured to:

[0136] receiving a third request message sent by the coordinating node to suspend transaction submission, wherein the third request message is used to instruct the participating nodes to suspend transaction submission;

[0137] After the transaction submission is aborted, a third request success message is sent to the coordinating node, where the third request success message is used to indicate to the coordinating node that the transaction abort of the participating node is complete.

[0138] Optionally, the first writing unit 800 is configured to:

[0139] Regularly query the status information of the coordinating node and all participating nodes;

[0140] If the state information of the coordinating node is abnormal, the participating node with the smallest coding ID is obtained based on the metadata information of all participating nodes, and the participating node with the smallest coding ID is used as the target coordinating node.

[0141] Figure 9 FIG. 1 is a schematic diagram of the structure of a distributed transaction submission device provided by an embodiment of the present invention. Figure 9 As shown, the execution subject may be a coordination node, and the device includes: a receiving unit 900, a third sending unit 901, a fourth sending unit 902 and a fifth sending unit 903, wherein,

[0142] Receiving unit 900, configured to receive transaction submission request information sent by a client;

[0143] The third sending unit 901 is configured to obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0144] The fourth sending unit 902 is configured to send a second request message to all participating nodes if a first request success message sent by all participating nodes is received within a preset time;

[0145] The fifth sending unit 903 is configured to receive the second request success messages sent by all the participating nodes, and send transaction execution completion information of all the participating nodes to the client.

[0146] In a distributed transaction submission device provided by an embodiment of the present invention, a coordination node generates a first request message based on the transaction submission request information sent by the client and the metadata information of all participating nodes obtained, and sends the first request message to all participating nodes, so that each participating node can query the metadata information of other participating nodes and make preparations for transaction submission. The coordination node sends a second request message to all participating nodes, so that each participating node executes related transactions. In the two request stages, the coordination node receives the first request success message and the second request success message respectively. There is no need to write status logs indicating that the participating nodes have made preparations for transaction submission and that the transaction has been executed, which can effectively reduce the delay caused by the coordination node writing a persistent status log.

[0147] Optionally, the third sending unit 901 is configured to:

[0148] If a first request failure message sent by the target participating node is received, or if the first request success message sent by all participating nodes is not received within a preset time, a third request message is sent to all participating nodes;

[0149] receiving third request success messages sent by all participating nodes, and sending transaction submission failure information of all participating nodes to the client;

[0150] The target participating node includes at least one participating node among all the participating nodes.

[0151] Figure 10 An example of a physical structure diagram of an electronic device is shown below. Figure 10 As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030, and a communication bus 1040, wherein the processor 1010, the communication interface 1020, and the memory 1030 communicate with each other via the communication bus 1040. The processor 1010 may call a computer program in the memory 1030 to execute the steps of the distributed transaction submission method, for example, including:

[0152] Receive a first request message sent by the coordinating node, and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0153] When the data has been successfully written into the storage medium, sending a first request success message to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0154] receiving a second request message sent by the coordinating node, and executing the relevant transaction, wherein the second request message is used to instruct the participating nodes to start executing the relevant transaction;

[0155] After the relevant transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0156] Writing the transaction execution completion status log of the participating nodes into the storage medium.

[0157] or,

[0158] The processor 1010 may call the computer program in the memory 1030 to execute the steps of the distributed transaction commit method, for example, including:

[0159] Receive transaction submission request information sent by the client;

[0160] Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0161] If a first request success message sent by all participating nodes is received within a preset time, a second request message is sent to all participating nodes;

[0162] Receive the second request success message sent by all the participating nodes, and send the transaction execution completion information of all the participating nodes to the client.

[0163] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0164] On the other hand, the present invention further provides a computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions. When the program instructions are executed by a computer, the computer is capable of executing the distributed transaction submission method provided by the above methods, which is applied to participating nodes, and comprises:

[0165] Receive a first request message sent by the coordinating node, and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0166] When the data has been successfully written into the storage medium, sending a first request success message to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0167] receiving a second request message sent by the coordinating node, and executing the relevant transaction, wherein the second request message is used to instruct the participating nodes to start executing the relevant transaction;

[0168] After the relevant transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0169] Writing the transaction execution completion status log of the participating nodes into the storage medium.

[0170] or,

[0171] When the program instructions are executed by a computer, the computer can execute the distributed transaction submission method provided by the above methods, applied to the coordination node, and the method includes:

[0172] Receive transaction submission request information sent by the client;

[0173] Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0174] If a first request success message sent by all participating nodes is received within a preset time, a second request message is sent to all participating nodes;

[0175] Receive the second request success message sent by all the participating nodes, and send the transaction execution completion information of all the participating nodes to the client.

[0176] On the other hand, an embodiment of the present application further provides a processor-readable storage medium, wherein the processor-readable storage medium stores a computer program, wherein the computer program is configured to cause the processor to execute the distributed transaction submission method provided in the above embodiments, applied to participating nodes, for example, including:

[0177] Receive a first request message sent by the coordinating node, and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes;

[0178] When the data has been successfully written into the storage medium, sending a first request success message to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction;

[0179] receiving a second request message sent by the coordinating node, and executing the relevant transaction, wherein the second request message is used to instruct the participating nodes to start executing the relevant transaction;

[0180] After the relevant transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed;

[0181] Writing the transaction execution completion status log of the participating nodes into the storage medium.

[0182] or,

[0183] The computer program is used to enable the processor to execute the distributed transaction submission method provided in each of the above embodiments, and is applied to the coordination node, for example, including:

[0184] Receive transaction submission request information sent by the client;

[0185] Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes;

[0186] If a first request success message sent by all participating nodes is received within a preset time, a second request message is sent to all participating nodes;

[0187] Receive the second request success message sent by all the participating nodes, and send the transaction execution completion information of all the participating nodes to the client.

[0188] The processor-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NANDFLASH), solid-state drives (SSDs)), etc.

[0189] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0190] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0191] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A distributed transaction submission method, applied to participating nodes, characterized in that: include: Receive a first request message sent by the coordinating node, and write data in the first request message to a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes; When the data has been successfully written into the storage medium, sending a first request success message to the coordinating node, where the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction; receiving a second request message sent by the coordinating node, and executing the relevant transaction, wherein the second request message is used to instruct the participating nodes to start executing the relevant transaction; After the relevant transaction is completed, a second request success message is sent to the coordinating node, where the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed; Writing a status log of transaction execution completion of the participating nodes into the storage medium; All participating nodes asynchronously write the status log of the transaction execution completion to the storage medium; After receiving the first request message sent by the coordination node, the method further includes: Regularly query the status information of the coordinating node and all participating nodes; If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node. The target coordination node is used to execute relevant operations of the coordination node. The metadata information of the participating node includes the unique code and status information of the participating node.

2. The distributed transaction submission method according to claim 1, characterized in that: Also includes: If the first request message is not received, or if an exception occurs in the processing of the first request message, a first request failure message is sent to the coordination node or no information is fed back. The first request failure message is used to indicate to the coordination node that the participating node is not ready to commit the transaction.

3. The distributed transaction submission method according to claim 2, characterized in that: After sending the first request failure message to the coordination node, the method further includes: receiving a third request message sent by the coordinating node to suspend transaction submission, wherein the third request message is used to instruct the participating nodes to suspend transaction submission; After the transaction submission is aborted, a third request success message is sent to the coordinating node, where the third request success message is used to indicate to the coordinating node that the transaction abort of the participating node is complete.

4. A distributed transaction submission method, applied to a coordination node, characterized in that: include: Receive transaction submission request information sent by the client; Obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes; If a first request success message sent by all participating nodes is received within a preset time, a second request message is sent to all participating nodes; Receiving the second request success message sent by all participating nodes, sending transaction execution completion information of all participating nodes to the client, and asynchronously writing the transaction execution completion status log to the storage medium by all participating nodes; After all participating nodes receive the first request message sent by the coordinating node, the following steps are also performed: Regularly query the status information of the coordinating node and all participating nodes; If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node. The target coordination node is used to execute relevant operations of the coordination node. The metadata information of the participating node includes the unique code and status information of the participating node.

5. The distributed transaction submission method according to claim 4, characterized in that: After sending the first request message to all participating nodes, the method further includes: If a first request failure message is received from the target participating node, or if the first request success message is not received from all participating nodes within a preset time, a third request message is sent to all participating nodes; receiving third request success messages sent by all participating nodes, and sending transaction submission failure information of all participating nodes to the client; The target participating node includes at least one participating node among all the participating nodes.

6. A distributed transaction submission device, characterized in that: include: A first writing unit is configured to receive a first request message sent by the coordinating node, and write data in the first request message into a storage medium, where the first request message carries transaction submission request information and metadata information of all participating nodes; A first sending unit is configured to send a first request success message to the coordinating node when the data has been successfully written into the storage medium, wherein the first request success message is used to indicate to the coordinating node that the participating nodes are ready to commit the transaction; an execution unit, configured to receive a second request message sent by the coordinating node and execute a related transaction, wherein the second request message is used to instruct the participating nodes to start executing the related transaction; A second sending unit is configured to send a second request success message to the coordinating node after completing the execution of the related transaction, wherein the second request success message is used to indicate to the coordinating node that the transaction execution of the participating node is completed; A second writing unit, configured to write a status log of transaction execution completion of the participating node into the storage medium; All participating nodes asynchronously write the status log of the transaction execution completion to the storage medium; After receiving the first request message sent by the coordination node, the method further includes: Regularly query the status information of the coordinating node and all participating nodes; If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node. The target coordination node is used to execute relevant operations of the coordination node. The metadata information of the participating node includes the unique code and status information of the participating node.

7. A distributed transaction submission device, characterized in that: include: A receiving unit, configured to receive transaction submission request information sent by a client; a third sending unit, configured to obtain metadata information of all participating nodes, generate a first request message based on the transaction submission request information and the metadata information of all participating nodes, and send the first request message to all participating nodes; A fourth sending unit is configured to send a second request message to all the participating nodes if a first request success message sent by all the participating nodes is received within a preset time; a fifth sending unit, configured to receive the second request success message sent by all participating nodes, and send transaction execution completion information of all participating nodes to the client, wherein the transaction execution completion status log is asynchronously written to a storage medium by all participating nodes; After all participating nodes receive the first request message sent by the coordinating node, the following steps are also performed: Regularly query the status information of the coordinating node and all participating nodes; If it is determined that the status information of the coordination node is abnormal, based on the metadata information of all participating nodes, the participating node with the smallest coding ID is obtained, and the participating node with the smallest coding ID is used as the target coordination node. The target coordination node is used to execute relevant operations of the coordination node. The metadata information of the participating node includes the unique code and status information of the participating node.

8. An electronic device comprising a processor and a memory storing a computer program, characterized in that: When the processor executes the computer program, the processor implements the steps of the distributed transaction submission method according to any one of claims 1 to 3, or implements the steps of the distributed transaction submission method according to any one of claims 4 to 5.

9. A processor-readable storage medium, characterized in that: The processor-readable storage medium stores a computer program, which is used to enable the processor to execute the steps of the distributed transaction submission method according to any one of claims 1 to 3, or to execute the steps of the distributed transaction submission method according to any one of claims 4 to 5.

Citation Information

Patent Citations

  • Distributed transaction processing method and apparatus

    CN106325978A

  • Distributed transaction processing method and device and storage medium

    CN109783204A