CN116302702A - Distributed transaction rollback method, electronic equipment and storage medium - Google Patents

Distributed transaction rollback method, electronic equipment and storage medium Download PDF

Info

Publication number
CN116302702A
CN116302702A CN202310273295.9A CN202310273295A CN116302702A CN 116302702 A CN116302702 A CN 116302702A CN 202310273295 A CN202310273295 A CN 202310273295A CN 116302702 A CN116302702 A CN 116302702A
Authority
CN
China
Prior art keywords
transaction
branch
executed
rollback
transactions
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
CN202310273295.9A
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.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202310273295.9A priority Critical patent/CN116302702A/en
Publication of CN116302702A publication Critical patent/CN116302702A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1469Backup restoration techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process
    • G06F11/1464Management of the backup or restore process for networked environments
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1474Saving, restoring, recovering or retrying in transactions

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a distributed transaction rollback method, electronic equipment and a storage medium, and relates to the technical field of cloud computing, wherein the method comprises the following steps: acquiring actual execution sequence information of a plurality of executed branch transactions of the global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored; if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; and according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions. In this embodiment, for a branch transaction whose actual execution sequence matches a predetermined execution sequence, a rollback transaction event-driven manner is adopted, and a flow engine is not required to be introduced, so that the implementation cost of transaction rollback can be reduced.

Description

