Distributed transaction processing method, apparatus, and electronic device

CN115390998BActive Publication Date: 2026-09-25CHINA UNITED NETWORK COMM GRP CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110574442.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-25
Publication Date
2026-09-25
Estimated Expiration
2041-05-25

AI Technical Summary

Technical Problem

[0005]本发明实施例提供一种分布式事务处理方法、装置及电子设备,以避免二阶段实现分布式事务实现过程中资源一直被锁定,导致业务无法正常实现的问题

Benefits of technology

[0037]第五方面,本发明实施例提供一种计算机程序产品,包括计算机程序,所述计算机程序被处理器执行时,实现如上第一方面以及第一方面各种可能的设计所述的分布式事务处理方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115390998B_ABST
    Figure CN115390998B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a distributed transaction processing method, device and electronic equipment, the method comprises real-time monitoring to be processed business, and when listening to to be processed business request database, the corresponding database instruction and the preset storage space are obtained when to be processed business request database, the database instruction is stored to the storage space, whether to be processed business is judged to be processed, the judgment result is obtained, if the judgment result is no, then continue to listen to to be processed business, and when listening to to be processed business request database, new database instruction is obtained, and new database instruction is stored in the storage space, if the judgment result is yes, then at least one database instruction in the storage space is executed in batches to realize to be processed business. Reduce the blocking between different services, guarantee the normal realization of business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a distributed transaction processing method, apparatus and electronic device. Background Technology

[0002] Distributed transactions refer to transactions where the participants, supporter servers, resource servers, and coordinators are located on different nodes of different distributed systems. Alternatively, it can be understood as a large operation consisting of different smaller operations distributed across different servers and belonging to different business applications.

[0003] In existing technologies, the implementation process of distributed transactions mainly includes two phases: a prepare phase and a commit phase. In the prepare phase, the coordinator sends a prepare message to each participant. Each database participant executes the transaction locally and writes to its local undo / redo logs; at this stage, the transaction is not committed. In the commit phase, if the coordinator receives a failure or timeout message from a participant, it directly sends a rollback message to each participant; otherwise, it sends a commit message. Participants can then execute the commit or rollback operation according to the coordinator's instructions and release the resources locked during the transaction processing.

[0004] However, in the process of implementing distributed transactions in the above two stages, all participating nodes are transaction-blocking. When a participant holds a shared resource, other participating nodes must be in a blocked state when accessing the shared resource. Furthermore, if a service fails, all participants are in a state of locking transaction resources and cannot continue to complete subsequent operations of the transaction, affecting the normal implementation of the business. Summary of the Invention

[0005] This invention provides a distributed transaction processing method, apparatus, and electronic device to avoid the problem that resources are locked during the two-phase distributed transaction implementation process, causing business operations to fail to function normally.

[0006] In a first aspect, embodiments of the present invention provide a distributed transaction processing method, comprising:

[0007] Real-time monitoring of pending business transactions, and when a pending business transaction requests the database, obtaining the corresponding database instruction and preset storage space;

[0008] Store the database instructions in the storage space;

[0009] Determine whether the pending service has been completed, and obtain the determination result;

[0010] If the judgment result is negative, then continue to monitor the pending business, and when the pending business requests the database, obtain a new database instruction and store the new database instruction in the storage space;

[0011] If the judgment result is yes, then at least one database instruction in the storage space is executed in batches to realize the business to be processed.

[0012] Optionally, the service to be processed includes a first service and at least one second service.

[0013] The step of obtaining the database instruction corresponding to the pending business request database and the preset storage space when the pending business request database is detected includes:

[0014] When the first service request database in the pending business is detected, the first database instruction corresponding to the first service request database in the pending business and the preset storage space corresponding to the pending business are obtained.

[0015] The step of storing the database instructions into the storage space includes:

[0016] The first database instruction is stored in the storage space.

[0017] Optionally, the storage space includes a storage space identifier, and after storing the first database instruction to the storage space, the method further includes:

