Distributed transaction double compensation method and device based on end-of-day reconciliation

By adopting the double compensation mechanism of daily end reconciliation in distributed transaction processing, the transactions are submitted and compensated in real time, and the problems of low real-time distribution transactions and high intrusion in business code are solved, and efficient and low-invasion distributed Transaction processing.

CN113032176BActive Publication Date: 2024-11-22中国邮政储蓄银行股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110310873.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-23
Publication Date
2024-11-22
Estimated Expiration
2041-03-23

AI Technical Summary

Technical Problem

Existing distributed transaction solutions have problems such as low transaction real-time, high invasiveness to business code, and high development costs.

Method used

Adopt a distributed transaction double compensation method based on daily end reconciliation. By submitting transactions in real time in the business processing process and performing real-time compensation when an exception is encountered, if the global transaction consistency is still not met, the daily reconciliation compensation is performed to ensure that Consistency of multiple databases.

Benefits of technology

It realizes a balance between real-time and consistency of transactions, avoids the time-consuming and inefficient synchronization and coordination of 2PC two-stage submissions, reduces business code intrusion and development costs, and ensures the real-time reflection of distributed transactions across libraries to the greatest extent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113032176B_ABST
    Figure CN113032176B_ABST
Patent Text Reader

Abstract

The present application provides a distributed transaction double compensation method and device based on end-of-day reconciliation. The method includes: processing each transaction normally according to the business processing flow, without considering the abnormal situation of the transaction; after the transaction is processed normally, submitting the database corresponding to the transaction in real time; if an abnormality is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the databases corresponding to each transaction before the scheduled transaction; if the global transaction consistency principle is still not met after real-time compensation, end-of-day reconciliation compensation is performed. The consistency of multiple databases is ensured by the double compensation mechanism of real-time compensation and end-of-day reconciliation compensation. A balance between transaction real-time and consistency is achieved. This solution has the advantages of high efficiency, transaction real-time and low intrusion into business code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of distributed transactions, and more specifically, to a distributed transaction double compensation method, device, computer-readable storage medium and processor based on end-of-day reconciliation. Background Art

[0002] When a business system uses multiple databases at the same time, it is necessary to coordinate multiple databases to ensure the consistency of global database transactions, that is, distributed database transactions. Traditionally, there are many ways to solve distributed transactions, such as 2PC two-phase commit, TCC confirmation compensation, MQ messages, etc. However, traditional distributed transaction solutions have shortcomings such as low transaction real-time performance, high intrusion into business code, and high development costs.

[0003] Specifically, traditional distributed transaction solutions have the following problems:

[0004] 2PC two-stage compensation mechanism: This mechanism has two steps: preparation and submission. It is a synchronous blocking mechanism, which requires all nodes in the distributed system to confirm before final submission, which is time-consuming and has low performance. It also lacks a fault-tolerant mechanism. When only some nodes submit and transactions are inconsistent, there is no self-correction mechanism.

[0005] TCC confirmation compensation mechanism: This mechanism has three operations: Try to reserve resources, Confirm to confirm submission, and Cancel to cancel and release resources. The fault tolerance steps of this mechanism are highly invasive to business development code. For example, there may be errors in the second step of confirming submission and the third step of canceling and releasing resources. If these errors are not handled, transaction consistency is destroyed. If these errors are handled, the business system needs to develop a large amount of error handling logic to ensure transaction consistency, which is highly invasive to the business system code, and there may also be defects in the error handling code that lead to transaction inconsistency.

[0006] MQ message mechanism: The MQ message mechanism is to asynchronously degenerate transactions and hand them over to the third-party MQ middleware for completion. This mechanism has the problem that database transactions are overly dependent on the third-party MQ middleware. MQ is an asynchronous mechanism and uses a queue queuing mechanism. When the business volume is at a peak, there is usually a backlog of messages in the MQ queue. It is not suitable for high-real-time business systems and has the disadvantage of poor transaction real-time performance. Summary of the invention

[0007] The main purpose of the present application is to provide a distributed transaction double compensation method, device, computer-readable storage medium and processor based on end-of-day reconciliation to solve the problems of low transaction real-time performance, high intrusion into business code and high development cost in the distributed transaction solutions in the prior art.

[0008] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a distributed transaction double compensation method based on end-of-day reconciliation is provided, including: processing each transaction normally according to the business processing flow, without considering transaction abnormalities; after processing the transaction normally, submitting the database corresponding to the transaction in real time; if an abnormality is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the database corresponding to each transaction before the scheduled transaction; if the global transaction consistency principle is still not met after the real-time compensation, end-of-day reconciliation compensation is performed.