Distributed transaction rollback method, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of cloud computing technologies, and in particular, to a distributed transaction rollback method, an electronic device, and a storage medium.
Background
The micro-service architecture is an architecture scheme for building applications. The micro-service architecture differs from the more traditional monolithic approach in that applications can be split into multiple core functions. Each function is called a service, which can be constructed and deployed separately, and the services do not affect each other when working and malfunctioning.
Under a micro-service architecture, distributed transactions typically require a Saga schema, which is a method of managing data consistency across micro-services in a distributed transaction scenario. Transaction rollback in Saga mode is currently implemented in a way of using Orchestration (organization), driven by a flow engine, the transaction link is complex, and the system implementation cost is high.
Disclosure of Invention
The embodiment of the application provides a distributed transaction rollback method, electronic equipment and a storage medium, so as to reduce the realization cost of transaction rollback.
In a first aspect, an embodiment of the present application provides a distributed transaction rollback method, including:
acquiring actual execution sequence information of a plurality of executed branch transactions of the global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored; if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the pre-stored global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; the transaction identification is determined according to the actual execution sequence of a plurality of executed branch transactions;
and according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions.
In a second aspect, embodiments of the present application provide an electronic device including a memory, a processor, and a computer program stored on the memory, the processor implementing a method of any one of the above when the computer program is executed.
In a third aspect, embodiments of the present application provide a computer-readable storage medium having a computer program stored therein, the computer program, when executed by a processor, implementing a method according to any one of the above.
Compared with the prior art, the application has the following advantages:
the application provides a distributed transaction rollback method, electronic equipment and a storage medium, wherein when a rollback transaction event of a branch transaction of a global transaction is monitored, actual execution sequence information of a plurality of executed branch transactions of the global transaction is acquired; if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; the transaction identification is determined according to the actual execution sequence of a plurality of executed branch transactions; and according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions. In this embodiment, for a branch transaction executed according to a determined execution sequence, that is, an actual execution sequence of the branch transaction is matched with a predetermined execution sequence, by comparing a transaction identifier in a rollback transaction event with transaction identifiers of a plurality of executed branch transactions, rollback of the executed branch transaction is implemented, and a manner driven based on the rollback transaction event is adopted, without introducing a flow engine, so that implementation cost of rollback of the transaction can be reduced.
The foregoing description is merely an overview of the technical solutions of the present application, and in order to make the technical means of the present application more clearly understood, it is possible to implement the present application according to the content of the present specification, and in order to make the above and other objects, features and advantages of the present application more clearly understood, the following detailed description of the present application will be given.
Drawings
In the drawings, the same reference numerals refer to the same or similar parts or elements throughout the several views unless otherwise specified. The figures are not necessarily drawn to scale. It is appreciated that these drawings depict only some embodiments according to the application and are not to be considered limiting of its scope.
Fig. 1 is a schematic diagram of an application scenario of a distributed transaction rollback method provided in the present application;
FIG. 2 is a schematic diagram of a distributed transaction rollback process according to an embodiment of the present application;
FIG. 3 is a flow chart of a distributed transaction rollback method of an embodiment of the present application;
FIG. 4 is a block diagram of a data security detection device according to an embodiment of the present application; and
fig. 5 is a block diagram of an electronic device used to implement an embodiment of the present application.
Detailed Description
Hereinafter, only certain exemplary embodiments are briefly described. As will be recognized by those of skill in the pertinent art, the described embodiments may be modified in various different ways without departing from the spirit or scope of the present application. Accordingly, the drawings and description are to be regarded as illustrative in nature, and not as restrictive.
In order to facilitate understanding of the technical solutions of the embodiments of the present application, the following describes related technologies of the embodiments of the present application. The following related technologies may be optionally combined with the technical solutions of the embodiments of the present application, which all belong to the protection scope of the embodiments of the present application.
Fig. 1 is a schematic diagram of an application scenario of a distributed transaction rollback method provided in the present application. The scheme in the embodiment of the application can be applied to a micro-service architecture, wherein the global transaction is a distributed transaction, and the branch transaction is a micro-service. As shown in fig. 1, the Global transaction Global Tx includes a plurality of branch transactions (local transactions): local Tx1, local Tx2, local Tx3, local Tx4, local Tx5, and Local Tx6. The execution sequence of each branch transaction of the global transaction is predetermined, and the execution sequence information is obtained. For example, the transaction sequence numbers corresponding to the respective branch transactions are predetermined, and the transaction sequence numbers corresponding to Local Tx1, local Tx2, local Tx3, local Tx4, local Tx5, and Local Tx6 are 1, 2, 3, 4, 5, and 6, respectively.
In the actual execution process of the transaction, the branch transaction may be executed according to a predetermined execution sequence, or may not be executed according to the predetermined execution sequence, and the actual execution sequence is determined according to the result after the execution is completed. After each branch transaction is executed, generating an order mark log corresponding to the branch transaction, and recording the identification of the transaction in the log. According to the sequence mark logs corresponding to the executed branch transactions respectively, the actual execution sequence of the executed branch transactions can be obtained.
Fig. 2 is a schematic diagram of a distributed transaction rollback process provided herein. As shown in fig. 2, if a Rollback Event (RBEvent) of a branch transaction Local Tx4 of a global transaction is monitored, as shown in RBEvent4 in the figure, the transaction sequence number 4 of the RBEvent4 includes a Local Tx4, predetermined execution sequence information of the branch transaction Local Tx1, local Tx2, local Tx3, local Tx4 of the global transaction is acquired, and compared with actual execution sequence information determined according to sequence marking logs of the Local Tx1, local Tx2, local Tx3, local Tx4, if matching, the transaction sequence number 4 is compared with the transaction sequence numbers of a plurality of executed branch transactions Local Tx1, local Tx2, local Tx3, and the transaction sequence number 4 in RBEvent4 is greater than the transaction sequence number 3 of the Local Tx3, and then the Rollback is performed to the Local Tx3, and then the transaction sequence number is again compared, and the Rollback is performed to the Local Tx2, and then the Rollback is continued until the Rollback is completed in the manner of the Local Tx1 (as shown in the RBEvent 1).
In the related art, whether or not a branch transaction is executed according to a certain execution sequence, a flow engine is used to control the transaction rollback sequence as a whole, i.e., the transaction rollback is implemented in an Orchestration (organization) manner. This way of processing requires recording the runtime information of the flow instance, requiring a significant overhead.
In this embodiment, for a branch transaction executed according to a determined execution order, that is, an actual execution order of the branch transaction matches a predetermined execution order, by comparing a transaction sequence number in a rollback transaction event with transaction sequence numbers of a plurality of executed branch transactions, rollback of the executed branch transaction is implemented, and only event driving of a coordination (chord) scheme is used, that is, sequential rollback is guaranteed, and a flow engine on which an heavyweight scheduling (organization) scheme depends is not introduced, so that implementation cost of rollback of the transaction can be reduced.
The embodiment of the application provides a distributed transaction rollback method, and the method in the embodiment can be applied to a computing device, and the computing device can comprise: server, user terminal, etc. FIG. 3 is a flow chart of a distributed transaction rollback method according to an embodiment of the present application, the method including:
in step S301, when a rollback transaction event of a branch transaction of a global transaction is monitored, actual execution sequence information of a plurality of executed branch transactions of the global transaction is acquired.
Step S302, if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; the transaction identification is determined based on the actual execution order of the plurality of executed branch transactions.
Step S303, according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions.
Wherein a transaction consists of operations performed between the start of the transaction and the end of the transaction. The transaction has attributes including: atomicity, consistency, isolation, and persistence. The global transaction is a distributed transaction and the branch transaction is a local transaction. Local transactions access and update data on a single data source, and distributed transactions access and update data across multiple data sources.
The execution sequence of each branch transaction of the global transaction is predetermined, and the execution sequence information is obtained. The execution sequence information may be configured according to specific needs or corresponding rules, or may be determined according to the sequence of the previous operation flows of multiple users, which is not limited in this application. In the actual execution process of the transaction, the branch transaction may be executed according to a predetermined execution sequence, or may not be executed according to the predetermined execution sequence, and the actual execution sequence is determined according to the result after the execution is completed.
When a rollback transaction event is heard, a specific transaction rollback policy is determined by comparing actual execution order information of a plurality of executed branch transactions to execution order information of a plurality of branch transactions of a predetermined global transaction.
If the actual execution sequence information of the plurality of executed branch transactions matches the execution sequence information of the plurality of branch transactions of the predetermined global transaction, the flow engine does not need to be started, and rollback of the branch transactions only needs to be triggered by a rollback transaction event. Determining transaction identifications according to the actual execution sequence of the plurality of executed branch transactions, comparing the transaction identifications in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions, determining which branch transaction the rollback transaction event rolls back to according to the comparison result, and then sequentially rollback to the branch transaction executed first in the plurality of executed branch transactions.
Illustratively, the branch transaction includes a microservice. Micro services refer to small services divided into single application programs, and the micro services are mutually coordinated and matched. Each micro-service runs in an independent process, and the micro-service communicate with each other by adopting a lightweight communication mechanism.
The application provides a distributed transaction rollback method, which is used for acquiring actual execution sequence information of a plurality of executed branch transactions of a global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored; if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; the transaction identification is determined according to the actual execution sequence of a plurality of executed branch transactions; and according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions. In this embodiment, for a branch transaction executed according to a determined execution sequence, that is, an actual execution sequence of the branch transaction is matched with a predetermined execution sequence, by comparing a transaction identifier in a rollback transaction event with transaction identifiers of a plurality of executed branch transactions, rollback of the executed branch transaction is implemented, and a manner driven based on the rollback transaction event is adopted, without introducing a flow engine, so that implementation cost of rollback of the transaction can be reduced.
The specific implementation manner of step S301 is as follows:
in one implementation, the transaction identification is a transaction sequence number, comparing the transaction identification in the rollback transaction event to transaction identifications of a plurality of executed branch transactions of the global transaction, comprising: the difference between the transaction sequence number in the rollback transaction event and the transaction sequence numbers of the plurality of executed branch transactions is determined.
In practical application, the transaction identifier may be a transaction sequence number, where the transaction sequence number may be an arabic number, and a specific implementation manner of comparing the transaction identifier in the rollback transaction event with the transaction identifiers of the plurality of executed branch transactions of the global transaction may include: for each executed branch transaction, calculating a difference value between the transaction sequence number in the rollback transaction event and the transaction sequence number of the executed branch transaction to obtain a plurality of difference values, and determining which branch transaction to rollback to according to the plurality of difference values.
In one implementation, step S302, according to the comparison result, sequentially rolls back to the first executed branch transaction among the plurality of executed branch transactions, including: if the difference value between the transaction sequence number in the rollback transaction event and the transaction sequence number of the executed branch transaction is a preset value, determining the executed branch transaction as a target branch transaction; sequentially rollback from the plurality of target branch transactions to a first executed branch transaction of the plurality of executed branch transactions.
In practical application, under the condition that the transaction identifier is a transaction sequence number, for the difference value between the transaction sequence number in the rollback transaction event and the transaction sequence numbers of the plurality of executed branch transactions, if one difference value is a preset value, for example, the preset value may be 1, the branch transaction corresponding to the executed transaction sequence number is used as a target branch transaction, rolled back to the target branch transaction, and then sequentially rolled back from the target branch transaction to the branch transaction executed first in the plurality of executed branch transactions.
In one implementation, sequentially rolling back from a plurality of target branch transactions to a first executed branch transaction of a plurality of executed branch transactions, includes: rollback to the target branch transaction, generating a rollback transaction event of the target branch transaction; rollback to the next target branch transaction according to the rollback transaction event of the current target branch transaction; from the plurality of target branch transactions, sequentially rollback to a first executed branch transaction of the plurality of executed branch transactions.
After the target branch transaction is rolled back, a rollback transaction event of the target branch transaction is generated, the rollback transaction event of the target branch transaction comprises a transaction sequence number of the target branch transaction, the transaction sequence number of the target branch transaction is continuously compared with the transaction sequence numbers of the executed branch transactions, a difference value between the transaction sequence numbers of the target branch transaction and the transaction sequence numbers of the executed branch transactions is calculated, if one difference value is a preset value, the next target branch transaction is obtained, and the rollback is continuously carried out in sequence in this way until the first executed branch transaction in the executed branch transactions is rolled back.
In one implementation, rolling back to a next target branch transaction based on a rollback transaction event for a current target branch transaction, includes: determining a next target branch transaction according to the transaction sequence number in the rollback transaction event of the current target branch transaction; and rolling back to the next target branch transaction according to the context information in the rollback transaction event of the current target branch transaction.
The rollback transaction event comprises a transaction sequence number and context information, wherein the context information comprises application execution flow link information, and the application execution flow link information comprises interface functions and the like which are called in the application execution process. Determining which executed branch transaction is the next target branch transaction according to the difference value between the transaction sequence number in the rollback transaction event and the transaction sequence number of the executed branch transaction, and rolling back to the next target branch transaction by utilizing the context information.
In one implementation, from a plurality of target branch transactions, sequentially rollback to a first executed branch transaction of a plurality of executed branch transactions, further comprising: and sequentially rolling back from the current target branch transaction to the first executed branch transaction in the plurality of executed branch transactions, and generating a rollback transaction event of the first executed branch transaction.
In the example shown in connection with fig. 1 and 2, when the Local Tx4 fails to execute, RBEvent4 generating the Local Tx4 is monitored, the Local Tx4 is rolled back to the Local Tx3, RBEvent3 generating the Local Tx3, the Local Tx3 is rolled back to the Local Tx2, RBEvent2 generating the Local Tx2, the Local Tx1 is generated from the Local Tx2 to the branch transaction executed first of the Local Tx1, and the Local Tx1 of the Local Tx1 is generated, thereby completing the whole rollback process.
In a specific example, the global transaction may be an application for online shopping, which may include a plurality of micro-services: order services, consumer services, inventory add-drop services, and payment services. The order service is used for creating orders; the consumer service is used for determining whether the consumer of the current order has authority to place an order; the inventory increasing and decreasing service is used for increasing and decreasing the inventory quantity of the commodities in the order; the payment service is used for the consumer to effect payment of the order. If the payment service finds that the order payment fails, the order is rolled back to the stock increasing and decreasing service, the stock increasing and decreasing service increases the deducted stock back again, and the like, and finally the order service is rolled back, and the created order is withdrawn.
In one implementation, in step S301, acquiring actual execution sequence information of a plurality of executed branch transactions of a global transaction includes: acquiring sequence mark logs corresponding to a plurality of executed branch transactions of the global transaction respectively; the sequence mark log corresponding to the branch transaction is generated when the execution of the branch transaction is completed; actual execution order information for a plurality of executed branch transactions is determined based on the plurality of order marker logs.
In practical application, after each branch transaction is executed, a sequence mark log corresponding to the branch transaction is generated, and the log records the identification of the transaction. According to the sequence mark logs corresponding to the executed branch transactions respectively, the actual execution sequence of the executed branch transactions can be obtained.
In one implementation, the method further comprises: if the actual execution sequence information of the plurality of executed branch transactions is not matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, starting a flow engine, and driving the branch transactions of the global transaction to roll back the transactions by using the flow engine.
In practical applications, for branch transactions that are not global transactions that are executed in a determined order of execution, transaction rollback is performed by starting the flow engine.
In one example, a lightweight transaction link journaling system is established. Branch transactions are numbered sequentially, whether or not it is a transaction link that determines the order. The branch transactions Local Tx1, local Tx2, local Tx3, local Tx4, and Local Tx5 are numbered 1, 2, 3, 4, and 5, respectively. And each branch transaction is executed, a sequence mark log is sent, and the sequence mark log records the transaction identification of the branch transaction. When the rollback is triggered, the transaction link log processing system judges whether the actual execution sequence of the branch transaction is matched with the predetermined execution sequence or not according to the stored transaction link log, namely judges whether the branch transaction is a transaction link with the determined sequence or not. If the log numbers of the branch transactions of the current global transaction are continuous, determining a sequential transaction link; otherwise not. For example, if the execution order determined by the acquired order flag log is 1, 2, 3, 5, 4 after the Local Tx1, local Tx2, local Tx3, local Tx4, local Tx5 is executed, then it is not the transaction link that determines the order. If the execution order determined by the acquired order marker log is 1, 2, 3, 4, 5, then it is the transaction link that determines the order. If the transaction link is the transaction link with the determined sequence, the process is rolled back according to the reverse order of the actual execution sequence, and if not, the process engine is started to roll back the transaction.
Corresponding to the application scene and the method of the method provided by the embodiment of the application, the embodiment of the application also provides a distributed transaction rollback device. FIG. 4 is a block diagram illustrating a distributed transaction rollback apparatus according to an embodiment of the present application, the apparatus including:
the acquiring module 401 is configured to acquire actual execution sequence information of a plurality of executed branch transactions of a global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored.
A comparison module 402, configured to compare the transaction identifier in the rollback transaction event with the transaction identifiers of the plurality of executed branch transactions if the actual execution sequence information of the plurality of executed branch transactions matches the execution sequence information of the plurality of branch transactions of the predetermined global transaction; the transaction identification is determined based on the actual execution order of the plurality of executed branch transactions.
And a rollback module 403, configured to sequentially rollback to a first executed branch transaction among the plurality of executed branch transactions according to the comparison result.
The application provides a distributed transaction rollback device, which acquires actual execution sequence information of a plurality of executed branch transactions of a global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored; if the actual execution sequence information of the plurality of executed branch transactions is matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions; the transaction identification is determined according to the actual execution sequence of a plurality of executed branch transactions; and according to the comparison result, sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions. In this embodiment, for a branch transaction executed according to a determined execution sequence, that is, an actual execution sequence of the branch transaction is matched with a predetermined execution sequence, by comparing a transaction identifier in a rollback transaction event with transaction identifiers of a plurality of executed branch transactions, rollback of the executed branch transaction is implemented, and a manner driven based on the rollback transaction event is adopted, without introducing a flow engine, so that implementation cost of rollback of the transaction can be reduced.
In one implementation, the transaction identification is a transaction sequence number, and the comparison module 402 is configured to, when comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions: the difference between the transaction sequence number in the rollback transaction event and the transaction sequence numbers of the plurality of executed branch transactions is determined.
In one implementation, rollback module 403 is configured to: if the difference value between the transaction sequence number in the rollback transaction event and the transaction sequence number of the executed branch transaction is a preset value, determining the executed branch transaction as a target branch transaction; sequentially rollback from the plurality of target branch transactions to a first executed branch transaction of the plurality of executed branch transactions.
In one implementation, rollback module 403, when sequentially rollback from a plurality of target branch transactions to a first executed branch transaction of a plurality of executed branch transactions, is to: rollback to the target branch transaction, generating a rollback transaction event of the target branch transaction; rollback to the next target branch transaction according to the rollback transaction event of the current target branch transaction; from the plurality of target branch transactions, sequentially rollback to a first executed branch transaction of the plurality of executed branch transactions.
In one implementation, rollback module 403 is configured to, upon rollback to a next target branch transaction according to a rollback transaction event for a current target branch transaction:
determining a next target branch transaction according to the transaction sequence number in the rollback transaction event of the current target branch transaction;
and rolling back to the next target branch transaction according to the context information in the rollback transaction event of the current target branch transaction.
In one implementation, rollback module 403, when sequentially rolling back from a plurality of target branch transactions to a first executed branch transaction of a plurality of executed branch transactions, is further to:
and sequentially rolling back from the current target branch transaction to the first executed branch transaction in the plurality of executed branch transactions, and generating a rollback transaction event of the first executed branch transaction.
In one implementation, the obtaining module 401 is configured to:
acquiring sequence mark logs corresponding to a plurality of executed branch transactions of the global transaction respectively; the sequence mark log corresponding to the branch transaction is generated when the execution of the branch transaction is completed;
actual execution order information for a plurality of executed branch transactions is determined based on the plurality of order marker logs.
In one implementation, the apparatus is further to:
if the actual execution sequence information of the plurality of executed branch transactions is not matched with the execution sequence information of the plurality of branch transactions of the predetermined global transaction, starting a flow engine, and driving the branch transactions of the global transaction to roll back the transactions by using the flow engine.
In one implementation, the branch transaction includes a microservice.
The functions of each module in each device of the embodiments of the present application may be referred to the corresponding descriptions in the above methods, and have corresponding beneficial effects, which are not described herein.
Fig. 5 is a block diagram of an electronic device used to implement an embodiment of the present application. As shown in fig. 5, the electronic device includes: memory 510 and processor 520, memory 510 stores a computer program executable on processor 520. The processor 520, when executing the computer program, implements the methods of the above-described embodiments. The number of memories 510 and processors 520 may be one or more.
The electronic device further includes:
and the communication interface 530 is used for communicating with external equipment and carrying out data interaction transmission.
If the memory 510, the processor 520, and the communication interface 530 are implemented independently, the memory 510, the processor 520, and the communication interface 530 may be connected to each other and communicate with each other through buses. The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component Interconnect, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The bus may be classified as an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in fig. 5, but not only one bus or one type of bus.
Alternatively, in a specific implementation, if the memory 510, the processor 520, and the communication interface 530 are integrated on a chip, the memory 510, the processor 520, and the communication interface 530 may communicate with each other through internal interfaces.
The present embodiments provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods provided in the embodiments of the present application.
The embodiment of the application also provides a chip, which comprises a processor and is used for calling the instructions stored in the memory from the memory and running the instructions stored in the memory, so that the communication device provided with the chip executes the method provided by the embodiment of the application.
The embodiment of the application also provides a chip, which comprises: the input interface, the output interface, the processor and the memory are connected through an internal connection path, the processor is used for executing codes in the memory, and when the codes are executed, the processor is used for executing the method provided by the application embodiment.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or any conventional processor or the like. It is noted that the processor may be a processor supporting an advanced reduced instruction set machine (Advanced RISC Machines, ARM) architecture.
Further alternatively, the memory may include a read-only memory and a random access memory. The memory may be volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), programmable ROM (PROM), erasable Programmable ROM (EPROM), electrically Erasable EPROM (EEPROM), or flash Memory, among others. Volatile memory can include random access memory (Random Access Memory, RAM), which acts as external cache memory. By way of example, and not limitation, many forms of RAM are available. For example, static RAM (SRAM), dynamic RAM (Dynamic Random Access Memory, DRAM), synchronous DRAM (SDRAM), double Data Rate Synchronous DRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), and Direct RAM (DR RAM).
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions in accordance with the present application are produced in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. Computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
Any process or method described in flow charts or otherwise herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing specific logical functions or steps of the process. And the scope of the preferred embodiments of the present application includes additional implementations in which functions may be performed in a substantially simultaneous manner or in an opposite order from that shown or discussed, including in accordance with the functions that are involved.
Logic and/or steps described in the flowcharts or otherwise described herein, e.g., may be considered a ordered listing of executable instructions for implementing logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions.
It is to be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above-described embodiments, the various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. All or part of the steps of the methods of the embodiments described above may be performed by a program that, when executed, comprises one or a combination of the steps of the method embodiments, instructs the associated hardware to perform the method.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing module, or each unit may exist alone physically, or two or more units may be integrated in one module. The integrated modules may be implemented in hardware or in software functional modules. The integrated modules described above, if implemented in the form of software functional modules and sold or used as a stand-alone product, may also be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a magnetic or optical disk, or the like.
The foregoing is merely exemplary embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily think of various changes or substitutions within the technical scope of the present application, which should be covered in the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (11)