[0018] If the first service is detected to be calling any of the second services, the storage space identifier is sent to the second service so that the second service can perform verification based on the storage space identifier;

[0019] If a successful verification message is received from the second service, then continue to listen for the first database command corresponding to the first service and the second database command corresponding to the second service;

[0020] The monitored first database instructions and second database instructions are stored in the storage space, and when the pending business is completed, the first database instructions and second database instructions in the storage space are executed in batches.

[0021] Optionally, the method further includes:

[0022] If a verification failure message is received from the second service, the storage space is released and a message indicating that the pending business execution has failed is generated.

[0023] Optionally, the method further includes:

[0024] If all database instructions in the storage space are executed successfully, a success message will be generated.

[0025] Optionally, the method further includes:

[0026] If any database instruction in the storage space fails to execute, the database instruction in the storage space is rolled back.

[0027] In a second aspect, embodiments of the present invention provide a distributed transaction processing apparatus, comprising:

[0028] The acquisition module is used to monitor pending business in real time, and when it detects that the pending business requests the database, it acquires the database instruction corresponding to the pending business requesting the database and the preset storage space.

[0029] The processing module is used to store the database instructions into the storage space;

[0030] The processing module is also used to determine whether the pending business has been processed and to obtain a determination result;

[0031] The processing module is further configured to continue listening to the pending business if the judgment result is negative, and when the pending business requests the database, obtain a new database instruction and store the new database instruction in the storage space.

[0032] The processing module is further configured to, if the judgment result is yes, execute at least one database instruction in the storage space in batches to realize the business to be processed.

[0033] Thirdly, embodiments of the present invention provide an electronic device, comprising: at least one processor and a memory;

[0034] The memory stores computer-executed instructions;

[0035] The at least one processor executes computer execution instructions stored in the memory, causing the at least one processor to perform the distributed transaction processing method as described in any of the first aspects.

[0036] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the distributed transaction processing method as described in any of the first aspects.

[0037] Fifthly, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the distributed transaction processing method described in the first aspect and various possible designs of the first aspect.

[0038] This invention provides a distributed transaction processing method, apparatus, and electronic device. By employing the above scheme, it can monitor pending business transactions in real time. When a pending business request to the database is detected, the system obtains the corresponding database instruction and storage space, stores the database instruction in the corresponding storage space, and then determines whether the pending business has been completed. If the result is negative, it continues to monitor the pending business and, upon detecting a pending business request to the database, obtains a new database instruction and stores it in the storage space. If the result is positive, it executes at least one database instruction from the storage space in batches, thereby realizing the pending business. By storing the database instruction in the storage space before submitting it and then executing it in batches after the business is completed, a transaction processing method that simultaneously submits database instructions corresponding to a business transaction is achieved, reducing blocking between different services and ensuring the normal implementation of the business. Attached Figure Description

[0039] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0040] Figure 1 This is a schematic diagram illustrating the application of distributed transaction processing in the prior art, as provided in the embodiments of the present invention.

[0041] Figure 2 This is a flowchart illustrating the distributed transaction processing method provided in an embodiment of the present invention.

[0042] Figure 3 A flowchart illustrating a distributed transaction processing method provided in another embodiment of the present invention;

[0043] Figure 4 This is a schematic diagram of the structure of a distributed transaction processing device provided in an embodiment of the present invention;