[0009] Furthermore, the database corresponding to each transaction before the scheduled transaction is compensated in real time, including: correcting the database corresponding to each transaction before the scheduled transaction to a state before submission.

[0010] Furthermore, if the global transaction consistency principle is still not met after the real-time compensation, the end-of-day reconciliation compensation is performed, including: in the event of failure to correct the database, based on the end-of-day reconciliation consistency guarantee mechanism, the data in all the databases are checked at the end of the day; if there are still inconsistencies in some of the databases, the data in the abnormal databases are modified to ensure the global transaction consistency of all the databases.

[0011] Furthermore, at the end of the day, all the data in the database are checked, including: based on the principle of checking each item, at the end of the day, all the data in the database are checked.

[0012] Furthermore, the real-time compensation mechanism is a public compensation mechanism.

[0013] According to another aspect of the present application, a distributed transaction double compensation device based on end-of-day reconciliation is provided, including: a processing unit, used to process each transaction normally according to the business processing flow, without considering transaction abnormalities; a submission unit, used to submit the database corresponding to the transaction in real time after the transaction is processed normally; a first compensation unit, used to use a real-time compensation mechanism to perform real-time compensation on the database corresponding to each transaction before the scheduled transaction if an exception is encountered when processing a scheduled transaction; a second compensation unit, used to perform end-of-day reconciliation compensation if the global transaction consistency principle is still not met after the real-time compensation.

[0014] Furthermore, the first compensation unit is further configured to correct the database corresponding to each of the transactions before the predetermined transaction to a state before submission.

[0015] Furthermore, the second compensation unit includes a checking module and a modification module. The checking module is used to check the data in all the databases at the end of the day based on the end-of-day reconciliation consistency guarantee mechanism when the database correction fails; the modification module is used to modify the data in the abnormal database if there are still inconsistencies in some of the databases to ensure the consistency of the global transactions of all the databases.

[0016] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute any one of the distributed transaction double compensation methods based on end-of-day reconciliation.

[0017] According to another aspect of the present application, a processor is provided, the processor being used to run a program, wherein the program, when running, executes any one of the distributed transaction double compensation methods based on end-of-day reconciliation.

[0018] Applying the technical solution of the present application, each transaction is processed normally according to the business processing flow, and after normal processing, the database corresponding to the transaction is submitted in real time. If an exception is encountered during the normal processing, the database corresponding to each transaction before the scheduled transaction being processed is compensated in real time. If the global transaction consistency principle is still not met after real-time compensation, the end-of-day reconciliation compensation is performed. The consistency of multiple databases is ensured by the dual compensation mechanism of real-time compensation and end-of-day reconciliation compensation. A balance between transaction real-time and consistency is achieved. This solution has the advantages of high efficiency, transaction real-time and low intrusion into business code. Each transaction is processed normally according to the business processing flow, and transaction abnormalities are not considered, which can avoid intrusion into business code. This solution avoids the time-consuming and inefficient action of synchronous coordination of 2PC two-stage submission, and ensures high efficiency; the real-time compensation action in the double compensation mechanism is to compensate in time, and to ensure that cross-library (i.e., cross-database) distributed transactions can be reflected in real time to the maximum extent. The problem of insufficient real-time performance of the existing MQ transaction mechanism is avoided. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0020] Figure 1 A flow chart of a distributed transaction double compensation method based on end-of-day reconciliation according to an embodiment of the present application is shown;

[0021] Figure 2A schematic diagram of a distributed transaction double compensation device based on end-of-day reconciliation according to an embodiment of the present application is shown;

[0022] Figure 3 A flow chart of a specific distributed transaction double compensation method for end-of-day reconciliation according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0024] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0026] It should be understood that when an element (such as a layer, film, region, or substrate) is described as being "on" another element, the element may be directly on the other element, or there may be intermediate elements. Moreover, in the specification and claims, when an element is described as being "connected" to another element, the element may be "directly connected" to the other element, or "connected" to the other element through a third element.

[0027] For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:

[0028] End-of-day reconciliation: In the financial field such as banking and insurance, from the perspective of business and technology, each system and each module will conduct batch reconciliation of detailed data at the end of each day (usually at night or in the early morning). Even if there are certain errors or inconsistencies during the day, there are summary reconciliation, detailed reconciliation, error identification and processing mechanisms at the end of the day, and the data between each system will be adjusted to be consistent through difference processing specifications and rules. In case of special abnormal situations, manual intervention will be carried out to ensure that the data of each system can be reconciled and consistent at the end of the day to ensure the final consistency at the end of the day.