1. A distributed transaction rollback method, the method comprising:
acquiring actual execution sequence information of a plurality of executed branch transactions of a global transaction when a rollback transaction event of the branch transaction of the global transaction is monitored;
if the actual execution sequence information of the executed branch transactions is matched with the execution sequence information of the predetermined branch transactions of the global transaction, comparing the transaction identification in the rollback transaction event with the transaction identifications of the executed branch transactions; the transaction identification is determined according to the actual execution sequence of the plurality of executed branch transactions;
and according to the comparison result, sequentially rolling back to the branch transaction executed first in the plurality of executed branch transactions.
2. The method of claim 1, wherein the transaction identification is a transaction sequence number, and wherein the comparing the transaction identification in the rollback transaction event with the transaction identifications of the plurality of executed branch transactions comprises:
a difference between the transaction sequence number in the rollback transaction event and the transaction sequence numbers of the plurality of executed branch transactions is determined.
3. The method according to claim 2, wherein the sequentially rolling back to the first executed branch transaction among the plurality of executed branch transactions according to the comparison result includes:
if the difference value between the transaction sequence number in the rollback transaction event and the transaction sequence number of the executed branch transaction is a preset value, determining the executed branch transaction as a target branch transaction;
sequentially rollback from the plurality of target branch transactions to a first executed branch transaction of the plurality of executed branch transactions.
4. A method according to claim 3, wherein said rolling back sequentially from a plurality of said target branch transactions to a first executed branch transaction of said plurality of executed branch transactions comprises:
rollback to the target branch transaction, generating a rollback transaction event for the target branch transaction;
according to the current rollback transaction event of the target branch transaction, rollback to the next target branch transaction;
and sequentially rolling back to the first executed branch transaction in the plurality of executed branch transactions from the plurality of target branch transactions.
5. The method of claim 4, wherein the rolling back to a next target branch transaction based on a rollback transaction event for the current target branch transaction comprises:
determining a next target branch transaction according to the transaction sequence number in the rollback transaction event of the current target branch transaction;
and rolling back to the next target branch transaction according to the context information in the rollback transaction event of the current target branch transaction.
6. The method of claim 4, wherein the rolling back from the plurality of target branch transactions to a first executed branch transaction of the plurality of executed branch transactions in turn further comprises:
and sequentially rolling back from the current target branch transaction to the first executed branch transaction in the plurality of executed branch transactions, and generating a rollback transaction event of the first executed branch transaction.
7. The method according to any one of claims 1-6, wherein said obtaining actual execution order information of a plurality of executed branch transactions of said global transaction comprises:
acquiring sequence mark logs corresponding to a plurality of executed branch transactions of the global transaction respectively; the sequence mark log corresponding to the branch transaction is generated when the execution of the branch transaction is completed;
and determining the actual execution sequence information of the executed branch transactions according to the sequence mark logs.
8. The method according to any one of claims 1-6, further comprising:
if the actual execution sequence information of the plurality of executed branch transactions is not matched with the execution sequence information of the plurality of branch transactions of the global transaction, starting a flow engine, and driving the branch transactions of the global transaction to roll back the transactions by using the flow engine.
9. The method of any of claims 1-6, wherein the branch transaction comprises a microservice.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory, the processor implementing the method of any one of claims 1-9 when the computer program is executed.
11. A computer readable storage medium having stored therein a computer program which, when executed by a processor, implements the method of any of claims 1-9.
CN202310273295.9A 2023-03-20 2023-03-20 Distributed transaction rollback method, electronic equipment and storage medium Pending CN116302702A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310273295.9A CN116302702A (en) 2023-03-20 2023-03-20 Distributed transaction rollback method, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310273295.9A CN116302702A (en) 2023-03-20 2023-03-20 Distributed transaction rollback method, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116302702A true CN116302702A (en) 2023-06-23

