CN111045794B - Distributed transaction processing method, device, system, computer equipment and storage medium - Google Patents

Distributed transaction processing method, device, system, computer equipment and storage medium Download PDF

Info

Publication number
CN111045794B
CN111045794B CN201911302134.8A CN201911302134A CN111045794B CN 111045794 B CN111045794 B CN 111045794B CN 201911302134 A CN201911302134 A CN 201911302134A CN 111045794 B CN111045794 B CN 111045794B
Authority
CN
China
Prior art keywords
transaction
processing
segmented
preset
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.)
Active
Application number
CN201911302134.8A
Other languages
Chinese (zh)
Other versions
CN111045794A (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.)
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Original Assignee
Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co 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 Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd filed Critical Shenzhen Qianhai Huanrong Lianyi Information Technology Service Co Ltd
Priority to CN201911302134.8A priority Critical patent/CN111045794B/en
Publication of CN111045794A publication Critical patent/CN111045794A/en
Application granted granted Critical
Publication of CN111045794B publication Critical patent/CN111045794B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention provides a distributed transaction processing method, a distributed transaction processing device, a distributed transaction processing system, computer equipment and a computer readable storage medium. The distributed system comprises a transaction coordinator end, an initiating end and a processing end when the distributed transaction processing is realized, wherein the transaction is divided into a plurality of segmented transactions, the initiating end receives a service request, a transaction opening instruction of the transaction corresponding to the service request is sent to the transaction coordinator end, the transaction coordinator end sends a preset transaction identification to the initiating end according to the transaction opening instruction, the initiating end calls the processing end corresponding to each segmented transaction with the preset transaction identification, each processing end processes the segmented transaction corresponding to each processing end, the segmented processing results are returned to the initiating end, the initiating end judges whether each segmented processing result is successful or not, if each segmented processing result is successful, the distributed processing of the transaction is judged to be completed, and the processing performance of the computer equipment on the distributed transaction is improved.

Description