[0044] Figure 5 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0046] The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can also include other sequential examples besides those illustrated or described. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0047] In existing technologies, the implementation process of distributed transactions mainly includes two phases: a prepare phase and a commit phase. Specifically, Figure 1 This is a schematic diagram illustrating the application of distributed transaction processing in the prior art provided by the embodiments of the present invention, such as... Figure 1 a and Figure 1 As shown in Figure b, this represents the successful commit of a distributed transaction. During the Prepare phase, the coordinator sends a Prepare message to each participant. Each database participant executes the transaction locally and writes to its local Undo / Redo logs. At this point, the transaction is not committed. (The Undo log records the data before modification, used for database rollback; the Redo log records the data after modification, used for writing to the data file after transaction commit.) During the Commit phase, if the coordinator receives a participant's execution failure or timeout message, it directly sends a Rollback message to each participant; otherwise, it sends a Commit message. Participants execute the commit or rollback operation according to the coordinator's instructions and release the resources locked during the transaction processing. It is crucial to release lock resources in the final phase. Figure 1 c and Figure 1As shown in Figure d, this illustrates a scenario where a distributed transaction commit fails. Potential problems during the two-phase commit process include: all participants are in a synchronous blocked state during the commit phase, consuming system resources and potentially leading to performance bottlenecks. If the coordinator experiences a single point of failure or fails, participants will remain locked. Furthermore, in phase two of the two-phase commit, if a local network anomaly occurs after the coordinator sends the commit request to the participants, or if the coordinator fails during the commit request process, only a portion of the participants may receive the commit request. This can lead to inconsistencies in the data received by the participants, impacting the normal operation of the business.

[0048] To address the aforementioned issues, this application addresses the problem by storing database commands in storage space before submitting them, and then executing them in batches after the business process is complete. This approach enables a transaction processing method where database commands corresponding to a business operation must be submitted simultaneously, achieving the technical effect of reducing blocking between different services while ensuring the normal implementation of the business.

[0049] The technical solution of the present invention will be described in detail below with reference to specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0050] Figure 2 This is a flowchart illustrating a distributed transaction processing method provided in an embodiment of the present invention. The method in this embodiment can be executed by a server. Figure 2 As shown, the method in this embodiment may include:

[0051] S201: Monitor pending business transactions in real time, and when a pending business transaction requests the database, obtain the corresponding database instruction and the preset storage space.

[0052] In this embodiment, the status of the pending business can be monitored in real time during its execution. If it is detected that the pending business needs to request the database, the database instruction corresponding to the request can be obtained, and the corresponding preset storage space can be acquired.

[0053] In addition, the pending business may involve one or more services during the execution process.

[0054] S202: Store the database command in the storage space.

[0055] In this embodiment, the preset storage space can be newly acquired storage space, i.e., storage space that has not yet stored database instructions, or storage space that has already stored database instructions corresponding to other pending services and has sufficient remaining space. Furthermore, when allocating storage space for pending services, the corresponding storage space can be distinguished and allocated through storage space identifiers.

[0056] In addition, if the business to be processed involves only one service during the execution process, the service can be monitored in real time. When the service requests the database, the corresponding database instruction and the preset storage space can be obtained. Then, the database instruction corresponding to the service can be stored in the storage space.

[0057] If the pending business involves multiple services during execution, for example, two, three or more services may be involved, and the services may call each other to realize the pending business.

[0058] Furthermore, the pending business includes a first service and at least one second service.

[0059] When the pending business request database is detected, the database instruction corresponding to the pending business request database and the preset storage space are obtained, which may specifically include:

[0060] When the first service request database is detected in the pending business, the first database instruction corresponding to the first service request database in the pending business and the preset storage space corresponding to the pending business are obtained.

[0061] Store the first database instruction in the storage space.

[0062] Specifically, the service that first requests the database in the pending business can be called the first service, and the others can be called the second service. When the first service in the pending business requests the database, the first database instruction corresponding to the first service's database request and the preset storage space corresponding to the pending business can be obtained. Then, the first database instruction is stored in the storage space. The storage space can be a queue.

[0063] Additionally, the storage space may include a storage space identifier, and after storing the first database instruction to the storage space, it may also include:

[0064] If the first service is detected calling any second service, the storage space identifier will be sent to the second service so that the second service can perform verification based on the storage space identifier.

[0065] If a successful verification message is received from the second service, then continue to listen for the first database command corresponding to the first service and the second database command corresponding to the second service.

[0066] The monitored first database instructions and second database instructions are stored in the storage space, and when the pending business is completed, the first database instructions and second database instructions in the storage space are executed in batches.

