Search

CN-113900785-B - Distributed transaction processing method and device and electronic equipment

CN113900785BCN 113900785 BCN113900785 BCN 113900785BCN-113900785-B

Abstract

The disclosure provides a distributed transaction processing method, relates to the technical field of computers, and particularly relates to the technical field of databases. The method comprises the steps of obtaining a current action state of a service state machine as a first action state, wherein the service state machine is a state machine for presenting service processing conditions, and calling a first service operation interface corresponding to the first action state of the service state machine to enable a service end to execute operation corresponding to the first service operation interface. Therefore, the transaction coordinator is decoupled from each service, the invasion of the transaction coordinator to the service end service is reduced, and the operation and maintenance cost of the service is reduced.

Inventors

  • WU YONGBIN
  • ZHAO XIN
  • WANG ZHENGHUA

Assignees

  • 北京百度网讯科技有限公司

Dates

Publication Date
20260505
Application Date
20211009

Claims (15)

  1. 1. A distributed transaction processing method, comprising: Acquiring a current action state of a service state machine as a first action state, wherein the service state machine is a state machine for presenting service processing conditions; calling a first service operation interface corresponding to a first action state of the service state machine, so that a service end executes operation corresponding to the first service operation interface; Updating the state of a transaction state machine according to the result of the execution of the corresponding operation by the service end, and obtaining a third action state of the transaction state machine, wherein the transaction state machine is a state machine presenting the transaction processing condition of the service end; Receiving a service request of a service end, and acquiring a context corresponding to the service request, wherein the context of the service request is a processing process of a service requested by the service request; Judging whether the service request is an abnormal service request according to the context and the third action state, wherein the abnormal service request is the service request which has been executed and is executed successfully; if yes, refusing to operate according to the service request; And if not, calling a service operation interface requested by the service request, so that the service end executes corresponding operation according to the service operation interface, and updating a third action state of the transaction state machine.
  2. 2. The method of claim 1, further comprising: Acquiring an execution result of each preset execution step of the service end; Updating the current action state of the service state machine according to the execution result of the service to obtain a second action state of the service state machine; and calling a second service operation interface corresponding to a second action state of the service state machine, so that the service end executes the operation corresponding to the second service operation interface.
  3. 3. The method of claim 1, wherein the service request is sent from a service side to a transaction coordinator over an idempotent transaction interface.
  4. 4. A method according to claim 1 or 3, wherein prior to said determining whether said service request is an abnormal service request according to said context and said third action state, further comprising: dividing a plurality of service requests into different types of service requests according to service types and transaction types, wherein the service types are used for representing the types of the services generating the service requests, and the transaction types are used for representing the types of the transactions requested by the service requests; the service requests of different types are arranged into corresponding request queues, wherein the request queues are queues divided according to the types of the service requests; and delivering the service requests to the same machine room according to the corresponding request queues, and receiving the service requests of the request queues.
  5. 5. A method according to any one of claims 1-3, wherein said if not invoking the service operation interface of the service request comprises: if not, dividing the service request into a plurality of first service messages according to the content contained in the service request; And calling a plurality of service operation interfaces corresponding to the first service messages concurrently.
  6. 6. The method of claim 4, wherein the invoking the service operation interface of the service request if not comprises: if not, dividing the service request into a plurality of first service messages according to the content contained in the service request; And calling a plurality of service operation interfaces corresponding to the first service messages concurrently.
  7. 7. A distributed transaction processing apparatus, comprising: the service state machine state acquisition module is used for acquiring the current action state of a service state machine as a first action state, wherein the service state machine is a state machine for presenting service processing conditions; the first interface calling module is used for calling a first service operation interface corresponding to a first action state of the service state machine, so that the service end executes the operation corresponding to the first service operation interface; the transaction state machine state updating module is used for updating the state of the transaction state machine according to the result of the execution of the corresponding operation by the service end to obtain a third action state of the transaction state machine, wherein the transaction state machine is a state machine for presenting the transaction processing condition of the service end; The system comprises a service request receiving module, a service request processing module and a service processing module, wherein the service request receiving module is used for receiving a service request of a service end and acquiring a context corresponding to the service request; The service request judging module is used for judging whether the service request is an abnormal service request according to the context and the third action state, and if so, refusing to operate according to the service request, wherein the abnormal service request is the service request which has been executed and is executed successfully; And the service request processing module is used for calling a service operation interface of the service request if not, so that the service end executes corresponding operation according to the service operation interface and updates the third action state of the transaction state machine.
  8. 8. The apparatus of claim 7, further comprising: The execution result acquisition module is used for acquiring the execution result of each preset execution step of the service end; the service state machine state updating module is used for updating the current action state of the service state machine according to the execution result of the service to obtain a second action state of the service state machine; and the second interface calling module is used for calling a second service operation interface corresponding to a second action state of the service state machine, so that the service end executes the operation corresponding to the second service operation interface.
  9. 9. The apparatus of claim 7, wherein the service request is sent from a service side to a transaction coordinator over an idempotent transaction interface.
  10. 10. The apparatus of claim 7 or 9, wherein the service request determination module further comprises: A service request classification unit, configured to classify a plurality of service requests into service requests of different types according to service types and transaction types, where the service types are used to represent types of services that generate the service requests, and the transaction types are used to represent types of transactions requested by the service requests; A request queue dividing module, configured to arrange each of the different types of service requests into a corresponding request queue, where the request queue is a queue divided according to the type of the service request; And the service request delivery module is used for delivering the service requests to the same machine room according to the corresponding request queues and receiving the service requests of the request queues.
  11. 11. The apparatus according to any one of claims 7-9, wherein the service request processing module further comprises: A service message splitting unit, configured to split the service request into a plurality of first service messages according to the content included in the service request if not; And the service message processing unit is used for calling the service operation interfaces corresponding to the plurality of first service messages in parallel.
  12. 12. The apparatus of claim 10, wherein the service request processing module further comprises: A service message splitting unit, configured to split the service request into a plurality of first service messages according to the content included in the service request if not; And the service message processing unit is used for calling the service operation interfaces corresponding to the plurality of first service messages in parallel.
  13. 13. An electronic device, comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
  14. 14. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-6.
  15. 15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-6.

