Nothing Special   »   [go: up one dir, main page]

CN108958894A - A kind of distributed transaction processing method, system, task manager and terminal device - Google Patents

A kind of distributed transaction processing method, system, task manager and terminal device Download PDF

Info

Publication number
CN108958894A
CN108958894A CN201810614040.3A CN201810614040A CN108958894A CN 108958894 A CN108958894 A CN 108958894A CN 201810614040 A CN201810614040 A CN 201810614040A CN 108958894 A CN108958894 A CN 108958894A
Authority
CN
China
Prior art keywords
transaction
sub
transactions
distributed transaction
distributed
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201810614040.3A
Other languages
Chinese (zh)
Other versions
CN108958894B (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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co 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 CN201810614040.3A priority Critical patent/CN108958894B/en
Publication of CN108958894A publication Critical patent/CN108958894A/en
Application granted granted Critical
Publication of CN108958894B publication Critical patent/CN108958894B/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
    • 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/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Multi Processors (AREA)

Abstract

This specification embodiment provides a kind of distributed transaction processing method, system, task manager and terminal device, more with the execution link for solving distributing real time system in the prior art, the longer problem of total time-consuming.The distributed transaction processing method includes: the request operation in response to distributed transaction, the preparation operation requests of the subtransaction of the distributed transaction, the implementing result for preparing operation requests and being used for the resource of the corresponding subtransaction of request confirmation are sent to multiple resource managers respectively;Based on the multiple resource manager to the response results of the preparation operation requests of the subtransaction of the distributed transaction, the corresponding transaction operation of the response results is executed to the distributed transaction by asynchronous system.

Description

Distributed transaction processing method, system, transaction manager and terminal equipment
Technical Field
The embodiments of the present disclosure relate to the field of distributed transaction processing technologies, and in particular, to a distributed transaction processing method, a distributed transaction processing system, a transaction manager, and a terminal device.
Background
The distributed transaction means that a participant of the transaction, a server supporting the transaction, a resource manager and a transaction manager are respectively positioned on different nodes of different distributed systems. A transaction is an indivisible unit of work, and a distributed transaction typically contains multiple local transactions, each of which is either executed or not executed. For example, assuming that operation 1 on database a, operation 2 on database B, and operation 3 on database C are a distributed transaction, the distributed transaction will be executed successfully only if all three operations, i.e., operation 1, operation 2, and operation 3, are executed successfully.
Most distributed transactions generally follow a Two Phase commit protocol (2 PC). 2PC is a basic protocol of distributed transactions, one stage in 2PC is a voting stage, and all resource managers send feedback results of whether the transaction is successful to the transaction manager; the two phases in 2PC are execution phases, and the transaction manager executes corresponding operations according to the feedback results of all resource managers. If the feedback results of all the resource managers are received successfully, all the resource managers are informed to submit on all the branches in a pace-consistent manner; and if the feedback result received from one of all the resource managers is failure, all the resource managers are notified to roll back on all the branches. As can be seen, the one and two phases are performed serially, and only after the two phases have ended is the execution of the distributed transaction completed.
for example, as shown in fig. 1, firstly, a participant of a transaction initiates a transaction, a transaction manager coordinates a resource manager in two stages, namely, in one stage, the transaction manager sends a preparation operation request to all resource managers, and all resource managers return response results according to the preparation operation request, ② 2 in two stages, the transaction manager sends an execution operation request to all resource managers according to the response results returned by all resource managers in one stage, and thirdly, all resource managers execute corresponding operations according to the execution operation request sent by the two-stage service manager, and finally, after the execution is completed from 0 to ④, the whole distributed transaction is executed.
In summary, the existing distributed transaction processing needs to execute one stage and two stages for each resource manager, so that the distributed transaction processing has more execution links and longer total time consumption.
Disclosure of Invention
Embodiments of the present specification provide a distributed transaction processing method, a distributed transaction processing system, a transaction manager, and a terminal device, so as to solve the problems in the prior art that the execution link of distributed transaction processing is more and the total time consumption is longer.
The embodiment of the specification adopts the following technical scheme:
in a first aspect, a distributed transaction processing method is provided, including:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
In a second aspect, there is provided a transaction manager comprising:
a sending module, configured to send, in response to a request operation of a distributed transaction, a preparation operation request of a sub-transaction of the distributed transaction to a plurality of resource managers, respectively, where the preparation operation request is used to request to confirm an execution result of a resource of the corresponding sub-transaction;
and the execution module is used for executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the preparation operation request of the plurality of resource managers on the sub-transaction of the distributed transaction.
In a third aspect, a distributed transaction processing system is provided, including:
the method comprises the steps that a transaction manager responds to request operation of distributed transactions, and sends preparation operation requests of sub-transactions of the distributed transactions to a plurality of resource managers respectively, wherein the preparation operation requests are used for requesting confirmation of execution results of resources of the corresponding sub-transactions;
the transaction manager distributes sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset distribution rule, and the thread pool is pre-configured with the plurality of synchronous threads;
and executing the transaction operation corresponding to the response result on the distributed transaction by a plurality of synchronous threads in the thread pool in an asynchronous mode.
In a fourth aspect, a distributed transaction processing system is provided, comprising:
the method comprises the steps that a transaction manager responds to request operation of distributed transactions, and sends preparation operation requests of sub-transactions of the distributed transactions to a plurality of resource managers respectively, wherein the preparation operation requests are used for requesting confirmation of execution results of resources of the corresponding sub-transactions;
the transaction manager stores the response result and the corresponding relation between the response result and the transaction operation request corresponding to the response result in a standby database;
and the other equipment asynchronously executes the transaction operation corresponding to the response result based on the response result inquired in the standby database.
In a fifth aspect, a terminal device is provided, which includes: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
In a sixth aspect, a computer-readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
The embodiment of the specification adopts at least one technical scheme which can achieve the following beneficial effects:
in the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
Drawings
The accompanying drawings, which are included to provide a further understanding of the specification and are incorporated in and constitute a part of this specification, illustrate embodiments of the specification and together with the description serve to explain the specification and not to limit the specification in a non-limiting sense. In the drawings:
FIG. 1 is a flow chart of a distributed transaction processing method in the prior art;
FIG. 2 is a second flowchart of a distributed transaction processing method in the prior art;
FIG. 3 is a flow diagram of a distributed transaction processing method provided by one embodiment of the present description;
fig. 4 is a schematic flowchart illustrating an actual application scenario of the distributed transaction processing method according to an embodiment of the present disclosure;
FIG. 5 is a block diagram of a distributed transaction processor provided by one embodiment of the present description;
FIG. 6 is one of block diagrams of a distributed transaction processing system provided by one embodiment of the present specification;
fig. 7 is a second block diagram of a distributed transaction processing system according to an embodiment of the present disclosure;
fig. 8 is a block diagram of a terminal device according to an embodiment of the present specification.
Detailed Description
In order to make the objects, technical solutions and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below with reference to the specific embodiments of the present disclosure and the accompanying drawings. It is to be understood that the embodiments described are only a few embodiments of the present disclosure, and not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present specification without any creative effort belong to the protection scope of the present specification.
Embodiments of the present specification provide a distributed transaction processing method and terminal device, so as to solve the problems in the prior art that there are many execution links of distributed transaction processing and the total time consumption is long. The embodiments of the present specification provide a distributed transaction processing method, and an execution subject of the method may be, but is not limited to, a transaction manager of a distributed transaction or an apparatus or system capable of being configured to execute the method provided by the embodiments of the present specification.
For convenience of description, the following description will be made of an embodiment of the method, taking an execution subject of the method as a transaction manager capable of executing the method. It is to be understood that the execution of the method by the transaction manager is merely an exemplary illustration and should not be construed as a limitation of the method.
Fig. 3 is a flowchart of a distributed transaction processing method provided in an embodiment of the present specification, where the method of fig. 3 may be executed by a transaction manager, and as shown in fig. 3, the method may include:
step 310, responding to the request operation of the distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers.
The prepare operation request requests validation of the execution results of the resources of the corresponding sub-transaction.
And 320, executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the preparation operation request of the plurality of resource managers on the sub-transaction of the distributed transaction.
It should be understood that after the transaction manager obtains the response result of the preparation operation request of the multiple resource managers to the sub-transaction of the distributed transaction, the transaction manager executes the transaction operation corresponding to the response result to the distributed transaction in an asynchronous manner.
In other words, the transaction manager's processing of the distributed transaction is completed after the transaction manager obtains the results of the responses of the multiple resource managers to the prepare operation requests of the sub-transactions of the distributed transaction.
The response result may be a preparation success or a preparation failure; alternatively, the response result may be an execution success or an execution failure.
Executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous manner, which may specifically be:
the transaction manager reports response results of the preparation operation requests of the resource managers for the sub-transactions of the distributed transactions to other equipment, such as a server, and the other equipment executes the transaction operation corresponding to the response result according to the response result; or,
and the transaction manager distributes response results of the preparation operation requests of the resource managers to the sub-transactions of the distributed transactions to a plurality of synchronous threads in the thread pool, and the plurality of synchronous threads execute the transaction operation corresponding to the response result according to the response result.
In the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
Optionally, as an embodiment, the distributed transaction processing method provided in this specification embodiment may further include:
receiving a transaction starting request sent by a client, and allocating a plurality of sub-transactions divided by a distributed transaction corresponding to the transaction starting request to a plurality of resource managers for processing a preparation operation.
For example, assuming "account a transfers to account B" as a distributed transaction, then a write operation needs to be performed on three resource managers (i.e., the distributed transaction can be divided into three sub-transactions), respectively:
operation 1, deducting a preset amount from the account A on the resource manager 1;
operation 2, adding corresponding amount to the account B on the resource manager 2;
and operation 3, performing transfer aggregation on the resource manager 3.
If the response results of the three resource managers after the preparation operation processing are all successful, determining to submit the distributed transaction; and if at least one response result in response results after the three resource managers perform the preparation operation processing is that the preparation is failed, determining to perform rollback operation on the distributed transaction.
In practical applications, the implementation of the method of the present specification is described in detail, for example, along with the above examples:
a user initiates an operation of transferring accounts from an account A to an account B at a client side, and registers a distributed transaction to a transaction manager according to the operation performed by the user; the transaction manager will assign a transaction identification ID to the distributed transaction. The "account a transfers to account B" requires a write operation on three resource managers, that is, the distributed transaction may be divided into three sub-transactions:
operation 1, deducting a preset amount from the account A on the resource manager 1;
operation 2, adding corresponding amount to the account B on the resource manager 2;
and operation 3, performing transfer aggregation on the resource manager 3.
If the response results of the three resource managers after the preparation operation processing are all successful, determining to submit the distributed transaction; and if at least one response result in response results after the three resource managers perform the preparation operation processing is that the preparation is failed, determining to perform rollback operation on the distributed transaction.
And after the sub-transaction processing is completed, the transaction manager executes the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response results of all the sub-transactions.
If so, after the transaction manager reports the response results of all the sub-transactions to the standby database, the server side serves as a coordinator to query the response results of all the sub-transactions in the standby database, and determines to initiate submission or rollback of the distributed transaction according to the queried response results of all the sub-transactions; or,
and the transaction manager distributes the sub-transactions respectively corresponding to the response results to a plurality of synchronous threads in the thread pool according to a preset distribution rule, and the synchronous threads determine to initiate the submission or rollback of the distributed transaction based on the response results.
Optionally, as an embodiment, the step 120 may be specifically implemented as:
distributing sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset distribution rule, wherein the thread pool is pre-configured with the plurality of synchronous threads;
and the synchronous threads in the thread pool are used for executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode.
In this application, a thread pool needs to be established in advance, and the synchronous threads in the thread pool in this embodiment may be: a thread that calls run method execution is required.
For example, 10 synchronous threads are configured in advance in the thread pool, the 10 thread synchronizations need to be executed by a run method, and the 10 synchronous threads executed by the run method can be executed in the main thread during execution, so that the ending time of the synchronous thread executing the task can be perceived by the main thread.
The thread pool can directly or indirectly extend from the threadpoolsexecutor provided by JDK (Java Development Kit, software Development Kit in Java language). The thread pool (doimmediateltylthreadthreadpottaskeexecutor) in this embodiment is different from the thread pool in the prior art, and the synchronous threads of the thread pool in this embodiment all call run methods to be executed, so that the synchronous threads can be synchronously executed in the called main thread.
The sub-transactions respectively corresponding to the multiple response results are allocated to multiple synchronous threads in a thread pool according to a preset allocation rule, and the multiple synchronous threads are preconfigured in the thread pool, and the specific implementation may include:
step A1: and establishing a task queue for the thread pool.
Firstly, a task queue is established for the created thread pool, and the task queue can store the tasks distributed to the synchronous threads in the thread pool according to the sequence.
Step A2: and adding the plurality of sub-transactions into the task queue according to the users triggering the plurality of sub-transactions respectively.
In this embodiment, the plurality of sub-transactions may be added to the task queue according to different users who trigger the sub-transactions.
For example, for the buffering and account-repairing service in practical application, there are four users that trigger 7 tasks of buffering and account-repairing.
Specifically, as shown in table 1:
TABLE 1
User tasks id
A 1
A 2
A 3
B 4
B 5
C 6
D 7
Then, the task queue may add the three sub-transactions of user a, then add the two sub-transactions of user B, and then add the tasks of user C and user D in sequence.
Step A3: and respectively distributing the sub-transactions in the task queue to a plurality of synchronous threads in a thread pool, wherein each user corresponds to one synchronous thread.
And then, the sub-transactions in the task queue are respectively allocated to a plurality of synchronous threads in the thread pool, for example, the sub-transaction of each user is correspondingly allocated to one synchronous thread. Then, referring to Table 1, three sub-transactions for user A may be assigned to the first synchronous thread in the thread pool, two sub-transactions for user B may be assigned to the second synchronous thread in the thread pool, and so on.
Certainly, in practical application, the method is not limited to allocating the threads to the tasks by taking the user as the dimension, and may also allocate one synchronization thread to each sub-transaction by taking the sub-transactions as the dimension, and of course, other allocation manners may also be adopted.
As shown in fig. 4, in the embodiment of the present specification, in the two-phase transaction manager, the sub-transactions corresponding to the multiple response results returned by all the resource managers in the one phase are respectively allocated to the multiple synchronous threads in the thread pool according to the preset allocation rule, and the multiple synchronous threads in the thread pool execute the transaction operation corresponding to the response result on the distributed transaction in an asynchronous manner, so that the transaction manager reduces the total execution link of the distributed transaction, and the total consumption time is changed to the sum of a + b + c + g, thereby effectively reducing the execution loss of the distributed transaction.
Optionally, as an embodiment, the step 120 may be specifically implemented as:
and storing the response result and the corresponding relation between the response result and the transaction operation request corresponding to the response result in a standby database, so that other equipment asynchronously executes the transaction operation corresponding to the response result based on the response result inquired in the standby database.
The backup database may be a database of other devices, or may be an independent database with respect to other devices, and the embodiments of the present specification are not particularly limited.
For example, after the transaction manager reports the response results of all the sub-transactions to the standby database, the server side, as a coordinator, queries the response result of each sub-transaction in the standby database, and determines to initiate submission or rollback of the distributed transaction according to the queried response result of each sub-transaction, specifically, if the response results of all the sub-transactions of the distributed transaction are successfully prepared, it is determined to submit the distributed transaction, and if at least one response result of all the sub-transactions is a sub-transaction that fails to be prepared, it is determined to rollback the distributed transaction. Specifically, after determining to commit or rollback the distributed transaction, the server sends a commit command or a rollback command to each of the sub-transactions to initiate a commit or rollback of the global transaction. Therefore, the committing of the distributed transaction can be executed according to the received command which is sent by the server and used for committing the distributed transaction; or according to a received command of rolling back the distributed transaction sent by the server, the roll back of the distributed transaction is executed. That is, if a command to commit the distributed transaction is received, which is sent by the server, the commit of the distributed transaction is performed; and if the received command sent by the server for rolling back the distributed transaction is received, the roll back of the distributed transaction is executed.
In the embodiment of the present specification, the response result and the corresponding relationship between the response result and the transaction operation request corresponding to the response result are stored in the standby database, and the other device executes the transaction operation corresponding to the response result based on the response result queried in the standby database, so that the purpose that the transaction operation corresponding to the response result is executed in an asynchronous manner is achieved, the execution link of the distributed transaction processing is reduced, and the execution loss of the distributed transaction is reduced.
The distributed transaction processing method according to the embodiment of the present disclosure is described in detail above with reference to fig. 3 to 4, and the transaction manager according to the embodiment of the present disclosure is described in detail below with reference to fig. 5.
Fig. 5 is a schematic structural diagram of a transaction manager provided in an embodiment of this specification, and as shown in fig. 5, the transaction manager 500 may include:
a sending module 501, configured to send, in response to a request operation of a distributed transaction, a preparation operation request of a sub-transaction of the distributed transaction to a plurality of resource managers, respectively, where the preparation operation request is used to request to confirm an execution result of a resource of the corresponding sub-transaction;
and the executing module 503 is configured to execute, based on response results of the preparation operation requests of the multiple resource managers for the sub-transactions of the distributed transaction, the transaction operation corresponding to the response result on the distributed transaction in an asynchronous manner.
In one embodiment, the execution module 503 may include:
the allocation unit is used for allocating the sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset allocation rule, and the thread pool is pre-configured with the plurality of synchronous threads;
and the execution unit is used for executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode by a plurality of synchronous threads in the thread pool.
In one embodiment, the allocation unit may include:
the establishing subunit is used for establishing a task queue for the thread pool;
the adding subunit is used for respectively adding the plurality of sub-transactions into the task queue according to each user triggering the plurality of sub-transactions;
and the distribution subunit is used for respectively distributing the sub-transactions in the task queue to a plurality of synchronous threads in a thread pool, wherein each user corresponds to one synchronous thread.
In one embodiment, the execution module 503 may include:
and the storage unit is used for storing the response result and the corresponding relation between the response result and the transaction operation request corresponding to the response result in a standby database, so that other equipment asynchronously executes the transaction operation corresponding to the response result based on the response result inquired in the standby database.
In one embodiment, the transaction manager may further include:
the receiving and allocating module 505 is configured to receive a transaction start request sent by a client, and allocate a plurality of sub-transactions divided by a distributed transaction corresponding to the transaction start request to the plurality of resource managers to perform preparation operation.
In the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
The distributed transaction processing method according to the embodiment of the present disclosure is described in detail above with reference to fig. 3 to 4, and the distributed transaction processing system according to the embodiment of the present disclosure is described in detail below with reference to fig. 6.
Fig. 6 is a schematic structural diagram of a distributed transaction processing system provided in an embodiment of the present specification, and as shown in fig. 6, the distributed transaction processing system 600 may include:
the transaction manager 601 responds to the request operation of the distributed transaction, and sends preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers respectively, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
the transaction manager 601 distributes the sub-transactions corresponding to the response results to a plurality of synchronous threads 603 in a thread pool according to a preset distribution rule, wherein the thread pool is configured with a plurality of synchronous threads in advance;
and executing the transaction operation corresponding to the response result on the distributed transaction by a plurality of synchronous threads 603 in the thread pool in an asynchronous mode.
In the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
The distributed transaction processing method according to the embodiment of the present disclosure is described in detail above with reference to fig. 3 and 4, and the distributed transaction processing system according to the embodiment of the present disclosure is described in detail below with reference to fig. 7.
Fig. 7 is a schematic structural diagram of a distributed transaction processing system provided in an embodiment of the present specification, and as shown in fig. 7, the distributed transaction processing system 700 may include:
the transaction manager 701 responds to a request operation of a distributed transaction, and respectively sends preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
the transaction manager 701 stores the response result and the corresponding relationship between the response result and the transaction operation request corresponding to the response result in the standby database 703;
the other device 705 asynchronously executes the transaction operation corresponding to the response result based on the response result queried in the standby database.
In the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
Fig. 8 is a schematic structural diagram of a terminal device provided in an embodiment of the present specification. Referring to fig. 8, in the hardware level, the terminal device includes a processor, and optionally further includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a Random-access memory (RAM), and may further include a non-volatile memory, such as at least 1 disk memory. Of course, the terminal device may also include hardware required for other services.
The processor, the network interface, and the memory may be connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (peripheral component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 8, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory to the memory and then runs the computer program to form the association device of the resource value-added object and the resource object on the logic level. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
In the embodiment of the description, based on the response result of the preparation operation request of the multiple resource managers for the sub-transaction of the distributed transaction, the transaction operation corresponding to the response result is executed on the distributed transaction in an asynchronous manner, so that the transaction operation corresponding to the response result is executed in an asynchronous manner, the execution link of distributed transaction processing is reduced, and the execution loss of the distributed transaction is shortened.
The distributed transaction processing method disclosed in the embodiment of fig. 3 in this specification can be applied to or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in one or more embodiments of the present specification may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with one or more embodiments of the present disclosure may be embodied directly in hardware, in a software module executed by a hardware decoding processor, or in a combination of the hardware and software modules executed by a hardware decoding processor. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
The terminal device may further execute the distributed transaction processing method of fig. 1 executed by the distributed transaction processing apparatus of fig. 3, which is not described herein again.
Of course, the terminal device in this specification does not exclude other implementations, such as a logic device or a combination of software and hardware, and the like, besides the software implementation, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or a logic device.
Embodiments of the present disclosure further provide a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements each process of the above method embodiments, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here. The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the description may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The description has been presented with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the description. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a system 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 data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction system 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 data processing 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.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
The foregoing description describes certain embodiments of the specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification.

Claims (10)

1. A distributed transaction processing method is applied to a transaction manager of a distributed transaction, and comprises the following steps:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
2. The method of claim 1, wherein performing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous manner comprises:
distributing sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset distribution rule, wherein the thread pool is pre-configured with the plurality of synchronous threads;
and the synchronous threads in the thread pool are used for executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode.
3. The method according to claim 2, wherein the allocating the sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset allocation rule comprises:
establishing a task queue for the thread pool;
adding the plurality of sub-transactions to the task queue according to each user triggering the plurality of sub-transactions;
and respectively distributing the sub-transactions in the task queue to a plurality of synchronous threads in a thread pool, wherein each user corresponds to one synchronous thread.
4. The method of claim 1, wherein performing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous manner comprises:
and storing the response result and the corresponding relation between the response result and the transaction operation request corresponding to the response result in a standby database, so that other equipment asynchronously executes the transaction operation corresponding to the response result based on the response result inquired in the standby database.
5. The method of claim 1, prior to sending the prepare operation requests for the sub-transactions of the distributed transaction to a plurality of resource managers, respectively, further comprising:
receiving a transaction starting request sent by a client, and allocating a plurality of sub-transactions divided by a distributed transaction corresponding to the transaction starting request to a plurality of resource managers for processing a preparation operation.
6. A transaction manager, comprising:
a sending module, configured to send, in response to a request operation of a distributed transaction, a preparation operation request of a sub-transaction of the distributed transaction to a plurality of resource managers, respectively, where the preparation operation request is used to request to confirm an execution result of a resource of the corresponding sub-transaction;
and the execution module is used for executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the preparation operation request of the plurality of resource managers on the sub-transaction of the distributed transaction.
7. A distributed transaction processing system comprising:
the method comprises the steps that a transaction manager responds to request operation of distributed transactions, and sends preparation operation requests of sub-transactions of the distributed transactions to a plurality of resource managers respectively, wherein the preparation operation requests are used for requesting confirmation of execution results of resources of the corresponding sub-transactions;
the transaction manager distributes sub-transactions respectively corresponding to the plurality of response results to a plurality of synchronous threads in a thread pool according to a preset distribution rule, and the thread pool is pre-configured with the plurality of synchronous threads;
and executing the transaction operation corresponding to the response result on the distributed transaction by a plurality of synchronous threads in the thread pool in an asynchronous mode.
8. A distributed transaction processing system comprising:
the method comprises the steps that a transaction manager responds to request operation of distributed transactions, and sends preparation operation requests of sub-transactions of the distributed transactions to a plurality of resource managers respectively, wherein the preparation operation requests are used for requesting confirmation of execution results of resources of the corresponding sub-transactions;
the transaction manager stores the response result and the corresponding relation between the response result and the transaction operation request corresponding to the response result in a standby database;
and the other equipment asynchronously executes the transaction operation corresponding to the response result based on the response result inquired in the standby database.
9. A terminal device, comprising: a memory, a processor and a computer program stored on the memory and executable on the processor, the computer program when executed by the processor implementing the steps of:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
10. A computer-readable storage medium having a computer program stored thereon, which when executed by a processor, performs the steps of:
responding to a request operation of a distributed transaction, respectively sending preparation operation requests of sub-transactions of the distributed transaction to a plurality of resource managers, wherein the preparation operation requests are used for requesting to confirm execution results of resources of the corresponding sub-transactions;
and executing the transaction operation corresponding to the response result on the distributed transaction in an asynchronous mode based on the response result of the plurality of resource managers to the preparation operation request of the sub-transaction of the distributed transaction.
CN201810614040.3A 2018-06-14 2018-06-14 Distributed transaction processing method, system, transaction manager and terminal equipment Active CN108958894B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810614040.3A CN108958894B (en) 2018-06-14 2018-06-14 Distributed transaction processing method, system, transaction manager and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810614040.3A CN108958894B (en) 2018-06-14 2018-06-14 Distributed transaction processing method, system, transaction manager and terminal equipment

Publications (2)

Publication Number Publication Date
CN108958894A true CN108958894A (en) 2018-12-07
CN108958894B CN108958894B (en) 2022-05-10

Family

ID=64488825

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810614040.3A Active CN108958894B (en) 2018-06-14 2018-06-14 Distributed transaction processing method, system, transaction manager and terminal equipment

Country Status (1)

Country Link
CN (1) CN108958894B (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109819023A (en) * 2018-12-29 2019-05-28 杭州励飞软件技术有限公司 Distributed transaction processing method and Related product
CN110134735A (en) * 2019-04-10 2019-08-16 阿里巴巴集团控股有限公司 The storage method and device of distributed transaction log
CN110264346A (en) * 2019-05-06 2019-09-20 阿里巴巴集团控股有限公司 Processing method, device and the equipment of assets consumer requests
CN110288255A (en) * 2019-06-28 2019-09-27 深圳前海微众银行股份有限公司 A kind of logistics method and device of distributed transaction
CN111414266A (en) * 2020-03-23 2020-07-14 山东浪潮通软信息科技有限公司 Synchronous and asynchronous communication method and device for distributed transactions
CN112416535A (en) * 2020-11-24 2021-02-26 中国工商银行股份有限公司 Distributed transaction processing method and system
CN112766829A (en) * 2021-03-16 2021-05-07 中国工商银行股份有限公司 Service processing method, device and equipment
CN113986923A (en) * 2021-10-28 2022-01-28 建信金融科技有限责任公司 Distributed transaction processing method, device and equipment based on only additional file storage
CN115185677A (en) * 2022-06-24 2022-10-14 湖南长银五八消费金融股份有限公司 Business data merging general ledger method, device, computer equipment and medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010039167A1 (en) * 2008-10-02 2010-04-08 Mindspeed Technologies, Inc. Multi-core system with central transaction control
CN103678556A (en) * 2013-12-06 2014-03-26 华为技术有限公司 Method for processing column-oriented database and processing equipment
CN105988862A (en) * 2015-02-04 2016-10-05 阿里巴巴集团控股有限公司 Distributed transaction processing method and device
CN106201853A (en) * 2015-04-30 2016-12-07 阿里巴巴集团控股有限公司 Method of testing and device
CN106502769A (en) * 2016-09-30 2017-03-15 华为技术有限公司 Distributed transaction processing method, apparatus and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010039167A1 (en) * 2008-10-02 2010-04-08 Mindspeed Technologies, Inc. Multi-core system with central transaction control
CN103678556A (en) * 2013-12-06 2014-03-26 华为技术有限公司 Method for processing column-oriented database and processing equipment
CN105988862A (en) * 2015-02-04 2016-10-05 阿里巴巴集团控股有限公司 Distributed transaction processing method and device
CN106201853A (en) * 2015-04-30 2016-12-07 阿里巴巴集团控股有限公司 Method of testing and device
CN106502769A (en) * 2016-09-30 2017-03-15 华为技术有限公司 Distributed transaction processing method, apparatus and system

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109819023A (en) * 2018-12-29 2019-05-28 杭州励飞软件技术有限公司 Distributed transaction processing method and Related product
CN109819023B (en) * 2018-12-29 2021-09-14 杭州励飞软件技术有限公司 Distributed transaction processing method and related product
CN110134735A (en) * 2019-04-10 2019-08-16 阿里巴巴集团控股有限公司 The storage method and device of distributed transaction log
CN110264346A (en) * 2019-05-06 2019-09-20 阿里巴巴集团控股有限公司 Processing method, device and the equipment of assets consumer requests
CN110288255A (en) * 2019-06-28 2019-09-27 深圳前海微众银行股份有限公司 A kind of logistics method and device of distributed transaction
CN111414266A (en) * 2020-03-23 2020-07-14 山东浪潮通软信息科技有限公司 Synchronous and asynchronous communication method and device for distributed transactions
CN111414266B (en) * 2020-03-23 2024-04-05 浪潮通用软件有限公司 Synchronous and asynchronous communication method and device for distributed transaction
CN112416535A (en) * 2020-11-24 2021-02-26 中国工商银行股份有限公司 Distributed transaction processing method and system
CN112416535B (en) * 2020-11-24 2023-12-22 中国工商银行股份有限公司 Distributed transaction processing method and system
CN112766829A (en) * 2021-03-16 2021-05-07 中国工商银行股份有限公司 Service processing method, device and equipment
CN113986923A (en) * 2021-10-28 2022-01-28 建信金融科技有限责任公司 Distributed transaction processing method, device and equipment based on only additional file storage
CN115185677A (en) * 2022-06-24 2022-10-14 湖南长银五八消费金融股份有限公司 Business data merging general ledger method, device, computer equipment and medium

Also Published As

Publication number Publication date
CN108958894B (en) 2022-05-10

Similar Documents

Publication Publication Date Title
CN108958894B (en) Distributed transaction processing method, system, transaction manager and terminal equipment
CN107360206B (en) Block chain consensus method, equipment and system
US10521268B2 (en) Job scheduling method, device, and distributed system
US8566641B2 (en) Fault tolerant batch processing
WO2017140131A1 (en) Data writing and reading method and apparatus, and cloud storage system
WO2021217986A1 (en) Distributed message transmission method and apparatus, computer device and storage medium
CN106899648B (en) Data processing method and equipment
CN107273195B (en) Big data batch processing method and device and computer system
CN107016029B (en) Method, device and system for processing service data
CN110134503B (en) Timed task processing method and device in cluster environment and storage medium
CN111667334B (en) Audit failure order processing method and device, computer equipment and storage medium
WO2015131542A1 (en) Data processing method, device and system
CN112581018A (en) Process task management method, system, device and storage medium
KR102327572B1 (en) Methods and devices for data storage and service processing
US11294729B2 (en) Resource provisioning for multiple invocations to an electronic design automation application
CN111831408A (en) Asynchronous task processing method and device, electronic equipment and medium
CN115544044A (en) Data consistency keeping method, device, equipment and storage medium
CN114253713B (en) Asynchronous batch processing method and system based on reactor
CN111124751A (en) Data recovery method and system, data storage node and database management node
CN111754117B (en) Task issuing method and device, electronic equipment and storage medium
CN114691309A (en) Batch business processing system, method and device
CN106855821B (en) Distributed transaction processing method and device
CN114090113A (en) Method, device and equipment for dynamically loading data source processing plug-in and storage medium
CN106598706B (en) Method and device for improving stability of server and server
CN106156185B (en) Method, device and system for inquiring service request execution state

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200921

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman, British Islands

Applicant after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Applicant before: Alibaba Group Holding Ltd.

GR01 Patent grant
GR01 Patent grant