[0067] Specifically, after storing the first database instruction in the storage space, the system can continue to monitor the first and second services. When either the first or second service calls the database, the corresponding call instruction can be stored in the storage space. Once the pending business processing is complete, the database instructions in the storage space are executed in batches. The storage space contains each first database instruction corresponding to the first service and each second database instruction corresponding to the second service. During the execution of the database instructions, they can be executed sequentially according to their storage time.

[0068] In addition, during the execution of pending business operations, the first service may need to call the second service. When the first service calls the second service, in order to ensure the security and accuracy of the data, the second service can first perform verification, and then execute the subsequent program after the verification is passed.

[0069] Furthermore, storage unit existence verification and business idempotency verification can be performed. The specific verification methods can be selected from existing verification methods, which will not be discussed in detail here.

[0070] S203: Determine whether the pending business has been completed and obtain the determination result.

[0071] In this embodiment, during the process of monitoring pending services, whether the pending service includes one service or multiple services, it is necessary to determine in real time whether the pending service has been completed and obtain the determination result.

[0072] Furthermore, the determination of whether a pending business transaction has been completed can be made by the business side itself. In synchronous scenarios, this is usually determined by the first service (the business initiator service), while in asynchronous scenarios, it is usually determined by the last service (the business endpoint).

[0073] S204: If the judgment result is negative, continue to listen for pending business requests, and when a pending business request to the database is detected, obtain the new database instruction and store the new database instruction in the storage space.

[0074] In this embodiment, the judgment result can include two types: one is that the pending business has been processed (i.e., the judgment result is yes), and the other is that the pending business has not been processed (i.e., the judgment result is no). The subsequent processing procedures corresponding to the two results are also different.

[0075] If the judgment result is negative, it indicates that the pending business has not been completed. In this case, it is necessary to continue listening to the pending business during its execution. When a database request is detected from the pending business, new database instructions should be obtained and stored in the storage space until the pending business is completed.

[0076] S205: If the judgment result is yes, then execute at least one database instruction in the storage space in batches to realize the business to be processed.

[0077] In this embodiment, if the determination result is yes, it indicates that the pending business processing is complete, and all database instructions stored in the storage space can be executed in batches. Specifically, if there is only one database instruction in the storage space, only that instruction is executed; if there are multiple database instructions in the storage space, each instruction can be executed sequentially according to its acquisition time.

[0078] After adopting the above scheme, pending business operations can be monitored in real time. When a pending business request to the database is detected, the corresponding database instruction and storage space are obtained and stored in the corresponding storage space. Then, it is determined whether the pending business has been processed. If the result is negative, the monitoring of the pending business continues, and when a pending business request to the database is detected, a new database instruction is obtained and stored in the storage space. If the result is positive, at least one database instruction in the storage space is executed in batches to realize the pending business. By storing the database instruction in the storage space when submitting the operation database instruction, and then executing the database instructions in the storage space in batches after the business is processed, a transaction processing method that submits database instructions corresponding to a business operation simultaneously is realized, reducing blocking between different services and ensuring the normal implementation of the business.

[0079] based on Figure 2 In addition to the method described herein, this specification also provides some specific implementation schemes of the method, which will be described below.

[0080] Furthermore, in another embodiment, the method may further include:

[0081] If a verification failure message is received from the second service, the storage space is released and a message indicating that the pending business execution has failed is generated.

[0082] In this embodiment, during the second service verification process, verification may fail. Specifically, this could be due to the storage space to be verified not existing, or the service being non-idempotent. If verification fails, a verification failure notification can be sent to the server. The server will then release the storage space based on the notification and generate a message indicating that the pending service execution has failed.

[0083] Furthermore, in another embodiment, the method may further include:

[0084] If all database commands in the storage space are executed successfully, a success message will be generated.

[0085] If any database instruction in the storage space fails to execute, the database instruction in the storage space will be rolled back.

[0086] In this embodiment, to improve the user experience, a success message can be generated after all database instructions in the storage space have been executed successfully, to remind the user that all instructions have been executed successfully, that is, the pending business has been successfully completed.

