CN112148394A - Distributed transaction coordination method and device and electronic equipment - Google Patents

Distributed transaction coordination method and device and electronic equipment Download PDF

Info

Publication number
CN112148394A
CN112148394A CN202010937837.4A CN202010937837A CN112148394A CN 112148394 A CN112148394 A CN 112148394A CN 202010937837 A CN202010937837 A CN 202010937837A CN 112148394 A CN112148394 A CN 112148394A
Authority
CN
China
Prior art keywords
transaction
distributed
service
distributed transaction
group
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.)
Pending
Application number
CN202010937837.4A
Other languages
Chinese (zh)
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.)
Sunplus Information Technology Chengdu Co ltd
Original Assignee
Sunplus Information Technology Chengdu 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 Sunplus Information Technology Chengdu Co ltd filed Critical Sunplus Information Technology Chengdu Co ltd
Priority to CN202010937837.4A priority Critical patent/CN112148394A/en
Publication of CN112148394A publication Critical patent/CN112148394A/en
Pending legal-status Critical Current

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/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4482Procedural
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/543User-generated data transfer, e.g. clipboards, dynamic data exchange [DDE], object linking and embedding [OLE]

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Hardware Redundancy (AREA)

Abstract

The invention discloses a distributed transaction coordination method, a distributed transaction coordination device and electronic equipment, wherein the method comprises the following steps: calling a micro service through a service interface, checking whether a distributed transaction environment exists at present through the micro service, if not, adding the micro service into a distributed transaction group as a transaction initiator and executing local transaction logic, if so, adding the micro service into the distributed transaction group as a transaction participant and executing the local transaction logic, and after the calling of the service interfaces of all the transaction participants is finished, informing a transaction coordinator cluster to finish the distributed transaction group through the transaction initiator so that the transaction coordinator cluster finishes the distributed transaction group; the distributed transaction coordinator provided by the embodiment of the invention uses multiple instances to form a cluster, so that single-point failure does not exist; the method has no excessive requirements on the database, only needs to support the transaction, and does not require the database to support two-stage submission; the coordinators adopt a multicast mode, and inconsistency caused by data replication is avoided.

Description