[0029] As introduced in the background technology, the distributed transaction solutions in the prior art have the disadvantages of low transaction real-time performance, high intrusion into business codes, and high development costs. In order to solve the above-mentioned problems of low transaction real-time performance, high intrusion into business codes, and high development costs, the embodiments of the present application provide a distributed transaction double compensation method, device, computer-readable storage medium, and processor based on end-of-day reconciliation.

[0030] According to an embodiment of the present application, a distributed transaction double compensation method based on end-of-day reconciliation is provided.

[0031] Figure 1 Flowchart of a distributed transaction double compensation method based on end-of-day reconciliation according to an embodiment of the present application. Figure 1 As shown, the method comprises the following steps:

[0032] Step S101, process each transaction normally according to the business process flow, without considering transaction abnormalities;

[0033] Step S102, after the above transaction is processed normally, submitting the database corresponding to the above transaction in real time;

[0034] Step S103, if an exception is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the database corresponding to each of the transactions before the scheduled transaction;

[0035] Step S104: If the global transaction consistency principle is still not met after the above real-time compensation, end-of-day reconciliation compensation is performed.

[0036] Specifically, for example, if an exception occurs when processing the third transaction, real-time compensation is performed on the database corresponding to the first transaction and the database corresponding to the second transaction.

[0037] Specifically, end-of-day reconciliation compensation refers to correcting the database that does not meet the global transaction consistency principle based on the end-of-day reconciliation principle.

[0038] In the above scheme, each transaction is processed normally according to the business processing flow, and after normal processing, the database corresponding to the transaction is submitted in real time. If an exception is encountered during the normal processing, the database corresponding to each transaction before the scheduled transaction being processed is compensated in real time. If the global transaction consistency principle is still not met after real-time compensation, the end-of-day reconciliation compensation is performed. The consistency of multiple databases is ensured through the dual compensation mechanism of real-time compensation and end-of-day reconciliation compensation. A balance between transaction real-time and consistency is achieved. This scheme has the advantages of high efficiency, transaction real-time and low intrusion to business code. Each transaction is processed normally according to the business processing flow, and transaction exceptions are not considered, which can avoid intrusion into business code. This scheme avoids the time-consuming and inefficient action of synchronous coordination of 2PC two-stage submission, ensuring high efficiency; the real-time compensation action in the double compensation mechanism is to compensate in time, to maximize the guarantee that cross-database (i.e., cross-database) distributed transactions can be reflected in real time. The problem of insufficient real-time performance of the existing MQ transaction mechanism is avoided.

[0039] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0040] In one embodiment of the present application, the database corresponding to each of the transactions before the scheduled transaction is compensated in real time, including: correcting the database corresponding to each of the transactions before the scheduled transaction to a state before submission.

[0041] In one embodiment of the present application, if the global transaction consistency principle is still not met after the above-mentioned real-time compensation, end-of-day reconciliation compensation is performed, including: in the event of failure to correct the above-mentioned database, based on the end-of-day reconciliation consistency guarantee mechanism, the data in all the above-mentioned databases are checked at the end of the day; if there are still inconsistencies in some of the above-mentioned databases, the data in the abnormal databases are modified to ensure the global transaction consistency of all the above-mentioned databases.

[0042] In one embodiment of the present application, the data in all the above databases are checked at the end of the day, including: based on the principle of checking each item, the data in all the above databases are checked at the end of the day.

[0043] In one embodiment of the present application, the above-mentioned real-time compensation mechanism is a public compensation mechanism. The public compensation mechanism means that the real-time compensation mechanism in this solution is a public mechanism that is applicable to different distributed transactions. There is no need to develop a large amount of control and processing code related to distributed transactions in the business system. The mechanism of this solution usually only requires one line of code to call the public compensation mechanism. This method avoids the intrusion of a large amount of TCC mechanism code into the business system, while also reducing the probability of development errors and having low intrusion into the business system. Since a large amount of distributed transaction processing code is not required in the business system, the difficulty and cost of development are greatly reduced. The real-time compensation mechanism is a public service that only needs to be developed once, avoiding the problem that the TCC mechanism is scattered in multiple business functions and requires multiple people to develop, which increases the development cost and error probability. High performance, high real-time performance, low intrusion, and low development cost are achieved.