Description

Distributed transaction processing method and device and electronic equipment Technical Field The present disclosure relates to the field of computer technology, and in particular, to the field of database technology. Background Currently, when a transaction is performed in a distributed system environment, the problem of atomic commit of a microservice multi-operation sequence needs to be guaranteed. Disclosure of Invention The disclosure provides a distributed transaction processing method, a distributed transaction processing device, a distributed transaction processing equipment and a storage medium. According to an aspect of the present disclosure, there is provided a distributed transaction processing method, including: Acquiring a current action state of a service state machine as a first action state, wherein the service state machine is a state machine for presenting service processing conditions; And calling a first service operation interface corresponding to the first action state of the service state machine, so that the service end executes the operation corresponding to the first service operation interface. According to another aspect of the present disclosure, there is provided a distributed transaction processing apparatus including: the service state machine state acquisition module is used for acquiring the current action state of a service state machine as a first action state, wherein the service state machine is a state machine for presenting service processing conditions; And the first interface calling module is used for calling a first service operation interface corresponding to the first action state of the service state machine, so that the service end executes the operation corresponding to the first service operation interface. It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification. Drawings The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein: FIG. 1 is a flow diagram of a distributed transaction processing method according to the present disclosure; FIG. 2 is another flow diagram of a distributed transaction processing method according to the present disclosure; FIG. 3 is another flow diagram of a distributed transaction processing method according to the present disclosure; FIG. 4 is another flow diagram of a distributed transaction processing method according to the present disclosure; FIG. 5 is another flow diagram of a distributed transaction processing method according to the present disclosure; FIG. 6 is a schematic diagram of one architecture of a distributed transaction processing device according to the present disclosure; fig. 7 is a block diagram of an electronic device for implementing a distributed transaction processing method of an embodiment of the present disclosure. Detailed Description Exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, which include various details of the embodiments of the present disclosure to facilitate understanding, and should be considered as merely exemplary. Accordingly, one of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness. In a distributed system environment, a service processing unit typically needs to combine requests for multiple services, especially in systems where the service already has a large number of micro-services, which may be up to tens of requests for combined services. In addition, for a complex, step-wise executable business logic, this is often accomplished by a relatively large number of operations. To ensure proper operation of a distributed system, it is necessary to ensure consistency of these requests and operations, and the mechanism of ensuring consistency of these requests and operations is called a distributed transaction. In the related art, there are various distributed transaction processing schemes, such as implementation schemes of XA (X/Open DTP organization defined two-phase commit protocol), TCC (Try, confirm, cancel) and the like, which can process distributed transactions, but in the related art, a problem that a service end and a transaction coordinator end are strongly coupled during implementation occurs. The code of the transaction coordinator invades into the service, so that the user needs to synchronously operate and maintain the transaction coordinator when operating and maintaining the service, and the co