Distributed transaction processing method, device, system, computer equipment and storage medium
Technical Field
The present invention relates to the field of database transaction processing technologies, and in particular, to a distributed transaction processing method, apparatus, system, computer device, and computer readable storage medium.
Background
The current software development of the server needs to use the storage function of the database, for example, the Mysql database already realizes ACID (ACID is four principles of normal execution of database transactions, which respectively refer to atomicity, consistency, independence and durability), so that the requirements of daily business can be met. However, when the database system is a distributed system, since there are multiple Mysql databases, the multiple Mysql databases cannot meet the ACID characteristic, which results in no way to perform an atomic operation between the multiple databases, and causes a problem of distributed transactions. For distributed transaction problems, conventional techniques typically employ XA transactions or TCC transactions to resolve.
XA transaction refers to processing the transaction by adopting an XA protocol, wherein the XA protocol is proposed by Tuxedo and is given to an X/Open organization to serve as an interface standard of a resource manager (database) and a transaction manager. Currently, each large database vendor, oracle, informix, DB and Sybase, etc., provides support for XA. Referring to fig. 1, fig. 1 is a schematic diagram of XA transaction processing in the conventional technology, and as shown in fig. 1, the XA protocol uses a two-phase commit mode to manage distributed transactions, and two-phase commit is performed by a transaction manager service a and a transaction manager service B to manage distributed transactions. The XA interface provides a standard interface for communication between the resource manager and the transaction manager. The XA protocol includes two sets of functions, XA-headed and ax-headed. The following functions enable the transaction manager to perform operations on the resource manager: 1) xa_open, xa_close function for establishing and closing connections with resource manager; 2) xa_start, xa_end function for starting and ending a local transaction; 3) xa_preparation, xa_commit, xa_rollback functions for pre-committing, and rolling back a local transaction; 4) An xa_recovery function to rollback a transaction that has been pre-committed; 5) The function of ax_start allows the resource manager to dynamically register in the transaction manager and operate on XID (TRANSACTIONIDS); 6) The ax_reg, ax_unreg function allows a resource manager to dynamically register or de-register in one TMS (TRANSACTIONMANAGERSERVER). TCC transactions, which are distributed transactions handled by TCC services, are composed of Try/Confirm/Cancel services, which when executed, access a Resource Manager (RM) to access data, and these access operations must participate in RM local transactions to make the data changed by either all Commit or all Rollback.
The TCC transaction is very highly coupled with traffic, resulting in additional system complexity, due to the poor performance caused by the long transaction time of XA transactions. Therefore, in the conventional technology, the XA transaction and the TCC transaction have serious problem of poor performance, and the processing performance for the distributed transaction is low.
Disclosure of Invention
The embodiment of the invention provides a distributed transaction processing method, a device, a system, computer equipment and a computer readable storage medium, which can solve the problem of lower distributed transaction processing performance in the traditional technology.
In a first aspect, an embodiment of the present invention provides a distributed transaction processing method applied to an initiator, where a distributed system includes a transaction coordinator and a plurality of server sides, an entire transaction is divided into a plurality of segmented transactions in advance, a plurality of server sides includes an initiator corresponding to the transaction initiator, and a plurality of processing sides for processing different segmented transactions, and the method includes: receiving a service request of a client; according to the service request, a transaction opening instruction of a transaction corresponding to the service request is sent to the transaction coordinator; receiving a preset transaction identifier corresponding to the transaction returned by the transaction coordinator, wherein the preset transaction identifier is distributed by the transaction coordinator according to the transaction starting instruction; transmitting processing instructions corresponding to each segmented transaction to the processing end according to a preset sequence, wherein the processing instructions carry the preset transaction identifiers so that the processing end processes the segmented transaction to obtain segmented processing results corresponding to each segmented transaction, and returning the segmented processing results to the initiating end; receiving the segmentation processing result returned by the processing end; judging whether each segmented processing result is successful; and if the segmentation processing results are successful, judging that the distributed processing of the transaction is completed.
In a second aspect, an embodiment of the present invention further provides a distributed transaction processing method applied to a processing end, where a distributed system includes a transaction coordinator end and a plurality of server ends, an entire transaction is divided into a plurality of segmented transactions in advance, a plurality of server ends include an initiating end corresponding to a transaction initiator, and a plurality of processing ends for processing different segmented transactions, where the method includes: receiving a processing instruction for processing the segmented transaction, which is sent by the initiating terminal, wherein the processing instruction carries a preset transaction identifier corresponding to the transaction, and the preset transaction identifier is distributed and returned to the initiating terminal by the transaction coordinator terminal when the initiating terminal starts the transaction to the transaction coordinator terminal; according to the processing instruction, a segmented transaction opening instruction for opening the segmented transaction is sent to the transaction coordinator, wherein the segmented transaction opening instruction carries the preset transaction identifier; receiving a preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, wherein the preset segmented transaction identifier is distributed by the transaction coordinator according to the segmented transaction starting instruction; processing the segmented transaction to obtain a segmented processing result; and returning the segmentation processing result to the initiating terminal so that the initiating terminal executes the step of receiving the segmentation processing result returned by the processing terminal in the distributed transaction processing method applied to the initiating terminal.
In a third aspect, an embodiment of the present invention further provides a distributed transaction processing method applied to a transaction coordinator, where a distributed system includes the transaction coordinator and a plurality of server sides, the entire transaction is divided into a plurality of segmented transactions in advance, the plurality of server sides include an initiator corresponding to a transaction initiator, and the plurality of processing sides process different segmented transactions, and the method includes: receiving a transaction opening instruction of opening a transaction sent by the initiating terminal, wherein the transaction corresponds to a service request of a client, and the opening transaction is started according to the service request; distributing a preset transaction identifier to the transaction; sending the preset transaction identifier to the initiating terminal, so that the initiating terminal carries the preset transaction identifier to execute the step of receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator terminal in the distributed transaction processing method applied to the initiating terminal, so as to call the processing terminal corresponding to each segmented transaction, so that the processing terminal executes the step of the distributed transaction processing method applied to the processing terminal, and the segmented transaction corresponding to the processing terminal is processed; and receiving a transaction processing result corresponding to the transaction submitted by the initiating terminal so as to complete the processing of the transaction.
In a fourth aspect, an embodiment of the present invention further provides a distributed transaction processing apparatus, including a unit for executing the distributed transaction processing method applied to the initiator, or including a unit for executing the distributed transaction processing method applied to the processing end, or including a unit for executing the distributed transaction processing method applied to the transaction coordinator end.
In a fifth aspect, an embodiment of the present invention further provides a distributed transaction processing system, where the distributed transaction processing system includes a transaction coordinator and a plurality of server sides, the entire transaction is divided into a plurality of segmented transactions in advance, the plurality of server sides include an initiator corresponding to a transaction initiator, and a plurality of processing sides for processing different segmented transactions, where the initiator is configured to execute steps of the distributed transaction processing method applied to the initiator, the processing sides are configured to execute steps of the distributed transaction processing method applied to the processing sides, and the transaction coordinator is configured to execute steps of the distributed transaction processing method applied to the transaction coordinator.
In a sixth aspect, an embodiment of the present invention further provides a computer device, where the computer device includes a first memory and a first processor connected to the first memory, or includes a second memory and a second processor connected to the second memory, or includes a third memory and a third processor connected to the third memory; the first memory is used for storing a first computer program, the second memory is used for storing a second computer program, and the third memory is used for storing a third computer program; the first processor is configured to execute the first computer program to perform the steps of the distributed transaction method applied to an initiator, the second processor is configured to execute the second computer program to perform the steps of the distributed transaction method applied to a processing end, and the third processor is configured to execute the third computer program to perform the steps of the distributed transaction method applied to a transaction coordinator.
In a seventh aspect, an embodiment of the present invention further provides a computer readable storage medium storing a first computer program, a second computer program, and/or a third computer program, where the first computer program, when executed by a processor, may implement steps of the distributed transaction method applied to an initiator, the second computer program, when executed by a processor, may implement steps of the distributed transaction method applied to a processor, and the third computer program, when executed by a processor, may implement steps of the distributed transaction method applied to a transaction coordinator.
The embodiment of the invention provides a distributed transaction processing method, a distributed transaction processing device, a distributed transaction processing system, computer equipment and a computer readable storage medium. When distributed transaction processing is achieved, the distributed system comprises a transaction coordinator end, an initiating end and a processing end, the whole transaction is divided into a plurality of segmented transactions in advance, the initiating end receives a service request of a client, a transaction opening instruction of the transaction corresponding to the service request is sent to the transaction coordinator end, the transaction coordinator end distributes preset transaction identifiers to the transaction according to the transaction opening instruction and sends the preset transaction identifiers to the initiating end, the initiating end carries the preset transaction identifiers to call the processing end corresponding to each segmented transaction, each processing end processes the segmented transaction corresponding to each segmented transaction to obtain a segmented processing result corresponding to each segmented transaction, the initiating end returns the segmented processing result to the initiating end, and judges whether each segmented processing result is successful or not, and if the segmented processing result is successful, the distributed processing of the transaction is judged to be completed. The embodiment of the invention divides the whole transaction into a plurality of segmented transactions, the initiating terminal controls the initiation management of the transaction, and the transaction coordinator terminal coordinates the processing of each segmented transaction, so that the plurality of segmented transactions are processed by different processing terminals, the problem of extremely high coupling degree of TCC transactions and businesses is solved while long transactions are avoided, the processing performance of computer equipment on distributed transactions is improved, the complexity of a distributed system and the maintenance cost of the distributed system are reduced, and the processing efficiency of the distributed transaction is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a conventional XA transaction;
FIG. 2 is a schematic flow chart of a distributed transaction processing method applied to an initiator according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of a distributed transaction processing method applied to a processing end according to an embodiment of the present invention;
FIG. 4 is a schematic flow chart of a distributed transaction processing method applied to a transaction coordinator according to an embodiment of the present invention;
fig. 5 (a) is a schematic diagram of an interaction flow sequence corresponding to a successful transaction in a distributed transaction in an embodiment of a distributed transaction method according to the present invention, and fig. 5 (b) is a schematic diagram of an interaction flow sequence when the transaction in fig. 5 (a) fails;
fig. 6 is a schematic block diagram of a distributed transaction processing apparatus applied to an initiator according to an embodiment of the present invention:
FIG. 7 is a schematic block diagram of a distributed transaction processing device applied to a processing end according to an embodiment of the present invention;
FIG. 8 is a schematic block diagram of a distributed transaction processing apparatus applied to a transaction coordinator side according to an embodiment of the present invention; and
fig. 9 is a schematic block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all embodiments of the invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
It should be understood that the terms "comprises" and "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
In the embodiment of the invention, the distributed system for processing the distributed transaction comprises a transaction coordinator and a plurality of server ends, wherein the whole transaction is divided into a plurality of segmented transactions in advance, and the plurality of server ends comprise an initiating end corresponding to a transaction initiator and a plurality of processing ends for processing different segmented transactions. Referring to fig. 2, fig. 2 is a flow chart of a distributed transaction processing method applied to an initiator according to an embodiment of the invention. As shown in fig. 2, the method is applied to the originating terminal, and includes the following steps S201 to S207:
S201, receiving a service request of a client.
S202, according to the service request, a transaction opening instruction of a transaction corresponding to the service request is sent to the transaction coordinator side.
Wherein, the Transaction, english is Transaction, refers to that all operations related to the activity corresponding to one service request are incorporated into one indistinct execution unit, and the Transaction consists of all operations executed between the Transaction start (Begin Transaction) and the Transaction End (End Transaction).
Specifically, in order to support processing of mass data, the background server side avoids performance bottleneck of a single server, and the server side generally adopts a distributed system. In the embodiment of the invention, the whole transaction corresponding to the service request is divided into a plurality of segmented transactions in advance, and the distributed system comprises an initiating terminal corresponding to a transaction initiator, a plurality of processing terminals for processing different segmented transactions and a transaction coordinator terminal. Because the server side generally adopts a distributed system to process the service request, when a user puts forward the service request to the server side through the client side, the initiating side receives the service request of the client side, opens a transaction corresponding to the service request according to the service request, and sends a transaction opening instruction of the transaction corresponding to the service request to the transaction coordinator side. For example, when a user makes shopping through a smart phone, a transaction corresponding to a service request for creating a shopping order of the user is divided into two subsection transactions in advance, when the user makes shopping through the smart phone and needs to create the shopping order, the smart phone is used for providing a service request for creating the shopping order to a background server, an initiating terminal corresponding to a transaction initiator corresponding to the shopping order is created in a distributed system of the background, the service request for creating the shopping order of a client is received, and a transaction opening instruction corresponding to a transaction for opening the creating the shopping order is sent to the transaction coordinator terminal according to the service request.
S203, receiving a preset transaction identifier corresponding to the transaction returned by the transaction coordinator, wherein the preset transaction identifier is distributed by the transaction coordinator according to the transaction starting instruction.
Specifically, after receiving a transaction opening instruction, the transaction coordinator allocates a preset transaction identifier to the transaction according to the transaction opening instruction, where the preset transaction identifier corresponds to the transaction one by one and is used for uniquely describing the transaction, and the preset transaction identifier may be a serial number or a unique code configured according to a preset coding mode, so that the transaction can be identified through the preset transaction identifier. And the transaction coordinator returns the preset transaction identifier to the initiating terminal, and the initiating terminal receives the preset transaction identifier corresponding to the transaction returned by the transaction coordinator.
S204, sending processing instructions corresponding to each segmented transaction to the processing end according to a preset sequence, wherein the processing instructions carry the preset transaction identifiers so that the processing end processes the segmented transaction to obtain segmented processing results corresponding to each segmented transaction, and returning the segmented processing results to the initiating end.
Specifically, after receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator, the initiator may concurrently process the segmented transactions included in the transaction according to a preset sequence of the segmented transaction, for example, the initiator may send the processing instruction corresponding to each segmented transaction to the processing end corresponding to each segmented transaction in parallel, the processing of the segmented transaction needs to be sequentially performed according to a sequence, the subsequent segmented transaction is based on the processing result corresponding to the previous segmented transaction, the serial relationship among the plurality of segmented transactions is provided, the subsequent segmented transaction can be performed only if the segmented transaction arranged on the front succeeds, the segmented transaction arranged on the front fails to process the subsequent segmented transaction, the initiator may sequentially send the processing instruction corresponding to each segmented transaction to the processing end corresponding to each segmented transaction according to the sequence, each processing instruction carries the preset transaction identifier, the processing instruction is used for the processing of the segmented transaction, and the processing efficiency of each segmented transaction is improved compared with the serial transaction of the serial transaction. After each processing end receives respective processing instructions, each processing end starts processing the segmented transaction corresponding to the processing end according to the respective processing instructions to obtain segmented processing results corresponding to each segmented transaction, the segmented processing results are returned to the initiating end, the corresponding relation between the segmented transaction and the service request corresponding to the transaction is identified through the preset transaction identification, and the processing results of all the segmented transactions are integrated according to the preset transaction identification to obtain transaction processing results of the transaction, namely the processing results of the service request. After each processing end receives the processing instruction of the segmented transaction corresponding to the processing of each processing end, the processing end processes the segmented transaction of the processing end to obtain the segmented processing result corresponding to the segmented transaction of each processing end, and returns the segmented processing result to the initiating end.
S205, receiving the segmentation processing result returned by the processing end.
S206, judging whether each segmentation processing result is successful.
S207, if the segmentation processing results are successful, determining that the distributed processing of the transaction is completed.
Specifically, the initiating terminal receives a segmentation processing result corresponding to each segmentation transaction returned by each processing terminal, judges whether each processing terminal successfully processes each segmentation transaction according to each segmentation processing result, and if each segmentation processing result is successful, namely each segmentation processing result is successful, judges that each processing terminal successfully processes each segmentation transaction, and the whole transaction is successfully completed, so that the corresponding segmentation transaction is completed through different processing terminals, and the distributed processing of the whole transaction is completed.
Further, the step of completing the distributed processing of the transaction includes:
generating a transaction processing result corresponding to the transaction according to the preset transaction identifier and the segmentation processing result; and submitting the transaction processing result to the transaction coordinator end to complete the distributed processing of the transaction.
Specifically, if the initiating terminal judges that each segmented processing result is successful in processing, the successful completion of the transaction is indicated, and then a transaction processing result corresponding to the transaction is generated according to the relation between the preset transaction identifier and the segmented transaction corresponding to each segmented processing result, and the transaction processing result is submitted, so that the distributed processing of the transaction is completed, and the service request is completed.
Further, in an embodiment, after the step of determining that the distributed processing of the transaction is completed if each of the segmented processing results is successful, the method further includes:
if the segmentation processing result is that the processing is not successful, a failure prompt that the transaction processing fails is sent to the transaction coordinator, so that the transaction coordinator instructs the processing end to execute rollback action to reprocess the segmentation transaction according to the failure prompt;
and iteratively executing the step if the segmentation processing result is unsuccessful until each segmentation processing result is successful.
Specifically, if the initiating terminal judges that the segmented transaction is not successfully processed, the initiating terminal judges that the transaction is not successfully processed, the initiating terminal sends a failure prompt of the transaction processing failure to the transaction coordinator, and the transaction coordinator terminal enables the transaction coordinator terminal to instruct the processing terminal to execute a rollback action to reprocess the segmented transaction according to the failure prompt, and iteratively executes the step of if the segmented processing result is that the processing is unsuccessful until each segmented processing result is that the processing is successful, and finally, the processing of all the segmented transactions contained in the transaction is successfully completed. Further, the transaction coordinator may instruct all the processing ends involved in the transaction to perform rollback actions respectively to reprocess all the segmented transactions according to the failure prompt, so that the processing of the whole transaction has temporal continuity, and the occurrence of time interruption of the transaction processing is avoided. When a processing end is in breakdown or other machine faults, the machine faults are prompted in a warning prompt mode, so that the computer equipment is maintained through manual intervention, and each sectional transaction can be processed successfully finally, and the transaction is completed.
When the embodiment of the invention realizes distributed transaction processing, the whole transaction is divided into a plurality of segmented transactions, the initiation terminal controls the initiation management of the transaction, and the transaction coordinator terminal coordinates the processing of each segmented transaction, so that the plurality of segmented transactions are processed by different processing terminals, compared with the problems of longer transaction time and poorer performance of XA transactions in the traditional technology, the TCC mode has extremely high coupling degree with services and brings extra system complexity.
Referring to fig. 3, fig. 3 is a flow chart of a distributed transaction processing method applied to a processing end according to an embodiment of the invention. The distributed system comprises a transaction coordinator and a plurality of server terminals, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server terminals comprise initiating terminals corresponding to transaction initiators and a plurality of processing terminals for processing different segmented transactions, as shown in fig. 3, the method is applied to the processing terminals and comprises the following steps of S301-S305:
S301, receiving a processing instruction for processing the segmented transaction, which is sent by the initiating terminal, wherein the processing instruction carries a preset transaction identifier corresponding to the transaction, and the preset transaction identifier is distributed and returned to the initiating terminal by the transaction coordinator terminal when the initiating terminal starts the transaction to the transaction coordinator terminal.
Specifically, when a user puts forward a service request to a server through a client, an initiating terminal receives the service request of the client, starts a transaction corresponding to the service request according to the service request, the initiating terminal sends a transaction start instruction of the transaction corresponding to the service request to the transaction coordinator, after the transaction coordinator receives the transaction start instruction, a preset transaction identifier corresponding to the transaction is allocated according to the transaction start instruction, the transaction coordinator returns the preset transaction identifier to the initiating terminal, after the initiating terminal receives the preset transaction identifier corresponding to the transaction returned by the transaction coordinator, the initiating terminal sends the processing instruction corresponding to each segmented transaction to the processing terminal according to the serial processing relation among the segmented transactions, and the initiating terminal sequentially sends the processing instruction corresponding to each segmented transaction to the processing instruction of each segmented transaction according to the processing procedure sequence.
S302, according to the processing instruction, a segmented transaction opening instruction for opening the segmented transaction is sent to the transaction coordinator, wherein the segmented transaction opening instruction carries the preset transaction identifier.
Specifically, after receiving a processing instruction for processing the segmented transaction sent by an initiating terminal, a processing terminal starts to process the segmented transaction according to the processing instruction, and sends a segmented transaction starting instruction for starting the segmented transaction to the transaction coordinator terminal, wherein the segmented transaction starting instruction carries the preset transaction identifier.
S303, receiving a preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, wherein the preset segmented transaction identifier is distributed by the transaction coordinator according to the segmented transaction starting instruction.
Specifically, after receiving a segment transaction opening instruction sent by the processing end and used for opening and processing the segment transaction, the transaction coordinator receives a segment transaction opening instruction, and then correspondingly distributes a preset segment transaction identifier to the segment transaction according to the segment transaction opening instruction, wherein the preset segment transaction identifier is similar to the preset transaction identifier and is used for uniquely describing the segment transaction and returning the preset segment transaction identifier to the processing end, and the processing end receives the preset segment transaction identifier corresponding to the segment transaction returned by the transaction coordinator end
S304, processing the segmented transaction to obtain a segmented processing result.
Specifically, after receiving a preset segmented transaction identifier corresponding to the segmented transaction, the processing end processes the segmented transaction. For example, for a segmented transaction corresponding to a deduction process in a transaction corresponding to the creation of the shopping order, a deduction operation is performed, so as to obtain a segmented processing result of the segmented transaction. Further, the segmentation processing result comprises the preset segmentation transaction identifier. The segmentation processing result comprises the preset segmentation transaction identifier, so that each main body contained in the distributed system recognizes which transaction is the processing result corresponding to which segmentation transaction in which transaction according to the preset transaction identifier and the preset segmentation transaction identifier, and further the processing result of generating the transaction according to each segmentation processing result is obtained.
S305, returning the segmentation processing result to the initiating terminal so that the initiating terminal executes the step of receiving the segmentation processing result returned by the processing terminal in the distributed transaction processing method applied to the initiating terminal.
Specifically, after the processing end processes the segmented transaction, the segmented processing result corresponding to the segmented transaction is obtained and returned to the initiating end, so that the processing of the segmented transaction is completed, the initiating end executes the step of receiving the segmented processing result returned by the processing end in the distributed transaction processing method applied to the initiating end, and executes the next action according to the processing result of the segmented transaction, and each processing end completes the corresponding segmented transaction, namely the distributed processing of the whole transaction is completed.
In the embodiment of the invention, the long transaction corresponding to the whole transaction is divided into a plurality of segmented transactions in advance according to the processing process and the processing property of the transaction, so that each segmented transaction can be processed independently, and then the initiating terminal and the transaction coordinator terminal jointly start the processing of the segmented transaction of each processing terminal to the processing terminal, so that each processing terminal completes the processing of the segmented transaction of the processing terminal, and a plurality of processing terminals jointly complete the processing of all segmented transactions contained in the whole transaction, thereby realizing the distributed processing of the long transaction, avoiding the long transaction, solving the problem of extremely high coupling degree of TCC transaction and service, improving the processing performance of computer equipment on the distributed transaction, reducing the complexity of a distributed system and the maintenance cost of the distributed system, and improving the processing efficiency of the distributed transaction.
In one embodiment, after the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, the method further includes:
creating a data image according to the segmented transaction according to a preset image creation mode, and storing the data image, wherein the data image comprises the preset transaction identifier and the preset segmented transaction identifier.
The mirror image is a Mirroring file storage form, namely, a copy which is identical to the original data is created, namely, the mirror image is obtained. Common image file formats are ISO, BIN, IMG, TAO, DAO, CIF, FCD, etc., and may be created using a Docker, etc.
Specifically, the processing end receives the preset segment transaction identifier corresponding to the segment transaction returned by the transaction coordinator, creates a data image according to the preset transaction identifier and the segment identifier, stores the data image, wherein the data image comprises the preset transaction identifier and the preset segment transaction identifier, and subsequently can acquire the data image through the preset transaction identifier and the preset segment transaction identifier so as to execute rollback operation on the segment transaction corresponding to the data image according to the data image and repeatedly process the segment transaction.
Further, after the step of returning the segmentation processing result to the initiating terminal, the method further includes:
receiving a rollback instruction sent by the transaction coordinator, wherein the rollback instruction carries the preset transaction identifier and the preset segmentation transaction identifier;
acquiring the preset transaction identifier and the data mirror image corresponding to the preset segmented transaction identifier according to the preset transaction identifier and the preset segmented transaction identifier;
returning to the step of executing the segmented transaction to obtain the segmented processing result according to the data mirror image;
and iteratively executing the step of receiving the rollback instruction sent by the transaction coordinator until the segmentation processing result is successful.
The Rollback refers to the action of restoring the program or the data to the correct state last time when the program or the data is processed by mistake, and includes the types of program Rollback, data Rollback and the like.
Specifically, if each processing end succeeds in processing the segmented transaction, the transaction to which the segmented transaction belongs is completed, if each processing end does not succeed in processing the segmented transaction, the initiating end receives a segmented processing result returned by the processing end, if the processing result is judged not to succeed in processing, a failure prompt of the transaction processing failure is sent to the transaction coordinator end, after the transaction coordinator end receives the failure prompt, the processing end is instructed to execute a rollback action according to the failure prompt to reprocess the segmented transaction, the failure prompt can include a preset transaction identifier and a preset segmented transaction identifier corresponding to the segmented transaction to which the processing fails, especially the processing end which leads the segmented transaction to fail to reprocess the segmented transaction corresponding to the processing end, the processing end obtains a data mirror image corresponding to the preset transaction identifier and the preset segmented transaction identifier according to the preset transaction identifier, and can execute the segmentation again according to the data mirror image to obtain a rollback instruction of the segmented transaction until the step of successfully executing the segmented transaction is executed by the processor, and the step of receiving the iteration result is executed by the processor. The processing performance of the computer equipment on the distributed transaction can be improved, and the processing efficiency of the distributed transaction is improved.
Referring to fig. 4, fig. 4 is a schematic flow chart of a distributed transaction processing method applied to a transaction coordinator according to an embodiment of the present invention. The distributed system comprises a transaction coordinator and a plurality of server terminals, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server terminals comprise initiating terminals corresponding to transaction initiators and a plurality of processing terminals for processing different segmented transactions, as shown in fig. 4, the method is applied to the transaction coordinator, and comprises the following steps of S401-S404:
s401, receiving a transaction opening instruction of opening a transaction sent by the initiating terminal, wherein the transaction corresponds to a service request of a client, and the opening transaction is started according to the service request.
Specifically, when a user puts forward a service request to a server through a client, an initiating terminal receives the service request of the client, opens a transaction corresponding to the service request according to the service request, the initiating terminal sends a transaction opening instruction of the transaction corresponding to the service request to the transaction coordinator terminal, and the transaction coordinator terminal receives the transaction opening instruction of the opening transaction sent by the initiating terminal.
S402, distributing a preset transaction identifier to the transaction.
S403, sending the preset transaction identifier to the initiating terminal, so that the initiating terminal carries the preset transaction identifier to execute the step of receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator terminal in the distributed transaction processing method applied to the initiating terminal, so as to call the processing terminal corresponding to each segmented transaction, so that the processing terminal executes the step of the distributed transaction processing method applied to the processing terminal, and the segmented transaction corresponding to the processing terminal is processed.
Specifically, after receiving a transaction starting instruction, the transaction coordinator allocates a preset transaction identifier corresponding to the transaction according to the transaction starting instruction, returns the preset transaction identifier to the initiating terminal, and after receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator terminal, the initiating terminal carries the preset transaction identifier to call the processing terminal corresponding to each segmented transaction, so that each processing terminal executes the steps in the distributed transaction processing method applied to the processing terminal to process the segmented transaction corresponding to the initiating terminal.
S404, receiving a transaction processing result corresponding to the transaction submitted by the initiating terminal so as to complete the transaction processing.
Specifically, after receiving a segmentation processing result of a segmentation transaction sent by a processing end, if all the segmentation transactions are judged to be successfully processed, the initiating end indicates that the transaction to which the segmentation transaction belongs is successfully processed, a transaction processing result of the transaction is generated, the transaction processing result is sent to the transaction coordinator end, the transaction coordinator end receives the transaction processing result corresponding to the transaction submitted by the initiating end, and according to the transaction processing result, the task corresponding to the transaction stored by the initiating end is terminated in a cache of the initiating end so as to complete the transaction processing.
In the embodiment of the invention, the long transaction corresponding to the whole transaction is divided into a plurality of segmented transactions in advance according to the processing process and the processing property of the transaction, so that each segmented transaction can be processed independently, then the processing of the segmented transaction of each processing end is started by the initiating end and the transaction coordinator end in a cooperative way, so that each processing end completes the processing of the segmented transaction of the processing end, and a plurality of processing ends complete the processing of all segmented transactions contained in the whole transaction in a common way, thereby realizing the distributed processing of the long transaction, solving the problem of extremely high coupling degree of TCC transaction and service while avoiding the long transaction, improving the processing performance of computer equipment on the distributed transaction, reducing the complexity of a distributed system and the maintenance cost of the distributed system, and improving the processing efficiency of the distributed transaction.
In one embodiment, before the step of receiving the transaction processing result corresponding to the transaction submitted by the initiator, the method further includes:
receiving a segmented transaction opening instruction which is sent by the processing end and corresponds to the segmented transaction and used for opening the segmented transaction, wherein the segmented transaction opening instruction is started by the processing end according to the call of the initiating end, and the segmented transaction opening instruction carries the preset transaction identifier;
distributing a preset segmented transaction identifier to the segmented transaction;
and sending the preset segmented transaction identifier to the processing end, so that the processing end executes the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator end in the distributed transaction processing method applied to the processing end, and the step of processing the segmented transaction corresponding to the processing end and obtaining a segmented processing result.
Specifically, after receiving a preset transaction identifier sent by a transaction coordinator end, the initiator end invokes a processing end corresponding to each segmented transaction respectively with the preset transaction identifier, so that each processing end respectively executes a step of requiring application of a claim to the segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator in the distributed transaction processing method of the processing end, and then sends a segmented transaction opening instruction for opening the segmented transaction to the transaction coordinator end, and the transaction coordinator end receives the segmented transaction opening instruction for opening the segmented transaction corresponding to each processing end respectively sent according to a preset sequence, wherein the segmented transaction opening instruction carries the preset transaction identifier, and sends the preset segmented transaction identifier corresponding to each segmented transaction to the processing end corresponding to each segmented transaction, so that each processing end respectively executes a step of requiring application to the segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator in the distributed transaction processing method of the processing end, and obtains respective segmented transaction results, thereby realizing the overall transaction distribution efficiency of each segmented transaction.
Referring to fig. 5 (a) and fig. 5 (b), fig. 5 (a) is a schematic diagram of an interaction flow sequence corresponding to a successful transaction in a distributed transaction method according to an embodiment of the present invention, and fig. 5 (b) is a schematic diagram of an interaction flow sequence corresponding to a failed transaction in fig. 5 (a). As shown in fig. 5 (a) and fig. 5 (B), the service request is a payment operation, where a transaction corresponding to the payment operation includes a segment transaction B corresponding to a deduction operation processed by the server B, and a segment transaction C corresponding to a payment operation processed by the server C, where Xid is an abbreviation of english Exchange Identifier, which refers to a swap identifier, that is, a preset transaction identifier in the embodiment of the present invention, and brandid, which refers to a branch, that is, a preset segment transaction described in the embodiment of the present invention, brandidb, which is used to describe the branch B, or may also be referred to as a preset segment transaction B. As shown in fig. 5 (a), the sequential interaction flow process of the distributed transaction normal state processing includes the following steps: 1) The client initiates a service request to a server A corresponding to an initiating terminal in the distributed transaction, wherein the service request is a payment operation; 2) The server A starts the transaction corresponding to the payment request and sends a transaction starting instruction for starting the transaction to the transaction coordinator; 3) After receiving the transaction starting instruction, the transaction coordinator returns an Xid to the server A; 4) The server A carries the Xid, and calls the segmentation transaction B corresponding to the deduction of money by the server B; 5) The server B starts a segmented transaction B with the Xid, and sends a segmented transaction starting instruction for starting the segmented transaction B to the transaction coordinator; 6) The transaction coordinator returns BranchIdB to the server B, namely returns a preset segmented transaction identifier B; 7) After receiving the BranchIdB, the server B creates a data image B corresponding to the segmentation transaction B and stores the data image B, wherein the data image B takes the Xid and the BranchIdB as a combined primary key; 8) The server B executes the deduction operation and obtains a deduction result; 9) The server B returns a deduction result to the server A; 10 After receiving the deduction result, the server A carries the Xid and invokes the server C to execute the processing instruction of the segmented transaction C corresponding to the payment operation; 11 The server C receives the processing instruction of the segmented transaction C, starts the segmented transaction C with the Xid, and sends a segmented transaction starting instruction for starting the segmented transaction C to the transaction coordinator end; 12 The transaction coordinator returns BranchIdC to the server C, namely returns a preset segmentation transaction identifier C;13 After receiving the BranchIdC, the server C creates a data image C and stores the data image C, wherein the data image C takes the Xid and the BranchIdC as a combined primary key; 14 Server C performs the payment operation and obtains the payment result, which means that server C successfully processes the payment; 15 Server C returns the payment result to server a; 16 Server a submits the completed payment transaction to the transaction coordinator after receiving the deduction result.
Further, referring to fig. 5 (b), as shown in fig. 5 (b), if the segmented transaction corresponding to the payment operation is abnormal, the following steps are performed: 14 Server C performs a payment operation abnormality; 15 Server C returns a payment failure result to server a; 16 After receiving the payment failure result, the server A sends a failure prompt of the failure of the Xid transaction to the transaction coordinator; 17 After the transaction coordinator receives the prompt of the failure of the Xid transaction, finding a data image B through the Xid and the brandhdb, rolling back the deduction operation B to reprocess the transaction, iterating the steps 16) and 17) until the transaction processing is successful.
It should be noted that, the distributed transaction processing method described in each of the foregoing embodiments may be used to recombine the technical features included in the different embodiments as needed to obtain a combined implementation, which is within the scope of protection claimed in the present invention.
The embodiment of the invention also provides a distributed transaction processing system, which comprises a transaction coordinator end and a plurality of server ends, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server ends comprise an initiating end corresponding to a transaction initiator and a plurality of processing ends for processing different segmented transactions, the initiating end is used for executing the steps of the distributed transaction processing method applied to the initiating end, which are described in the above embodiments, the processing ends are used for executing the steps of the distributed transaction processing method applied to the processing ends, which are described in the above embodiments, and the transaction coordinator end is used for executing the steps of the distributed transaction processing method applied to the transaction coordinator end, which are described in the above embodiments.
Referring to fig. 6, fig. 6 is a schematic block diagram of a distributed transaction processing apparatus applied to an initiator according to an embodiment of the present invention. Corresponding to the above-mentioned distributed transaction processing method applied to the initiator, the embodiment of the invention also provides a distributed transaction processing device applied to the initiator. As shown in fig. 6, the distributed transaction processing apparatus applied to the initiator includes a unit for executing the above-mentioned distributed transaction processing method applied to the initiator, and the apparatus may be configured in a computer device corresponding to the initiator in a distributed system. Specifically, referring to fig. 6, the distributed transaction processing apparatus 600 applied to an initiator includes a first receiving unit 601, a first transmitting unit 602, a second receiving unit 603, a second transmitting unit 604, a third receiving unit 605, a judging unit 606 and a judging unit 607. The first receiving unit 601 is configured to receive a service request of a client; a first sending unit 602, configured to send, according to the service request, a transaction start instruction of a transaction corresponding to the service request to the transaction coordinator; a second receiving unit 603, configured to receive a preset transaction identifier corresponding to the transaction returned by the transaction coordinator, where the preset transaction identifier is allocated by the transaction coordinator according to the transaction opening instruction; a second sending unit 604, configured to send processing instructions corresponding to each of the segmented transactions to the processing end according to a preset sequence, where the processing instructions carry the preset transaction identifier, so that the processing end processes the segmented transaction to obtain a segmented processing result corresponding to each of the segmented transactions, and return the segmented processing result to the initiating end; a third receiving unit 605, configured to receive the segmentation processing result returned by the processing end; a judging unit 606, configured to judge whether each of the segmentation processing results is successful; and the determining unit 607 is configured to determine that the distributed processing of the transaction is completed if each of the segmented processing results is successful.
In one embodiment, the distributed transaction processing apparatus 600 applied to the initiator further includes: the third sending unit is configured to send a failure prompt that the transaction processing fails to the transaction coordinator side if the segmentation processing result is that the segmentation processing result is not successful, so that the transaction coordinator side instructs the processing side to execute a rollback action according to the failure prompt to reprocess the segmented transaction; and the iteration unit is used for iteratively executing the step if the segmentation processing result is unsuccessful until each segmentation processing result is successful.
Referring to fig. 7, fig. 7 is a schematic block diagram of a distributed transaction processing apparatus applied to a processing end according to an embodiment of the present invention. Corresponding to the above-mentioned distributed transaction processing method applied to the processing end, the embodiment of the invention also provides a distributed transaction processing device applied to the processing end. As shown in fig. 7, the distributed transaction processing apparatus applied to the processing end includes a unit for executing the above-mentioned distributed transaction processing method applied to the processing end, and the apparatus may be configured in a computer device corresponding to the processing end in the distributed system. Specifically, referring to fig. 7, the distributed transaction processing apparatus 700 applied to an initiator includes a fourth receiving unit 701, a fourth transmitting unit 702, a fifth receiving unit 703, a processing unit 704 and a first returning unit 705. The fourth receiving unit 701 is configured to receive a processing instruction for processing the segmented transaction sent by the initiator, where the processing instruction carries a preset transaction identifier corresponding to the transaction, and when the transaction is started by the initiator to the transaction coordinator, the preset transaction identifier is distributed by the transaction coordinator and returned to the initiator; a fourth sending unit 702, configured to send a segment transaction starting instruction for starting the segment transaction to the transaction coordinator according to the processing instruction, where the segment transaction starting instruction carries the preset transaction identifier; a fifth receiving unit 703, configured to receive a preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, where the preset segmented transaction identifier is allocated by the transaction coordinator according to the segmented transaction start instruction; a processing unit 704, configured to process the segmented transaction to obtain a segmented processing result; a first returning unit 705, configured to return the segmentation processing result to the initiator, so that the initiator performs the step of receiving the segmentation processing result returned by the processing end in the distributed transaction processing method applied to the initiator.
In one embodiment, the distributed transaction processing apparatus 700 applied to the initiator further includes: the creating unit is used for creating a data image according to the segmented transaction in a preset image creating mode and storing the data image, wherein the data image comprises the preset transaction identifier and the preset segmented transaction identifier.
Referring to fig. 8, fig. 8 is a schematic block diagram of a distributed transaction processing apparatus applied to a transaction coordinator according to an embodiment of the present invention. Corresponding to the above-mentioned distributed transaction processing method applied to the transaction coordinator, the embodiment of the invention also provides a distributed transaction processing device applied to the transaction coordinator. As shown in fig. 8, the distributed transaction processing apparatus applied to the transaction coordinator side includes a unit for executing the above-mentioned distributed transaction processing method applied to the transaction coordinator side, and the apparatus may be configured in a computer device corresponding to the transaction coordinator side in the distributed system. Specifically, referring to fig. 8, the distributed transaction processing apparatus 800 applied to the transaction coordinator includes a sixth receiving unit 801, a first allocating unit 802, a fifth transmitting unit 803, and a seventh receiving unit 804. The sixth receiving unit 801 is configured to receive a transaction start instruction for starting a transaction sent by the initiator, where the transaction corresponds to a service request of the client, and the start transaction is started according to the service request; a first allocation unit 802, configured to allocate a preset transaction identifier to the transaction; a fifth sending unit 803, configured to send the preset transaction identifier to the initiator, so that the initiator carries the preset transaction identifier to perform the step of receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator in the distributed transaction processing method applied to the initiator described in the above embodiments, so as to call the processing end corresponding to each segmented transaction, so that the processing end performs the step of the distributed transaction processing method applied to the processing end described in the above embodiments, so as to process the segmented transaction corresponding to the processing end; a seventh receiving unit 804, configured to receive a transaction processing result corresponding to the transaction submitted by the initiator, so as to complete processing of the transaction.
In one embodiment, the distributed transaction processing apparatus 800 applied to the transaction coordinator side further includes: an eighth receiving unit, configured to receive a segmented transaction start instruction sent by the processing end and used to start the segmented transaction corresponding to the segmented transaction, where the segmented transaction start instruction is started by the processing end according to the call of the initiating end, and the segmented transaction start instruction carries the preset transaction identifier; the second allocation unit is used for allocating a preset segmentation transaction identifier to the segmentation transaction; a sixth sending unit, configured to send the preset segmented transaction identifier to the processing end, so that the processing end executes the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator end in the distributed transaction processing method applied to the processing end described in the above embodiments, so as to process the segmented transaction corresponding to the processing end and obtain a segmented processing result.
It should be noted that, as will be clearly understood by those skilled in the art, the specific implementation process of each of the above-mentioned distributed transaction processing devices and each unit may refer to the corresponding description in the foregoing method embodiments, and for convenience and brevity of description, the description is omitted here.
Meanwhile, the above-mentioned dividing and connecting manners of the units in each distributed transaction processing device are only used for illustration, in other embodiments, each distributed transaction processing device may be divided into different units according to needs, and each unit in each distributed transaction processing device may also be connected in different order and manners, so as to complete all or part of functions of each distributed transaction processing device.
Each of the above-described distributed transaction processing arrangements may be implemented in the form of a computer program which is executable on a computer device as shown in fig. 9.
Referring to fig. 9, fig. 9 is a schematic block diagram of a computer device according to an embodiment of the present invention. The computer device 900 may be a computer device such as a desktop computer or a server, or may be a component or part of another device. With reference to fig. 9, the computer device 900 includes a processor 902, a memory, and a network interface 905, which are connected by a system bus 901, wherein the memory may include a non-volatile storage medium 903 and an internal memory 904. The non-volatile storage medium 903 may store an operating system 9031 and a computer program 9032. The computer program 9032, when executed, may cause the processor 902 to perform one of the distributed transaction methods described above. The processor 902 is operable to provide computing and control capabilities to support the operation of the overall computer device 900.
The internal memory 904 provides an environment for the execution of a computer program 9032 in a non-volatile storage medium 903, which computer program 9032, when executed by the processor 902, causes the processor 902 to perform a distributed transaction method as described above.
The network interface 905 is used for network communication with other devices. It will be appreciated by those skilled in the art that the architecture shown in fig. 9 is merely a block diagram of some of the architecture relevant to the present inventive arrangements and is not limiting of the computer device 900 to which the present inventive arrangements may be implemented, and that a particular computer device 900 may include more or less components than those shown, or may combine some components, or have a different arrangement of components. For example, in some embodiments, the computer device may include only a memory and a processor, and in such embodiments, the structure and function of the memory and the processor are consistent with the embodiment shown in fig. 9, and will not be described again.
Taking the distributed transaction method applied to the initiator as an example, the processor 902 is configured to execute a computer program 9032 stored in a memory, so as to implement the following steps: receiving a service request of a client; according to the service request, a transaction opening instruction of a transaction corresponding to the service request is sent to the transaction coordinator; receiving a preset transaction identifier corresponding to the transaction returned by the transaction coordinator, wherein the preset transaction identifier is distributed by the transaction coordinator according to the transaction starting instruction; transmitting processing instructions corresponding to each segmented transaction to the processing end according to a preset sequence, wherein the processing instructions carry the preset transaction identifiers so that the processing end processes the segmented transaction to obtain segmented processing results corresponding to each segmented transaction, and returning the segmented processing results to the initiating end; receiving the segmentation processing result returned by the processing end; judging whether each segmented processing result is successful; and if the segmentation processing results are successful, judging that the distributed processing of the transaction is completed.
In one embodiment, after implementing the step of determining that the distributed processing of the transaction is completed if each of the segmented processing results are successful, the processor 902 further implements the following steps:
if the segmentation processing result is that the processing is not successful, a failure prompt that the transaction processing fails is sent to the transaction coordinator, so that the transaction coordinator instructs the processing end to execute rollback action to reprocess the segmentation transaction according to the failure prompt; and iteratively executing the step if the segmentation processing result is unsuccessful until each segmentation processing result is successful.
Taking the distributed transaction processing method applied to the processing end as an example, the processor 902 is configured to execute a computer program 9032 stored in a memory, so as to implement the following steps: receiving a processing instruction for processing the segmented transaction, which is sent by the initiating terminal, wherein the processing instruction carries a preset transaction identifier corresponding to the transaction, and the preset transaction identifier is distributed and returned to the initiating terminal by the transaction coordinator terminal when the initiating terminal starts the transaction to the transaction coordinator terminal; according to the processing instruction, a segmented transaction opening instruction for opening the segmented transaction is sent to the transaction coordinator, wherein the segmented transaction opening instruction carries the preset transaction identifier; receiving a preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, wherein the preset segmented transaction identifier is distributed by the transaction coordinator according to the segmented transaction starting instruction; processing the segmented transaction to obtain a segmented processing result; and returning the segmentation processing result to the initiating terminal, so that the initiating terminal executes the step of receiving the segmentation processing result returned by the processing terminal in the distributed transaction processing method applied to the initiating terminal, which is described in the above embodiments.
In an embodiment, after implementing the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, the processor 902 further implements the following steps:
creating a data image according to the segmented transaction according to a preset image creation mode, and storing the data image, wherein the data image comprises the preset transaction identifier and the preset segmented transaction identifier.
Taking the distributed transaction processing method applied to the transaction coordinator side as an example, the processor 902 is configured to execute a computer program 9032 stored in a memory, so as to implement the following steps: receiving a transaction opening instruction of opening a transaction sent by the initiating terminal, wherein the transaction corresponds to a service request of a client, and the opening transaction is started according to the service request; distributing a preset transaction identifier to the transaction; the preset transaction identifier is sent to the initiating terminal, so that the initiating terminal carries the preset transaction identifier to execute the step of receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator terminal in the distributed transaction processing method applied to the initiating terminal described in the above embodiments, so as to call the processing terminal corresponding to each segmented transaction, so that the processing terminal executes the step of executing the distributed transaction processing method applied to the processing terminal described in the above embodiments, and processes the segmented transaction corresponding to the processing terminal; and receiving a transaction processing result corresponding to the transaction submitted by the initiating terminal so as to complete the processing of the transaction.
In an embodiment, before implementing the step of receiving the transaction result corresponding to the transaction submitted by the initiator, the processor 902 further implements the following steps:
receiving a segmented transaction opening instruction which is sent by the processing end and corresponds to the segmented transaction and used for opening the segmented transaction, wherein the segmented transaction opening instruction is started by the processing end according to the call of the initiating end, and the segmented transaction opening instruction carries the preset transaction identifier; distributing a preset segmented transaction identifier to the segmented transaction; and sending the preset segmented transaction identifier to the processing end, so that the processing end executes the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator end in the distributed transaction processing method applied to the processing end, which is described in the above embodiments, so as to process the segmented transaction corresponding to the processing end and obtain a segmented processing result.
It should be appreciated that in an embodiment of the invention, the processor 902 may be a central processing unit (Central Processing Unit, CPU), the processor 902 may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSPs), application specific integrated circuits (Application Specific Integrated Circuit, ASICs), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It will be appreciated by those skilled in the art that all or part of the flow of the method of the above embodiments may be implemented by a computer program, which may be stored on a computer readable storage medium. The computer program is executed by at least one processor in the computer system to implement the flow steps of the embodiments of the method described above.
Accordingly, the present application also provides a computer-readable storage medium. The computer readable storage medium may be a non-volatile computer readable storage medium storing a first computer program which, when executed by a processor, causes the processor to perform the steps of:
a computer program product which, when run on a computer, causes the computer to perform the steps of the distributed transaction method described in the embodiments above as being applied to an initiator.
The present application also provides another computer-readable storage medium. The computer readable storage medium may be a non-volatile computer readable storage medium storing a second computer program which, when executed by a processor, causes the processor to perform the steps of:
A computer program product which, when run on a computer, causes the computer to perform the steps of the distributed transaction method described in the embodiments above as being applied to a processing side.
The present application also provides another computer-readable storage medium. The computer readable storage medium may be a non-volatile computer readable storage medium storing a third computer program which, when executed by a processor, causes the processor to perform the steps of:
a computer program product which, when run on a computer, causes the computer to perform the steps of the distributed transaction method described in the embodiments above as being applied to the transaction coordinator side.
The computer readable storage medium may be an internal storage unit of the aforementioned device, such as a hard disk or a memory of the device. The computer readable storage medium may also be an external storage device of the device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card) or the like, which are provided on the device. Further, the computer readable storage medium may also include both internal storage units and external storage devices of the device.
It will be clearly understood by those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus, device and unit described above may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
The storage medium is a physical, non-transitory storage medium, and may be, for example, a U-disk, a removable hard disk, a Read-Only Memory (ROM), a magnetic disk, or an optical disk.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied in electronic hardware, in computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of function in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the device embodiments described above are merely illustrative. For example, the division of each unit is only one logic function division, and there may be another division manner in actual implementation. For example, multiple units or components may be combined or may be integrated into another system, or some features may be omitted, or not performed.
The steps in the method of the embodiment of the invention can be sequentially adjusted, combined and deleted according to actual needs. The units in the device of the embodiment of the invention can be combined, divided and deleted according to actual needs. In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The integrated unit may be stored in a storage medium if implemented in the form of a software functional unit and sold or used as a stand-alone product. Based on such understanding, the technical solution of the present invention is essentially or a part contributing to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a storage medium, comprising several instructions for causing an electronic device (which may be a personal computer, a terminal, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the invention is subject to the protection scope of the claims.

Claims (10)

1. The distributed transaction processing method is characterized by comprising a transaction coordinator and a plurality of server sides, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server sides comprise an initiating side corresponding to a transaction initiator and a plurality of processing sides for processing different segmented transactions, the method is applied to the initiating side, and the method comprises the following steps:
receiving a service request of a client;
according to the service request, a transaction opening instruction of a transaction corresponding to the service request is sent to the transaction coordinator;
receiving a preset transaction identifier corresponding to the transaction returned by the transaction coordinator, wherein the preset transaction identifier is distributed by the transaction coordinator according to the transaction starting instruction;
Transmitting processing instructions corresponding to each segmented transaction to the processing end according to a preset sequence, wherein the processing instructions carry the preset transaction identifiers so that the processing end processes the segmented transaction to obtain segmented processing results corresponding to each segmented transaction, and returning the segmented processing results to the initiating end;
receiving the segmentation processing result returned by the processing end;
judging whether each segmented processing result is successful;
and if the segmentation processing results are successful, judging that the distributed processing of the transaction is completed.
2. The method according to claim 1, wherein after the step of determining that the distributed processing of the transaction is completed if each of the segmented processing results is successful, further comprising:
if the segmentation processing result is that the processing is not successful, a failure prompt that the transaction processing fails is sent to the transaction coordinator, so that the transaction coordinator instructs the processing end to execute rollback action to reprocess the segmentation transaction according to the failure prompt;
and iteratively executing the step if the segmentation processing result is unsuccessful until each segmentation processing result is successful.
3. The distributed transaction processing method is characterized by comprising a transaction coordinator and a plurality of server sides, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server sides comprise initiating sides corresponding to transaction initiators and a plurality of processing sides for processing different segmented transactions, the method is applied to each processing side, and the method comprises the following steps:
receiving a processing instruction for processing the segmented transaction, which is sent by the initiating terminal, wherein the processing instruction carries a preset transaction identifier corresponding to the transaction, and the preset transaction identifier is distributed and returned to the initiating terminal by the transaction coordinator terminal when the initiating terminal starts the transaction to the transaction coordinator terminal;
according to the processing instruction, a segmented transaction opening instruction for opening the segmented transaction is sent to the transaction coordinator, wherein the segmented transaction opening instruction carries the preset transaction identifier;
receiving a preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, wherein the preset segmented transaction identifier is distributed by the transaction coordinator according to the segmented transaction starting instruction;
Processing the segmented transaction to obtain a segmented processing result;
returning the segmentation processing result to the initiating terminal, so that the initiating terminal executes the step of receiving the segmentation processing result returned by the processing terminal in the method of any one of claims 1-2.
4. The distributed transaction processing method according to claim 3, wherein after the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator, the method further comprises:
creating a data image according to the segmented transaction according to a preset image creation mode, and storing the data image, wherein the data image comprises the preset transaction identifier and the preset segmented transaction identifier.
5. The distributed transaction processing method is characterized by comprising a transaction coordinator and a plurality of server sides, wherein the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server sides comprise initiating sides corresponding to transaction initiators and a plurality of processing sides for processing different segmented transactions, and the method is applied to the transaction coordinator and comprises the following steps:
Receiving a transaction opening instruction of opening a transaction sent by the initiating terminal, wherein the transaction corresponds to a service request of a client, and the opening transaction is started according to the service request;
distributing a preset transaction identifier to the transaction;
sending the preset transaction identifier to the initiating terminal, so that the initiating terminal carries the preset transaction identifier to execute the step of receiving the preset transaction identifier corresponding to the transaction returned by the transaction coordinator terminal in the method of any one of claims 1-2, so as to call the processing terminal corresponding to each segmented transaction, so that the processing terminal executes the step of any one of claims 3-4, so as to process the segmented transaction corresponding to the processing terminal;
and receiving a transaction processing result corresponding to the transaction submitted by the initiating terminal so as to complete the processing of the transaction.
6. The method of claim 5, further comprising, prior to the step of receiving a transaction result corresponding to the transaction submitted by the initiator:
receiving a segmented transaction opening instruction which is sent by the processing end and corresponds to the segmented transaction and used for opening the segmented transaction, wherein the segmented transaction opening instruction is started by the processing end according to the call of the initiating end, and the segmented transaction opening instruction carries the preset transaction identifier;
Distributing a preset segmented transaction identifier to the segmented transaction;
sending the preset segmented transaction identifier to the processing end, so that the processing end executes the step of receiving the preset segmented transaction identifier corresponding to the segmented transaction returned by the transaction coordinator end in the method of any one of claims 3-4, so as to process the segmented transaction corresponding to the processing end and obtain a segmented processing result.
7. A distributed transaction arrangement comprising means for performing the method according to any of claims 1-2, or means for performing the method according to any of claims 3-4, or means for performing the method according to any of claims 5-6.
8. A distributed transaction processing system, characterized in that the distributed transaction processing system comprises a transaction coordinator and a plurality of server ends, the whole transaction is divided into a plurality of segmented transactions in advance, the plurality of server ends comprise an initiating end corresponding to a transaction initiator and a plurality of processing ends for processing different segmented transactions, wherein the initiating end is used for executing the steps of the method according to any one of claims 1-2, the processing ends are used for executing the steps of the method according to any one of claims 3-4, and the transaction coordinator is used for executing the steps of the method according to any one of claims 5-6.
9. A computer device, comprising a first memory and a first processor connected to the first memory, or comprising a second memory and a second processor connected to the second memory, or comprising a third memory and a third processor connected to the third memory; the first memory is used for storing a first computer program, the second memory is used for storing a second computer program, and the third memory is used for storing a third computer program; the first processor being adapted to run the first computer program for performing the steps of the method according to any of claims 1-2, the second processor being adapted to run the second computer program for performing the steps of the method according to any of claims 3-4, and the third processor being adapted to run the third computer program for performing the steps of the method according to any of claims 5-6.
10. A computer readable storage medium, characterized in that the computer readable storage medium stores a first computer program, which when executed by a processor, performs the steps of the method according to any of claims 1-2, a second computer program, which when executed by a processor, performs the steps of the method according to any of claims 3-4, and/or a third computer program, which when executed by a processor, performs the steps of the method according to any of claims 5-6.
CN201911302134.8A 2019-12-17 2019-12-17 Distributed transaction processing method, device, system, computer equipment and storage medium Active CN111045794B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911302134.8A CN111045794B (en) 2019-12-17 2019-12-17 Distributed transaction processing method, device, system, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911302134.8A CN111045794B (en) 2019-12-17 2019-12-17 Distributed transaction processing method, device, system, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111045794A CN111045794A (en) 2020-04-21
CN111045794B true CN111045794B (en) 2023-04-25

Family

ID=70237005

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911302134.8A Active CN111045794B (en) 2019-12-17 2019-12-17 Distributed transaction processing method, device, system, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111045794B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113296896B (en) * 2020-06-09 2022-05-06 阿里巴巴集团控股有限公司 Distributed transaction processing method, device and equipment
CN111930830B (en) * 2020-06-22 2024-04-16 心有灵犀科技股份有限公司 Distributed transaction data processing method and system based on shared database
CN111722946A (en) * 2020-06-28 2020-09-29 深圳壹账通智能科技有限公司 Distributed transaction processing method and device, computer equipment and readable storage medium
CN113448788A (en) * 2021-06-29 2021-09-28 平安证券股份有限公司 Test-based service processing method and device, electronic equipment and storage medium
CN113518384B (en) * 2021-07-29 2023-12-01 中移(杭州)信息技术有限公司 Distributed transaction processing method, device, equipment and computer readable storage medium
CN114138888B (en) * 2021-12-03 2022-07-05 北京宇信科技集团股份有限公司 Processing method, system, medium and equipment for distributed data routing
CN116578395B (en) * 2023-07-13 2024-04-05 腾讯科技(深圳)有限公司 Transaction processing method, system, device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107528912A (en) * 2017-09-11 2017-12-29 金蝶软件(中国)有限公司 A kind of automatic method, system and relevant apparatus for realizing distributing real time system
CN108139927A (en) * 2015-10-01 2018-06-08 华为技术有限公司 The routing based on action of affairs in online transaction processing system
CN109189855A (en) * 2018-08-14 2019-01-11 平安普惠企业管理有限公司 Method of data synchronization and terminal device based on distribution memory technology
CN109388481A (en) * 2018-09-21 2019-02-26 网易(杭州)网络有限公司 A kind of transmission method of transaction information, device, calculates equipment and medium at system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108139927A (en) * 2015-10-01 2018-06-08 华为技术有限公司 The routing based on action of affairs in online transaction processing system
CN107528912A (en) * 2017-09-11 2017-12-29 金蝶软件(中国)有限公司 A kind of automatic method, system and relevant apparatus for realizing distributing real time system
CN109189855A (en) * 2018-08-14 2019-01-11 平安普惠企业管理有限公司 Method of data synchronization and terminal device based on distribution memory technology
CN109388481A (en) * 2018-09-21 2019-02-26 网易(杭州)网络有限公司 A kind of transmission method of transaction information, device, calculates equipment and medium at system

Also Published As

Publication number Publication date
CN111045794A (en) 2020-04-21

Similar Documents

Publication Publication Date Title
CN111045794B (en) Distributed transaction processing method, device, system, computer equipment and storage medium
US11074661B2 (en) Transaction processing method, apparatus, and electronic device using a blockchain having nonce records
WO2018103318A1 (en) Distributed transaction handling method and system
WO2020001370A1 (en) Multi-chain concurrent transaction method
CN111277639B (en) Method and device for maintaining data consistency
CN110888893A (en) Order processing method based on micro-service e-commerce system
CN110888718A (en) Method and device for realizing distributed transaction
CN108415758B (en) Distributed transaction coordination method and device
CN112015811A (en) Method, node and computing device for node management of blockchain system
CN107436799A (en) Distributed transaction uniformity implementation method and device
CN110264169A (en) A kind of payment method for routing, device, equipment and readable storage medium storing program for executing
CN109684048B (en) Method and device for processing transaction in transaction submitting system
CN115220876A (en) Virtual resource creating method, device, program product, medium and electronic equipment
CN113112344B (en) Service processing method, device, storage medium and computer program product
CN108874947B (en) Data processing system and data processing method
EP4195033A1 (en) Method and apparatus for upgrading blockchain system, and terminal device
CN111143041A (en) Data consistency method, distributed coordinator and central coordinator
US10956077B2 (en) Data access method, routing apparatus, and storage system
US11500857B2 (en) Asynchronous remote calls with undo data structures
CN113297281A (en) Account consistency processing method and server
CN114579260A (en) Transaction processing method and system
CN113051008A (en) Interface request processing method and device, computer equipment and storage medium
CN110677465B (en) Control method and device of distributed lock
CN111754348A (en) Scene combined transaction method and device
CN115577031B (en) Database transaction processing method and device, 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
GR01 Patent grant
GR01 Patent grant