CN113296897B - 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
CN113296897B
CN113296897B CN202010706300.7A CN202010706300A CN113296897B CN 113296897 B CN113296897 B CN 113296897B CN 202010706300 A CN202010706300 A CN 202010706300A CN 113296897 B CN113296897 B CN 113296897B
Authority
CN
China
Prior art keywords
transaction
node
branch
request
action
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.)
Active
Application number
CN202010706300.7A
Other languages
Chinese (zh)
Other versions
CN113296897A (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

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)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a method, a device, equipment and a machine-readable medium for processing distributed transactions, wherein the method comprises the following steps: intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction; in the case that the relevant 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 invention 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, an apparatus, and a machine readable medium.
Background
A Transaction (Transaction) is a logical unit of work in which a sequence of operations accesses a database to implement a particular service function, and typically includes local transactions and distributed transactions. Distributed transactions, which are transactions that are made up of several transaction branches in a distributed system that may span different resources, require that the transaction branches remain relatively consistent across the execution of the transaction.
In the case of a distributed transaction ending, the consistency of the transaction requires that the database operations involved either be fully committed or fully aborted. To fulfill the above requirements, distributed transaction processing typically employs a two-phase commit approach. In the first phase, a preparation request is sent by an initiator (or coordinator) to a participant to ask the participant if the participant can complete the distributed transaction branch for which it is responsible, and the participant replies to the initiator with the result of success or failure of one phase of processing. In the second stage, if all participants reply that one stage of processing is successful, the initiator sends a two-stage submitting request to all participants; otherwise, the initiator sends a two-stage rollback request to all participants, and the participants execute the submitting or rollback operation according to the two-stage request of the initiator.
The inventor finds out in the process of implementing the embodiment of the application that in the first stage, after a participant receives a preparation request, if the participant can submit own transaction branches, the undo (undo and redo) information is recorded in a transaction log; the above log operations 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, participants may set global locks, specifically read locks for read operations and write locks for write operations, thus achieving a higher level of isolation. However, the global locks described above will affect the processing performance of distributed transactions.
Disclosure of Invention
The technical problem to be solved by the embodiments of the present application is to provide a method for processing distributed transactions, which can improve the processing performance of the distributed transactions.
Correspondingly, the embodiment of the application also provides a processing device, a device and a machine-readable medium of the distributed transaction, which are used for ensuring the implementation and application of the method.
In order to solve the above problems, an embodiment of the present application discloses a method for processing a distributed transaction, which is applied to a first node, and the method includes:
intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant 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 method for processing a distributed transaction, which is applied to a second node, and the method includes:
Intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant 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 method for processing a distributed transaction, 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 a first node or a 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 related action of the database operation command is the commit action; the connection object of the database is matched with the distributed transaction.
In order to solve the above problems, an embodiment of the present application discloses a method for processing a distributed transaction, which is applied to a first node, and the method includes:
Intercepting relevant actions of a local transaction branch corresponding to a data operation command; the data operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant 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 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 method for processing a distributed transaction, which is applied to a second node, and the method includes:
intercepting relevant actions of a local transaction branch corresponding to a data operation command; the data operation command is applied to the environment of the 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 that the relevant 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 method for processing a distributed transaction, 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 a first node or a second node 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 related action of the data operation command is the commit action; the connection object of the database is matched with the distributed transaction.
On the other hand, the embodiment of the application also discloses a processing device of the distributed transaction, which is applied to the first node and comprises:
the interception module is used for intercepting the related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
the non-submitting module is used for not executing the submitting action under the condition that the related action is the submitting action;
And the global request sending module is used for 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.
On the other hand, the embodiment of the application also discloses a processing device of the distributed transaction, which is applied to the second node, and the device comprises:
the interception module is used for intercepting the related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of the 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 application also discloses a processing device of the distributed transaction, which is applied to a third node, and the device comprises:
the global request receiving module is used for receiving a global request sent by the 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 a first node or a 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 related action of the database operation command is the commit action; the connection object of the database is matched with the distributed transaction.
In yet 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 that, when executed by one or more processors, cause an apparatus to perform one or more of the methods described above.
Embodiments of the present application include the following advantages:
according to the embodiment of the application, the relevant actions of the database operation command corresponding to the local transaction branches are intercepted, and the commit actions are not executed under the condition that the relevant actions are commit actions. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 without setting the global lock, for example, the isolation level of the non-REPEATABLE READ (RR) can be realized. The method and the device can save the corresponding cost of the global lock, so that the processing performance of the distributed transaction can be improved.
And after executing the local transaction branch in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method or the local transaction branch can be rolled back according to the rolling-back method under the condition that the local transaction branch is not submitted, or the rolling-back of the local transaction branch can be automatically carried out under the condition that the crash occurs. In this way, the embodiment of the application can realize the subsequent commit action or rollback action of the local transaction branch under the condition that the log operation corresponding to the undo information and the redo information is not executed. According to the embodiment of the invention, the corresponding cost of the log operation of the local transaction branch can be saved, so that the processing performance of the distributed transaction can be improved.
Drawings
FIG. 1 is a schematic diagram of a distributed system according to an embodiment of the present application;
FIG. 2 is a flow chart of steps of an embodiment of a method of processing a distributed transaction of the present application;
FIG. 3 is a flow chart of steps of a second embodiment of a method of processing a distributed transaction according to the present application;
FIG. 4 is a flow chart of steps of a third embodiment of a method of processing a distributed transaction of the present application;
FIG. 5 is a flow chart of steps of a fourth embodiment of a method of processing a distributed transaction of the present application;
FIG. 6 is a flow chart of steps of a second embodiment of a method of processing a distributed transaction of the present application;
FIG. 7 is a flow chart of steps of a third embodiment of a method of processing a distributed transaction of the present application;
FIG. 8 is a flow chart of steps in a fourth embodiment of a method of processing a distributed transaction of the present application;
FIG. 9 is a block diagram of an embodiment of a processing apparatus for distributed transactions of the present application;
FIG. 10 is a block diagram of an embodiment of a processing apparatus for distributed transactions of the present application;
FIG. 11 is a block diagram of an embodiment of a processing device for distributed transactions of the present application; and
fig. 12 is an exemplary device 1300 that may be used to implement various embodiments described above in this application.
Detailed Description
In order that the above-recited objects, features and advantages of the present application will become more readily apparent, a more particular description of the invention briefly described above will be rendered by reference to specific embodiments that are illustrated in the appended drawings.
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application are within the scope of the protection of the present application.
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 herein of specific embodiments is not intended to limit the concepts of the present application to the particular forms disclosed, but on the contrary, the intention is to cover all modifications, equivalents, and alternatives.
Reference in the specification to "one embodiment," "an embodiment," "one particular embodiment," etc., means that a particular feature, structure, or characteristic may be included in the described embodiments, 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 purview of one skilled in the art to effect such feature, structure, or characteristic in connection with other ones of the embodiments whether or not explicitly described. In addition, it should be understood that the items in the list included in this form of "at least one of A, B and C" may include the following possible items: (A); (B); (C); (A and B); (A and C); (B and C); or (A, B and C). Likewise, an item listed in this form of "at least one of A, B or C" may mean (A); (C); (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 on 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., volatile or non-volatile memory, a media disc, 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 methodological 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 a different manner and/or order than as shown in the drawings. Furthermore, inclusion of a feature in a particular figure that is not necessarily meant to imply that such feature is required in all embodiments and that, in some embodiments, may not be included or may be combined with other features.
The embodiment of the application can be applied to the processing scene of the distributed transaction, and is used for improving the processing performance of the distributed transaction. A distributed transaction may involve transactions involving 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: transaction scenarios, or user management scenarios, etc.
Taking the transaction scenario as an example, assuming that a transaction is a 200-element transfer from user a to user B, the transaction process may include: the transaction begins; calling a transfer-out service, wherein A transfers out 200 yuan; calling a transfer service, and transferring B to 200 yuan; the transaction is ended. The transaction involves a distributed transaction, as the roll-out service or roll-in service may be located in different processes, or the account of user a and the account of user B may be located in different databases.
Assuming that the user management scenario is a new user send point scenario, the corresponding process flow may include: starting; calling a newly added user service; calling an add point service; and (5) ending. This process flow involves distributed transactions, as the new user service or the added points service may be located in a different process or involve a different database.
In a conventional method for processing a distributed transaction, the undo information and the redo information are generally recorded in a transaction log, and a global lock is set to realize 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 operation and global lock affect the processing performance of distributed transactions, the embodiment of the application provides a processing method of the distributed transactions, which specifically comprises the following steps: intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the 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 relevant action is a commit action, the commit action is not performed.
In the environment of the connection object of the database, the embodiment of the application executes the database operation command corresponding to the local transaction branch (hereinafter, the local transaction branch is executed). The connection object may characterize a session with the database.
After executing the local transaction branch in the environment of the connection object of the database, the local transaction branch may be submitted according to a commit (commit) method, or the local transaction branch may be rolled back according to a rollback (rollback) method, and if not submitted, the data corresponding to the local transaction branch may not be actually inserted into the database corresponding to the connection object.
According to the embodiment of the application, the relevant actions of the database operation command corresponding to the local transaction branches are intercepted, and the commit actions are not executed under the condition that the relevant actions are commit actions. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 without setting the global lock, for example, the isolation level of the non-REPEATABLE READ (RR) can be realized. The method and the device can save the corresponding cost of the global lock, so that the processing performance of the distributed transaction can be improved.
And, after executing the local transaction branch in the environment of the connection object of the database, the local transaction branch may be submitted according to the submitting method or the rollback of the local transaction branch may be performed according to the rollback method without submitting the local transaction branch. In this way, the embodiment of the application can realize the subsequent commit action or rollback action of the local transaction branch under the condition that the log operation corresponding to the undo information and the redo information is not executed. According to the embodiment of the invention, the corresponding cost of the log operation of the local transaction branch can be saved, 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.
Wherein the first node 101 may be a global management node of the distributed transaction, on which a GTM (global transaction manager ) may be run to manage the global transaction of the distributed transaction. The first node 101 may also manage a transaction branch of a distributed transaction, such as transaction branch 1 in fig. 1.
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 running to manage transaction branches of the distributed transaction, such as transaction branch 2-transaction branch n in fig. 1, where n may be a natural number greater than 1.
The third node 103 may be a transaction orchestration node of the distributed transaction, on which a TC (transaction orchestrator, transaction coordinator) may be running to maintain the running state of the distributed transaction, and orchestrate and drive the commit or rollback of the distributed transaction.
In the embodiment of the invention, the transaction branch 2 to the transaction branch n can be triggered by a service calling mode.
For example, the first node 101 calls the service corresponding to the transaction branch 2 and the service corresponding to the transaction branch 3 according to the transaction branch 1.
For another example, the first node 101 invokes a service corresponding to the transaction branch 2 according to the transaction branch 1, and the second node 102 invokes a 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 will be appreciated that embodiments of the present application are not limited to a particular manner of triggering transaction branch 2 through transaction branch n.
Embodiments of the present application may conduct the processing of distributed transactions via two phases.
Wherein, in a first phase, the first node 101 and the second node 102 register transaction branches with the third node 103; and executing the local transaction branches in the environment of the connection object of the database, and returning the execution results corresponding to the local transaction branches to the corresponding calling nodes 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 results of the database operation commands corresponding to all 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: global commit requests or global rollback requests. The third node 103 may send a branch request corresponding to the global request to the first node 101 and the second node 102 to synchronize the global request in a global scope.
For the first node 101 and the second node 102, it may execute a local transaction branch in the environment of the connection object of the database, and intercept a related action of the local transaction branch corresponding to the database operation command, and not execute the commit action in case that the related action is a commit action. Because the actual submitting action is not executed, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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.
And under the condition that the local transaction branch is not submitted, the local transaction branch can be submitted according to a submitting method, or the local transaction branch can be rolled back according to a rolling-back method, or the local transaction branch can be automatically rolled back under the condition that a downtime occurs. In this way, the embodiment of the application can realize the subsequent commit action or rollback action of the local transaction branch under the condition that the log operation corresponding to the undo information and the redo information is not executed.
In addition, embodiments of the present application may carry database operation commands via database statements, such as SQL (structured query language ) statements. In the embodiment of the present application, the first node 101 and the second node 102 execute the SQL statement in the environment of the connection object of the database, and may not perform analysis and front-back mirror image storage of the SQL statement, so that the application range of the database may be enhanced, and the processing performance of the distributed transaction may be improved.
Method embodiment one
Referring to fig. 2, a flowchart illustrating steps of a first embodiment of a method for processing a distributed transaction of the present application is applied to a first node, where the method may specifically include 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 the connection object of the database; the connection object of the database is matched with the distributed transaction;
step 202, if the related action is a commit action, not executing the commit action;
step 203, sending a global request to a third node according to an 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 of the distributed transaction that may trigger an initiate action, commit action or rollback action, and an end action of the distributed transaction based on data interactions with the third node.
In an alternative 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; the transaction identifier is saved in the 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 increment sequence method. It will be appreciated that the embodiments of the present application do not limit the specific method of generating xid.
The transaction context (Transaction Context) records information about the transaction it represents. The transaction context allows for the unique determination of the transaction involved and the status of the transaction.
Alternatively, the transaction context may be bound to the thread using a thread local variable (thread), and it is understood that embodiments of the present application are not limited to a particular manner of saving the transaction context.
After the distributed transaction is initiated, 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 a remote transaction branch by means of calling a service.
Embodiments of triggering remote transaction branches are provided herein.
In one embodiment, the method may further include: sending a first call request to a first related service of the distributed transaction; the first call request carries the 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, the first remote transaction branch is transaction B, and/or the local transaction branch is transaction a, the first remote transaction branch is transaction C, etc.
The embodiment of the application carries a transaction context in the first call request, wherein the transaction context may include: xid, processing logic of the transaction, etc. Xid in the transaction context may associate different transaction branches onto the same distributed transaction. Processing logic may cause the first remote transaction branch to process 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 caused to invoke an associated third remote transaction branch, and so on.
Alternatively, the first call request of the embodiment of the present application may be an RPC (procedure remote call, remote Procedure Call) request, or 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, which is returned by the first related service according to the first call request; and judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition.
In practical application, the 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 the environment of the connection object to obtain a corresponding execution result, which is not described herein.
The format of the execution result may include: JSON (JSON object profile, javaScript Object Notation), XML (extensible markup language ), structure, collection object, etc.
The first preset condition may represent that the execution result corresponding to the transaction branch meets a condition that is expected to be met. It may be appreciated that different transaction branches may correspond to different first preset conditions, and the embodiment of the present application does not limit specific first preset conditions.
According to an 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 meets the expectation, the execution result may be considered to meet the first preset condition.
According to another embodiment, the result code in the execution result does not conform to the expectation, and the execution result may be considered to not conform to the first preset condition. Alternatively, the execution result may include an abnormal code, for example, an abnormal code caused by timeout, connection shutdown, or the like, and may be considered as not conforming to the first preset condition.
According to one embodiment, the method may further include: if the execution result corresponding to the first remote transaction branch meets a first preset condition, sending a second call request to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second call request carries the transaction context of the distributed transaction, so that the second correlation service executes a second remote transaction branch of the distributed transaction. According to the processing logic of the distributed transaction, under the condition that the execution result corresponding to the first remote transaction branch meets the first preset condition, the second remote transaction branch can be triggered continuously.
It may be appreciated that, in the above-mentioned case that the execution result corresponding to the first remote transaction branch meets the first preset condition, the second remote transaction branch is triggered, which is just an alternative embodiment, in fact, whether to trigger the second remote transaction branch may be determined according to the processing logic of the distributed transaction, which is not limited in this embodiment.
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 can be continuously received; and judging whether the execution result corresponding to the second remote transaction branch meets a first preset condition. 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 in detail herein, but is referred to in the cross-reference.
Embodiments of managing local transaction branches are provided herein.
According to the method and the device for processing the database operation command, the connection object of the database corresponding to the local transaction branch can be obtained, and the database operation command corresponding to the local transaction branch is executed in the environment of the connection object of the database.
In the embodiment of the present application, the category of the connection object may include: JDBC (Java database connection, java Database Connectivity), or ODBC (open database connection, open Database Connectivity), etc.
JDBC, among other things, is an application program interface in the JAVA language that is used to specify how client programs access a database, providing methods such as querying and updating data in the database. ODBC may provide standard APIs (application programming interfaces, APPlication Interface) for database access that accomplish database access tasks through SQL.
In the embodiment of the application, transaction branching management is performed through a connection object in JDBC. After executing the transaction branch, the commit of the transaction branch is performed by utilizing a commit method, the rollback of the transaction branch is performed by utilizing a rollback method, and if the transaction branch is not committed, the data cannot be truly inserted into the database.
In an alternative embodiment of the present application, the relevant action of the local transaction branch corresponding to the database operation command may be intercepted, and the transaction branch may be registered with the third node in the case that the relevant action is the execution action. The third node may return transaction branch identifications to coordinate a plurality of transaction branches corresponding to one distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In an alternative embodiment of the present application, the relevant actions of the local transaction branch corresponding to the database operation command may be intercepted, and in the case that the relevant actions are commit actions, the commit actions are not performed.
According to one embodiment, the not performing the submitting action specifically includes: when the relevant action is a commit action, the commit action is replaced with an empty action. Of course, replacing commit actions with null actions is merely an alternative embodiment, and in fact commit actions may not be processed.
After executing the database operation command corresponding to the local transaction branch, the first node can obtain a corresponding execution result. In addition, as an 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 the transaction branch a locally, and then 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 manner, the second node corresponding to the transaction branch B may return an execution result of the transaction branch B by using a callback manner.
In one example 2, the distributed transaction includes: transaction branch a, transaction branch B, and transaction branch C. The triggering manners of the transaction branch a and the transaction branch B in the example 1 and the example 2 are similar, and are not described herein. Assuming that the first node triggers the transaction branch C by using a service calling manner, the second node corresponding to the transaction branch C may return an execution result of the transaction branch C by using a callback manner.
In one example 3, a distributed transaction includes: transaction branch a, transaction branch B, and transaction branch C. The triggering manners of the transaction branch a and the transaction branch B in the example 1 and the example 2 are similar, and are not described herein. Assuming that the second node corresponding to the transaction branch B triggers the transaction branch C by using a service calling manner, the second node corresponding to the transaction branch C may return an execution result of the transaction branch C by using a callback manner. 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 results of the database operation commands corresponding to all the transaction branches in the distributed transaction may be determined, and a global request may be sent to the third node according to the corresponding determination result. Correspondingly, the sending mode adopted by the global request to the third node specifically includes:
the sending method 1 includes that if execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, a global commit request is sent to a third node; or alternatively
And 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, sending a global rollback request to a third node.
For the sending mode 1, if the execution results of all the transaction branches in the distributed transaction meet the first preset condition, then it can 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 may be sent to the third node to effect commit of the entire distributed transaction.
For the sending mode 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 the distributed transaction, a global rollback request may be sent to the third node to achieve rollback of the entire distributed transaction.
In an alternative embodiment of the present application, the method may further include: receiving a branch submitting request sent by a third node; and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the database operation command.
In this embodiment of the present application, the execution result of the commit action may include: commit success or commit failure. The first node may send the result of the execution of the commit action to the third node. If the execution result of the commit action is that the commit fails, the third node may continue to send the branch commit request to the first node until the execution result of the commit action corresponding to the first node is that the commit is successful.
In another alternative embodiment of the present application, the method may further include: receiving a branch rollback request sent by a third node; and executing the rollback action of the local transaction branch corresponding to the database operation command in response to the branch rollback request.
In the process of executing the branch commit request or the branch rollback request, if the crash occurs, a transaction compensation method may be adopted to perform a remedial process. 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 rollback failure, 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 rollback success.
In yet another alternative embodiment of the present application, the method may further include: the result of the global transaction action success is received from the third node, in which case the distributed transaction may be ended.
The result of the success of the global transaction action may include: global commit success, or global rollback success. And under the condition that the branch request execution results corresponding to all the transaction branches in the distributed transaction meet the second preset condition, the third node can send the result of successful global transaction actions to the first node.
The second preset condition may be used to characterize a condition satisfied by a branch request execution result in a case where the branch request execution is successful. The branch commit request or the branch rollback request may correspond to a second, different preset condition.
In summary, according to the method for processing distributed transactions in the embodiments of the present application, relevant actions of the local transaction branches corresponding to the database operation command are intercepted, and if the relevant actions are commit actions, the commit actions are not executed. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 under the condition that the global lock is not set, for example, the isolation level of the non-repeatable reading can be realized. The method and the device can save the corresponding cost of the global lock, so that the processing performance of the distributed transaction can be improved.
And after executing the local transaction branch in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method or the local transaction branch can be rolled back according to the rolling-back method under the condition that the local transaction branch is not submitted, or the rolling-back of the local transaction branch can be automatically carried out under the condition that the crash occurs. In this way, the embodiment of the application can realize the subsequent commit action or rollback action of the local transaction branch under the condition that the log operation corresponding to the undo information and the redo information is not executed. According to the embodiment of the invention, the corresponding cost of the log operation of the local transaction branch can be saved, so that the processing performance of the distributed transaction can be improved.
Method embodiment II
Referring to fig. 3, a flowchart illustrating steps of a second embodiment of a method for processing a distributed transaction, applied to a second node, may specifically 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 the connection object of the database; the connection object of the database is matched with the distributed transaction;
Step 302, if the related action is a commit action, the commit action is not executed.
The second node may be a local management node of the distributed transaction, which may manage transaction branches of the distributed transaction.
In this embodiment of the present application, the second node may trigger the local transaction branch according to a call request sent by the first node or other second nodes. It will be appreciated that embodiments of the present application are not limited to invoking nodes that invoke requests.
According to one embodiment, a first call request sent by a first node may be received; the first call 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 call request. For example, the first node triggers the transaction a, and the first node may call the transaction B related to the transaction a according to the first call request; and the second node may trigger and execute transaction B upon the first invocation request.
According to another embodiment, call requests sent by other nodes may be received. For example, the first node triggers the transaction a, and the first node may call the transaction B related to the transaction a according to the first call request; while the second node a may continue to invoke transaction C associated with transaction B; and the second node b may trigger and execute transaction C, etc.
In this embodiment of the present application, optionally, a service may be called, where a transaction branch related to a local transaction branch is called, for example, if the local transaction branch is a transaction B, a transaction B related to a transaction a may be called, and so on. Accordingly, the method may further include: sending a third call request to a third related service of the distributed transaction; and the third call request carries the transaction context of the distributed transaction so that the third correlation service executes a third remote transaction branch of the distributed transaction.
In an embodiment of the present 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 call request; and judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition.
In this embodiment of the present application, the second node may determine whether an execution result corresponding to the remote transaction branch invoked by the second node meets a first preset condition, and if yes, may continue to execute processing logic of the distributed transaction; otherwise, a corresponding notification message may be returned to the upper layer call node (e.g., the ith layer call node), where the notification message may prompt that an execution result corresponding to a transaction branch does not conform to the first preset condition. It can be appreciated that the calling node of the upper layer may be the first node; alternatively, the upper layer call node may be different from the first node, in which case the i-th layer call node may continue to return a corresponding notification message to the (i-1) th layer call node until the first node learns of the notification message.
According to the method and the device for processing the database operation command, the connection object of the database corresponding to the local transaction branch can be obtained, and the database operation command corresponding to the local transaction branch is executed in the environment of the connection object of the database.
In the embodiment of the application, the transaction branches are managed through the connection object. After executing the transaction branch, the commit of the transaction branch is performed by utilizing a commit method, the rollback of the transaction branch is performed by utilizing a rollback method, and if the transaction branch is not committed, the data cannot be truly inserted into the database.
In an alternative embodiment of the present application, the relevant action of the local transaction branch corresponding to the database operation command may be intercepted, and the transaction branch may be registered with the third node in the case that the relevant action is the execution action. The third node may return transaction branch identifications to coordinate a plurality of transaction branches corresponding to one distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In an alternative embodiment of the present application, the relevant actions of the local transaction branch corresponding to the database operation command may be intercepted, and in the case that the relevant actions are commit actions, the commit actions are not performed.
According to one embodiment, the not performing the submitting action specifically includes: when the relevant action is a commit action, the commit action is replaced with an empty action. Of course, replacing commit actions with null actions is merely an alternative embodiment, and in fact commit actions may not be processed.
After executing the database operation command corresponding to the local transaction branch, the second node can obtain a corresponding execution result. Optionally, a callback may be performed on a parameter in the first call request, so as to return the execution result to the calling node. The execution result can be used for the calling node to judge so as to judge whether the execution result accords with a first preset condition.
In an alternative embodiment of the present application, the method may further include: receiving a branch submitting request sent by a third node; and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the database operation command.
In this embodiment of the present application, the execution result of the commit action may include: commit success or commit failure. The second node may send the result of the execution of the commit action to the third node. If the execution result of the commit action is that the commit fails, the third node may continue to send the branch commit request to the second node until the execution result of the commit action corresponding to the second node is that the commit is successful.
In another alternative embodiment of the present application, the method may further include: receiving a branch rollback request sent by a third node; and executing the rollback action of the local transaction branch corresponding to the database operation command in response to the branch rollback request.
In the process of executing the branch commit request or the branch rollback request, if the crash occurs, a transaction compensation method may be adopted to perform a remedial process. 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 rollback failure, 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 rollback success.
In summary, according to the method for processing distributed transactions in the embodiments of the present application, relevant actions of the local transaction branches corresponding to the database operation command are intercepted, and if the relevant actions are commit actions, the commit actions are not executed. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 under the condition that the global lock is not set, for example, the isolation level of the non-repeatable reading can be realized. The method and the device can save the corresponding cost of the global lock, so that the processing performance of the distributed transaction can be improved.
And after executing the local transaction branch in the environment of the connection object of the database, the local transaction branch can be submitted according to the submitting method or the local transaction branch can be rolled back according to the rolling-back method under the condition that the local transaction branch is not submitted, or the rolling-back of the local transaction branch can be automatically carried out under the condition that the crash occurs. In this way, the embodiment of the application can realize the subsequent commit action or rollback action of the local transaction branch under the condition that the log operation corresponding to the undo information and the redo information is not executed. According to the embodiment of the invention, the corresponding cost of the log operation of the local transaction branch can be saved, so that the processing performance of the distributed transaction can be improved.
Method example III
Referring to fig. 4, a flowchart illustrating steps of a third embodiment of a method for processing a distributed transaction of the present application is shown, where the method may specifically include 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 a database operation command corresponding to a transaction branch in the distributed transaction;
step 402, sending the branch request to a first node or a 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 the database, and does not execute the commit action when the related action of the database operation command is the commit action; the connection object of the database is matched with the distributed transaction.
In the embodiment of the application, 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 submission or rollback of the distributed transaction.
In this embodiment of the present application, the third node may provide, for the distributed transaction, a connection object corresponding to the database, so that the first node or the second node obtains a connection object corresponding to the local transaction branch. It may be appreciated that other nodes may also provide connection objects corresponding to the database for distributed transactions, and the embodiment of the present application does not limit the specific providing nodes of the connection objects.
In the embodiment of the application, the third node may provide registration service of transaction branches. Accordingly, the third node may receive the registration request of the first node or the second node and identify to the return transaction branch to coordinate a plurality of transaction branches corresponding to one distributed transaction. Alternatively, the transaction branch identification may have global uniqueness.
In this embodiment of the present application, optionally, the receiving the global request sent by the first node specifically includes:
if the execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, receiving a global commit request from a first node; or alternatively
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 an embodiment of the present application, optionally, the method may further include: receiving a branch request execution result sent by a first node or a second node; 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 submitting action corresponding to the first node is successful.
In an embodiment of the present 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, the result of the success of the global transaction action is sent to the first node, and in this case, the first node can end the processing of the distributed transaction.
Method example IV
Referring to fig. 5, a flowchart illustrating steps of a fourth embodiment of a method for processing a distributed transaction according to the present application, where the method may perform data interaction between a first node, a second node, and a third node, the method may specifically include the following steps:
step 501, a first node sends a transaction initiation request to a 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 connection 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 a transaction branch 2, and associates 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 connection object of the database.
Step 507, the second node intercepts the commit action of transaction branch 2 and replaces the commit action with a null operation;
after the execution of transaction branch 2 is completed, 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 in accordance with execution result 2, or other transaction branches, such as transaction branch 3, transaction branch 4, etc., may be triggered in accordance with execution result 2.
Step 510, the first node intercepts the commit action of 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 commit 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, the first node may determine, after completing the processing logic of the distributed transaction, whether all 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 commit 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 the first commit 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 commit request to the second node;
step 516, the second node performs a commit action of transaction branch 2;
step 517, the second node sends a second commit execution result to the third node;
it should be noted that, under the condition 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.
Step 518, in the case that the first commit execution result and the second commit execution result both meet the second preset condition, the third node sends a global commit successful result to the first node.
It will be appreciated that in the embodiment shown in fig. 5, the distributed transaction includes transaction branch 1 and transaction branch, by way of example only, and in fact, the distributed transaction may further include: transaction branches other than transaction branch 1 and transaction branch 2.
In addition, it will be appreciated that in the above embodiment of fig. 5, the order of actions described is merely an example, and in fact, embodiments of the present application are not limited by the order of actions described. For example, embodiments of the present application are not limited by the order of actions described in steps 504 and 505; as another example, embodiments of the present application are not limited by the order of actions described by steps 512 and 515.
In the above embodiment of fig. 5, the case where the execution result 2 and the execution result 1 both meet the first preset condition is described.
In other embodiments, if either the execution result 2 or 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 may be skipped to the step corresponding to the first node sending the global rollback request to the third node.
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 global rollback request sent by the first node to the third node may be skipped.
Method embodiment five
Referring to fig. 6, a flowchart illustrating steps of a fifth embodiment of a method for processing a distributed transaction, applied to a first node, may specifically 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 the connection object of the database; the connection object of the database is matched with the distributed transaction;
step 602, in the case that the related action is a commit action, not executing the commit action;
step 603, sending a global request to a third node according to an 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 does not execute the commit action under the condition that the related action is the commit action. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 under the condition that the global lock is not set, for example, the isolation level of the non-repeatable reading can be realized. The method and the device can save the corresponding cost of the global lock, so that the processing performance of the distributed transaction can be improved.
The data operation commands of the present embodiment may characterize commands related to data operations. The data operation command may be a database operation command or other operation commands. Other operation commands may be application layer operation commands, such as transaction operation commands, which may include: the transfer in or out operation of the amount, the ordering or payment operation of the commodity, the user management operation, etc., it will be appreciated that the embodiments of the present application are not limited to specific data operation commands.
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 may 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 operation command is a database operation command, the data operation 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, the processing procedure is similar to that of the first embodiment of the method shown in fig. 2, so that the description is omitted herein for brevity and cross-reference.
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 the first preset condition, sending a global commit request to a third node; or alternatively
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, sending a global rollback request to a third node.
Optionally, the method may further include:
receiving a branch submitting request sent by a third node;
and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the data operation command.
Optionally, the method may further include:
receiving a branch rollback request sent by a third node;
and executing the rollback action of the local transaction branch corresponding data operation command in response to the branch rollback request.
Optionally, the method may further include:
in the case where the above-described related action is an execution action, a transaction branch is registered with the third node.
Optionally, the not performing the submitting act may include:
when the relevant action is a commit action, the commit action is replaced with an empty 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;
the transaction identifier is saved in the transaction context of the distributed transaction.
Optionally, the method may further include:
sending a first call request to a first related service of the distributed transaction; the first call request carries the 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, which is returned by the first related service according to the first call request;
and judging whether the execution result corresponding to the first remote transaction branch meets a first preset condition.
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 call request to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second call request carries the transaction context of the distributed transaction, so that the second correlation service executes a second remote transaction branch of the distributed transaction.
Method example six
Referring to fig. 7, a flowchart illustrating steps of a sixth embodiment of a method for processing a distributed transaction, applied to a second node, may specifically include the following steps:
step 701, intercepting relevant actions of a data operation command corresponding to a local transaction branch; the data operation command is applied to the environment of the 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, in the case that the related action is a commit action, the commit action is not executed.
According to the embodiment of the application, the relevant actions of the data operation commands corresponding to the local transaction branches are intercepted, and the commit actions are not executed under the condition that the relevant actions are commit actions. Because the embodiment of the application does not execute actual submitting action, under the condition that the local transaction branch is not submitted, the data corresponding to the local transaction branch cannot be truly 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 under the condition that the global lock is not set, for example, the isolation level of the non-repeatable reading can be realized. The method and the device can save the corresponding cost of 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, so that the details are not repeated herein and reference is made to each other.
Optionally, the method may further include:
receiving a branch submitting request sent by a third node;
and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the data operation command.
Optionally, the method may further include:
receiving a branch rollback request sent by a third node;
and executing the rollback action of the local transaction branch corresponding data operation command in response to the branch rollback request.
Optionally, the method may further include:
in the case where the above-described related action is an execution action, a transaction branch is registered with the third node.
Optionally, the not performing the submitting act may include:
when the relevant action is a commit action, the commit action is replaced with an empty action.
Optionally, the method may further include:
sending a third call request to a third related service of the distributed transaction; and the third call request carries the transaction context of the distributed transaction so that the third correlation 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 call request;
and judging whether the execution result corresponding to the third remote transaction branch meets a first preset condition.
Method embodiment seven
Referring to fig. 8, a flowchart illustrating steps of a seventh embodiment of a method for processing a distributed transaction of the present application is applied to a third node, where the method may specifically include 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 a first node or a second node 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 the database, and does not execute the commit action when the related action of the data operation command is the commit action; the connection object of the database is matched with the distributed transaction.
In the embodiment of the application, 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 submission 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 embodiment of the method shown in fig. 4, so that the description is omitted herein and the processing procedures are referred to each other.
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 alternatively
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 a corresponding branch request to a 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 the second preset condition, sending a result of successful global transaction action to the first node.
Optionally, the method may further include:
for distributed transactions, a connection object is provided for the corresponding database.
It should be noted that, for simplicity of description, the method embodiments are shown as a series of acts, but it should be understood by those skilled in the art that the embodiments are not limited by the order of acts described, as some steps may occur in other orders or concurrently in accordance with the embodiments. Further, those skilled in the art will appreciate that the embodiments described in the specification are all preferred embodiments and that the acts referred to are not necessarily required by the embodiments of the present application.
The embodiment of the application also provides a processing device of the distributed transaction.
Referring to fig. 9, there is shown a block diagram of an embodiment of a distributed transaction processing apparatus of the present application, which is applied to a first node, and may specifically include the following modules:
the interception module 901 is configured to intercept related actions of the local transaction branch corresponding to the database operation command; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
A non-commit module 902, configured to, in a case where the related action is a commit action, not perform the commit action;
the global request sending module 903 is configured to send a global request to a 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 database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or alternatively
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, sending a global rollback request to a third node.
Optionally, the apparatus may further include:
the first receiving module is used for receiving a branch submitting request sent by the third node;
and the submitting module is used for responding to the branch submitting request and executing the submitting action of the local transaction branch corresponding to the database operation command.
Optionally, the apparatus may further include:
the second receiving module is used for receiving a branch rollback request sent by the third node;
and the rollback module is used for responding to the branch rollback request and executing rollback action of the local transaction branch corresponding to the database operation command.
Optionally, the apparatus may further include:
and the registration module is used for registering the transaction branch with 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 commit action with the null action under the condition that the related action is the commit 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;
and the storage module is used for storing the transaction identifier into the 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 call request carries the 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 a database operation command corresponding to the first remote transaction branch returned by the first related service according to the first call 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 call request carries the transaction context of the distributed transaction to enable the second correlation service to execute a second remote transaction branch of the distributed transaction.
Referring to fig. 10, there is shown a block diagram of an embodiment of a distributed transaction processing apparatus applied to a second node, and may specifically include the following modules:
an interception module 1001, configured to intercept related actions of the local transaction branch corresponding to the database operation command; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
the non-commit module 1002 is configured to not execute the commit action if the relevant action is a commit action.
Optionally, the apparatus may further include:
the first receiving module is used for receiving a branch submitting request sent by the third node;
and the submitting module is used for responding to the branch submitting request and executing the submitting action of the local transaction branch corresponding to the database operation command.
Optionally, the apparatus may further include:
the second receiving module is used for receiving a branch rollback request sent by the third node;
and the rollback module is used for responding to the branch rollback request and executing rollback action of the local transaction branch corresponding to the database operation command.
Optionally, the apparatus may further include:
and the registration module is used for registering the transaction branch with 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 commit action with the null action under the condition that the related action is the commit action.
Optionally, the apparatus may further include:
a third call request sending module, configured to send a third call request to a third related service of the distributed transaction; and the third call request carries the 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:
the third receiving module is used for receiving an execution result of a database operation command corresponding to a third remote transaction branch, which is returned by the third related service according to the third call 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, there is shown a block diagram of an embodiment of a distributed transaction processing apparatus applied to a third node, and may specifically include 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 a first node or a 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 the database, and does not execute the commit action when the related action of the database operation command is 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 database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition; or alternatively
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:
the first result receiving module is used for receiving 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 execution result of the branch request does not meet a second preset condition.
Optionally, the apparatus may further include:
the second result receiving module is used for receiving a branch request execution result sent by the first node or the second node;
and the result sending module is used for sending the result of successful global transaction action to the first node if the branch request execution results corresponding to all the transaction branches in the distributed transaction meet the second preset condition.
Optionally, the apparatus may further include:
and the providing module is used for providing the connection object corresponding to the database for the distributed transaction.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the method, and will not be described in detail herein.
Embodiments of the present application may be implemented as a system or apparatus configured as desired using any suitable hardware and/or software. Fig. 12 schematically illustrates an exemplary device 1300 that may be used to implement various embodiments described herein.
For one embodiment, fig. 12 illustrates an exemplary device 1300, the device 1300 may include: one or more processors 1302, a system control module (chipset) 1304 coupled to at least one of the processors 1302, a system memory 1306 coupled to the system control module 1304, a 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 1304. The system memory 1306 may include: instructions 1362, the instructions 1362 being executable by the one or more processors 1302.
The processor 1302 may include one or more single-core or multi-core processors, and the processor 1302 may include any combination of general-purpose 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 of the present application.
In some embodiments, the apparatus 1300 may include one or more machine-readable media (e.g., system memory 1306 or NVM/storage 1308) having instructions and one or more processors 1302, in combination with the one or more machine-readable media, configured to execute the instructions to implement the modules included in the foregoing apparatus to perform the actions described in the embodiments of the present application.
The system control module 1304 of an embodiment may include any suitable interface controller for providing any suitable interface to at least one of the processors 1302 and/or any suitable device or component in communication with the system control module 1304.
The system control module 1304 of an embodiment may include one or more memory controllers to provide an interface to the system memory 1306. The memory controller may be a hardware module, a software module, and/or a firmware module.
The system memory 1306 of one embodiment may be used to load and store data and/or instructions 1362. For one embodiment, the system memory 1306 may include any suitable volatile memory, such as suitable DRAM (dynamic random Access memory). In some embodiments, the system memory 1306 may include: double data rate type four synchronous dynamic random access memory (DDR 4 SDRAM).
The system control module 1304 of an embodiment may include one or more input/output controllers to provide interfaces to the NVM/storage 1308 and the 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 nonvolatile memory (e.g., flash memory, etc.) and/or may include any suitable nonvolatile storage device(s), such as, for example, 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.
NVM/storage 1308 may include storage resources that are physically part of the device on which apparatus 1300 is installed, or which may be accessed by the device without being part of the device. For example, NVM/storage 1308 may be accessed over a network via network interface 1312 and/or through 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, input/output device 1310 may include a communication component, an audio component, a sensor component, and the like.
The network interface 1312 for one embodiment may provide an interface for the apparatus 1300 to communicate over one or more networks and/or with any other suitable device, and the apparatus 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, such as accessing 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 of 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 of 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 new product as the logic of one or more controllers of the system control module 1304. For one embodiment, at least one of the processors 1302 may be integrated on the same chip with logic of one or more controllers of the system control module 1304 to form a system on chip (SoC).
In various embodiments, device 1300 may include, but is not limited to: a desktop computing device or a mobile computing device (e.g., a laptop computing device, a handheld computing device, a tablet, a netbook, etc.), among others. 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, keyboards, liquid Crystal Display (LCD) screens (including touch screen displays), non-volatile memory ports, multiple antennas, graphics chips, application Specific Integrated Circuits (ASICs), and speakers.
Wherein if the display comprises a touch panel, the display screen may be implemented as a touch screen display to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation.
The embodiment of the application also provides a non-volatile readable storage medium, where one or more modules (programs) are stored, where the one or more modules are applied to an apparatus, and the apparatus may be caused to execute instructions (instructions) of each method in the embodiment of the application.
In one example, an apparatus is provided, 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 an embodiment of the present application, the method may comprise: 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 that, when executed by one or more processors, cause an apparatus to perform a method as in an embodiment of the present application, the method may comprise: the method shown in fig. 1 or fig. 2 or fig. 3 or fig. 4 or fig. 5.
The specific manner in which the operations of the respective modules are performed in the apparatus of the above embodiments has been described in detail in the embodiments related to the method, and will not be described in detail herein, but only with reference to the portions of the description related to the embodiments of the method.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described by differences from other embodiments, and identical and similar parts between the embodiments are all enough to be 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 flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations 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 embodiments have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. It is therefore intended that the following claims be interpreted as including the preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the present application.
Finally, it is further noted that relational terms such as first and second, and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing has outlined a detailed description of a distributed transaction processing method, a distributed transaction processing apparatus, a device, and a machine readable medium, wherein specific examples are provided herein to illustrate the principles and embodiments of the present application and to help understand the method and core concepts thereof; meanwhile, as those skilled in the art will have modifications in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (28)

1. A method of processing a distributed transaction, applied to a first node, the method comprising:
intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant action is a commit action, not performing the commit action;
sending a global request to a third node according to an execution result of a database operation command corresponding to a transaction branch in the distributed transaction;
Wherein the sending the global request to the third node includes:
if the execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or alternatively
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, sending a global rollback request to a third node.
2. The method according to claim 1, wherein the method further comprises:
receiving a branch submitting request sent by a third node;
and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the database operation command.
3. The method according to claim 1, wherein the method further comprises:
receiving a branch rollback request sent by a third node;
and executing the rollback action of the local transaction branch corresponding to the database operation command in response to the branch rollback request.
4. The method according to claim 1, wherein the method further comprises:
in the event that the dependent action is an execution action, registering a transaction branch with a third node.
5. The method of claim 1, wherein the not performing the commit action comprises:
and replacing the commit action with an empty action in the case that the related action is the commit action.
6. The method according to any one of claims 1 to 5, 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.
7. The method according to any one of claims 1 to 5, further comprising:
sending a first call request to a first related service of the distributed transaction; the first call request carries the transaction context of the distributed transaction so that the first related service executes a first remote transaction branch of the distributed transaction.
8. The method of claim 7, wherein the method further comprises:
receiving an execution result of a database operation command corresponding to a first remote transaction branch, which is returned by the first related service according to the first call request;
And judging whether an execution result corresponding to the first remote transaction branch meets a first preset condition or not.
9. The method of claim 8, wherein the method further comprises:
if the execution result corresponding to the first remote transaction branch meets a first preset condition, a second call request is sent to a second related service of the distributed transaction according to the execution result corresponding to the first remote transaction branch; the second call request carries the transaction context of the distributed transaction to enable the second correlation service to execute a second remote transaction branch of the distributed transaction.
10. A method of processing a distributed transaction, for application to a second node, the method comprising:
intercepting relevant actions of a database operation command corresponding to a local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant action is a commit action, not performing the commit action;
sending a third call request to a third related service of the distributed transaction; and the third call request carries the transaction context of the distributed transaction so that the third correlation service executes a third remote transaction branch of the distributed transaction.
11. The method according to claim 10, wherein the method further comprises:
receiving a branch submitting request sent by a third node;
and responding to the branch submitting request, and executing the submitting action of the local transaction branch corresponding to the database operation command.
12. The method according to claim 10, wherein the method further comprises:
receiving a branch rollback request sent by a third node;
and executing the rollback action of the local transaction branch corresponding to the database operation command in response to the branch rollback request.
13. The method according to claim 10, wherein the method further comprises:
in the event that the dependent action is an execution action, registering a transaction branch with a third node.
14. The method of claim 10, wherein the not performing the commit action comprises:
and replacing the commit action with an empty action in the case that the related action is the commit action.
15. The method according to claim 10, wherein the method further comprises:
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 call request;
And judging whether an execution result corresponding to the third remote transaction branch meets a first preset condition or not.
16. A method of 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 a first node or a 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 related action of the database operation command is the commit action; the connection object of the database is matched with the distributed transaction.
17. The method of claim 16, wherein receiving the global request sent by the first node comprises:
if the execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, receiving a global commit request from a first node; or alternatively
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.
18. The method of claim 16, wherein the method further comprises:
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.
19. The method of claim 16, wherein the method further comprises:
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 the second preset condition, sending a result of successful global transaction action to the first node.
20. The method according to any one of claims 16 to 19, further comprising:
for distributed transactions, a connection object is provided for the corresponding database.
21. A processing apparatus for a distributed transaction, applied to a first node, the apparatus comprising:
the interception module is used for intercepting the related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
The non-submitting module is used for not executing the submitting action under the condition that the related action is the submitting action;
the global request sending module is used for 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;
wherein the sending the global request to the third node includes:
if the execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or alternatively
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, sending a global rollback request to a third node.
22. A processing apparatus for a distributed transaction, for application to a second node, the apparatus comprising:
the interception module is used for intercepting the related actions of the database operation command corresponding to the local transaction branch; the database operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
the non-submitting module is used for not executing the submitting action under the condition that the related action is the submitting action;
Sending a third call request to a third related service of the distributed transaction; and the third call request carries the transaction context of the distributed transaction so that the third correlation service executes a third remote transaction branch of the distributed transaction.
23. A processing apparatus for 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 the 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 a first node or a 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 related action of the database operation command is the commit action; the connection object of the database is matched with the distributed transaction.
24. An apparatus, comprising:
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 the method of one or more of claims 1-10.
25. One or more machine-readable media having instructions stored thereon, which when executed by one or more processors, cause the processors to perform the method of one or more of claims 1-10.
26. A method of processing a distributed transaction, applied to a first node, the method comprising:
intercepting relevant actions of a local transaction branch corresponding to a data operation command; the data operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant action is a commit action, not performing the commit action;
sending a global request to a third node according to an execution result of a data operation command corresponding to a transaction branch in the distributed transaction;
wherein the sending the global request to the third node includes:
if the execution results of database operation commands corresponding to all transaction branches in the distributed transaction meet a first preset condition, sending a global commit request to a third node; or alternatively
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, sending a global rollback request to a third node.
27. A method of processing a distributed transaction, for application to a second node, the method comprising:
intercepting relevant actions of a local transaction branch corresponding to a data operation command; the data operation command is applied to the environment of the connection object of the database; the connection object of the database is matched with the distributed transaction;
in the case that the relevant action is a commit action, not performing the commit action;
sending a third call request to a third related service of the distributed transaction; and the third call request carries the transaction context of the distributed transaction so that the third correlation service executes a third remote transaction branch of the distributed transaction.
28. A method of 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 a first node or a second node 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 related action of the data operation command is 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 CN113296897A (en) 2021-08-24
CN113296897B true 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)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138888B (en) * 2021-12-03 2022-07-05 北京宇信科技集团股份有限公司 Processing method, system, medium and equipment for distributed data routing
CN114490769A (en) * 2022-01-28 2022-05-13 国泰新点软件股份有限公司 Database transaction management method, device, equipment and storage medium

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
The Study of the Distributed Transaction in the Service Bearer Network;Lingjia G.等;2010 First International Conference on Networking and Distributed Computing;全文 *
基于分布式事务流的动态可串行调度算法;梁雄友;薛永生;;计算机工程与应用(第08期);全文 *