[0044] The embodiment of the present application also provides a distributed transaction double compensation device based on end-of-day reconciliation. It should be noted that the distributed transaction double compensation device based on end-of-day reconciliation in the embodiment of the present application can be used to execute the distributed transaction double compensation method based on end-of-day reconciliation provided in the embodiment of the present application. The following introduces the distributed transaction double compensation device based on end-of-day reconciliation provided in the embodiment of the present application.

[0045] Figure 2 Schematic diagram of a distributed transaction double compensation device based on end-of-day reconciliation according to an embodiment of the present application. Figure 2 As shown, the device comprises:

[0046] The processing unit 10 is used to process each transaction normally according to the business processing flow, without considering the abnormal situation of the transaction;

[0047] A submission unit 20, used to submit the database corresponding to the transaction in real time after the transaction is processed normally;

[0048] The first compensation unit 30 is used to use a real-time compensation mechanism to perform real-time compensation on the database corresponding to each of the transactions before the scheduled transaction if an exception is encountered when processing the scheduled transaction;

[0049] The second compensation unit 40 is used to perform end-of-day reconciliation compensation if the global transaction consistency principle is still not satisfied after the above real-time compensation.

[0050] Specifically, for example, if an exception occurs when processing the third transaction, real-time compensation is performed on the database corresponding to the first transaction and the database corresponding to the second transaction.

[0051] Specifically, end-of-day reconciliation compensation refers to correcting the database that does not meet the global transaction consistency principle based on the end-of-day reconciliation principle.

[0052] In the above scheme, the processing unit processes each transaction normally according to the business processing flow, and the submission unit submits the database corresponding to the transaction in real time after normal processing. If an exception is encountered during the normal processing, the first compensation unit will compensate the database corresponding to each transaction before the scheduled transaction being processed in real time. If the global transaction consistency principle is still not met after real-time compensation, the second compensation unit will perform day-end reconciliation compensation. The consistency of multiple databases is ensured through the dual compensation mechanism of real-time compensation and day-end reconciliation compensation. A balance between transaction real-time and consistency is achieved. This scheme has the advantages of high efficiency, transaction real-time and low intrusion to business code. Each transaction is processed normally according to the business processing flow, and transaction exceptions are not considered, which can avoid intrusion into business code. This scheme avoids the time-consuming and inefficient action of synchronous coordination of 2PC two-stage submission, and ensures high efficiency; the real-time compensation action in the double compensation mechanism is to compensate in time, and to maximize the guarantee that cross-database (i.e., cross-database) distributed transactions can be reflected in real time. The problem of insufficient real-time performance of the existing MQ transaction mechanism is avoided.

[0053] In an embodiment of the present application, the first compensation unit is further used to correct the database corresponding to each of the transactions before the predetermined transaction to a state before submission.

[0054] In one embodiment of the present application, the second compensation unit includes a verification module and a modification module. The verification module is used to verify the data in all the above-mentioned databases at the end of the day based on the end-of-day reconciliation consistency guarantee mechanism when the correction of the above-mentioned database fails; the modification module is used to modify the data in the abnormal database if there are still inconsistencies in some of the above-mentioned databases to ensure the global transaction consistency of all the above-mentioned databases.

[0055] In one embodiment of the present application, the verification module is also used to verify all the data in the above-mentioned databases at the end of the day based on the principle of verification item by item.

[0056] The distributed transaction double compensation device based on end-of-day reconciliation includes a processor and a memory. The above-mentioned processing unit, submission unit, first compensation unit and second compensation unit, etc. are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.

[0057] The processor contains a kernel, which calls the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters can be adjusted to solve the problems of distributed transaction solutions such as low transaction real-time performance, high intrusion into business code, and high development costs.

[0058] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0059] An embodiment of the present invention provides a computer-readable storage medium, which includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the distributed transaction double compensation method based on end-of-day reconciliation.

[0060] An embodiment of the present invention provides a processor, which is used to run a program, wherein the distributed transaction double compensation method based on end-of-day reconciliation is executed when the program is running.

[0061] An embodiment of the present invention provides a device, the device including a processor, a memory, and a program stored in the memory and executable on the processor, and when the processor executes the program, at least the following steps are implemented:

[0062] Step S101, process each transaction normally according to the business process flow, without considering transaction abnormalities;

[0063] Step S102, after the above transaction is processed normally, submitting the database corresponding to the above transaction in real time;

[0064] Step S103, if an exception is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the database corresponding to each of the transactions before the scheduled transaction;

[0065] Step S104: If the global transaction consistency principle is still not met after the above real-time compensation, end-of-day reconciliation compensation is performed.

[0066] The devices in this article can be servers, PCs, PADs, mobile phones, etc.

[0067] The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program for initializing at least the following method steps:

[0068] Step S101, process each transaction normally according to the business process flow, without considering transaction abnormalities;

[0069] Step S102, after the above transaction is processed normally, submitting the database corresponding to the above transaction in real time;

[0070] Step S103, if an exception is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the database corresponding to each of the transactions before the scheduled transaction;

[0071] Step S104: If the global transaction consistency principle is still not met after the above real-time compensation, end-of-day reconciliation compensation is performed.

[0072] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0073] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0074] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0075] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0076] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0077] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0078] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0079] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0080] Example

[0081] This embodiment relates to a specific distributed transaction double compensation method based on end-of-day reconciliation. Figure 3 The flowchart of the method is shown. The method mainly includes three steps:

[0082] Step 1: Normal processing. According to the optimistic principle, the business logic is processed normally step by step. There is no need to consider transaction exceptions too much to avoid code intrusion. Since most businesses can be processed normally in the actual environment, most businesses only need to perform normal processing operations without compensation actions, which improves the overall performance of the business system.

[0083] Step 2: Real-time compensation: If an exception is encountered during normal processing, the entire database needs to be rolled back. Figure 3 In the example, the entire business processing flow involves 4 transactions and 4 databases. Suppose transaction 1 and transaction 2 have been completed and submitted in database A and database B. However, when processing transaction 3, an exception is encountered and the entire transaction needs to be rolled back (that is, the data in database A and database B need to be corrected to the state before submission). At this time, the business system only needs to issue a real-time compensation notification. The public real-time compensation mechanism, after receiving the compensation notification, performs reverse database compensation operations (such as data reverse operations) on the data in database A and database B according to relevant information to restore the submitted key data to the state before submission. Real-time compensation tries to compensate successfully as much as possible. Usually, real-time compensation can succeed in most cases, that is, the transaction takes effect in real time.

[0084] Step 3: End-of-day reconciliation compensation. Although real-time compensation can succeed in most cases, there are still a few occasional exceptions or errors that cause failure. Therefore, with the help of the end-of-day reconciliation consistency guarantee mechanism, at the end of the day, the end-of-day reconciliation compensation will check the data in all databases and check each transaction. If there are still inconsistent transactions, the final consistency compensation mechanism will be carried out according to the relevant information, that is, the data will be modified to make the transactions consistent across databases. Therefore, the end-of-day reconciliation compensation realizes the bottom-up mechanism of transaction final consistency.

[0085] This solution achieves a balance between transaction real-time and consistency through a dual compensation mechanism of real-time compensation and end-of-day reconciliation compensation.

[0086] The double compensation mechanism of this scheme has four characteristics:

[0087] 1. High performance. It avoids the time-consuming and inefficient synchronization coordination of the 2PC two-phase commit.

[0088] 2. Transactions are close to real-time. The real-time compensation mechanism in the double compensation mechanism is to compensate in time, to ensure that cross-database distributed transactions can be reflected in real time to the greatest extent possible. This avoids the lack of real-time performance of the existing MQ-based transaction mechanism.

[0089] 3. Low intrusion into business systems. There is no need to develop a large amount of control and processing code related to distributed transactions in the business system. The mechanism of this solution usually only requires one line of code to call a public compensation mechanism (the real-time compensation mechanism in this solution is a public compensation mechanism). This method avoids the intrusion of a large amount of TCC mechanism code into the business system, and also reduces the probability of development errors.

[0090] 4. Development cost. Since a large amount of distributed transaction processing code is not required in the business system, the difficulty and cost of development are greatly reduced. The real-time compensation mechanism is a public service that only needs to be developed once, which avoids the TCC mechanism being scattered in multiple business functions, requiring multiple people to develop, which increases the development cost and error probability.

[0091] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:

[0092] 1) The distributed transaction double compensation method based on end-of-day reconciliation of the present application processes each transaction normally according to the business processing flow, and after normal processing, submits the database corresponding to the transaction in real time. If an exception is encountered during the normal processing, the database corresponding to each transaction before the scheduled transaction being processed is compensated in real time. If the global transaction consistency principle is still not met after real-time compensation, the end-of-day reconciliation compensation is performed. The consistency of multiple databases is ensured by the double compensation mechanism of real-time compensation and end-of-day reconciliation compensation. A balance between transaction real-time and consistency is achieved. This solution has the advantages of high efficiency, transaction real-time and low intrusion into business code. Each transaction is processed normally according to the business processing flow, and transaction exceptions are not considered, which can avoid intrusion into business code. This solution avoids the time-consuming and inefficient action of synchronous coordination of 2PC two-stage submission, and ensures high efficiency; the real-time compensation action in the double compensation mechanism is to compensate in time, and to ensure that cross-database (i.e., cross-database) distributed transactions can be reflected in real time to the maximum extent. The problem of insufficient real-time performance of the existing MQ transaction mechanism is avoided.

[0093] 2) The distributed transaction double compensation device based on end-of-day reconciliation of the present application, the processing unit processes each transaction normally according to the business processing flow, and the submission unit submits the database corresponding to the transaction in real time after normal processing. If an abnormality is encountered during the normal processing, the first compensation unit will perform real-time compensation on the database corresponding to each transaction before the scheduled transaction being processed. If the global transaction consistency principle is still not met after real-time compensation, the second compensation unit will perform end-of-day reconciliation compensation. The consistency of multiple databases is ensured by the double compensation mechanism of real-time compensation and end-of-day reconciliation compensation. A balance between transaction real-time and consistency is achieved. This solution has the advantages of high efficiency, transaction real-time and low intrusion to business code. Each transaction is processed normally according to the business processing flow, and transaction abnormalities are not considered, which can avoid intrusion into business code. This solution avoids the time-consuming and inefficient action of synchronous coordination of 2PC two-stage submission, and ensures high efficiency; the real-time compensation action in the double compensation mechanism is to compensate in time, and to maximize the guarantee that cross-database (i.e., cross-database) distributed transactions can be reflected in real time. The problem of insufficient real-time performance of the existing MQ transaction mechanism is avoided.

[0094] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A distributed transaction double compensation method based on end-of-day reconciliation, characterized in that: include: Process each transaction normally according to the business process flow, without considering abnormal transaction situations; After the transaction is processed normally, submitting the database corresponding to the transaction in real time; If an exception is encountered when processing a scheduled transaction, a real-time compensation mechanism is used to perform real-time compensation on the database corresponding to each transaction before the scheduled transaction, wherein the real-time compensation mechanism is a public compensation mechanism, which means that the real-time compensation mechanism is a public mechanism and is applicable to different distributed transactions; If the global transaction consistency principle is still not met after the real-time compensation, the end-of-day reconciliation compensation is performed; Among them, if the global transaction consistency principle is still not met after the real-time compensation, the end-of-day reconciliation compensation is performed, including: in the case of failure to correct the database, based on the end-of-day reconciliation consistency guarantee mechanism, the data in all the databases are checked at the end of the day; if there are still inconsistencies in some of the databases, the data in the abnormal databases are modified to ensure the global transaction consistency of all the databases.

2. The method according to claim 1, characterized in that: Performing real-time compensation on the database corresponding to each transaction before the scheduled transaction includes: The database corresponding to each of the transactions before the scheduled transaction is corrected to a state before submission.

3. The method according to claim 1, characterized in that At the end of the day, all data in the databases are checked, including: Based on the principle of item-by-item verification, all data in the database are verified at the end of the day.

4. A distributed transaction double compensation device based on end-of-day reconciliation, characterized in that: include: The processing unit is used to process each transaction normally according to the business processing flow, without considering the abnormal situation of the transaction; A submission unit, used to submit the database corresponding to the transaction in real time after the transaction is processed normally; A first compensation unit is configured to, if an exception is encountered when processing a scheduled transaction, use a real-time compensation mechanism to perform real-time compensation on the database corresponding to each transaction before the scheduled transaction, wherein the real-time compensation mechanism is a public compensation mechanism, which means that the real-time compensation mechanism is a public mechanism and is applicable to different distributed transactions; A second compensation unit is used to perform end-of-day reconciliation compensation if the global transaction consistency principle is still not satisfied after the real-time compensation; The second compensation unit includes a checking module and a modification module. The checking module is used to check the data in all the databases at the end of the day based on the end-of-day reconciliation consistency guarantee mechanism when the database correction fails; the modification module is used to modify the data in the abnormal database if there are still inconsistencies in some of the databases to ensure the consistency of global transactions of all the databases.

5. The device according to claim 4, characterized in that The first compensation unit is further configured to correct the database corresponding to each transaction before the predetermined transaction to a state before submission.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is running, the device where the computer-readable storage medium is located is controlled to execute the distributed transaction double compensation method based on end-of-day reconciliation as described in any one of claims 1 to 3.