[0087] Furthermore, if any database command in the storage space fails to execute, in order to ensure the consistency of data among all participants (different services can represent different participants), all database commands in the storage space can be rolled back. That is, none of the database commands in the storage space are executed, and the database commands involved in the pending business are retrieved again, thus avoiding the problem of data inconsistency among participants and ensuring the normal implementation of the business.

[0088] Figure 3 A flowchart illustrating a distributed transaction processing method provided in another embodiment of the present invention is shown below. Figure 3As shown, in this embodiment, a microservice on a server can be started first as a repository service. Then, multiple microservices (e.g., service A and service B) are started. According to the business process, before the first microservice executes database operations, it obtains a storage space from the repository service. This storage space must be globally unique. When calling the repository service to execute database commands, the storage space identifier needs to be sent to the repository service. When the repository service receives an operation with available storage space, it does not execute the database command but first stores it in the queue corresponding to the storage space. If the first microservice needs other microservices to perform database operations, it can remotely call those other services. After receiving the command, the other services can call the repository service to execute the operation, specifying the storage space for storing the database command through the storage space identifier. Furthermore, other services can perform business validation. If validation fails, the storage space can be canceled at any time, avoiding resource waste. Furthermore, once the business process is complete, the storage space can be submitted to the warehousing service. Only after submission will all database instructions in the storage space queue be executed, ensuring the consistency and integrity of database instructions. This also reduces blocking between different services, controls the submission and rollback of database transactions across services, reduces performance overhead, and increases flexibility.

[0089] Based on the same idea, this specification also provides an apparatus corresponding to the above method. Figure 4 This is a schematic diagram of the structure of the distributed transaction processing device provided in an embodiment of the present invention, as shown below. Figure 4 As shown, it may include:

[0090] The acquisition module 401 is used to monitor pending business in real time, and when it detects that the pending business requests the database, it acquires the database instruction corresponding to the pending business requesting the database and the preset storage space.

[0091] In this embodiment, the service to be processed includes a first service and at least one second service.

[0092] The acquisition module 401 is further configured to:

[0093] When the first service request database in the pending business is detected, the first database instruction corresponding to the first service request database in the pending business and the preset storage space corresponding to the pending business are obtained.

[0094] The processing module 402 is used to store database instructions into the storage space.

[0095] In this embodiment, the processing module 402 is further configured to:

[0096] The first database instruction is stored in the storage space.

[0097] The storage space includes a storage space identifier, and the processing module 402 is further configured to:

[0098] If the first service is detected to be calling any second service, the storage space identifier is sent to the second service so that the second service can perform verification based on the storage space identifier.

[0099] If a successful verification message is received from the second service, then continue to listen for the first database command corresponding to the first service and the second database command corresponding to the second service.

[0100] The monitored first database instructions and second database instructions are stored in the storage space, and when the pending business is completed, the first database instructions and second database instructions in the storage space are executed in batches.

[0101] The processing module 402 is also used to determine whether the pending service has been processed and to obtain a determination result.

[0102] The processing module 402 is further configured to continue listening to the pending business if the judgment result is negative, and when the pending business requests the database, obtain a new database instruction and store the new database instruction in the storage space.

[0103] The processing module 402 is further configured to, if the judgment result is yes, execute at least one database instruction in the storage space in batches to realize the business to be processed.

[0104] Furthermore, in another embodiment, the processing module 402 is also used for:

[0105] If a verification failure message is received from the second service, the storage space is released and a message indicating that the pending business execution has failed is generated.

[0106] Furthermore, in another embodiment, the processing module 402 is also used for:

[0107] If all database instructions in the storage space are executed successfully, a success message will be generated.

[0108] If any database instruction in the storage space fails to execute, the database instruction in the storage space is rolled back.

[0109] The apparatus provided in this embodiment of the invention can achieve the above-mentioned... Figure 2 The methods in the embodiments shown are similar in principle and technical effect, and will not be described again here.

[0110] Figure 5 A schematic diagram of the hardware structure of the electronic device provided in the embodiments of the present invention, such as... Figure 5 As shown, the device 500 provided in this embodiment includes at least one processor 501 and a memory 502. The processor 501 and the memory 502 are connected via a bus 503.

[0111] In a specific implementation, at least one processor 501 executes computer execution instructions stored in the memory 502, causing at least one processor 501 to execute the method in the above method embodiment.

[0112] The specific implementation process of processor 501 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0113] In the above Figure 5 In the illustrated embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.

[0114] The memory may include high-speed RAM, and may also include non-volatile storage (NVM), such as at least one disk storage.

[0115] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.

[0116] This invention also provides a computer-readable storage medium storing computer-executable instructions. When a processor executes the computer-executable instructions, it implements the distributed transaction processing method described in the above method embodiments.

[0117] This invention also provides a computer program product, including a computer program that, when executed by a processor, implements the distributed transaction processing method described above.

[0118] The aforementioned computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.

[0119] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.

[0120] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0121] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A distributed transaction processing method, characterized in that, include: Real-time monitoring of pending services, wherein the pending services include a first service and at least one second service; When the first service request database in the pending business is detected, the first database instruction corresponding to the first service request database in the pending business and the preset storage space corresponding to the pending business are obtained. Store the first database instruction into the storage space; If the first service is detected to be calling any of the second services, the storage space identifier is sent to the second service so that the second service can perform verification based on the storage space identifier; If a successful verification message is received from the second service, then continue to listen for the first database command corresponding to the first service and the second database command corresponding to the second service; The first database instructions and the second database instructions that are monitored are stored in the storage space, and when the pending business is completed, the first database instructions and the second database instructions in the storage space are executed in batches. Determine whether the pending service has been completed, and obtain the determination result; If the judgment result is negative, then continue to monitor the pending business, and when the pending business requests the database, obtain a new database instruction and store the new database instruction in the storage space; If the judgment result is yes, then at least one database instruction in the storage space is executed in batches to realize the business to be processed.

2. The method according to claim 1, characterized in that, Also includes: If a verification failure message is received from the second service, the storage space is released and a message indicating that the pending business execution has failed is generated.

3. The method according to any one of claims 1-2, characterized in that, The method further includes: If all database instructions in the storage space are executed successfully, a success message will be generated.

4. The method according to any one of claims 1-2, characterized in that, The method further includes: If any database instruction in the storage space fails to execute, the database instruction in the storage space is rolled back.

5. A distributed transaction processing device, characterized in that, include: The acquisition module is used to monitor pending services in real time, the pending services including a first service and at least one second service; When the first service request database in the pending business is detected, the first database instruction corresponding to the first service request database in the pending business and the preset storage space corresponding to the pending business are obtained. The processing module is used to store the first database instruction into the storage space; The processing module is further configured to send the storage space identifier to the second service if it detects that the first service calls any second service, so that the second service can perform verification based on the storage space identifier; If a successful verification message is received from the second service, then continue to listen for the first database command corresponding to the first service and the second database command corresponding to the second service; The first database instructions and the second database instructions that are monitored are stored in the storage space, and when the pending business is completed, the first database instructions and the second database instructions in the storage space are executed in batches. The processing module is also used to determine whether the pending business has been processed and to obtain a determination result; The processing module is further configured to continue listening to the pending business if the judgment result is negative, and when the pending business requests the database, obtain a new database instruction and store the new database instruction in the storage space. The processing module is further configured to, if the judgment result is yes, execute at least one database instruction in the storage space in batches to realize the business to be processed.

6. An electronic device, characterized in that, include: At least one processor and memory; The memory stores computer-executed instructions; The at least one processor executes the computer execution instructions stored in the memory, causing the at least one processor to perform the distributed transaction processing method as described in any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the distributed transaction processing method as described in any one of claims 1 to 4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the distributed transaction processing method as described in any one of claims 1 to 4.

Citation Information

Patent Citations

  • Batch task processing method and system

    CN108536532A