Family

ID=86781246

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310273295.9A Pending CN116302702A (en) 2023-03-20 2023-03-20 Distributed transaction rollback method, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116302702A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056116A (en) * 2023-10-11 2023-11-14 荣耀终端有限公司 Flow management method and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117056116A (en) * 2023-10-11 2023-11-14 荣耀终端有限公司 Flow management method and electronic equipment
CN117056116B (en) * 2023-10-11 2024-04-02 荣耀终端有限公司 Flow management method and electronic equipment

Similar Documents

Publication Publication Date Title
US20210157800A1 (en) Blockchain-based transaction processing methods, apparatuses, and electronic devices
US20210150519A1 (en) Blockchain-based transaction processing method and apparatus and electronic device
US20200134737A1 (en) Blockchain-based transaction processing method, apparatus, and electronic device
US11250395B2 (en) Blockchain-based transaction processing methods and apparatuses and electronic devices
CN112016921B (en) Transaction processing method, device and equipment
CN112131504B (en) Webpage editing and displaying method, device, equipment and storage medium
CN110413507B (en) System test method, device, computer equipment and storage medium
CN108846763A (en) Core protects request processing method, device, computer equipment and storage medium
CN112817995B (en) Data processing method and device, electronic equipment and storage medium
CN116302702A (en) Distributed transaction rollback method, electronic equipment and storage medium
CN110955724A (en) Data processing method and device based on block chain, node equipment and storage medium
EP3779755A1 (en) A computer-implemented method for cross-chain-interoperability
CN111047322A (en) Intelligent contract deployment method and device based on block chain and hardware equipment
CN109711809A (en) Trade company's property setting method, device, computer equipment and storage medium
CN111506784B (en) Asset creditor matching method, device, computer equipment and storage medium
CN114092074A (en) Channel routing-based transaction method and device, computer equipment and storage medium
CN114265997B (en) Page information output method, device, storage medium and terminal
CN116485514B (en) Wind control processing method and device, electronic equipment and computer readable storage medium
CN112149951A (en) Risk control method and device, computer equipment and storage medium
CN111507783B (en) Electronic bill pushing method and device, blockchain node equipment and storage medium
CN112907278B (en) Rights object distribution control method and device, equipment and medium thereof
CN118467798B (en) Product matching method, device, equipment and medium
CN114422594B (en) Service processing method, device, computer equipment and storage medium
CN118780906A (en) Method, device, equipment and storage medium for managing amount
CN108536438B (en) Dotting module, method and computer readable medium for processing user behavior data

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