CN113296897A - Distributed transaction processing method, device, equipment and machine readable medium - Google Patents

Distributed transaction processing method, device, equipment and machine readable medium Download PDF

Info

Publication number
CN113296897A
CN113296897A CN202010706300.7A CN202010706300A CN113296897A CN 113296897 A CN113296897 A CN 113296897A CN 202010706300 A CN202010706300 A CN 202010706300A CN 113296897 A CN113296897 A CN 113296897A
Authority
CN
China
Prior art keywords
transaction
branch
node
action
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010706300.7A
Other languages
Chinese (zh)
Other versions
CN113296897B (en
Inventor
季敏
郭平
申海强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Group Holding Ltd
Original Assignee
Alibaba Group Holding Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN202010706300.7A priority Critical patent/CN113296897B/en
Publication of CN113296897A publication Critical patent/CN113296897A/en
Application granted granted Critical
Publication of CN113296897B publication Critical patent/CN113296897B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • Software Systems (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a distributed transaction processing method, a device, equipment and a machine readable medium, wherein the method comprises the following steps: intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; in the case that the correlation action is a commit action, not performing the commit action; and sending a global request to a third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction. The embodiment of the application can improve the processing performance of the distributed transaction.

Description

Distributed transaction processing method, device, equipment and machine readable medium
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method for processing a distributed transaction, a device for processing a distributed transaction, and a machine-readable medium.
Background
Transactions (transactions) are a logical unit of work that accesses a database for the purpose of implementing a particular service function, and typically include local transactions and distributed transactions. A distributed transaction refers to a transaction that consists of several transaction branches in a distributed system, which may span different resources, and requires that the multiple transaction branches remain relatively consistent during execution of the transaction.
In the case of the end of a distributed transaction, the consistency of the transaction requires that the database operations involved either commit or abort altogether. To fulfill the above requirements, the processing of distributed transactions typically employs a two-phase commit approach. In the first phase, a prepare request is sent by the initiator (or coordinator) to the participants to ask whether the participants can complete the distributed transaction branch under their responsibility, and the participants reply to the initiator with the result of success or failure of the phase processing. In the second stage, if all participants reply that the one-stage processing is successful, the initiator sends two-stage submission requests to all the participants; otherwise, the initiator sends a two-phase rollback request to all participants, and the participants execute submission or rollback operation according to the two-phase request of the initiator.
The inventor finds that, in the first stage, after a participant receives a preparation request, if a transaction branch of the participant can be submitted, the participant records undo (undo) and redo (redo) information into a transaction log; the log operations described above will affect the processing performance of the distributed transaction.
Also, to achieve isolation of distributed transactions, for example, to avoid uncommitted data of one transaction being read by another transaction, a participant sets a global lock, specifically a read lock for read operations and a write lock for write operations, thus achieving a higher level of isolation. However, the global lock described above will affect the processing performance of the distributed transaction.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present application is to provide a method for processing a distributed transaction, which can improve the processing performance of the distributed transaction.
Correspondingly, the embodiment of the application also provides a distributed transaction processing device, equipment and a machine readable medium, which are used for ensuring the implementation and application of the method.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a first node, and the method includes:
intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the correlation action is a commit action, not performing the commit action;
and sending a global request to a third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a second node, and the method includes:
intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
in the event that the correlation action is a commit action, the commit action is not performed.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a third node, and the method includes:
receiving a global request sent by a first node; the global request is obtained according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
sending the branch request to first nodes or second nodes corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a first node, and the method includes:
intercepting related actions of the data operation command corresponding to the local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the correlation action is a commit action, not performing the commit action;
and sending a global request to the third node according to the execution result of the data operation command corresponding to the transaction branch in the distributed transaction.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a second node, and the method includes:
intercepting related actions of the data operation command corresponding to the local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; the connection object of the database is matched with the distributed transaction;
in the event that the correlation action is a commit action, the commit action is not performed.
In order to solve the above problem, an embodiment of the present application discloses a distributed transaction processing method, which is applied to a third node, and the method includes:
receiving a global request sent by a first node; the global request is obtained according to the execution result of the data operation command corresponding to the transaction branch in the distributed transaction;
sending the branch request to first nodes or second nodes corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a data operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the data operation command is used as the commit action; the connection object of the database is matched with the distributed transaction.
On the other hand, the embodiment of the present application further discloses a distributed transaction processing apparatus, which is applied to a first node, and includes:
the interception module is used for intercepting related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
a non-commit module, configured to not execute the commit action if the relevant action is a commit action;
and the global request sending module is used for sending a global request to the third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
On the other hand, the embodiment of the present application further discloses a distributed transaction processing apparatus, which is applied to a second node, and the apparatus includes:
the interception module is used for intercepting related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
and the non-submitting module is used for not executing the submitting action under the condition that the related action is the submitting action.
On the other hand, the embodiment of the present application further discloses a distributed transaction processing apparatus, which is applied to a third node, and the apparatus includes:
the global request receiving module is used for receiving a global request sent by a first node; the global request is obtained according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
a branch request sending module, configured to send the branch request to the first node or the second node corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
In another aspect, an embodiment of the present application further discloses an apparatus, including:
one or more processors; and
one or more machine-readable media having instructions stored thereon, which when executed by the one or more processors, cause the apparatus to perform one or more of the methods described above.
In yet another aspect, embodiments of the present application disclose one or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform one or more of the aforementioned methods.
The embodiment of the application has the following advantages:
the method and the device for intercepting the database operation command intercept the related action of the local transaction branch corresponding to the database operation command, and do not execute the submitting action under the condition that the related action is taken as the submitting action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; in this way, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level of a REPEATABLE READ (RR) may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
Moreover, after the local transaction branch is executed in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method under the condition that the local transaction branch is not submitted, or the local transaction branch can be rolled back according to the rolling back method, or the local transaction branch can be automatically rolled back under the condition that the downtime occurs. Therefore, the embodiment of the application can realize the subsequent submission action or the rollback action of the local transaction branch under the condition of not executing the log operation corresponding to the undo information and the redo information. The embodiment of the application can save the cost corresponding to the log operation of the local transaction branch, so that the processing performance of the distributed transaction can be improved.
Drawings
FIG. 1 is a schematic diagram of a distributed system of an embodiment of the present application;
FIG. 2 is a flowchart illustrating a first embodiment of a distributed transaction processing method according to the present application;
FIG. 3 is a flowchart illustrating steps of a second embodiment of a distributed transaction processing method according to the present application;
FIG. 4 is a flowchart illustrating a third embodiment of a distributed transaction processing method according to the present application;
FIG. 5 is a flowchart illustrating a fourth step of an embodiment of a method for processing distributed transactions according to the present application;
FIG. 6 is a flowchart of the steps of an embodiment of a distributed transaction processing method of the present application;
FIG. 7 is a flowchart illustrating a third embodiment of a distributed transaction processing method according to the present application;
FIG. 8 is a flowchart illustrating a fourth step of an embodiment of a method for processing distributed transactions according to the present application;
FIG. 9 is a block diagram of an embodiment of a distributed transaction processing apparatus according to the present application;
FIG. 10 is a block diagram of an embodiment of a distributed transaction processing apparatus of the present application;
FIG. 11 is a block diagram of an embodiment of a distributed transaction processing apparatus according to the present application; and
fig. 12 is an exemplary device 1300 that can be used to implement the various embodiments described above in this application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description.
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments that can be derived from the embodiments given herein by a person of ordinary skill in the art are intended to be within the scope of the present disclosure.
While the concepts of the present application are susceptible to various modifications and alternative forms, specific embodiments thereof have been shown by way of example in the drawings and will herein be described in detail. It should be understood, however, that the description above is not intended to limit the application to the particular forms disclosed, but on the contrary, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the application.
Reference in the specification to "one embodiment," "an embodiment," "a particular embodiment," or the like, means that the embodiment described may include a particular feature, structure, or characteristic, but every embodiment may or may not necessarily include the particular feature, structure, or characteristic. Moreover, such phrases are not necessarily referring to the same embodiment. Further, where a particular feature, structure, or characteristic is described in connection with an embodiment, it is submitted that it is within the knowledge of one skilled in the art to affect such feature, structure, or characteristic in connection with other embodiments whether or not explicitly described. In addition, it should be understood that items in the list included in the form "at least one of a, B, and C" may include the following possible items: (A) (ii) a (B) (ii) a (C) (ii) a (A and B); (A and C); (B and C); or (A, B and C). Likewise, a listing of items in the form of "at least one of a, B, or C" may mean (a); (B) (ii) a (C) (ii) a (A and B); (A and C); (B and C); or (A, B and C).
In some cases, the disclosed embodiments may be implemented as hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more transitory or non-transitory machine-readable (e.g., computer-readable) storage media, which may be executed by one or more processors. A machine-readable storage medium may be implemented as a storage device, mechanism, or other physical structure (e.g., a volatile or non-volatile memory, a media disk, or other media other physical structure device) for storing or transmitting information in a form readable by a machine.
In the drawings, some structural or methodical features may be shown in a particular arrangement and/or ordering. Preferably, however, such specific arrangement and/or ordering is not necessary. Rather, in some embodiments, such features may be arranged in different ways and/or orders than as shown in the figures. Moreover, the inclusion of structural or methodical features in particular figures is not meant to imply that such features are required in all embodiments and that, in some embodiments, such features may not be included or may be combined with other features.
The embodiment of the application can be applied to a processing scene of the distributed transaction and is used for improving the processing performance of the distributed transaction. A distributed transaction may involve a transaction of multiple database operations, which may be operations on different databases or multiple operations on one database.
Examples of processing scenarios for distributed transactions may include: a transaction scenario, or a user management scenario, etc.
Taking a transaction scenario as an example, assuming that a transaction is a transfer of 200 yuan from a user a to a user B, the processing flow of the transaction may include: the transaction is started; calling a roll-out service, and rolling out 200 yuan A; transferring the transfer-in service, and transferring B into 200 yuan; the transaction is ended. The transaction involves a distributed transaction, as the roll-out or roll-in service may be located in a different process, or the account of user a and the account of user B are located in different databases.
Assuming that the user management scenario is a new user credit scenario, the corresponding processing flow may include: starting; calling a new user service; invoking an add points service; and (6) ending. This process involves a distributed transaction, since the added user service or the added points service may be located in a different process or involve a different database.
In a conventional processing method for a distributed transaction, undo information and redo information are usually recorded in a transaction log, and a global lock is set to achieve isolation of the distributed transaction. The log operations and global locks described above will affect the processing performance of the distributed transaction.
Aiming at the technical problem that diary operations and global locks affect the processing performance of distributed transactions, the embodiment of the application provides a distributed transaction processing method, which specifically comprises the following steps: intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; the connection object of the database is matched with the distributed transaction; in the case where the above-described correlation action is a commit action, the above-described commit action is not performed.
In the embodiment of the present application, in an environment of a connection object of a database, a database operation command corresponding to a local transaction branch is executed (hereinafter, referred to as a local transaction branch execution). The connection object may characterize a session with the database.
After the local transaction branch is executed in the environment of the connection object of the database, the local transaction branch may be committed according to a commit (commit) method, or the local transaction branch may be rolled back according to a roll back (rollback) method, and if the local transaction branch is not committed, the data corresponding to the local transaction branch is not really inserted into the database corresponding to the connection object.
The method and the device for intercepting the database operation command intercept the related action of the local transaction branch corresponding to the database operation command, and do not execute the submitting action under the condition that the related action is taken as the submitting action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; in this way, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level of a REPEATABLE READ (RR) may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
After the local transaction branch is executed in the environment of the connection object of the database, the local transaction branch can be submitted according to a submission method under the condition that the local transaction branch is not submitted, or the local transaction branch can be rolled back according to a rollback method. Therefore, the embodiment of the application can realize the subsequent submission action or the rollback action of the local transaction branch under the condition of not executing the log operation corresponding to the undo information and the redo information. The embodiment of the application can save the cost corresponding to the log operation of the local transaction branch, so that the processing performance of the distributed transaction can be improved.
Referring to fig. 1, a schematic diagram of a distributed system according to an embodiment of the present application is shown, where the distributed system may specifically include: a first node 101, a second node 102 and a third node 103.
The first node 101 may be a global management node of the distributed transaction, and a GTM (global transaction manager) may be run on the global management node to manage the global transaction of the distributed transaction. First node 101 may also manage a transaction branch of a distributed transaction, such as transaction branch 1 in FIG. 1.
The at least one second node 102 may be a local management node of the distributed transaction, on which an LTM (local transaction manager) may be run to manage transaction branches of the distributed transaction, such as transaction branch 2 to transaction branch n in fig. 1, where n may be a natural number greater than 1.
The third node 103 may be a transaction coordinator node of the distributed transaction, on which a TC (transaction coordinator) may run to maintain the running state of the distributed transaction, and coordinate and drive the commit or rollback of the distributed transaction.
In the embodiment of the invention, the transaction branch 2-the transaction branch n can be triggered by using a service calling mode.
For example, the first node 101 calls the service corresponding to the transaction branch 2 and calls the service corresponding to the transaction branch 3 according to the transaction branch 1.
For another example, the first node 101 calls the service corresponding to the transaction branch 2 according to the transaction branch 1, and the second node 102 calls the service corresponding to the transaction branch (i +1) according to the transaction branch i, where i may be a natural number greater than 1.
It can be understood that the embodiment of the present application does not impose a limitation on the specific triggering manner of the transaction branch 2 to the transaction branch n.
The embodiment of the application can perform distributed transaction processing through two phases.
Wherein, in a first phase, the first node 101 and the second node 102 register a transaction branch with the third node 103; executing the local transaction branch in the environment of the connection object of the database, and returning the execution result corresponding to the local transaction branch to the corresponding calling node, so that the first node 101 obtains the execution results corresponding to all the transaction branches.
In the second stage, the first node 101 determines the execution result of the database operation command corresponding to all the transaction branches in the distributed transaction, and sends a global request to the third node 103 according to the corresponding determination result, where the global request may include: a global commit request or a global rollback request. The third node 103 may send branch requests corresponding to the global requests to the first node 101 and the second node 102 to synchronize the global requests on a global scale.
For the first node 101 and the second node 102, it may execute the local transaction branch in the environment of the connection object of the database, intercept the related action of the local transaction branch corresponding to the database operation command, and in the case that the related action is a commit action, not execute the commit action. Because the actual commit action is not executed, under the condition that the local transaction branch is not committed, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; thus, the embodiment of the application can realize the isolation level of the distributed transaction according to the isolation level of the local transaction branch.
Moreover, the local transaction branch can be submitted according to the submitting method under the condition that the local transaction branch is not submitted, or the local transaction branch can be rolled back according to the rolling back method, or the local transaction branch can be automatically rolled back under the condition that the local transaction branch is down. Therefore, the embodiment of the application can realize the subsequent submission action or the rollback action of the local transaction branch under the condition of not executing the log operation corresponding to the undo information and the redo information.
In addition, the embodiment of the present application may carry the database operation command through a database statement such as an SQL (Structured Query Language) statement. The first node 101 and the second node 102 in the embodiment of the present application execute the SQL statement in the environment of the connection object of the database, and do not perform the analysis of the SQL statement and the storage of the front and back mirror images, so that the application range of the database can be enhanced, and the processing performance of the distributed transaction can be improved.
Method embodiment one
Referring to fig. 2, a flowchart of a first embodiment of a distributed transaction processing method according to the present application is shown, and is applied to a first node, where the method specifically includes the following steps:
step 201, intercepting relevant actions of database operation commands corresponding to local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
step 202, when the correlation action is a submitting action, the submitting action is not executed;
step 203, sending a global request to the third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
The first node may be a global management node for the distributed transaction, which may trigger an initiating action, a committing action or a rollback action, and an ending action for the distributed transaction based on data interactions with the third node.
In an optional embodiment of the present application, the method may further include: sending a transaction initiation request to a third node; receiving xid (transaction identifier) returned by the first node according to the transaction initiation request; saving the transaction identifier to a transaction context of the distributed transaction.
xid may have global uniqueness. Alternatively, the third node may generate xid using a snowflake algorithm or a full incremental sequence method. It is understood that the embodiment of the present application does not limit the specific method for generating xid.
The Transaction Context (Transaction Context) records the relevant information of the Transaction it represents. Through the transaction context, the transaction involved and the state of the transaction can be uniquely determined.
Optionally, the transaction context may be bound to the thread by using a thread local variable (thread local), and it is understood that the embodiment of the present application is not limited to a specific storage manner of the transaction context.
After initiating the distributed transaction, on one hand, the first node triggers a local transaction branch and manages the local transaction branch; on the other hand, the first node triggers the remote transaction branch by calling the service.
Embodiments of triggering a remote transaction branch are provided herein.
In one embodiment, the method may further include: sending a first calling request to a first related service of the distributed transaction; the first invocation request carries a transaction context of the distributed transaction, so that the first related service executes a first remote transaction branch of the distributed transaction. For example, the local transaction branch is transaction a and the first remote transaction branch is transaction B, and/or the local transaction branch is transaction a and the first remote transaction branch is transaction C, etc.
In the embodiment of the present application, the first invocation request carries a transaction context, where the transaction context may include: xid, processing logic for the transaction, etc. Xid in the context of a transaction may associate different transaction branches onto the same distributed transaction. Processing logic may cause the first remote transaction branch to be processed in accordance with the processing logic, e.g., may cause the first remote transaction branch to execute its own transaction branch information. Optionally, the first remote transaction branch may also be made to call an associated third remote transaction branch, and so on.
Optionally, the first Call request in the embodiment of the present application may be an RPC (Remote Procedure Call) request, an HTTP (hypertext Transfer Protocol) request, or the like.
Optionally, the method may further include: receiving an execution result of a database operation command corresponding to a first remote transaction branch, returned by the first related service according to the first calling request; and judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition or not.
In practical applications, a parameter in the first call request may be called back to return the execution result. The database operation command corresponding to the first remote transaction branch may be executed in an environment of the connection object to obtain a corresponding execution result, which is not described herein again.
The format of the execution result may include: JSON (JSON Object Notation), XML (Extensible Markup Language), structure, collection Object, and the like.
The first preset condition may characterize that the execution result corresponding to the transaction branch meets the condition that is expected to be met. It is understood that different transaction branches may correspond to different first preset conditions, and the specific first preset conditions are not limited in the embodiment of the present application.
According to one embodiment, the execution result includes a wrapper class of the result, the wrapper class includes a result code and/or an execution message, and if the result code is expected, the execution result may be considered to meet a first preset condition.
According to another embodiment, if the result code in the execution result is not in accordance with the expectation, the execution result may be considered to be not in accordance with the first preset condition. Or, the execution result includes an exception code, for example, an exception code caused by timeout or connection closure, and the execution result may be considered to be not in compliance with the first preset condition.
According to an embodiment, the method may further comprise: if the execution result corresponding to the first remote transaction branch meets a first preset condition, sending a second calling request to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second invocation request carries a transaction context of the distributed transaction, so that the second related service executes a second remote transaction branch of the distributed transaction. According to the processing logic of the distributed transaction, when the execution result corresponding to the first remote transaction branch meets the first preset condition, the second remote transaction branch can be continuously triggered.
It can be understood that, the triggering of the second remote transaction branch when the execution result corresponding to the first remote transaction branch meets the first preset condition is only an optional embodiment, and actually, whether the second remote transaction branch is triggered may be determined according to the processing logic of the distributed transaction.
It can be understood that the execution result of the database operation command corresponding to the first remote transaction branch, returned by the second correlation service according to the second call request, may be continuously received; and judging whether the execution result corresponding to the second remote transaction branch meets a first preset condition or not. The processing procedure of the execution result corresponding to the second remote transaction branch is similar to the processing procedure of the execution result corresponding to the first remote transaction branch, and is not described herein again, but only by referring to each other.
Embodiments of managing local transaction branches are provided herein.
The method and the device for processing the database operation command can obtain the connection object of the database corresponding to the local transaction branch, and execute the database operation command corresponding to the local transaction branch in the environment of the connection object of the database.
In this embodiment of the present application, the category of the connection object may include: JDBC (Java Database Connectivity), ODBC (Open Database Connectivity), or the like.
JDBC, among other things, is an application program interface in JAVA language that specifies how client programs access databases, providing methods such as querying and updating data in databases. ODBC may provide standard APIs (APPlication programming Interface) for database access, which accomplish the database access task through SQL.
In the embodiment of the application, the management of the transaction branch is performed through the connection object in the JDBC. After the transaction branch is executed, committing the transaction branch by using a commit method, rolling back the transaction branch by using a rollback method, and if the transaction branch is not committed, the data cannot be really inserted into the database.
In an optional embodiment of the present application, an action related to the database operation command corresponding to the local transaction branch may be intercepted, and in a case where the above-mentioned action is an execution action, the transaction branch is registered with the third node. The third node may return a transaction branch identification to coordinate multiple transaction branches for a distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In an optional embodiment of the present application, a related action of a database operation command corresponding to a local transaction branch may be intercepted, and in a case where the related action is a commit action, the commit action is not performed.
According to an embodiment, the not performing the submitting action specifically includes: if the correlation action is a commit action, the commit action is replaced with a null action. Of course, replacing the commit action with a null action is merely an alternative embodiment, and in fact, the commit action may not be processed.
After the database operation command corresponding to the local transaction branch is executed, the first node may obtain a corresponding execution result. In addition, as the initiating node of the distributed transaction, the first node may also obtain the execution results of other transaction branches.
In one example 1, a distributed transaction includes: transaction branch a and transaction branch B. The first node first triggers transaction branch a locally, and the execution result of the transaction branch can be obtained. Assuming that the first node triggers the transaction branch B by using a service calling method, the second node corresponding to the transaction branch B may return the execution result of the transaction branch B by using a callback method.
In one example 2, a distributed transaction includes: transaction branch a, transaction branch B, and transaction branch C. The triggering manner of the transaction branch a and the transaction branch B in example 1 and example 2 is similar, and details are not described here. Assuming that the first node triggers the transaction branch C by using a service calling method, the second node corresponding to the transaction branch C may return an execution result of the transaction branch C by using a callback method.
In one example 3, a distributed transaction includes: transaction branch a, transaction branch B, and transaction branch C. The triggering manner of the transaction branch a and the transaction branch B in example 1 and example 2 is similar, and details are not described here. Assuming that the second node corresponding to the transaction branch B triggers the transaction branch C by using a service calling method, the second node corresponding to the transaction branch C may return an execution result of the transaction branch C by using a callback method. And the second node corresponding to the transaction branch B may directly or indirectly feed back the execution result of the transaction branch C to the first node.
In this embodiment of the present application, optionally, the execution result of the database operation command corresponding to all the transaction branches in the distributed transaction may be judged, and according to the corresponding judgment result, the global request may be sent to the third node. Correspondingly, the sending method adopted for sending the global request to the third node specifically includes:
the sending method 1 is that if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction all meet a first preset condition, a global commit request is sent to a third node; or
And a sending mode 2, if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not accord with the first preset condition, sending a global rollback request to the third node.
For the sending method 1, if the execution results of all the transaction branches in the distributed transaction all meet the first preset condition, it may be considered that all the transaction branches in the distributed transaction are successfully executed, which will enable the whole distributed transaction to be successfully executed; a global commit request can be sent to the third node to effect commit of the entire distributed transaction.
For the sending method 2, if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not meet the first preset condition, it may be considered that any transaction branch is not successfully executed, which will make the whole distributed transaction unable to be executed; thus, to achieve consistency of distributed transactions, a global rollback request may be sent to the third node to achieve rollback of the entire distributed transaction.
In an optional embodiment of the present application, the method may further include: receiving a branch submission request sent by a third node; and responding to the branch submission request, and executing the submission action of the database operation command corresponding to the local transaction branch.
In this embodiment of the application, the result of the execution of the submitting action may include: commit success or commit failure. The first node may send the result of the performance of the commit action to the third node. If the execution result of the submitting action is a submitting failure, the third node can continue to send the branch submitting request to the first node until the execution result of the submitting action corresponding to the first node is a submitting success.
In another optional embodiment of the present application, the method may further include: receiving a branch rollback request sent by a third node; and responding to the branch rollback request, and executing the rollback action of the local transaction branch corresponding to the database operation command.
It should be noted that, in the process of executing the branch submission request or the branch rollback request, if a downtime occurs, a transaction compensation method may be adopted to perform remedial processing. Transaction compensation, i.e. any forward transaction operation in the transaction chain, must have a reversible transaction that fully complies with the rollback rules.
In this embodiment of the present application, the execution result of the rollback action may include: rollback success or rollback failure. The first node may send the result of the execution of the rollback action to the third node. If the execution result of the rollback action is that the rollback fails, the third node may continue to send the branch rollback request to the first node until the execution result of the rollback action corresponding to the first node is that the rollback succeeds.
In yet another optional embodiment of the present application, the method may further include: the result of the successful action of the global transaction is received from the third node, in which case the distributed transaction can be ended.
The result of the successful global transaction action may include: a global commit success, or a global rollback success. In the case that the branch request execution results corresponding to all the transaction branches in the distributed transaction all meet the second preset condition, the third node may send a result that the global transaction action is successful to the first node.
The second preset condition can be used for representing the condition met by the execution result of the branch request under the condition that the execution of the branch request is successful. The branch commit request or the branch rollback request may correspond to a second, different preset condition.
In summary, the distributed transaction processing method according to the embodiment of the present application intercepts the relevant actions of the database operation command corresponding to the local transaction branch, and does not execute the commit action when the relevant actions are taken as the commit action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; thus, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level that is not repeatable to read may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
Moreover, after the local transaction branch is executed in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method under the condition that the local transaction branch is not submitted, or the local transaction branch can be rolled back according to the rolling back method, or the local transaction branch can be automatically rolled back under the condition that the downtime occurs. Therefore, the embodiment of the application can realize the subsequent submission action or the rollback action of the local transaction branch under the condition of not executing the log operation corresponding to the undo information and the redo information. The embodiment of the application can save the cost corresponding to the log operation of the local transaction branch, so that the processing performance of the distributed transaction can be improved.
Method embodiment two
Referring to fig. 3, a flowchart illustrating steps of a second embodiment of a distributed transaction processing method according to the present application is shown, and the method is applied to a second node, and specifically may include the following steps:
step 301, intercepting relevant actions of database operation commands corresponding to local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
and step 302, when the correlation action is taken as a submitting action, not executing the submitting action.
The second node may be a local management node for the distributed transaction, which may manage the transaction branches for the distributed transaction.
In this embodiment, the second node may trigger the local transaction branch according to a call request sent by the first node or another second node. It is to be understood that the calling node of the calling request is not limited in the embodiments of the present application.
According to one embodiment, a first call request sent by a first node can be received; the first invocation request carries the transaction context of the distributed transaction, so that the corresponding transaction branch of the distributed transaction can be triggered and executed according to the first invocation request. For example, a first node triggers a transaction a, and the first node may invoke a transaction B related to the transaction a according to a first invocation request; and the second node may trigger and execute transaction B according to the first call request.
According to another embodiment, a call request sent by other nodes may be received. For example, a first node triggers a transaction a, and the first node may invoke a transaction B related to the transaction a according to a first invocation request; while the second node a may continue to invoke transaction C associated with transaction B; while the second node b may trigger and execute transaction C, etc.
In this embodiment of the application, optionally, a service calling manner may also be adopted to call the transaction branch related to the local transaction branch, for example, if the local transaction branch is transaction B, then transaction B related to transaction a may be called, and the like. Correspondingly, the method may further include: sending a third calling request to a third correlation service of the distributed transaction; the third invocation request carries a transaction context of the distributed transaction, so that the third related service executes a third remote transaction branch of the distributed transaction.
In this embodiment of the application, optionally, the method may further include: receiving an execution result of a database operation command corresponding to a third remote transaction branch, returned by the third correlation service according to the third calling request; and judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition or not.
In the embodiment of the application, the second node may determine whether an execution result corresponding to the remote transaction branch called by the second node meets a first preset condition, and if so, may continue to execute the processing logic of the distributed transaction; otherwise, a corresponding notification message may be returned to the calling node of the upper layer (e.g., the i-th layer calling node), and the notification message may prompt that the execution result corresponding to a certain transaction branch does not meet the first preset condition. It is understood that the calling node of the upper layer may be the first node; or, the calling node on the upper layer may be different from the first node, and in this case, the calling node on the i-th layer may continue to return the corresponding notification message to the calling node on the (i-1) th layer until the first node learns the notification message.
The method and the device for processing the database operation command can obtain the connection object of the database corresponding to the local transaction branch, and execute the database operation command corresponding to the local transaction branch in the environment of the connection object of the database.
In the embodiment of the application, the management of the transaction branch is performed through the connection object. After the transaction branch is executed, committing the transaction branch by using a commit method, rolling back the transaction branch by using a rollback method, and if the transaction branch is not committed, the data cannot be really inserted into the database.
In an optional embodiment of the present application, an action related to the database operation command corresponding to the local transaction branch may be intercepted, and in a case where the above-mentioned action is an execution action, the transaction branch is registered with the third node. The third node may return a transaction branch identification to coordinate multiple transaction branches for a distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In an optional embodiment of the present application, a related action of a database operation command corresponding to a local transaction branch may be intercepted, and in a case where the related action is a commit action, the commit action is not performed.
According to an embodiment, the not performing the submitting action specifically includes: if the correlation action is a commit action, the commit action is replaced with a null action. Of course, replacing the commit action with a null action is merely an alternative embodiment, and in fact, the commit action may not be processed.
After the second node executes the database operation command corresponding to the local transaction branch, a corresponding execution result can be obtained. Optionally, a parameter in the first call request may be called back to return the execution result to the calling node. The execution result can be used for the calling node to judge whether the execution result meets the first preset condition or not.
In an optional embodiment of the present application, the method may further include: receiving a branch submission request sent by a third node; and responding to the branch submission request, and executing the submission action of the database operation command corresponding to the local transaction branch.
In this embodiment of the application, the result of the execution of the submitting action may include: commit success or commit failure. The second node may send the result of the performance of the commit action to the third node. If the execution result of the submitting action is a submitting failure, the third node can continue to send the branch submitting request to the second node until the execution result of the submitting action corresponding to the second node is a submitting success.
In another optional embodiment of the present application, the method may further include: receiving a branch rollback request sent by a third node; and responding to the branch rollback request, and executing the rollback action of the local transaction branch corresponding to the database operation command.
It should be noted that, in the process of executing the branch submission request or the branch rollback request, if a downtime occurs, a transaction compensation method may be adopted to perform remedial processing. Transaction compensation, i.e. any forward transaction operation in the transaction chain, must have a reversible transaction that fully complies with the rollback rules.
In this embodiment of the present application, the execution result of the rollback action may include: rollback success or rollback failure. The second node may send the result of the execution of the rollback action to the third node. If the execution result of the rollback action is that the rollback fails, the third node may continue to send the branch rollback request to the second node until the execution result of the rollback action corresponding to the second node is that the rollback succeeds.
In summary, the distributed transaction processing method according to the embodiment of the present application intercepts the relevant actions of the database operation command corresponding to the local transaction branch, and does not execute the commit action when the relevant actions are taken as the commit action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; thus, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level that is not repeatable to read may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
Moreover, after the local transaction branch is executed in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method under the condition that the local transaction branch is not submitted, or the local transaction branch can be rolled back according to the rolling back method, or the local transaction branch can be automatically rolled back under the condition that the downtime occurs. Therefore, the embodiment of the application can realize the subsequent submission action or the rollback action of the local transaction branch under the condition of not executing the log operation corresponding to the undo information and the redo information. The embodiment of the application can save the cost corresponding to the log operation of the local transaction branch, so that the processing performance of the distributed transaction can be improved.
Method embodiment three
Referring to fig. 4, a flowchart of a third step of the embodiment of the distributed transaction processing method according to the present application is shown, and is applied to a third node, where the method specifically includes the following steps:
step 401, receiving a global request sent by a first node; the global request may be obtained according to an execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
step 402, sending the branch request to the first node or the second node corresponding to all the transaction branches in the distributed transaction;
the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute the commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
In this embodiment, the third node may be a transaction coordination node of the distributed transaction, which may maintain the running state of the distributed transaction, and coordinate and drive the commit or rollback of the distributed transaction.
In this embodiment of the application, the third node may provide a connection object corresponding to the database for the distributed transaction, so that the first node or the second node obtains the connection object corresponding to the local transaction branch. It can be understood that other nodes may also provide a connection object corresponding to the database for the distributed transaction, and the embodiment of the present application does not impose a limitation on the specific providing node of the connection object.
In an embodiment of the present application, the third node may provide a registration service for the transaction branch. Accordingly, the third node may receive the registration request of the first node or the second node and return the transaction branch identification to coordinate the plurality of transaction branches corresponding to one distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In this embodiment of the application, optionally, the receiving the global request sent by the first node specifically includes:
if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, receiving a global commit request from a first node; or
And if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not meet the first preset condition, receiving a global rollback request from the first node.
In this embodiment of the application, optionally, the method may further include: receiving a branch request execution result sent by a first node or a second node; and if the execution result of the branch request does not meet the second preset condition, sending the corresponding branch request to the corresponding node until the execution result of the corresponding submitting action of the first node is successful in submitting.
In this embodiment of the application, optionally, the method may further include: receiving a branch request execution result sent by a first node or a second node; if the branch request execution results corresponding to all the transaction branches in the distributed transaction meet the second preset condition, a result that the global transaction action is successful is sent to the first node, and under the condition, the first node can finish the processing of the distributed transaction.
Method example four
Referring to fig. 5, a flowchart illustrating a fourth step of an embodiment of a distributed transaction processing method according to the present application is shown, where the method may perform data interaction among a first node, a second node, and a third node, and the method specifically includes the following steps:
step 501, the first node sends a transaction initiation request to the third node;
step 502, the third node returns xid to the first node;
step 503, the first node stores xid to the transaction context;
step 504, the first node intercepts a database operation command corresponding to the transaction branch 1, and registers the transaction branch 1;
the first node may execute the database operation command corresponding to transaction branch 1 in the context of the join object of the database.
Step 505, the first node sends a call request to the second node, where the call request carries a transaction context to trigger the transaction branch 2, and associate the transaction branch 1 and the transaction branch 2 to the same xid;
it will be appreciated that the second node may bind the transaction context to the transaction context of transaction branch 2.
Step 506, the second node intercepts a database operation command corresponding to the transaction branch 2, and registers the transaction branch 2;
the second node may execute the database operation command corresponding to transaction branch 2 in the context of the join object of the database.
Step 507, the second node intercepts the commit action of the transaction branch 2 and replaces the commit action with a null operation;
after completion of the transactional branch 2 execution, the connection object may automatically initiate a corresponding commit action, which may be intercepted by the second node.
Step 508, the second node returns the execution result 2 of the transaction branch 2 to the first node;
step 509, if the execution result 2 meets the first preset condition, the first node continues to execute the processing logic; for example, transaction branch 1 may be executed according to execution result 2, or other transaction branches, such as transaction branch 3, transaction branch 4, etc., may be triggered according to execution result 2.
Step 510, the first node intercepts the commit action of the transaction branch 1, and replaces the commit action with a null operation;
step 511, if the execution result 1 meets the first preset condition, the first node sends a global submission request to the third node;
or, in the case that the distributed transaction includes transaction branches other than the transaction branch 1 and the transaction branch 2, after the processing logic of the distributed transaction is completed, the first node may determine whether all the transaction branches meet the first preset condition, and if so, send a global commit request to the third node.
Step 512, the third node sends a first branch submission request to the first node;
step 513, the first node executes the commit action of the transaction branch 1;
step 514, the first node sends a first submitting execution result to the third node;
it should be noted that, in the case that the first commit execution result does not meet the second preset condition, the third node may continue to send the first branch commit request to the first node until the first commit execution result does not meet the second preset condition.
Step 515, the third node sends a second branch submission request to the second node;
step 516, the second node executes the commit action of the transaction branch 2;
step 517, the second node sends a second submission execution result to the third node;
it should be noted that, in the case that the second commit execution result does not meet the second preset condition, the third node may continue to send the second branch commit request to the second node until the second commit execution result does not meet the second preset condition.
And 518, under the condition that the first submitting execution result and the second submitting execution result both accord with the second preset condition, the third node sends a result that the global submitting is successful to the first node.
It is understood that in the embodiment shown in fig. 5, the distributed transaction includes a transaction branch 1 and a transaction branch, which is only an example, and actually, the distributed transaction may further include: transaction branches other than transaction branch 1 and transaction branch 2.
In addition, it is understood that the order of actions described in the above embodiment of fig. 5 is only an example, and in fact, the embodiment of the present application is not limited by the described order of actions. For example, the embodiment of the present application is not limited by the sequence of actions described in step 504 and step 505; as another example, the present application is not limited by the sequence of actions described in step 512 and step 515.
Fig. 5 in the above embodiment, a case where both the execution result 2 and the execution result 1 satisfy the first preset condition is described.
In other embodiments, if any one of the execution result 2 and the execution result 1 does not meet the first preset condition, the first node sends a global rollback request to the third node.
For example, in the case that the execution result 2 does not meet the first preset condition, step 510 may be saved, and the step corresponding to the first node sending the global rollback request to the third node is skipped.
For another example, when the execution result 2 meets the first preset condition and the execution result 1 meets the first preset condition, the step corresponding to the first node sending the global rollback request to the third node may be skipped to.
Method example five
Referring to fig. 6, a flowchart illustrating fifth steps of an embodiment of a distributed transaction processing method according to the present application is shown, and the method is applied to a first node, and specifically may include the following steps:
step 601, intercepting related actions of a data operation command corresponding to a local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
step 602, in the case that the correlation action is a commit action, not executing the commit action;
step 603, sending a global request to the third node according to the execution result of the data operation command corresponding to the transaction branch in the distributed transaction.
The embodiment can intercept the related action of the data operation command corresponding to the local transaction branch, and do not execute the commit action under the condition that the related action is taken as the commit action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; thus, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level that is not repeatable to read may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
The data operation command of the present embodiment may characterize a command related to a data operation. The data operation command may be a database operation command or other operation commands. The other operation command may be an operation command of an application layer, such as a transaction operation command, and the transaction operation may include: the method includes the steps of money transfer-in or transfer-out operation, commodity ordering or payment operation, user management operation and the like, and it can be understood that specific data operation commands are not limited in the embodiment of the application.
The data operation command of the present embodiment corresponds to a local transaction branch. The data operation command is applied to the environment of the connection object of the database and can refer to executing the local transaction branch in the environment of the connection object of the database. For example, in the case where the data manipulation command is a database manipulation command, the data manipulation command may be directly executed. Alternatively, in the case where the data operation command is not a database operation command, the database operation command associated with the data operation command may be executed.
For the fifth embodiment of the method shown in fig. 6, since the processing procedure is similar to that of the first embodiment of the method shown in fig. 2, it is not repeated herein and reference may be made to each other.
Optionally, the sending the global request to the third node may include:
if the execution results of the data operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or
And if the execution result of the data operation command corresponding to any transaction branch in the distributed transaction does not accord with the first preset condition, sending a global rollback request to the third node.
Optionally, the method may further include:
receiving a branch submission request sent by a third node;
and responding to the branch submission request, and executing the submission action of the data operation command corresponding to the local transaction branch.
Optionally, the method may further include:
receiving a branch rollback request sent by a third node;
and responding to the branch rollback request, and executing the rollback action of the data operation command corresponding to the local transaction branch.
Optionally, the method may further include:
in the case where the above-described correlation action is an execution action, the transaction branch is registered with the third node.
Optionally, the not performing the submitting action may include:
if the correlation action is a commit action, the commit action is replaced with a null action.
Optionally, the method may further include:
sending a transaction initiation request to a third node;
receiving a transaction identifier returned by the first node according to the transaction initiation request;
saving the transaction identifier to a transaction context of the distributed transaction.
Optionally, the method may further include:
sending a first calling request to a first related service of the distributed transaction; the first invocation request carries a transaction context of the distributed transaction, so that the first related service executes a first remote transaction branch of the distributed transaction.
Optionally, the method may further include:
receiving an execution result of a data operation command corresponding to a first remote transaction branch, returned by the first related service according to the first calling request;
and judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition or not.
Optionally, the method may further include:
if the execution result corresponding to the first remote transaction branch meets a first preset condition, sending a second calling request to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second invocation request carries a transaction context of the distributed transaction, so that the second related service executes a second remote transaction branch of the distributed transaction.
Method example six
Referring to fig. 7, a flowchart of sixth steps of an embodiment of a distributed transaction processing method according to the present application is shown, and is applied to a second node, where the method specifically includes the following steps:
step 701, intercepting related actions of a data operation command corresponding to a local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; the connection object of the database is matched with the distributed transaction;
step 702, when the correlation action is a commit action, the commit action is not executed.
The method and the device for processing the data operation command intercept the related action of the data operation command corresponding to the local transaction branch, and do not execute the submitting action under the condition that the related action is used as the submitting action. Because the embodiment of the application does not execute the actual submission action, under the condition of not submitting the local transaction branch, the data corresponding to the local transaction branch cannot be really inserted into the database corresponding to the connection object; thus, the embodiment of the present application may implement, without setting a global lock, an isolation level of a distributed transaction according to an isolation level of a local transaction branch, for example, an isolation level that is not repeatable to read may be implemented. The embodiment of the application can save the cost corresponding to the global lock, so that the processing performance of the distributed transaction can be improved.
For the sixth embodiment of the method shown in fig. 7, the processing procedure is similar to that of the embodiment of the method shown in fig. 3, and therefore, the description is omitted here and reference may be made to each other.
Optionally, the method may further include:
receiving a branch submission request sent by a third node;
and responding to the branch submission request, and executing the submission action of the data operation command corresponding to the local transaction branch.
Optionally, the method may further include:
receiving a branch rollback request sent by a third node;
and responding to the branch rollback request, and executing the rollback action of the data operation command corresponding to the local transaction branch.
Optionally, the method may further include:
in the case where the above-described correlation action is an execution action, the transaction branch is registered with the third node.
Optionally, the not performing the submitting action may include:
if the correlation action is a commit action, the commit action is replaced with a null action.
Optionally, the method may further include:
sending a third calling request to a third correlation service of the distributed transaction; the third invocation request carries a transaction context of the distributed transaction, so that the third related service executes a third remote transaction branch of the distributed transaction.
Optionally, the method may further include:
receiving an execution result of a data operation command corresponding to a third remote transaction branch, returned by the third correlation service according to the third calling request;
and judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition or not.
Method example seven
Referring to fig. 8, a flowchart illustrating steps of a seventh embodiment of a distributed transaction processing method according to the present application is shown, and is applied to a third node, where the method specifically includes the following steps:
step 801, receiving a global request sent by a first node; the global request may be obtained according to an execution result of the data operation command corresponding to the transaction branch in the distributed transaction;
step 802, sending the branch request to the first node or the second node corresponding to all the transaction branches in the distributed transaction; the first node or the second node executes a data operation command corresponding to a local transaction branch in the environment of a connection object of the database, and does not execute the commit action under the condition that the correlation action of the data operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
In this embodiment, the third node may be a transaction coordination node of the distributed transaction, which may maintain the running state of the distributed transaction, and coordinate and drive the commit or rollback of the distributed transaction.
For the seventh embodiment of the method shown in fig. 8, the processing procedure is similar to that of the seventh embodiment of the method shown in fig. 4, and therefore, the description thereof is omitted and reference may be made to the seventh embodiment of the method.
Optionally, the receiving the global request sent by the first node may include:
if the execution results of the data operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, receiving a global commit request from a first node; or
And if the execution result of the data operation command corresponding to any transaction branch in the distributed transaction does not meet the first preset condition, receiving a global rollback request from the first node.
Optionally, the method may further include:
receiving a branch request execution result sent by a first node or a second node;
and if the execution result of the branch request does not meet the second preset condition, sending the corresponding branch request to the corresponding node.
Optionally, the method may further include:
receiving a branch request execution result sent by a first node or a second node;
and if the branch request execution results corresponding to all the transaction branches in the distributed transaction meet a second preset condition, sending a result that the global transaction action is successful to the first node.
Optionally, the method may further include:
for distributed transactions, connection objects of corresponding databases are provided.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently depending on the embodiments. Further, those skilled in the art will also appreciate that the embodiments described in the specification are presently preferred and that no particular act is required of the embodiments of the application.
The embodiment of the application also provides a device for processing the distributed transactions.
Referring to fig. 9, a block diagram of an embodiment of a distributed transaction processing apparatus according to the present application is shown, and applied to a first node, the apparatus may specifically include the following modules:
an interception module 901, configured to intercept a relevant action of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
a non-commit module 902, configured to not execute the commit action if the correlation action is a commit action;
a global request sending module 903, configured to send a global request to the third node according to an execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
Optionally, the global request sending module 903 may include:
if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or
And if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not accord with the first preset condition, sending a global rollback request to a third node.
Optionally, the apparatus may further include:
a first receiving module, configured to receive a branch submission request sent by a third node;
and the submitting module is used for responding to the branch submitting request and executing the submitting action of the database operation command corresponding to the local transaction branch.
Optionally, the apparatus may further include:
a second receiving module, configured to receive a branch rollback request sent by a third node;
and the rollback module is used for responding to the branch rollback request and executing the rollback action of the database operation command corresponding to the local transaction branch.
Optionally, the apparatus may further include:
and the registering module is used for registering a transaction branch to the third node under the condition that the related action is an execution action.
Optionally, the non-commit module may include:
and the replacement module is used for replacing the submission action with a null action when the related action is a submission action.
Optionally, the apparatus may further include:
an initiation request sending module, configured to send a transaction initiation request to a third node;
a third receiving module, configured to receive a transaction identifier returned by the first node according to the transaction initiation request;
a save module to save the transaction identifier to a transaction context of the distributed transaction.
Optionally, the apparatus may further include:
a first call request sending module, configured to send a first call request to a first related service of the distributed transaction; the first invocation request carries a transaction context of the distributed transaction, so that the first related service executes a first remote transaction branch of the distributed transaction.
Optionally, the apparatus may further include:
a fourth receiving module, configured to receive an execution result of the database operation command corresponding to the first remote transaction branch, where the execution result is returned by the first relevant service according to the first invocation request;
and the judging module is used for judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition.
Optionally, the apparatus may further include:
a second call request sending module, configured to send a second call request to a second related service of the distributed transaction according to an execution result corresponding to the first remote transaction branch if the execution result corresponding to the first remote transaction branch meets a first preset condition; the second invocation request carries a transaction context of the distributed transaction, so that the second correlation service executes a second remote transaction branch of the distributed transaction.
Referring to fig. 10, a block diagram of an embodiment of a distributed transaction processing apparatus according to the present application is shown, and is applied to a second node, where the apparatus specifically includes the following modules:
an interception module 1001, configured to intercept a relevant action of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
a non-commit module 1002, configured to not execute the commit action if the correlation action is a commit action.
Optionally, the apparatus may further include:
a first receiving module, configured to receive a branch submission request sent by a third node;
and the submitting module is used for responding to the branch submitting request and executing the submitting action of the database operation command corresponding to the local transaction branch.
Optionally, the apparatus may further include:
a second receiving module, configured to receive a branch rollback request sent by a third node;
and the rollback module is used for responding to the branch rollback request and executing the rollback action of the database operation command corresponding to the local transaction branch.
Optionally, the apparatus may further include:
and the registering module is used for registering a transaction branch to the third node under the condition that the related action is an execution action.
Optionally, the non-commit module may include:
and the replacement module is used for replacing the submission action with a null action when the related action is a submission action.
Optionally, the apparatus may further include:
a third calling request sending module, configured to send a third calling request to a third correlation service of the distributed transaction; the third invocation request carries a transaction context of the distributed transaction, so that the third correlation service executes a third remote transaction branch of the distributed transaction.
Optionally, the apparatus may further include:
a third receiving module, configured to receive an execution result of a database operation command corresponding to a third remote transaction branch, where the execution result is returned by the third relevant service according to the third invocation request;
and the judging module is used for judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition.
Referring to fig. 11, a block diagram of an embodiment of a distributed transaction processing apparatus according to the present application is shown, and is applied to a third node, where the block diagram specifically includes the following modules:
a global request receiving module 1101, configured to receive a global request sent by a first node; the global request is obtained according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
a branch request sending module 1102, configured to send the branch request to the first node or the second node corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute the commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
Optionally, the global request receiving module 1101 may include:
the first global request receiving module is used for receiving a global commit request from a first node if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction all meet a first preset condition; or
And the second global request receiving module is used for receiving a global rollback request from the first node if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not meet the first preset condition.
Optionally, the apparatus may further include:
a first result receiving module, configured to receive a branch request execution result sent by the first node or the second node;
the branch request sending module 1102 is further configured to send a corresponding branch request to a corresponding node if the branch request execution result does not meet a second preset condition.
Optionally, the apparatus may further include:
a second result receiving module, configured to receive a branch request execution result sent by the first node or the second node;
and the result sending module is used for sending a result that the global transaction action is successful to the first node if the branch request execution results corresponding to all the transaction branches in the distributed transaction all meet a second preset condition.
Optionally, the apparatus may further include:
and the providing module is used for providing the connection object of the corresponding database aiming at the distributed transaction.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Embodiments of the application can be implemented as a system or apparatus employing any suitable hardware and/or software for the desired configuration. Fig. 12 schematically illustrates an example device 1300 that can be used to implement various embodiments described herein.
For one embodiment, fig. 12 illustrates an exemplary apparatus 1300, which apparatus 1300 may comprise: one or more processors 1302, a system control module (chipset) 1304 coupled to at least one of the processors 1302, system memory 1306 coupled to the system control module 1304, non-volatile memory (NVM)/storage 1308 coupled to the system control module 1304, one or more input/output devices 1310 coupled to the system control module 1304, and a network interface 1312 coupled to the system control module 1306. The system memory 1306 may include: instruction 1362, the instruction 1362 executable by the one or more processors 1302.
Processor 1302 may include one or more single-core or multi-core processors, and processor 1302 may include any combination of general-purpose processors or special-purpose processors (e.g., graphics processors, application processors, baseband processors, etc.). In some embodiments, the device 1300 can be a server, a target device, a wireless device, etc., as described in embodiments herein.
In some embodiments, device 1300 may include one or more machine-readable media (e.g., system memory 1306 or NVM/storage 1308) having instructions thereon and one or more processors 1302, which in combination with the one or more machine-readable media, are configured to execute the instructions to implement the modules included in the aforementioned means to perform the actions described in embodiments of the present application.
System control module 1304 for one embodiment may include any suitable interface controller to provide any suitable interface to at least one of processors 1302 and/or any suitable device or component in communication with system control module 1304.
System control module 1304 for one embodiment may include one or more memory controllers to provide an interface to system memory 1306. The memory controller may be a hardware module, a software module, and/or a firmware module.
System memory 1306 for one embodiment may be used to load and store data and/or instructions 1362. For one embodiment, system memory 1306 may include any suitable volatile memory, such as suitable DRAM (dynamic random access memory). In some embodiments, system memory 1306 may include: double data rate type four synchronous dynamic random access memory (DDR4 SDRAM).
System control module 1304 for one embodiment may include one or more input/output controllers to provide an interface to NVM/storage 1308 and input/output device(s) 1310.
NVM/storage 1308 for one embodiment may be used to store data and/or instructions 1382. NVM/storage 1308 may include any suitable non-volatile memory (e.g., flash memory, etc.) and/or may include any suitable non-volatile storage device(s), e.g., one or more Hard Disk Drives (HDDs), one or more Compact Disc (CD) drives, and/or one or more Digital Versatile Disc (DVD) drives, etc.
The NVM/storage 1308 may include storage resources that are physically part of the device on which the apparatus 1300 is installed or may be accessible by the device and not necessarily part of the device. For example, the NVM/storage 1308 may be accessed over a network via the network interface 1312 and/or through the input/output devices 1310.
Input/output device(s) 1310 for one embodiment may provide an interface for device 1300 to communicate with any other suitable device, and input/output devices 1310 may include communication components, audio components, sensor components, and so forth.
Network interface 1312 of one embodiment may provide an interface for device 1300 to communicate with one or more networks and/or with any other suitable means, and device 1300 may communicate wirelessly with one or more components of a Wireless network according to any of one or more Wireless network standards and/or protocols, e.g., to access a Wireless network based on a communication standard, such as WiFi (Wireless Fidelity), 2G or 3G or 4G or 5G, or a combination thereof.
For one embodiment, at least one of the processors 1302 may be packaged together with logic for one or more controllers (e.g., memory controllers) of the system control module 1304. For one embodiment, at least one of the processors 1302 may be packaged together with logic for one or more controllers of the system control module 1304 to form a System In Package (SiP). For one embodiment, at least one of the processors 1302 may be integrated on the same novelty as the logic of one or more controllers of the system control module 1304. For one embodiment, at least one of processors 1302 may be integrated on the same chip with logic for one or more controllers of system control module 1304 to form a system on a chip (SoC).
In various embodiments, apparatus 1300 may include, but is not limited to: a computing device such as a desktop computing device or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet, a netbook, etc.). In various embodiments, device 1300 may have more or fewer components and/or different architectures. For example, in some embodiments, device 1300 may include one or more cameras, a keyboard, a Liquid Crystal Display (LCD) screen (including a touch screen display), a non-volatile memory port, multiple antennas, a graphics chip, an Application Specific Integrated Circuit (ASIC), and speakers.
Wherein, if the display includes a touch panel, the display screen may be implemented as a touch screen display to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
The present application also provides a non-transitory readable storage medium, where one or more modules (programs) are stored in the storage medium, and when the one or more modules are applied to an apparatus, the apparatus may be caused to execute instructions (instructions) of methods in the present application.
Provided in one example is an apparatus comprising: one or more processors; and, instructions in one or more machine-readable media stored thereon, which when executed by the one or more processors, cause the apparatus to perform a method as in embodiments of the present application, which may include: the method shown in fig. 1 or fig. 2 or fig. 3 or fig. 4 or fig. 5.
One or more machine-readable media are also provided in one example, having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform a method as in embodiments of the application, which may include: the method shown in fig. 1 or fig. 2 or fig. 3 or fig. 4 or fig. 5.
The specific manner in which each module performs operations of the apparatus in the above embodiments has been described in detail in the embodiments related to the method, and will not be described in detail here, and reference may be made to part of the description of the method embodiments for relevant points.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
Embodiments of the present application are described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present application have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including the preferred embodiment and all such alterations and modifications as fall within the true scope of the embodiments of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing detailed description is directed to a distributed transaction processing method, a distributed transaction processing apparatus, a device, and a machine-readable medium, which are provided by the present application, and specific examples are applied in this text to explain the principles and embodiments of the present application, and the descriptions of the foregoing examples are only used to help understand the method and core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (30)

1. A method for processing a distributed transaction, applied to a first node, the method comprising:
intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the correlation action is a commit action, not performing the commit action;
and sending a global request to a third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
2. The method of claim 1, wherein sending a global request to a third node comprises:
if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or
And if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not accord with the first preset condition, sending a global rollback request to a third node.
3. The method of claim 1, further comprising:
receiving a branch submission request sent by a third node;
and responding to the branch submission request, and executing the submission action of the database operation command corresponding to the local transaction branch.
4. The method of claim 1, further comprising:
receiving a branch rollback request sent by a third node;
and responding to the branch rollback request, and executing the rollback action of the local transaction branch corresponding to the database operation command.
5. The method of claim 1, further comprising:
in the event that the associated action is an execute action, registering the transaction branch with the third node.
6. The method of claim 1, wherein the not performing the commit action comprises:
in the event that the dependent action is a commit action, replacing the commit action with a null action.
7. The method according to any one of claims 1 to 6, further comprising:
sending a transaction initiation request to a third node;
receiving a transaction identifier returned by the first node according to the transaction initiation request;
saving the transaction identifier to a transaction context of the distributed transaction.
8. The method according to any one of claims 1 to 6, further comprising:
sending a first invocation request to a first related service of the distributed transaction; the first invocation request carries a transaction context of the distributed transaction, so that the first related service executes a first remote transaction branch of the distributed transaction.
9. The method of claim 8, further comprising:
receiving an execution result of a database operation command corresponding to a first remote transaction branch, returned by the first relevant service according to the first calling request;
and judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition or not.
10. The method of claim 9, further comprising:
if the execution result corresponding to the first remote transaction branch meets a first preset condition, sending a second calling request to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second invocation request carries a transaction context of the distributed transaction, so that the second correlation service executes a second remote transaction branch of the distributed transaction.
11. A method for processing a distributed transaction, applied to a second node, the method comprising:
intercepting related actions of the database operation commands corresponding to the local transaction branches; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; the connection object of the database is matched with the distributed transaction;
in the event that the correlation action is a commit action, the commit action is not performed.
12. The method of claim 11, further comprising:
receiving a branch submission request sent by a third node;
and responding to the branch submission request, and executing the submission action of the database operation command corresponding to the local transaction branch.
13. The method of claim 11, further comprising:
receiving a branch rollback request sent by a third node;
and responding to the branch rollback request, and executing the rollback action of the local transaction branch corresponding to the database operation command.
14. The method of claim 11, further comprising:
in the event that the associated action is an execute action, registering the transaction branch with the third node.
15. The method of claim 11, wherein the not performing the commit action comprises:
in the event that the dependent action is a commit action, replacing the commit action with a null action.
16. The method of claim 11, further comprising:
sending a third call request to a third correlation service of the distributed transaction; the third invocation request carries a transaction context of the distributed transaction, so that the third correlation service executes a third remote transaction branch of the distributed transaction.
17. The method of claim 16, further comprising:
receiving an execution result of a database operation command corresponding to a third remote transaction branch, returned by the third correlation service according to the third calling request;
and judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition.
18. A method for processing a distributed transaction, applied to a third node, the method comprising:
receiving a global request sent by a first node; the global request is obtained according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
sending the branch request to first nodes or second nodes corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
19. The method of claim 18, wherein receiving the global request sent by the first node comprises:
if the execution results of the database operation commands corresponding to all the transaction branches in the distributed transaction meet a first preset condition, receiving a global commit request from a first node; or
And if the execution result of the database operation command corresponding to any transaction branch in the distributed transaction does not meet the first preset condition, receiving a global rollback request from the first node.
20. The method of claim 18, further comprising:
receiving a branch request execution result sent by a first node or a second node;
and if the branch request execution result does not meet a second preset condition, sending a corresponding branch request to a corresponding node.
21. The method of claim 18, further comprising:
receiving a branch request execution result sent by a first node or a second node;
and if the branch request execution results corresponding to all the transaction branches in the distributed transaction meet a second preset condition, sending a result that the global transaction action is successful to the first node.
22. The method of any one of claims 18 to 21, further comprising:
for distributed transactions, connection objects of corresponding databases are provided.
23. An apparatus for processing a distributed transaction, the apparatus being applied to a first node, the apparatus comprising:
the interception module is used for intercepting related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
a non-commit module, configured to not execute the commit action if the relevant action is a commit action;
and the global request sending module is used for sending a global request to the third node according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction.
24. An apparatus for processing a distributed transaction, applied to a second node, the apparatus comprising:
the interception module is used for intercepting related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
and the non-submitting module is used for not executing the submitting action under the condition that the related action is the submitting action.
25. An apparatus for processing a distributed transaction, applied to a third node, the apparatus comprising:
the global request receiving module is used for receiving a global request sent by a first node; the global request is obtained according to the execution result of the database operation command corresponding to the transaction branch in the distributed transaction;
a branch request sending module, configured to send the branch request to the first node or the second node corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a database operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the database operation command is taken as the commit action; the connection object of the database is matched with the distributed transaction.
26. An apparatus, comprising:
one or more processors; and
one or more machine-readable media having instructions stored thereon that, when executed by the one or more processors, cause the apparatus to perform the method of one or more of claims 1-10.
27. One or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause an apparatus to perform the method recited by one or more of claims 1-10.
28. A method for processing a distributed transaction, applied to a first node, the method comprising:
intercepting related actions of the data operation command corresponding to the local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the correlation action is a commit action, not performing the commit action;
and sending a global request to the third node according to the execution result of the data operation command corresponding to the transaction branch in the distributed transaction.
29. A method for processing a distributed transaction, applied to a second node, the method comprising:
intercepting related actions of the data operation command corresponding to the local transaction branch; the data operation command is applied to the environment of a connection object of the database; the connection object of the database is matched with the distributed transaction; the connection object of the database is matched with the distributed transaction;
in the event that the correlation action is a commit action, the commit action is not performed.
30. A method for processing a distributed transaction, applied to a third node, the method comprising:
receiving a global request sent by a first node; the global request is obtained according to the execution result of the data operation command corresponding to the transaction branch in the distributed transaction;
sending the branch request to first nodes or second nodes corresponding to all transaction branches in the distributed transaction; the first node or the second node executes a data operation command corresponding to a local transaction branch in the environment of a connection object of a database, and does not execute a commit action under the condition that the correlation action of the data operation command is used as the commit action; the connection object of the database is matched with the distributed transaction.
CN202010706300.7A 2020-07-21 2020-07-21 Distributed transaction processing method, device, equipment and machine-readable medium Active CN113296897B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010706300.7A CN113296897B (en) 2020-07-21 2020-07-21 Distributed transaction processing method, device, equipment and machine-readable medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010706300.7A CN113296897B (en) 2020-07-21 2020-07-21 Distributed transaction processing method, device, equipment and machine-readable medium

Publications (2)

Publication Number Publication Date
CN113296897A true CN113296897A (en) 2021-08-24
CN113296897B CN113296897B (en) 2023-12-26

Family

ID=77318643

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010706300.7A Active CN113296897B (en) 2020-07-21 2020-07-21 Distributed transaction processing method, device, equipment and machine-readable medium

Country Status (1)

Country Link
CN (1) CN113296897B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138888A (en) * 2021-12-03 2022-03-04 北京宇信科技集团股份有限公司 Processing method, system, medium and equipment for distributed data routing

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU7767387A (en) * 1986-08-29 1988-03-03 Tolerant Systems, Inc. Distributed multiprocess transaction processing system
CN102831156A (en) * 2012-06-29 2012-12-19 浙江大学 Distributed transaction processing method on cloud computing platform
CN105988862A (en) * 2015-02-04 2016-10-05 阿里巴巴集团控股有限公司 Distributed transaction processing method and device
WO2016180164A1 (en) * 2015-09-29 2016-11-17 中兴通讯股份有限公司 Method and apparatus for rolling back distributed transaction
WO2017132621A1 (en) * 2016-01-28 2017-08-03 Oracle International Corporation Guaranteed commit outcome in a distributed transaction processing system
CN108446167A (en) * 2018-02-09 2018-08-24 烽火通信科技股份有限公司 A kind of distributed transaction processing method and system
CN109240738A (en) * 2018-08-30 2019-01-18 广州虎牙信息科技有限公司 Data base authority management method, device and computer equipment
CN111259083A (en) * 2020-02-13 2020-06-09 神州数码融信软件有限公司 Distributed transaction processing method and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
AU7767387A (en) * 1986-08-29 1988-03-03 Tolerant Systems, Inc. Distributed multiprocess transaction processing system
CN102831156A (en) * 2012-06-29 2012-12-19 浙江大学 Distributed transaction processing method on cloud computing platform
CN105988862A (en) * 2015-02-04 2016-10-05 阿里巴巴集团控股有限公司 Distributed transaction processing method and device
WO2016180164A1 (en) * 2015-09-29 2016-11-17 中兴通讯股份有限公司 Method and apparatus for rolling back distributed transaction
WO2017132621A1 (en) * 2016-01-28 2017-08-03 Oracle International Corporation Guaranteed commit outcome in a distributed transaction processing system
CN108446167A (en) * 2018-02-09 2018-08-24 烽火通信科技股份有限公司 A kind of distributed transaction processing method and system
CN109240738A (en) * 2018-08-30 2019-01-18 广州虎牙信息科技有限公司 Data base authority management method, device and computer equipment
CN111259083A (en) * 2020-02-13 2020-06-09 神州数码融信软件有限公司 Distributed transaction processing method and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
LINGJIA G.等: "The Study of the Distributed Transaction in the Service Bearer Network", 2010 FIRST INTERNATIONAL CONFERENCE ON NETWORKING AND DISTRIBUTED COMPUTING *
梁雄友;薛永生;: "基于分布式事务流的动态可串行调度算法", 计算机工程与应用, no. 08 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138888A (en) * 2021-12-03 2022-03-04 北京宇信科技集团股份有限公司 Processing method, system, medium and equipment for distributed data routing

Also Published As

Publication number Publication date
CN113296897B (en) 2023-12-26

Similar Documents

Publication Publication Date Title
US11829349B2 (en) Direct-connect functionality in a distributed database grid
US8352421B2 (en) Recording distributed transactions using probabalistic data structures
CN110765178B (en) Distributed transaction processing method and device and computer storage medium
US11681683B2 (en) Transaction compensation for single phase resources
CN110018884B (en) Distributed transaction processing method, coordination device, database and electronic equipment
CN111522631A (en) Distributed transaction processing method, device, server and medium
CN114925084B (en) Distributed transaction processing method, system, equipment and readable storage medium
CN112817995B (en) Data processing method and device, electronic equipment and storage medium
CN111414266B (en) Synchronous and asynchronous communication method and device for distributed transaction
CN109614270A (en) Data read-write method, device, equipment and storage medium based on Hbase
CN113296897B (en) Distributed transaction processing method, device, equipment and machine-readable medium
CN107797850B (en) Method, device and system for distributed transaction processing
US8719316B2 (en) Write agent delayed write to data stores
WO2022206429A1 (en) Distributed transaction implementation method and distributed system
CN108153796B (en) Data processing method, device and system for electronic red packet
CN113961253A (en) Driver calling method and device, electronic equipment and storage medium
CN117453750B (en) Data processing method, device, electronic equipment and storage medium
CN113872781A (en) Transaction processing method, device, equipment and storage medium
US20230164243A1 (en) Systems and methods for context-aware event ordering protocol for distributed service systems
CN116401022A (en) Method and device for processing operation log data of distributed transaction
CN113849278A (en) Global transaction processing method and system
CN113961315A (en) Transaction processing method, device, equipment and storage medium
CN116414846A (en) Transaction processing method, device, equipment and storage medium based on database connection
CN117829988A (en) Redis-based account fund processing method and device, storage medium and electronic equipment
US10013277B2 (en) Rolling back state changes in distributed transactions

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40058001

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant