Transaction processing method and device, electronic equipment and storage medium

By presetting key sub-transactions in transaction transactions and performing compensation processing, the problem of inconsistency in transaction data is solved, and the accuracy of transaction status and transaction efficiency are improved.

CN119557311APending Publication Date: 2025-03-04BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411603387.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-11
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The existing technology has the problem of inconsistency in transaction data during the transaction process, especially after the sub-transaction execution fails, the transaction status confirmation is inaccurate, resulting in inefficiency and inconsistency in data.

Method used

By presetting key sub-transactions in transactions, if the current sub-transaction is a key sub-transaction or its previous sub-transactions fail to execute, compensation processing is performed; if the current sub-transactions are a key sub-transactions fail to execute, the transaction transaction is recorded as successful and stored in the transaction result table.

Benefits of technology

Improve the consistency of transaction data, ensure the accuracy of transaction status, improve transaction efficiency, and avoid errors caused by data inconsistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557311A_ABST
    Figure CN119557311A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a transaction processing method and device, electronic equipment and a storage medium. The method can be used in financial or other fields. The method comprises the steps of obtaining an execution result of a current executed sub-transaction; if the execution result indicates that the execution fails and the current sub-transaction is the key sub-transaction or the sub-transaction executed before the key sub-transaction, performing compensation processing on the successfully executed sub-transaction; and if the execution result indicates execution failure and the current sub-transaction is the sub-transaction executed after the key sub-transaction, storing successful transaction of the transaction in a transaction result table. According to the embodiment of the invention, the effect of improving data consistency can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a transaction processing method, device, electronic device and storage medium. Background Art

[0002] Transaction is a kind of business in the financial field, including deposits, withdrawals, transfers, remittances and other specific businesses. For example, from a business perspective, a transfer is a transfer of funds from a user's debit card, account or credit card to another user's debit card, account or credit card. From an accounting perspective, it involves two atomic transactions: the transfer of funds and the transfer of funds.

[0003] Among them, completing the transaction requires calling the action account operation and database operation. The current transaction process requires all steps to be completed before the transaction is confirmed to be completed, which leads to the problem of inconsistent transaction data. Summary of the invention

[0004] The embodiments of the present application provide a transaction processing method, device, electronic device and storage medium to improve the consistency of transaction data.

[0005] In a first aspect, an embodiment of the present application provides a method for processing a transaction, including: a transaction includes multiple sub-transactions, the multiple sub-transactions are executed in sequence, the multiple sub-transactions include: a key sub-transaction, and the method for processing the transaction includes:

[0006] Get the execution result of the current sub-transaction;

[0007] If the execution result indicates that the execution failed, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, compensation processing is performed on the subtransaction that has been successfully executed;

[0008] If the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the critical subtransaction, the transaction success is stored in the transaction result table.

[0009] In a possible implementation, compensating for a successfully executed subtransaction includes:

[0010] Determine that the transaction has failed, and update the successfully executed sub-transaction to failed.

[0011] The successfully executed subtransactions are rolled back in reverse order.

[0012] In a possible implementation, the method further includes: if the execution result indicates neither failure nor success, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, obtaining first transaction flow information of the current subtransaction; if the first transaction flow information indicates that the current subtransaction failed to execute, determining that the execution result is an execution failure.

[0013] In a possible implementation, the method further includes: if the execution result indicates neither failure nor success, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, interrupting the execution of the transaction.

[0014] In a possible implementation, the method further includes: if the first transaction information indicates that the current subtransaction is successfully executed, determining that the current subtransaction is successfully executed; and calling an asynchronous extension interface of the current subtransaction, where the asynchronous extension interface is used to execute a subtransaction after the current subtransaction.

[0015] In a possible implementation, if the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the critical subtransaction, it also includes: terminating the execution of the transaction and obtaining second transaction information; and storing the second transaction information as error data.

[0016] In a possible implementation, the method further includes: obtaining a compensation result; if the compensation result is neither a failure nor a success, obtaining compensation flow information; and determining whether the compensation result is successful according to the compensation flow information.

[0017] In a second aspect, an embodiment of the present application provides a transaction processing device, including a transaction including multiple sub-transactions, the multiple sub-transactions are executed in sequence, and the multiple sub-transactions include: a key sub-transaction, including:

[0018] The transaction processing module is used to obtain the execution result of the current sub-transaction;

[0019] A self-check module, used to perform compensation processing on the successfully executed subtransaction if the execution result indicates that the execution failed and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction;

[0020] The self-checking module is also used to store the transaction success in the transaction result table if the execution result indicates that the execution failed and the current subtransaction is a subtransaction executed after the key subtransaction.

[0021] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory, a processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory, so that the processor executes the first aspect above and / or various possible implementations of the first aspect.

[0022] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.

[0023] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.

[0024] The transaction transaction processing method, device, electronic device and storage medium provided in the embodiments of the present application obtain the execution result of the current subtransaction being executed; if the execution result indicates an execution failure, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, compensation processing is performed on the subtransaction that has been successfully executed; if the execution result indicates an execution failure, and the current subtransaction is a subtransaction executed after the critical subtransaction, the means of successful transaction of the transaction transaction are stored in the transaction result table, thereby achieving the effect of improving the consistency of transaction data. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0026] Figure 1 A schematic diagram of a scenario of a method for processing a transaction provided in this application;

[0027] Figure 2 Schematic diagram of the process of processing transaction affairs provided by this application Figure 1 ;

[0028] Figure 3 Schematic diagram of the process of processing transaction affairs provided by this application Figure 2 ;

[0029] Figure 4 A schematic diagram of the structure of a transaction processing device provided by the present application;

[0030] Figure 5 A schematic diagram of the structure of the electronic device provided in this application.

[0031] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION

[0032] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.

[0033] First, the terms involved in this application are explained:

[0034] Transaction: It is a program execution unit that accesses and possibly updates various data items in the database. A transaction consists of all operations performed between the start and end of the transaction.

[0035] SAGA mode: is a mode for implementing distributed transactions, which decomposes distributed transactions into a series of independent subtransactions (also called "steps"), and each subtransaction is submitted separately.

[0036] Figure 1 A schematic diagram of a scenario of a method for processing a transaction provided in this application, such as Figure 1 As shown, the specific application scenario of the present application is a transaction transaction such as a transfer transaction, where the transfer transaction is used to complete the transfer from account A to account B, wherein the transaction transaction includes multiple sub-transactions, for example, sub-transaction a1 to sub-transaction a4, and sub-transactions a1 to sub-transaction a4 are executed in sequence to realize the transfer.

[0037] Combined with the above scenario, it can be seen that in the prior art, it is necessary for all subtransactions a1 to a4 to be successfully executed before the transaction is determined to be successful. In this case, there is a problem of low transfer efficiency. For example, subtransaction a3 is used to transfer an amount to account a3, and subtransaction a4 is used to notify the transfer user of the successful transfer. If subtransaction a4 is not successfully executed, that is, the success is not notified, the transfer is actually successful, but the prior art confirms that the transfer is unsuccessful, and there is a problem of inconsistent transaction data.

[0038] The transaction processing method provided in the present application presets key sub-transactions. If the execution of a key sub-transaction or a transaction before the key sub-transaction fails, compensation processing can be performed to improve the transfer efficiency. If the execution of a sub-transaction after the key sub-transaction fails, it can be determined that the transaction execution is successful, thereby improving the consistency of transaction data.

[0039] It should be noted that the method and device for processing transaction affairs of the present application can be used in the financial field, and can also be used in any field other than the financial field. The application field of the method and device for processing transaction affairs of the present application is not limited.

[0040] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0041] Figure 2 Schematic diagram of the process of processing transaction affairs provided by this application Figure 1 ,like Figure 2 As shown, the method includes:

[0042] S201. Obtain the execution result of the current sub-transaction.

[0043] Reference Figure 1 , a transaction includes multiple sub-transactions, and the multiple sub-transactions are executed in sequence. The multiple sub-transactions include: preset key sub-transactions.

[0044] In an embodiment of the present application, a transaction coordinator is used to call up each sub-transaction to execute each sub-transaction in sequence and obtain the returned execution results. A transaction manager is used to record the flow information of each sub-transaction and store the recorded flow information in a transaction flow database.

[0045] In the embodiment of the present application, different transaction transactions include different numbers of multiple sub-transactions, each of which is used to complete a step in the transaction transaction. A corresponding key sub-transaction can be preset for each transaction transaction, and the transaction before the key sub-transaction and the key sub-transaction are successfully executed, indicating that the transaction is successful.

[0046] Furthermore, a critical subtransaction is a marked subtransaction among multiple subtransactions.

[0047] For example, refer to Figure 1 , the transaction is used to transfer an amount x from account A to account B, and the transaction includes: subtransaction a1, subtransaction a2, subtransaction a3 and subtransaction a4. Subtransaction a1 is used to implement fund verification, specifically, after receiving the transfer request from user p1, it verifies the funds under account A under user p1 according to the transfer request. If the funds meet the transfer amount requirement, subtransaction a2 is executed. Subtransaction a2 is used to deduct the amount x from account A, subtransaction a3 is used to increase the amount x under account B, and subtransaction a4 is used to notify user p1 and / or user p2 that the transfer is successful. In this transaction, subtransaction a3 is a key subtransaction, that is, if subtransaction a3 and the subtransaction a1 and subtransaction a2 before subtransaction a3 are all executed successfully, it can be determined that the transfer is successful, that is, the transfer from account A to account B is completed.

[0048] Furthermore, after each sub-transaction is executed, an execution result will be returned, which includes at least one of the following: successful execution, failed execution, and neither successful execution nor failed execution. Successful execution means that the corresponding sub-task is successfully executed, and failed execution means that the corresponding sub-task fails to execute. Both successful execution and non-failed execution means that it is uncertain whether the corresponding sub-transaction is successfully executed or failed. Both successful execution and non-failed execution include unclear results or execution timeout.

[0049] Among them, unclear or execution timeout means that it is uncertain whether the subtransaction is executed successfully.

[0050] S202: If the execution result indicates that the execution has failed, determine whether the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction.

[0051] If yes, execute S203; if no, execute S204.

[0052] S203: Perform compensation processing on the sub-transactions that have been successfully executed.

[0053] It can be understood that if the execution result indicates that the execution has failed, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, compensation processing is performed on the subtransaction that has been successfully executed.

[0054] In an embodiment of the present application, compensation processing is performed on sub-transactions that have been successfully executed, including: determining that the transaction has failed, updating the sub-transaction that has been successfully executed as an execution failure; and rolling back the sub-transactions that have been successfully executed in reverse order.

[0055] Among them, after each sub-transaction is successfully executed, the transaction information and execution result (failed execution) of the sub-transaction will be stored. If the transaction fails, in order to ensure the consistency of the transaction data. The successful execution of the sub-transaction needs to be updated to failed execution. For example, when executing a transaction, first execute sub-transaction a1. After the transaction of sub-transaction a1 is successful, the transaction information and execution result of sub-transaction a1 are stored (successful execution), and then execute sub-transaction a2. After the transaction of sub-transaction a2 is successful, the transaction information and execution result of sub-transaction a2 are stored (successful execution), and then execute sub-transaction a3. If sub-transaction a3 fails to execute, the transaction information and execution result of sub-transaction a3 are stored (failed execution). Among them, the failure of sub-transaction a3 can determine that the transaction has failed, and the execution results of sub-transaction a1 and sub-transaction a2 are updated to failure.

[0056] It can be understood that when the execution result of a critical sub-transaction or a sub-transaction before the critical sub-transaction indicates an execution failure, the transaction is determined to have failed, and the information on the transaction failure is stored in a transaction result table, where the transaction result table is used to record the final transaction status of the transaction.

[0057] Furthermore, the successfully executed subtransactions are rolled back in reverse order. In this embodiment, reverse order refers to the reverse order of the subtransactions executed in sequence. For example, Figure 1 In the example, if subtransactions a1 and a2 are executed successfully, and subtransaction a3 fails to execute, subtransaction a2 is rolled back first, and then subtransaction a1 is rolled back. Rollback refers to restoring the subtransaction to the state before execution. For example, if subtransaction a2 is used to deduct amount x from account A, the rollback is to return the amount x deducted from account A to account A. If subtransaction a1 is used to check the funds under account A, the corresponding rollback is to check whether the funds under account A are restored to the state before the deduction of amount x.

[0058] In one embodiment, before rolling back the successful sub-transaction, the process further includes: reversing the transaction.

[0059] In the embodiment of the present application, rollback processing is a type of compensation processing. In addition, compensation processing can be implemented in a variety of ways, which is not limited by the present application.

[0060] Furthermore, the method further includes: obtaining a compensation result; if the compensation result is neither a failure nor a success, obtaining compensation flow information; and determining whether the compensation result is successful according to the compensation flow information.

[0061] In the embodiment of the present application, the compensation process may also return a variety of situations such as compensation success, compensation failure, or non-failure and non-success (unclear or timed out). If the compensation is returned to be non-failure and non-successful, it is also necessary to call the compensation flow information to determine whether the actual compensation result is compensation success or compensation failure. If the compensation process cannot determine the actual compensation result, the compensation flow information may also be sent to the error handling module for error handling.

[0062] The compensation processing of this application can make the transaction data of each database return to the state before the transaction was executed after the transaction failed, thereby ensuring the consistency of the transaction data.

[0063] S204. Store the transaction success in the transaction result table.

[0064] It can be understood that if the execution result indicates that the execution failed, and the current sub-transaction is a sub-transaction executed after the key sub-transaction, the transaction success is stored in the transaction result table.

[0065] In the embodiment of the present application, whether the subtransaction after the key subtransaction is successfully executed is not very important to the transaction. For example, the key subtransaction is subtransaction a3, and subtransactions a1 to a3 are all successfully executed, then the transfer from user A to account B has been realized. For subtransaction a4, it is not important whether the user is notified of the success. Therefore, even if the subtransaction after the key subtransaction fails to execute, it can also be determined that the transaction is successful.

[0066] In fact, referring to the above example, after the sub-transaction a3 is successfully executed, the transaction is actually successful. If the transaction is recorded as failed because the sub-transaction a4 fails to execute, it will cause inconsistent transaction data. Therefore, this application records the success of the transaction under the favor of the sub-transaction transaction failure after the key sub-transaction, which can ensure the consistency of transaction data.

[0067] In the embodiment of the present application, the self-check module is used to obtain the transaction flow information of the sub-transaction from the transaction flow database to confirm the actual execution result of the sub-transaction, and automatically compensate for the sub-transaction whose execution result is a failure.

[0068] Furthermore, if the execution result indicates that the execution has failed, and the current subtransaction is a subtransaction executed after the critical subtransaction, it also includes: terminating the execution of the transaction and obtaining second transaction information; and storing the second transaction information as error data.

[0069] In an embodiment of the present application, the second transaction flow information records the execution process of the current sub-transaction, and the second transaction flow information is stored as error data, wherein the error data can be stored in an error database or other databases through an error processing module, and the error processing module can be used to process the error data subsequently.

[0070] In the embodiment of the present application, the error handling module has at least one of the following functions, such as error data storage, error data query and error data alarm, etc. Among them, when the error data includes preset alarm information, an alarm is issued to prompt the staff to handle the error.

[0071] It can be understood that in the embodiment of the present application, a critical subtransaction is a mark for a subtransaction, indicating that the subtransaction is a critical subtransaction, the subtransaction before the critical subtransaction is a compensable subtransaction, and the subtransaction after the critical subtransaction is an uncompensable subtransaction.

[0072] The transaction processing method provided in the embodiment of the present application obtains the execution result of the current subtransaction being executed; if the execution result indicates that the execution failed, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, compensation processing is performed on the subtransaction that has been successfully executed; if the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the critical subtransaction, the means of successful transaction of the transaction is stored in the transaction result table, so as to achieve the effect of improving the consistency of transaction data.

[0073] Figure 3 Schematic diagram of the process of processing transaction affairs provided by this application Figure 2 ,like Figure 3 As shown, in this embodiment Figure 2 Based on the embodiment, a method for processing a transaction is described in detail, and the method includes:

[0074] S301. Obtain the execution result of the current sub-transaction.

[0075] The specific implementation process of this step refers to S201 and will not be repeated here.

[0076] S302: Determine whether the execution result indicates execution failure.

[0077] If yes, execute S202 to S204, which will not be described in detail. If no, execute S303.

[0078] S303: Determine whether the execution result indicates that the execution is successful.

[0079] If yes, it means that the execution result of the current subtransaction is determined to be successful. If the current subtransaction is a subtransaction before the key subtransaction, the next subtransaction of the current subtransaction can be executed. If the current subtransaction is a key subtransaction or a subtransaction after the key subtransaction, the transaction success can be stored in the transaction result table. If there are subtransactions to be executed after the current subtransaction, the remaining subtransactions are executed in sequence.

[0080] For example, if the current subtransaction is subtransaction a1, after subtransaction a1 is successfully executed, subtransaction a2 is executed. If the current subtransaction is subtransaction a3, the transaction success is stored in the transaction result table, and then subtransaction a4 is executed.

[0081] If not, that is, it is determined that the execution result is neither a failure nor a success, then S304 is executed.

[0082] S304: interrupt the execution of the transaction and obtain the first transaction information of the current sub-transaction.

[0083] It can be understood that if the execution result indicates neither failure nor success, and the current subtransaction is a critical subtransaction or a subtransaction executed before a critical subtransaction, the execution of the transaction transaction is interrupted, and after a preset self-check time interval, the transaction self-check module is used to collect the first transaction flow information of the current subtransaction exception to confirm the actual execution result of the current subtransaction.

[0084] In addition, if the execution result indicates neither failure nor success, and the current subtransaction is a subtransaction executed after the key subtransaction, the transaction can be terminated and the transaction success can be stored in the transaction result table. It is also possible to use the transaction self-check module to collect the first transaction flow information of the current subtransaction exception after a preset self-check time interval to confirm the actual execution result of the current subtransaction.

[0085] S305: Determine whether the first transaction information indicates that the current sub-transaction has failed to execute.

[0086] If yes, execute S306; if no, execute S307.

[0087] In the embodiment of the present application, the first transaction flow information is information recorded during the execution of the current sub-transaction. The actual execution result of the current sub-transaction can be determined by analyzing the first transaction flow information.

[0088] S306: Determine that the execution result is execution failure.

[0089] It can be understood that if the first transaction information indicates that the current sub-transaction has failed to execute, the actual execution result of the current sub-task is determined to be an execution failure, wherein S202 to S204 are executed in the case of execution failure, which will not be repeated here.

[0090] S307: Determine that the execution of the current subtransaction is successful, and call the asynchronous extension interface of the current subtransaction.

[0091] It can be understood that if the first transaction information indicates that the current subtransaction is successfully executed, the current subtransaction is determined to be successfully executed; the asynchronous extension interface of the current subtransaction is called, and the asynchronous extension interface is used to execute the subtransaction after the current subtransaction. After the next subtransaction is executed, the next subtransaction is used as the current subtransaction to continue to execute S301, that is, the above process can be performed for each subtransaction.

[0092] Among them, the key subtransaction and each subtransaction before the key subtransaction have corresponding asynchronous extension interfaces. When a subtransaction returns an execution result that is neither successful nor failed, the execution of the transaction is interrupted, that is, the execution of the next subtransaction is no longer performed. When the subtransaction is determined to be executed successfully, the subtransaction asynchronous extension interface is called to continue executing the next subtransaction of the subtransaction.

[0093] In the embodiment of the present application, the processing logic of the asynchronous extension interface is customized, with the purpose of ensuring the complete execution of the transaction and the final consistency of the transaction data.

[0094] In another embodiment, the first transaction flow information may also indicate that the execution result of the current sub-transaction is "unclear". In this case, when the first transaction flow information indicates that the execution result is "unclear" or "execution failed", the first transaction flow information is recorded as transaction error information.

[0095] In one embodiment, an error handling module is used to determine whether the transaction in the transaction result table has reached a final state (transaction success or transaction failure).

[0096] Among them, if the final state is not reached, that is, the final state of the transaction is not stored in the transaction result table, then the transfer-in state of the transferee (account B) of the transaction is checked. If the transfer-in state of the transferee is a successful transfer-in, it means that the key sub-transaction is executed successfully, and the transaction is a successful transaction; if the transfer-in state of the transferee is a failed transfer-in, then continue to verify the transfer-out state of the transferor (account A). If the transfer-out state of the transferor is a successful transfer-out, the transfer-out transaction needs to be reversed. If the transferor fails, it means that the transaction is a failed transaction, and it is necessary to ensure that the final state in the transaction result table is not a failed transaction.

[0097] Furthermore, in the embodiment of the present application, it is implemented based on the SAGA model, wherein the transaction in the SAGA model is implemented through multiple subtransactions, and the present application can configure a compensation interface, a status query interface, a compensation status query interface, and an asynchronous extension interface for each subtransaction, and these interfaces are all idempotent, and these interfaces and the original forward interface are in the same component. Among them, the compensation interface is used to compensate the subtransaction, the status query interface is used to query the execution result of the subtransaction, and the compensation status query interface is used to query the compensation result.

[0098] In an embodiment of the present application, the transaction flow information of the entire execution process of the transaction can be stored in a transaction flow database, and a sub-transaction flow table and a transaction flow table are created in the transaction flow database, wherein the sub-transaction flow table is used to store the flow information for each sub-transaction, and the transaction flow table is used to store the flow information of the transaction.

[0099] In summary, the present application can uniformly and distributedly control transaction affairs and database operations in the financial field. By setting key sub-transactions, during the transaction process, when the key sub-transaction or the sub-transaction before the key sub-transaction returns unclear or the execution times out, the transaction can be interrupted and abnormal flow information can be obtained. When it is determined that the sub-transaction is actually executed successfully, the asynchronous extension interface is called to execute subsequent sub-transactions. When it is determined that the actual execution of the sub-transaction fails, compensation processing is performed. When it is determined that the actual execution of the sub-transaction is unclear, the transaction error data is recorded, thereby ensuring the consistency of the transaction data.

[0100] Figure 4 A schematic diagram of the structure of the transaction processing device provided by this application, such as Figure 4 As shown, the transaction processing device 40 provided in this embodiment includes:

[0101] The transaction processing module 401 is used to obtain the execution result of the current sub-transaction;

[0102] A self-check module 402, configured to, if the execution result indicates that the execution has failed and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, perform compensation processing on the subtransaction that has been successfully executed;

[0103] The self-check module 402 is further configured to store a transaction success in the transaction result table if the execution result indicates that the execution has failed and the current subtransaction is a subtransaction executed after the critical subtransaction.

[0104] In a possible implementation, when the self-check module 402 performs compensation processing on a sub-transaction that has been successfully executed, it is specifically used to: determine that the transaction has failed, and store the transaction failure in the transaction result table; and roll back the sub-transactions that have been successfully executed in reverse order.

[0105] In one possible implementation, the self-check module 402 is also used to obtain the first transaction flow information of the current subtransaction if the execution result indicates neither failure nor success, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction; if the first transaction flow information indicates that the current subtransaction failed to execute, determine that the execution result is an execution failure.

[0106] In a possible implementation, if the execution result indicates neither failure nor success, and the current subtransaction is a critical subtransaction or a subtransaction executed before the critical subtransaction, the transaction processing module 401 is further configured to interrupt the execution of the transaction.

[0107] In a possible implementation, the self-check module 402 is further used to: if the first transaction flow information indicates that the current subtransaction is executed successfully, determine that the current subtransaction is executed successfully; and call the asynchronous extension interface of the current subtransaction, where the asynchronous extension interface is used to execute the subtransaction after the current subtransaction.

[0108] In one possible implementation, if the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the critical subtransaction, the transaction processing module 401 is further used to: terminate the execution of the transaction, and the self-check module 402 is further used to: obtain the second transaction information; and store the second transaction information as error data.

[0109] In a possible implementation, the self-check module 402 is further used to: obtain a compensation result; if the compensation result is neither a failure nor a success, obtain compensation flow information; and determine whether the compensation result is successful according to the compensation flow information.

[0110] In summary, the present application also provides a transaction processing device, including: a transaction processing module, a self-checking module and an error processing module. Among them, the transaction processing module includes: a transaction coordinator and a transaction manager, wherein the transaction coordinator is used to call up subtransactions to execute each subtransaction in sequence, and the transaction manager is used to record the flow information of each subtransaction, and store the recorded flow information in the transaction flow database. The self-checking module is used to obtain the flow information of the subtransaction from the transaction flow database to confirm the actual execution result of the subtransaction, check the subtransaction with unclear execution results, perform automatic compensation processing or send query data to the error processing module, and after the self-checking service is completed, the flow information with errors can be sent as error data to the error processing module for processing, wherein the error processing module has at least one of the following functions, such as error data storage, error data query and error data alarm. Among them, the error processing module is used to store the error data in the transaction error database, and when the error data includes preset alarm information, an alarm is issued to prompt the staff to handle the error.

[0111] The transaction processing device provided in this embodiment can execute the method provided in the above method embodiment. Its implementation principle and technical effect are similar, and this embodiment will not be described in detail here.

[0112] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this application. Figure 5 As shown, the electronic device 50 provided in this embodiment includes: at least one processor 501 and a memory 502. Optionally, the device 50 also includes a communication component 503. The processor 501, the memory 502 and the communication component 503 are connected via a bus 504.

[0113] In a specific implementation process, at least one processor 501 executes the computer-executable instructions stored in the memory 502, so that at least one processor 501 executes the above method.

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

[0115] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0116] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.

[0117] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0118] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.

[0119] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.

[0120] The above-mentioned 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 memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.

[0121] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium 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 be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.

[0122] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0123] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0124] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0125] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0126] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0127] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A method for processing a transaction, characterized in that: The transaction includes multiple sub-transactions, which are executed in sequence. The multiple sub-transactions include: preset key sub-transactions. The processing method of the transaction includes: Get the execution result of the current sub-transaction; If the execution result indicates that the execution has failed, and the current subtransaction is the critical subtransaction or a subtransaction executed before the critical subtransaction, performing compensation processing on the subtransaction that has been successfully executed; If the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the key subtransaction, the transaction success is stored in the transaction result table.

2. The method for processing a transaction according to claim 1, characterized in that: The compensation processing of the successfully executed sub-transaction includes: Determining that the transaction transaction fails, and storing the transaction transaction failure in the transaction result table; The successfully executed subtransactions are rolled back in reverse order.

3. The method for processing transaction affairs according to claim 1, characterized in that: Also includes: If the execution result indicates neither failure nor success, and the current subtransaction is the key subtransaction or a subtransaction executed before the key subtransaction, obtaining first transaction information of the current subtransaction; If the first transaction information indicates that the current sub-transaction has failed to execute, it is determined that the execution result is an execution failure.

4. The method for processing transactions according to claim 3, characterized in that: Also includes: If the execution result indicates neither failure nor success, and the current subtransaction is the critical subtransaction or a subtransaction executed before the critical subtransaction, the execution of the transaction is interrupted.

5. The method for processing transaction affairs according to claim 3 or 4, characterized in that: Also includes: If the first transaction information indicates that the current subtransaction is successfully executed, determining that the current subtransaction is successfully executed; The asynchronous extension interface of the current subtransaction is called, and the asynchronous extension interface is used to execute a subtransaction after the current subtransaction.

6. The method for processing a transaction according to any one of claims 1 to 4, characterized in that: If the execution result indicates that the execution failed, and the current subtransaction is a subtransaction executed after the key subtransaction, the method further includes: terminating the transaction and obtaining the second transaction information; The second flow information is stored as error data.

7. The method for processing a transaction according to any one of claims 1 to 4, characterized in that: Also includes: Get compensation results; If the compensation result is neither failure nor success, obtaining compensation flow information; Whether the compensation result is successful is determined according to the compensation flow information.

8. A transaction processing device, characterized in that: The transaction includes multiple sub-transactions, which are executed in sequence. The multiple sub-transactions include: key sub-transactions, including: The transaction processing module is used to obtain the execution result of the current sub-transaction; A self-checking module, configured to, if the execution result indicates that the execution has failed and the current subtransaction is the critical subtransaction or a subtransaction executed before the critical subtransaction, perform compensation processing on the subtransaction that has been successfully executed; The self-check module is further configured to store the transaction success in a transaction result table if the execution result indicates that the execution has failed and the current subtransaction is a subtransaction executed after the key subtransaction.

9. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.

Citation Information

Patent Citations

  • Job processing method, device and system

    CN113269631A

  • Distributed transaction execution method and device

    CN118860579A