Also Published As

Publication number Publication date
CN113296897A (en) 2021-08-24

Similar Documents

Publication Publication Date Title
US11829349B2 (en) Direct-connect functionality in a distributed database grid
US20190354539A1 (en) Asynchronous Notifications for a Datastore of a Distributed System
US8352421B2 (en) Recording distributed transactions using probabalistic data structures
CN113296897B (en) Distributed transaction processing method, device, equipment and machine-readable medium
CN111414266B (en) Synchronous and asynchronous communication method and device for distributed transaction
CN114925084B (en) Distributed transaction processing method, system, equipment and readable storage medium
CN110018884B (en) Distributed transaction processing method, coordination device, database and electronic equipment
US20220229822A1 (en) Data processing method and device for distributed database, storage medium, and electronic device
CN112817995B (en) Data processing method and device, electronic equipment and storage medium
JP5754301B2 (en) Transaction concurrency control system, transaction concurrency control method, and program
CN111488367A (en) Method, device and equipment for realizing data consistency and computer storage medium
US11797523B2 (en) Schema and data modification concurrency in query processing pushdown
US20230376479A1 (en) Schema and data modification concurrency in query processing pushdown
US9218386B2 (en) Dual locking mechanism for a domain
CN113296896A (en) Distributed transaction processing method, device and equipment
WO2022206429A1 (en) Distributed transaction implementation method and distributed system
CN113961253B (en) Driving program calling method, device, electronic equipment and storage medium
CN108153796B (en) Data processing method, device and system for electronic red packet
US10728323B2 (en) Method and apparatus for operating infrastructure layer in cloud computing architecture
CN113961315A (en) Transaction processing method, device, equipment and storage medium
CN113077241A (en) Approval processing method, device, equipment and storage medium
CN113872781A (en) Transaction processing method, device, equipment and storage medium
CN116401022A (en) Method and device for processing operation log data of distributed transaction
CN105574020B (en) Database operation method and device
CN116302845B (en) Method and device for determining transaction operation mode, electronic equipment and storage medium

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