Distributed transaction coordination method and device and electronic equipment
Technical Field
The invention relates to the field of distributed microservice architectures, in particular to a distributed transaction coordination method, a distributed transaction coordination device and electronic equipment.
Background
With the widespread use of distributed microservice architectures, the issue of data consistency among multiple microservices becomes more and more pronounced.
The consistency problem is an unavoidable problem in a distributed system, and two-stage submission is one of traditional solutions for solving data consistency, but the following disadvantages exist: the requirement on the database is high due to the realization of the database; there is no timeout mechanism; single point failure, due to the importance of the coordinator, once the coordinator fails, the participants will block all the time, and the whole cluster will not be available; in the second phase of two-phase submission, after the coordinator sends a submission request to the participants, if a local network exception occurs or the coordinator fails during the submission request, only a part of the participants receive the submission request.
Disclosure of Invention
The invention mainly aims to provide a distributed transaction coordination method and a distributed transaction coordination device, which are used for solving the problems that the existing two-stage submission has higher requirements on a database, no timeout mechanism exists, and single-point failure and inconsistent data exist.
In order to achieve the above object, a first aspect of the present invention provides a distributed transaction coordination method, including:
calling the micro-service through a business interface;
checking whether a distributed transaction environment currently exists through the micro-service;
if the distributed transaction environment does not exist at present, adding the micro-service as a transaction initiator into the distributed transaction group, and executing local transaction logic;
if the distributed transaction environment exists currently, adding the micro-service as a transaction participant into a distributed transaction group, and executing local transaction logic;
and when the service interface calls of all the transaction participants are completed, the transaction initiator informs the transaction coordinator cluster to complete the distributed transaction group so that the transaction coordinator cluster completes the distributed transaction group.
Optionally, if there is no distributed transaction environment currently, joining the microservice as a transaction initiator to the distributed transaction group, and executing local transaction logic, including:
if the distributed transaction environment does not exist at present, the micro-service is used as a transaction initiator to initialize the distributed transaction environment, and the transaction coordinator cluster is informed to create a distributed transaction group;
creating a distributed transaction group through the transaction coordinator cluster, and sending a distributed transaction group identifier to a transaction initiator;
and enabling the transaction initiator to join the distributed transaction group according to the distributed transaction group identification, and executing local transaction logic.
Optionally, after the service interface calls of all the transaction participants are completed, the transaction initiator notifies the transaction coordinator cluster to complete the distributed transaction group, so that the transaction coordinator cluster completes the distributed transaction group, including:
and judging whether the service interface calling of the transaction participant is abnormal or not.
Further, if there is no exception:
informing the transaction coordinator cluster to submit the distributed transaction group through a transaction initiator;
after the transaction coordinator cluster receives the submission notification, sending information for confirming the receipt of the submission notification to a transaction initiator, and asynchronously notifying a transaction participant to submit a local transaction;
the local transaction is committed by the transaction participant and the transaction initiator.
Further, if there is an anomaly, then:
the transaction participant sends the abnormal information of the service call to the transaction initiator through the service response;
informing the transaction coordinator cluster to roll back all transaction participants local transactions through a transaction initiator;
all transaction participant local transactions are rolled back through the transaction coordinator cluster.
Optionally, after the transaction coordinator cluster is notified of the completion of the distributed transaction group by the transaction initiator, so that the transaction coordinator cluster completes the distributed transaction group, the method further includes:
if the notification fails, then a transaction coordinator cluster failure log is logged.
A second aspect of the present invention provides a distributed transaction coordination apparatus, including:
the calling module is used for calling the micro-service through the service interface;
the checking module is used for checking whether a distributed transaction environment exists currently through the microservice;
the first joining module is used for joining the micro-service as a transaction initiator into the distributed transaction group and executing local transaction logic if the distributed transaction environment does not exist at present;
the second joining module is used for joining the micro-service as a transaction participant into the distributed transaction group and executing local transaction logic if the distributed transaction environment exists at present;
and the completion module is used for notifying the transaction coordinator cluster to complete the distributed transaction group through the transaction initiator after the service interface calls of all the transaction participants are completed so that the transaction coordinator cluster completes the distributed transaction group.
A third aspect of the present invention provides an electronic apparatus, comprising: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform the distributed transaction coordination method provided in any one of the first aspect.
A fourth aspect of the present invention provides a distributed transaction coordination system, which includes a microserver, a transaction coordinator cluster, an SDK, and the electronic device of the third aspect;
the micro-service is used as a transaction initiator or a transaction participant of the distributed transaction group and used for calling the database according to the user request received by the client, executing the business logic and submitting the business service;
the transaction coordinator cluster is used for creating a distributed transaction group and coordinating local transactions of transaction participants; the transaction coordinator cluster comprises at least three coordinators, distributed transaction information is stored in any coordinator connected with a transaction initiator, if a transaction participant accesses the coordinator cluster from other coordinators except the coordinator connected with the transaction initiator, the coordinator where the transaction data is located is inquired in a multicast mode, and the coordinator where the transaction data is located responds to a multicast inquiry request; moreover, the coordinators communicate with each other in a UDP mode;
and the SDK is used for establishing bidirectional network communication between the micro-service and the transaction coordinator cluster, and intercepting and enhancing in an AOP (automatic optic protocol) plane-oriented programming mode.
Optionally, the system further comprises a client and a database;
the client is used for receiving a request of a user and interacting with the user;
the database is used for storing service data, providing local affairs and being called by the micro-service.
In the embodiment of the invention, a micro service is called through a service interface, whether a distributed transaction environment exists at present is checked through the micro service, if the distributed transaction environment does not exist at present, the micro service is used as a transaction initiator to be added into a distributed transaction group, and local transaction logic is executed, if the distributed transaction environment exists at present, the micro service is used as a transaction participant to be added into the distributed transaction group, and the local transaction logic is executed, and after the calling of the service interfaces of all the transaction participants is completed, the transaction initiator informs a transaction coordinator cluster to complete the distributed transaction group, so that the transaction coordinator cluster completes the distributed transaction group; the distributed transaction coordinator provided by the embodiment of the invention uses multiple instances to form a cluster based on the C/S architecture coordinator, and single-point failure does not exist; all network communication between the transaction participants and the coordinator has a timeout mechanism, so that indefinite waiting is avoided; the method has no excessive requirements on the database, only needs to support the transaction, and does not require the database to support two-stage submission; the coordinators adopt a multicast mode, and inconsistency caused by data replication is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
Fig. 1 is a schematic flow chart of a distributed transaction coordination method according to an embodiment of the present invention;
FIG. 2 is a diagram of a distributed transaction coordination process provided by an embodiment of the invention;
FIG. 3 is a block diagram of a distributed transaction coordination apparatus according to an embodiment of the present invention;
FIG. 4 is a block diagram of an electronic device provided by an embodiment of the invention;
fig. 5 is a block diagram of a distributed transaction coordination system according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged under appropriate circumstances in order to facilitate the description of the embodiments of the invention herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that the embodiments and features of the embodiments may be combined with each other without conflict. The present invention will be described in detail below with reference to the embodiments with reference to the attached drawings.
The consistency problem is an unavoidable problem in a distributed system, two-stage submission is one of traditional solutions for data consistency, but the two-stage submission depends on a database to realize, and the requirement on the database is high; there is no timeout mechanism; single point failure, due to the importance of the coordinator, once the coordinator fails, the participants will block all the time, and the whole cluster will not be available; in the second phase of two-phase submission, after the coordinator sends a submission request to the participants, if a local network exception occurs or the coordinator fails during the submission request, only a part of the participants receive the submission request.
In order to solve the above problem, an embodiment of the present invention provides a distributed transaction coordination method, as shown in fig. 1, the method includes the following steps S101 to S105:
s101: calling the micro-service through a business interface;
the calling microservice process includes: the client calls the micro-service through the business interface, and one micro-service calls another micro-service when executing the local transaction logic. Specifically, the client includes a mobile phone APP, a computer, a web browser, and the like, and a certain microservice has no precedence relationship between executing the local transaction logic and calling another microservice, and may execute the local transaction logic first or call another microservice first.
S102: checking whether a distributed transaction environment currently exists through the micro-service; i.e. check if the distributed transaction information already exists in the current environment.
S103: if the distributed transaction environment does not exist at present, adding the micro-service as a transaction initiator into the distributed transaction group, and executing local transaction logic;
s104: if the distributed transaction environment exists currently, adding the micro-service as a transaction participant into a distributed transaction group, and executing local transaction logic;
s105: and when the service interface calls of all the transaction participants are completed, the transaction initiator informs the transaction coordinator cluster to complete the distributed transaction group so that the transaction coordinator cluster completes the distributed transaction group.
Specifically, the step S103 includes:
if the distributed transaction environment does not exist at present, the micro-service is used as a transaction initiator to initialize the distributed transaction environment, and the transaction coordinator cluster is informed to create a distributed transaction group;
creating a distributed transaction group through the transaction coordinator cluster, and sending a distributed transaction group identifier to a transaction initiator; specifically, after the transaction coordinator cluster creates the distributed transaction group, the distributed transaction group ID is sent to the transaction initiator;
and enabling the transaction initiator to join the distributed transaction group according to the distributed transaction group identification, and executing local transaction logic.
Specifically, the step S105 includes:
and judging whether the service interface calling of the transaction participant is abnormal or not.
If no exception exists, then:
informing the transaction coordinator cluster to submit the distributed transaction group through a transaction initiator;
after the transaction coordinator cluster receives the submission notification, sending information for confirming the receipt of the submission notification to a transaction initiator, and asynchronously notifying a transaction participant to submit a local transaction;
the local transaction is committed by the transaction participant and the transaction initiator.
If there is an exception:
the transaction participant sends the abnormal information of the service call to the transaction initiator through the service response;
informing the transaction coordinator cluster to roll back all transaction participants local transactions through a transaction initiator;
all transaction participant local transactions are rolled back through the transaction coordinator cluster.
Specifically, after step S105, the method further includes:
and if the notification fails, counting a failure log of the transaction coordinator cluster, and providing data for subsequent manual processing.
An embodiment of the present invention further provides a distributed transaction coordination process, as shown in fig. 2, the process includes:
the client is called through a service interface;
the micro-service checks whether a distributed transaction environment exists at present, if the distributed transaction environment does not exist, the distributed transaction environment is initialized in the role of a transaction initiator and a notice is sent to the coordinator cluster, the coordinator cluster creates a distributed transaction group, and then the coordinator responds to the ID of the transaction group and connects local transactions among the micro-services in series;
the initiator executes local transactional logic and may invoke another microservice in the process. The initiator does not have a precedence relationship between executing the local transaction logic and calling another micro-service, and can execute the local transaction logic first or call the other micro-service first;
another microservice checks that distributed transaction information already exists in the current environment, and joins the distributed transaction group as a transaction participant, and the transaction participant executes local transaction logic;
after all the participant service calls are completed normally, the transaction initiator informs the transaction coordinator to submit the transaction group; the coordinator cluster sends a confirmation to the transaction and receives a completion notification; the coordinator cluster informs all participants to submit local transactions;
if the transaction participant has an exception, the transaction participant can feed back to the transaction initiator through the service response, and the transaction initiator informs the coordinator cluster to roll back all the participant local transactions.
An embodiment of the present invention further provides a distributed transaction coordination apparatus for implementing the distributed transaction coordination method, as shown in fig. 3, the apparatus includes:
the calling module 31 is used for calling the micro-service through the service interface;
a checking module 32, configured to check whether a distributed transaction environment currently exists through the microservice;
a first joining module 33, configured to join the microservice as a transaction initiator to the distributed transaction group and execute a local transaction logic if the distributed transaction environment does not exist currently;
a second joining module 34, configured to join the microservice as a transaction participant to the distributed transaction group and execute local transaction logic if a distributed transaction environment currently exists;
and a completion module 35, configured to notify the transaction coordinator cluster to complete the distributed transaction group through the transaction initiator after the service interface calls of all the transaction participants are completed, so that the transaction coordinator cluster completes the distributed transaction group.
An embodiment of the present invention further provides an electronic device, as shown in fig. 4, the electronic device includes one or more processors 41 and a memory 42, where one processor is taken as an example in fig. 4.
The controller may further include: an input device 43 and an output device 44.
The processor 41, the memory 42, the input device 43 and the output device 44 may be connected by a bus or other means, and fig. 4 illustrates the connection by a bus as an example.
The processor 41 may be a Central Processing Unit (CPU). The processor 41 may also be other general purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or combinations thereof. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 42, which is a non-transitory computer readable storage medium, may be used for storing non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules corresponding to the control method in the embodiments of the present invention. The processor 41 executes various functional applications of the server and data processing by running non-transitory software programs, instructions, and modules stored in the memory 42, i.e., implements the distributed transaction coordination method of the above-described method embodiments.
The memory 42 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created according to use of a processing device operated by the server, and the like. Further, the memory 42 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, memory 42 may optionally include memory located remotely from processor 41, which may be connected to a network connection device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 43 may receive input numeric or character information and generate key signal inputs related to user settings and function control of the processing device of the server. The output device 44 may include a display device such as a display screen.
One or more modules are stored in the memory 42, which when executed by the one or more processors 41, perform the method as shown in fig. 1.
An embodiment of the present invention further provides a distributed transaction coordination system, as shown in fig. 5, where the system includes a microservice, a transaction coordinator cluster, an SDK, and the electronic device;
the micro-service is used as a transaction initiator or a transaction participant of the distributed transaction group and used for calling the database according to the user request received by the client, executing the business logic and submitting the business service; microservices are divided into two roles in the order of joining into a distributed transaction group: the first microservice to join a distributed transaction group is the transaction initiator and the later to join is the transaction participant.
The transaction coordinator cluster is used for creating a distributed transaction group and coordinating local transactions of transaction participants; the transaction coordinator cluster comprises at least three coordinators, distributed transaction information is stored in any coordinator connected with a transaction initiator, if a transaction participant accesses the coordinator cluster from other coordinators except the coordinator connected with the transaction initiator, the coordinator where the transaction data is located is inquired in a multicast mode, and the coordinator where the transaction data is located responds to a multicast inquiry request;
the coordinator cluster is not dependent on other components, all data being stored by the nodes or the coordinator itself. The distributed transaction information is stored on any node or coordinator connected by the initiator. If the participator accesses from other nodes or coordinators, other nodes or coordinators inquire the node or coordinator where the transaction data is located in a multicast mode, and the node or coordinator where the transaction data is located responds to the multicast request, so that inconsistency caused by data replication is avoided. Moreover, all nodes or coordinators in the coordinator cluster communicate in a UDP mode;
the transaction coordinator cluster coordinates the local transactions of the transaction participants, and the transactions are either completely submitted or completely rolled back, a plurality of coordinators form a cluster, high service availability is ensured, and a transaction index panel is provided for counting auxiliary functions of cluster states, error logs, a management terminal information list and the like. The coordinator transaction index panel is used for feeding back the current cluster state, and comprises the following statistical items: creating transaction group number, joining local transaction request number, ignoring joining transaction group number, receiving multicast joining transaction group number, sending multicast request number, multicast joining transaction group success number, multicast joining transaction group timeout number, submitting transaction group number, notifying participant submission success number, notifying participant submission failure number, notifying participant submission timeout number, rollback transaction group number, checking transaction group status number, cleared transaction group number, and current transaction group number.
The SDK is used for establishing bidirectional network communication between the micro-service and the transaction coordinator cluster, and intercepting and enhancing by using an AOP (automatic optic protocol) plane-oriented programming mode;
in order to realize local transaction management and control and avoid influencing the encoding of developers, the SDK is intercepted and enhanced by using an AOP (automatic optic programming) plane-oriented programming mode; by utilizing the AOP, all parts of the business logic can be isolated, so that the coupling degree between all parts of the business logic is reduced, the reusability of a program is improved, and the development efficiency is improved; the main interception method comprises the following steps: the business method of the distributed transaction annotation mark is used for marking a transaction control range, a database connection pool and a method for starting, submitting and rolling back transactions of a database connection object. Local transactions use an annotation mode to increase distributed transaction support, so that the invasion of business codes is reduced; the transaction initiator or participant communicates bi-directionally with the coordinator; it can be seen from the above interaction logic that it is possible for both the transaction initiator and the coordinator to actively initiate network communication. The scheme enables a long connection mode to be established between the transaction participants and the coordinator cluster, and network data transmission can be initiated from one party to the other party at any time.
Specifically, the system further comprises a client and a database;
the client is used for receiving a request of a user and interacting with the user; the client comprises a user program of the business service, such as: browser, cell phone APP, etc.
The database is used for storing service data, providing local affairs and being called by the micro-service.
From the above description, it can be seen that the present invention achieves the following technical effects:
1. the coordinators in the cluster adopt a multicast mode, nodes where the transaction data are located or the coordinators respond to the multicast request, and inconsistency caused by data replication is avoided;
2, the SDK uses an AOP section-oriented programming mode, is transparent to developers, does not influence the code writing mode of the developers, does not need the developers to know the relevant logic of the distributed transaction, and only needs to control the local transaction;
3. the micro-service is communicated with the transaction coordinator cluster through the SDK in a bidirectional network manner, transaction participants are offline and subjected to overtime scene processing in the distributed transaction process, and all network communication between the transaction participants and the coordinator has an overtime mechanism, so that the situation that the network communication is subjected to indefinite waiting is avoided;
4. the coordinator supports the cluster, and the production environment generally uses three or more nodes to form the cluster, so that the problem of single-point fault of the coordinator is solved;
5. the method has no excessive requirements on the database, only needs to support the transaction, and does not require the database to support two-stage submission;
6. coordinator error logging provides data for manual recovery.
Those skilled in the art will appreciate that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and the processes of the embodiments of the motor control methods described above can be included when the computer program is executed. The storage medium may be a magnetic disk, an optical disk, a Read-only memory (ROM), a Random Access Memory (RAM), a Flash Memory (FM), a hard disk (hard disk drive, HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.

Claims (10)

1. A distributed transaction coordination method, the method comprising:
calling the micro-service through a business interface;
checking whether a distributed transaction environment currently exists through the micro-service;
if the distributed transaction environment does not exist at present, adding the micro-service as a transaction initiator into the distributed transaction group, and executing local transaction logic;
if the distributed transaction environment exists currently, adding the micro-service as a transaction participant into a distributed transaction group, and executing local transaction logic;
and when the service interface calls of all the transaction participants are completed, the transaction initiator informs the transaction coordinator cluster to complete the distributed transaction group so that the transaction coordinator cluster completes the distributed transaction group.
2. The distributed transaction coordination method according to claim 1, wherein if no distributed transaction environment currently exists, joining the microservice as a transaction initiator to the distributed transaction group and executing local transaction logic comprises:
if the distributed transaction environment does not exist at present, the micro-service is used as a transaction initiator to initialize the distributed transaction environment, and the transaction coordinator cluster is informed to create a distributed transaction group;
creating a distributed transaction group through the transaction coordinator cluster, and sending a distributed transaction group identifier to a transaction initiator;
and enabling the transaction initiator to join the distributed transaction group according to the distributed transaction group identification, and executing local transaction logic.
3. The distributed transaction coordination method according to claim 1, wherein after the service interface calls of all transaction participants are completed, the transaction initiator notifies the transaction coordinator cluster to complete the distributed transaction group, so that the transaction coordinator cluster completes the distributed transaction group, including:
and judging whether the service interface calling of the transaction participant is abnormal or not.
4. The distributed transaction reconciliation method of claim 3 wherein if no exception exists:
informing the transaction coordinator cluster to submit the distributed transaction group through a transaction initiator;
after the transaction coordinator cluster receives the submission notification, sending information for confirming the receipt of the submission notification to a transaction initiator, and asynchronously notifying a transaction participant to submit a local transaction;
the local transaction is committed by the transaction participant and the transaction initiator.
5. The distributed transaction reconciliation method of claim 3 wherein if there is an exception:
the transaction participant sends the abnormal information of the service call to the transaction initiator through the service response;
informing the transaction coordinator cluster to roll back all transaction participants local transactions through a transaction initiator;
all transaction participant local transactions are rolled back through the transaction coordinator cluster.
6. The distributed transaction coordination method according to claim 1, wherein after notifying the transaction coordinator cluster of completion of the distributed transaction group by the transaction initiator, such that the transaction coordinator cluster completes the distributed transaction group, the method further comprises:
if the notification fails, then a transaction coordinator cluster failure log is logged.
7. A distributed transaction coordination apparatus, the apparatus comprising:
the calling module is used for calling the micro-service through the service interface;
the checking module is used for checking whether a distributed transaction environment exists currently through the microservice;
the first joining module is used for joining the micro-service as a transaction initiator into the distributed transaction group and executing local transaction logic if the distributed transaction environment does not exist at present;
the second joining module is used for joining the micro-service as a transaction participant into the distributed transaction group and executing local transaction logic if the distributed transaction environment exists at present;
and the completion module is used for notifying the transaction coordinator cluster to complete the distributed transaction group through the transaction initiator after the service interface calls of all the transaction participants are completed so that the transaction coordinator cluster completes the distributed transaction group.
8. An electronic device, characterized in that the electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, the computer program being executable by the at least one processor to cause the at least one processor to perform the distributed transaction coordination method of any one of claims 1-7.
9. A distributed transaction coordination system, characterized in that said system comprises a microservice, a transaction coordinator cluster, an SDK and an electronic device according to claim 8;
the micro-service is used as a transaction initiator or a transaction participant of the distributed transaction group and used for calling the database according to the user request received by the client, executing the business logic and submitting the business service;
the transaction coordinator cluster is used for creating a distributed transaction group and coordinating local transactions of transaction participants; the transaction coordinator cluster comprises at least three coordinators, distributed transaction information is stored in any coordinator connected with a transaction initiator, if a transaction participant accesses the coordinator cluster from other coordinators except the coordinator connected with the transaction initiator, the coordinator where the transaction data is located is inquired in a multicast mode, and the coordinator where the transaction data is located responds to a multicast inquiry request; moreover, the coordinators communicate with each other in a UDP mode;
and the SDK is used for establishing bidirectional network communication between the micro-service and the transaction coordinator cluster, and intercepting and enhancing in an AOP (automatic optic protocol) plane-oriented programming mode.
10. The distributed transaction coordination system of claim 9, wherein said system further comprises a client and a database;
the client is used for receiving a request of a user and interacting with the user;
the database is used for storing service data, providing local affairs and being called by the micro-service.
CN202010937837.4A 2020-09-08 2020-09-08 Distributed transaction coordination method and device and electronic equipment Pending CN112148394A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010937837.4A CN112148394A (en) 2020-09-08 2020-09-08 Distributed transaction coordination method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010937837.4A CN112148394A (en) 2020-09-08 2020-09-08 Distributed transaction coordination method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112148394A true CN112148394A (en) 2020-12-29

Family

ID=73890074

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010937837.4A Pending CN112148394A (en) 2020-09-08 2020-09-08 Distributed transaction coordination method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112148394A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113127570A (en) * 2021-05-18 2021-07-16 上海莉莉丝科技股份有限公司 Data operation method, system, equipment and storage medium of distributed server
WO2022206426A1 (en) * 2021-03-30 2022-10-06 华为云计算技术有限公司 Distributed transaction processing method and system, and related device
CN115964198A (en) * 2023-03-17 2023-04-14 北京徐工汉云技术有限公司 Distributed flexible transaction processing method and device based on long transaction

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473318A (en) * 2013-09-12 2013-12-25 中国科学院软件研究所 Distributed transaction security method for memory data grid
CN109783204A (en) * 2018-12-28 2019-05-21 咪咕文化科技有限公司 A kind of distributed transaction processing method, device and storage medium
CN110022367A (en) * 2019-04-11 2019-07-16 软通动力信息技术(集团)有限公司 A kind of transaction methods and transacter
US20200125654A1 (en) * 2018-10-23 2020-04-23 Microsoft Technology Licensing, Llc Lock free distributed transaction coordinator for in-memory database participants

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103473318A (en) * 2013-09-12 2013-12-25 中国科学院软件研究所 Distributed transaction security method for memory data grid
US20200125654A1 (en) * 2018-10-23 2020-04-23 Microsoft Technology Licensing, Llc Lock free distributed transaction coordinator for in-memory database participants
CN109783204A (en) * 2018-12-28 2019-05-21 咪咕文化科技有限公司 A kind of distributed transaction processing method, device and storage medium
CN110022367A (en) * 2019-04-11 2019-07-16 软通动力信息技术(集团)有限公司 A kind of transaction methods and transacter

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
就这样吧: "TX-LCN分布式事务框架", 《HTTPS://ZHUANLAN.ZHIHU.COM/P/106476994?UTM_ID=0》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022206426A1 (en) * 2021-03-30 2022-10-06 华为云计算技术有限公司 Distributed transaction processing method and system, and related device
CN113127570A (en) * 2021-05-18 2021-07-16 上海莉莉丝科技股份有限公司 Data operation method, system, equipment and storage medium of distributed server
CN115964198A (en) * 2023-03-17 2023-04-14 北京徐工汉云技术有限公司 Distributed flexible transaction processing method and device based on long transaction

Similar Documents

Publication Publication Date Title
CN112148394A (en) Distributed transaction coordination method and device and electronic equipment
CN110990182B (en) Transaction processing method, device, equipment and storage medium
US11036598B2 (en) Notification mechanism for disaster recovery events
CN110413424B (en) Configurable third-party message callback method, device, server and storage medium
CN111768288B (en) Service processing method, device, electronic equipment and storage medium
CN107437222B (en) Processing method and system of online business data based on front end of bank counter
JP6431197B2 (en) Snapshot processing methods and associated devices
CN113162848B (en) Method, device, gateway and medium for realizing block chain gateway
WO2020006902A1 (en) Batch payment method and apparatus, computer device, and storage medium
CN109495540A (en) A kind of method, apparatus of data processing, terminal device and storage medium
CN111414266B (en) Synchronous and asynchronous communication method and device for distributed transaction
WO2020258653A1 (en) Cross-node data processing method and apparatus
US10425778B2 (en) Distributed transactions on mobile devices via a messaging service provided by a mobile network operator
CN109118352A (en) Remaining sum monitoring method, device, computer equipment and storage medium
CN112711466B (en) Hanging affair inspection method and device, electronic equipment and storage medium
CN115643271A (en) Method, device, server and medium for synchronizing multi-application data on cloud
CN108735278B (en) Instruction transmission method and application suitable for rehabilitation equipment
CN114116141A (en) Transaction processing method and device for distributed system, storage medium and electronic device
CN112395102A (en) Distributed database middleware solution method
CN113094571A (en) Multi-platform account checking method and device
US10334078B2 (en) Tunable client-server communications filtering
CN113448931B (en) Data processing method, business transaction platform and business providing platform
CN114896258B (en) Transaction data synchronization method and device, computer equipment and storage medium
CN108900636B (en) Transaction data processing method and platform
CN117675443A (en) Method, device, equipment, medium and product for erecting FIX gateway cluster

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
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20201229