Cross-database transaction management method, device, equipment and storage medium
By configuring mapping labels and executing preset transaction mechanisms in heterogeneous databases, the problem of being unable to configure XA transactions and binary log files in heterogeneous databases, which reduces business request processing efficiency, is solved, and cross-database transaction management and data consistency are achieved.
Patent Information
- Application Number
- CN202010000435.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-02
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2040-01-02
AI Technical Summary
Heterogeneous databases cannot configure XA transactions, resulting in reduced efficiency in processing cross-database business requests, and low performance when restoring data through binary log files.
By determining the data operation statements of multiple databases from the preset mapping object files, and configuring the first mapping label and the second mapping label for them, transactions to be executed are formed, and the preset transaction mechanism is used to execute these transactions, including preliminary operations, Cancel operations and confirm operations, ensure data backup and rollback when transactions succeed or fail, and verify data consistency.
It realizes cross-database transaction management, ensures data consistency and efficient processing of business requests, avoids the problem of low performance of XA transactions, and ensures the correctness of data through data rollback verification.
Smart Images

Figure CN111209142B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a cross-database transaction management method, device, equipment and storage medium. Background Art
[0002] A database transaction usually includes a sequence of read / write operations on the database, which restores the database operation sequence from failure to normal state, while ensuring that the database remains consistent under abnormal conditions. When multiple applications access the database concurrently, it provides an isolation between applications to prevent interference between each other's operations.
[0003] When multiple cross-database business requests are concurrent, the use of asynchronous operations can easily lead to inconsistency in the data of the entire target database system. If the distributed transaction processing interface XA transaction management method is used, its performance is poor and can only be applied to databases of the same source. Heterogeneous databases cannot be configured with XA transactions, and data restoration is performed through binary log files binlog or relaylog, which reduces the processing efficiency of business requests. Summary of the invention
[0004] The main purpose of the present invention is to solve the problem that heterogeneous databases cannot be configured with XA transactions, and solve the technical problem that the processing efficiency of business requests is reduced due to data restoration through binary log files.
[0005] To achieve the above-mentioned purpose, the first aspect of the present invention provides a cross-database transaction management method, comprising: determining data operation statements of multiple databases from a preset mapping object file, and configuring a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback; executing the multiple transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancel operations, and confirm operations; when it is detected that the multiple transactions to be executed are all executed successfully, The confirmation operation commits all successfully executed transactions; when it is detected that any one of the multiple transactions to be executed fails to execute, the executed transaction is rolled back according to the backup data through the cancellation operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain a verification result; it is determined whether the verification result is equal to a target value; if the verification result is equal to the target value, the remaining executed transactions are determined, and data of the remaining executed transactions are rolled back according to the backup data; if the verification result is not equal to the target value, the difference data is determined, and data recovery of the difference data is performed according to the backup data.
[0006] Optionally, in a first implementation manner of the first aspect of the present invention, determining data operation statements of multiple databases from a preset mapping object file, and configuring a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback, includes: deploying a preset project framework to obtain a preset mapping object file; configuring connection information of multiple databases and data operation statements of the multiple databases in the preset mapping object file, wherein the data operation statements of the multiple databases are used to indicate association with different function names of a preset interface class according to a first preset attribute; adding a first mapping tag to the data operation statements of the multiple databases, and associating the first mapping tag and the preset query statement according to a second preset attribute, wherein the first mapping tag is used to indicate triggering data backup; adding the second mapping tag to the data operation statements of the multiple databases, wherein the second mapping tag is used to indicate triggering data rollback; and reloading the preset mapping object file to obtain multiple transactions to be executed.
[0007] Optionally, in a second implementation manner of the first aspect of the present invention, the multiple transactions to be executed are executed through preliminary operations in a preset transaction mechanism to obtain backup data, and the preset transaction mechanism includes preliminary operations, cancellation operations and confirmation operations, including: reading connection information of the multiple databases and the multiple transactions to be executed from the preset mapping object file; connecting to the multiple databases according to a preset connection class and the connection information of the multiple databases; executing the multiple transactions to be executed through preliminary operations in the preset transaction mechanism to obtain backup data, and adding distributed transaction locks to the multiple transactions to be executed, and the preset transaction mechanism includes the preliminary operations, confirmation operations and cancellation operations.
[0008] Optionally, in a third implementation manner of the first aspect of the present invention, the multiple transactions to be executed are executed through the preliminary operation in the preset transaction mechanism to obtain backup data, and distributed transaction locks are added to the multiple transactions to be executed, and the preset transaction mechanism includes the preliminary operation, confirmation operation and cancellation operation, including: executing the multiple transactions to be executed one by one according to different function names of the preset interface class through the preliminary operation in the preset transaction mechanism to obtain a unique identifier of the transaction, and the preset transaction mechanism includes the preliminary operation, confirmation operation and cancellation operation; executing the preset query statement corresponding to the first mapping label to obtain backup data; setting the unique identifier of the transaction and the backup data as a target key-value pair, and storing the target key-value pair in the cache; adding distributed transaction locks to the multiple transactions to be executed, and executing data operation statements of the multiple databases.
[0009] Optionally, in a fourth implementation manner of the first aspect of the present invention, when it is detected that any one of the multiple transactions to be executed fails to execute, the executed transaction is rolled back according to the backup data through the cancellation operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain a verification result, including: when it is detected that any one of the multiple transactions to be executed fails to execute, the backup data is obtained according to the unique identifier of the transaction through the cancellation operation; the executed transaction is rolled back according to the backup data, and the distributed transaction lock is released to obtain the rolled back data; and data consistency verification is performed on the rolled back data and the backup data to obtain a verification result.
[0010] Optionally, in a fifth implementation manner of the first aspect of the present invention, when it is detected that all of the multiple transactions to be executed are successfully executed, submitting all of the successfully executed transactions through the confirmation operation includes: when it is detected that all of the multiple transactions to be executed are successfully executed, obtaining a unique identifier of all successfully executed transactions through the confirmation operation; submitting transactions according to the unique identifier of all successfully executed transactions to obtain a submission status; judging whether the submission status is a success status; if the submission status is a success status, triggering a release operation of the distributed transaction lock; if the submission status is a failure status, resubmitting the transaction in the failed status, and counting the number of submissions until the number of submissions is not less than a preset number of times or the submission status is a success status.
[0011] Optionally, in a sixth implementation manner of the first aspect of the present invention, when it is detected that all of the multiple transactions to be executed are successfully executed, after all the successfully executed transactions are submitted through the confirmation operation, the cross-database transaction management method also includes: obtaining different execution states of the transactions to be executed, the different execution states including a successful execution state of the transaction and a failed execution state of the transaction; recording the successful execution state of the transaction and the failed execution state of the transaction in a preset transaction log according to a unique identifier of the transaction; and sending a preset alarm information for the failed execution state of the transaction.
[0012] The second aspect of the present invention provides a cross-database transaction management device, comprising: a configuration unit, used to determine data operation statements of multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback; an execution unit, used to execute the multiple transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancel operations and confirmation operations; a submission unit, when it is detected that the multiple transactions to be executed are all executed successfully, is used to submit all of them through the confirmation operation. A successfully executed transaction; a rollback verification unit, when it is detected that any one of the multiple transactions to be executed fails to execute, is used to roll back the executed transaction according to the backup data through the cancellation operation to obtain the rolled back data, and verify the rolled back data according to the backup data to obtain a verification result; a judgment unit, used to judge whether the verification result is equal to a target value; a processing unit, if the verification result is equal to the target value, is used to determine the remaining executed transactions, and roll back the remaining executed transactions according to the backup data; a recovery unit, if the verification result is not equal to the target value, is used to determine the difference data, and recover the difference data according to the backup data.
[0013] Optionally, in a first implementation method of the second aspect of the present invention, the configuration unit is specifically used to: deploy a preset project framework to obtain a preset mapping object file; configure connection information of multiple databases and data operation statements of the multiple databases in the preset mapping object file, the data operation statements of the multiple databases are used to indicate association with different function names of the preset interface class according to a first preset attribute; add a first mapping tag to the data operation statements of the multiple databases, and associate the first mapping tag and the preset query statement according to a second preset attribute, the first mapping tag is used to indicate triggering data backup; add the second mapping tag to the data operation statements of the multiple databases, the second mapping tag is used to indicate triggering data rollback; reload the preset mapping object file to obtain multiple transactions to be executed.
[0014] Optionally, in a second implementation manner of the second aspect of the present invention, the execution unit further includes: a reading subunit, used to read the connection information of the multiple databases and the multiple transactions to be executed from the preset mapping object file; a connection subunit, used to connect to the multiple databases according to the preset connection class and the connection information of the multiple databases; an execution subunit, used to execute the multiple transactions to be executed through preliminary operations in a preset transaction mechanism, obtain backup data, and add distributed transaction locks to the multiple transactions to be executed, and the preset transaction mechanism includes the preliminary operation, confirmation operation and cancellation operation.
[0015] Optionally, in a third implementation method of the second aspect of the present invention, the execution sub-unit is specifically used to: execute the multiple transactions to be executed one by one according to different function names of the preset interface class through preliminary operations in the preset transaction mechanism to obtain a unique identifier of the transaction, and the preset transaction mechanism includes the preliminary operation, confirmation operation and cancellation operation; execute the preset query statement corresponding to the first mapping label to obtain backup data; set the unique identifier of the transaction and the backup data as a target key-value pair, and store the target key-value pair in the cache; add distributed transaction locks to the multiple transactions to be executed, and execute data operation statements of the multiple databases.
[0016] Optionally, in a fourth implementation method of the second aspect of the present invention, the rollback verification unit is specifically used to: when it is detected that any one of the multiple transactions to be executed fails, obtain the backup data according to the unique identifier of the transaction through the cancellation operation; roll back the executed transaction according to the backup data, and release the distributed transaction lock to obtain the rolled back data; perform data consistency verification on the rolled back data and the backup data to obtain a verification result.
[0017] Optionally, in a fifth implementation manner of the second aspect of the present invention, the submission unit is specifically used to: when it is detected that all the multiple transactions to be executed are executed successfully, obtain the unique identifier of all the successfully executed transactions through the confirmation operation; submit the transaction according to the unique identifier of all the successfully executed transactions to obtain a submission status; determine whether the submission status is a success status; if the submission status is a success status, trigger a release operation of the distributed transaction lock; if the submission status is a failure status, resubmit the transaction in the failure status, and count the number of submissions until the number of submissions is not less than a preset number or the submission status is a success status.
[0018] Optionally, in a sixth implementation manner of the second aspect of the present invention, the cross-database transaction management device further includes: an acquisition unit, used to acquire different execution states of the transaction to be executed, the different execution states including a successful execution state of the transaction and a failed execution state of the transaction; a recording unit, used to record the successful execution state of the transaction and the failed execution state of the transaction in a preset transaction log according to a unique identifier of the transaction; and a sending unit, used to send a preset alarm information for the failed execution state of the transaction.
[0019] The third aspect of the present invention provides a cross-database transaction management device, comprising: a memory and at least one processor, wherein instructions are stored in the memory, and the memory and the at least one processor are interconnected via a line; the at least one processor calls the instructions in the memory so that the cross-database transaction management device executes the method described in the first aspect above.
[0020] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method described in the first aspect.
[0021] It can be seen from the above technical solutions that the present invention has the following advantages:
[0022] In the technical solution provided by the present invention, data operation statements of multiple databases are determined from a preset mapping object file, and a first mapping tag and a second mapping tag are configured for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback; the multiple transactions to be executed are executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancel operations, and confirmation operations; when it is detected that the multiple transactions to be executed are all executed successfully, the confirmation operation is used to submit all the executed transactions successfully. successful transactions; when it is detected that any one of the multiple transactions to be executed fails to execute, the executed transactions are rolled back according to the backup data through the cancellation operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain the verification result; it is determined whether the verification result is equal to the target value; if the verification result is equal to the target value, the remaining executed transactions are determined, and the remaining executed transactions are rolled back according to the backup data; if the verification result is not equal to the target value, the difference data is determined, and the difference data is restored according to the backup data. In an embodiment of the present invention, the backup data is obtained by configuring and executing the distributed mapping object file across databases, and the distributed transaction is verified for data rollback and committed according to the transaction mechanism and the backup data to ensure the correctness of the rollback data and the consistency of the business data of multiple cross-database business concurrent requests. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A schematic diagram of an embodiment of a cross-database transaction management method in an embodiment of the present invention;
[0024] Figure 2 It is a schematic diagram of another embodiment of the cross-database transaction management method in an embodiment of the present invention;
[0025] Figure 3 A schematic diagram of an embodiment of a cross-database transaction management device in an embodiment of the present invention;
[0026] Figure 4 It is a schematic diagram of another embodiment of a cross-database transaction management device in an embodiment of the present invention;
[0027] Figure 5 The figure is a schematic diagram of an embodiment of a cross-database transaction management device in an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The embodiments of the present invention provide a cross-database transaction management method, apparatus, device and storage medium, which are used to obtain backup data by configuring and executing a cross-database distributed mapping object file, and perform data rollback verification and transaction submission on the distributed transaction according to the transaction mechanism and the backup data, so as to ensure the correctness of the rollback data and the consistency of the business data of multiple cross-database business concurrent requests.
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the embodiments of the present invention will be described below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0030] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention 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 described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of a cross-database transaction management method in an embodiment of the present invention includes:
[0032] 101. Determine data operation statements of multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback;
[0033] The server determines the data operation statements of multiple databases from the preset mapping object file, and configures the first mapping tag and the second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate the triggering of data backup, and the second mapping tag is used to indicate the triggering of data rollback. Among them, the preset mapping object file is a mapper file, for example, Mapper.xml. The data operation statements include adding operation statements, deleting operation statements and updating operation statements, that is, the data operation statements include inserting insert tags, deleting delete tags and updating update tags. The first mapping tag is the prior before tag, and the second mapping tag is the rollback rollback tag. That is to say, the before tag and the rollback tag are pre-configured in the context of the insert tag, delete tag and update tag of multiple databases in the Mapper.xml file.
[0034] 102. Execute multiple pending transactions through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancel operations, and confirm operations;
[0035] The server executes multiple pending transactions through preliminary operations in the preset transaction mechanism to obtain backup data. The preset transaction mechanism includes preliminary operations, cancellation operations, and confirmation operations. Among them, the preliminary operation is a try statement block, and the preset transaction mechanism is a TCC transaction mechanism. The server attempts to execute database connection, cache backup data, and apply for distributed transaction locks according to the try statement block, and logically locks the data of multiple databases. Further, when it is determined that at least two transaction-related data operations belong to different databases, the server generates an insert statement for a distributed transaction lock; the server executes the insert statement for the distributed transaction lock to obtain a distributed transaction lock. For example, the server logically locks the data corresponding to library A and the data corresponding to library B to ensure the consistency of the transaction.
[0036] It is understandable that the server generates a unique identifier of the transaction according to a pre-made rule in the try statement block, sets the unique identifier of the transaction and the backup data as a target key-value pair, and stores the target key-value pair in the cache.
[0037] 103. When it is detected that all the pending transactions are successfully executed, all the successfully executed transactions are committed through a confirmation operation;
[0038] When it is detected that all the pending transactions are successfully executed, all the successfully executed transactions are committed through the confirmation operation. The confirmation operation is a confirm statement block. Specifically, when it is detected that all the pending transactions are successfully executed, the server commits all the successful executions through the confirmation operation and obtains the commit status; when the commit status is a successful status, the server triggers the release operation of the distributed transaction lock; when the commit status is a failed status, the server resubmits the failed transaction and counts the number of commits until the number of commits is not less than the preset number or the commit status is a successful status.
[0039] It should be noted that the server will execute the unfinished items of the preliminary operation by executing the confirm statement blocks specified by the preliminary operation one by one. For example, if accounts A, B, and C are normal accounts, and the balances of accounts A and B meet the preset conditions, the server will execute the transfer operation of transferring 100 yuan from account A to account C and 500 yuan from account B to account C, until both transfers are successful, and the storage account data of A, B, and C are updated to ensure that the total amount of the three accounts is equal before and after the transfer. Furthermore, it is ensured that the transaction to be executed must be in a consistent state before and after execution, and the transaction is committed to ensure the validity of the updated data.
[0040] 104. When it is detected that any one of the multiple pending transactions fails to execute, the executed transaction is rolled back according to the backup data by canceling the operation, the rolled back data is obtained, and the rolled back data is verified according to the backup data;
[0041] When it is detected that any one of the multiple pending transactions fails to execute, the server rolls back the executed transaction according to the backup data through a cancel operation to obtain the rolled back data, and verifies the rolled back data according to the backup data. The cancel operation is a cancel statement block. Specifically, when it is detected that any one of the multiple pending transactions fails to execute, the server obtains the backup data through a cancel operation, rolls back the executed transaction according to the backup data and releases the transaction lock to obtain the rolled back data; the server verifies the data consistency of the rolled back data and the backup data to obtain the verification result. For example, for the following data operation statements:
[0042] update tmp set username = 'A1' where userid = '001'; --- marked as A1
[0043] update tmp set username = 'B1' where userid = '001'; --- marked as B1
[0044] The server first rolls back to B1, and all data modifications after B1 are considered invalid; the server then rolls back to A1, and all data modifications after A1 are considered invalid. The server rolls back all executed transactions through backup data, which means undoing all data modifications since the last transaction was submitted.
[0045] It should be noted that the executed transactions include successfully executed transactions and failed transactions. When a transaction execution failure is detected, the transaction is divided at the time of failure.
[0046] 105. Determine whether the verification result is equal to the target value;
[0047] The server determines whether the verification result is equal to the target value. For example, the target field value before the transaction is submitted is 3, and the target field value after the update is set to 5. Due to an exception in the transaction execution, if the server rolls back the target field value to 5 according to the backup data, the server obtains a verification result of 1, and the target value is 1. The server determines that the verification result is equal to the target value, and the server executes step 106; if the server rolls back the target field value to 6 according to the backup data, the server obtains a verification result of 0, and the target value is 1. The server determines that the verification result is not equal to the target value, and the server executes step 107.
[0048] 106. If the verification result is equal to the target value, the remaining executed transactions are determined, and the remaining executed transactions are rolled back according to the backup data;
[0049] If the verification result is equal to the target value, the server determines the remaining executed transactions and rolls back the remaining executed transactions according to the backup data. The remaining executed transactions are a set of transactions obtained by removing the rolled back transactions from the executed transactions. For example, the server executes transactions A and B in sequence. Transaction B has an exception during execution. The server rolls back B and A in sequence according to the backup data. After B is rolled back, the verification result C is obtained. If the verification result C is equal to the target value, the server continues to roll back the remaining executed transaction A.
[0050] 107. If the verification result is not equal to the target value, the difference data is determined, and the difference data is restored according to the backup data. After the data recovery is successful, the remaining executed transactions are rolled back.
[0051] If the verification result is not equal to the target value, the server determines the difference data and restores the difference data based on the backup data. After the data is successfully restored, the remaining executed transactions are rolled back. For example, for the following statement:
[0052] update table name set target field name = value where primary key = primary key value;
[0053] The server adds a before tag and a rollback tag to the update tag. The rollback tag is used to indicate that the statement is rolled back to the backup data before the transaction is committed. The target field value before the transaction is committed is 3, and the target field value after the update is 5. However, due to an exception in the transaction execution, the server rolls back the target field value to 3. If the server detects that the target field value is 4 after the update, the server determines that there is differential data and recovers the differential data 4 based on the backup data 2. It can be understood that after the data recovery is successful, the remaining executed transactions are rolled back.
[0054] In an embodiment of the present invention, backup data is obtained by configuring and executing a distributed mapping object file across databases, and data rollback verification and transaction submission are performed on distributed transactions based on the transaction mechanism and the backup data to ensure the correctness of the rollback data and the consistency of business data of multiple concurrent cross-database business requests.
[0055] See also Figure 2 Another embodiment of the cross-database transaction management method in the embodiment of the present invention includes:
[0056] 201. Deploy a preset project framework and obtain a preset mapping object file;
[0057] The server deploys the preset project framework and obtains the preset mapping object file. Among them, the preset project framework includes the persistence layer framework mybatis, and the preset mapping object file is a mapper file, and the file format is identified in the form of xml. Specifically, the server imports the installation package of the preset project framework, and the installation package includes the jar package of mybatis; the server receives the installation jar package command and executes the installation jar package command; the server creates a mapping service interface; the server creates a database identifier and a dynamic data source, wherein the database identifier is used to indicate that each thread is stored by an independent object, and the dynamic data source is used to connect to different databases according to unused data indexes; the server creates access objects and access tasks, and the access task packages each request for database access as an access object, writes it to the preset task management, and then waits for the task to be executed and retrieves the execution result. Further, the server executes the database access task through the preset thread pool; the server creates a mapper.xml file and obtains the preset mapping object file.
[0058] 202. configuring connection information of multiple databases and data operation statements of multiple databases in a preset mapping object file, wherein the data operation statements of multiple databases are used to indicate association with different function names of a preset interface class according to a first preset attribute;
[0059] The server configures the connection information of multiple databases and the data operation statements of multiple databases in the preset mapping object file. The data operation statements of multiple databases are used to indicate the association with different function names of the preset interface class according to the first preset attribute. Specifically, the server configures the connection information of multiple databases in the preset mapping object file according to the preset configuration information of multiple databases; the server configures the data operation statements of multiple databases in the preset mapping object file according to the preset business and SQL grammar rules. The data operation statements of multiple databases include adding operation statements, deleting operation statements and updating operation statements for multiple databases. Among them, the preset mapping object file is a mapper configuration file, for example, a mapper.xml configuration file or a configuration file in the form of a preset interface, which is not limited here.
[0060] 203. Add a first mapping tag to data operation statements of multiple databases, and associate the first mapping tag with the preset query statement according to a second preset attribute, wherein the first mapping tag is used to indicate triggering data backup;
[0061] The server adds the first mapping tag to the data operation statements of multiple databases, and associates the first mapping tag and the preset query statement according to the second preset attribute, and the first mapping tag is used to indicate the triggering of data backup, wherein the first mapping tag is the previous before tag, and the before tag is used to indicate the cached data before the transaction to be executed is committed. Further, the server confirms the data operation statements of multiple databases from the preset mapping object file, wherein the data operation statements include updating update tags, inserting insert tags, and deleting delete tags; the server obtains the preset query statement, and adds the first mapping tag to the data operation statements of multiple databases; the server associates the first mapping tag and the preset query statement according to the second preset attribute, and the first mapping tag is used to indicate the triggering of data backup. For example, a preset query statement including an identifier id, and the attribute value of the identifier id is querySegment, as shown below:
[0062] <select id="querysegment">
[0063] select*from common_document_attachment WHERE document_id=#{documentId}
[0064] < / select>
[0065] The server adds a before tag after the update start tag according to the preset query statement, and sets the backup identifier refid for before; the server sets the attribute value of the preset query statement identifier id to the attribute value of refid; and the server sets the update statement. The details are as follows:
[0066]
[0067]
[0068] 204. Add a second mapping tag to data operation statements of multiple databases, where the second mapping tag is used to indicate triggering data rollback;
[0069] The server adds a second mapping tag to the data operation statements of multiple databases, and the second mapping tag is used to indicate triggering data rollback, wherein the second mapping tag is a rollback tag, and the rollback tag is used to indicate that when a cross-database transaction fails to execute, the transaction is rolled back according to the cached backup data. Further, the server adds a second mapping tag to the data operation statements of multiple databases that have configured the before tag, and is used to perform a rollback operation when the update statement is executed abnormally. For example, the server adds rollback before the update end tag, as shown below:
[0070]
[0071] 205. Reload the preset mapping object file to obtain multiple transactions to be executed;
[0072] The server reloads the preset mapping object file to obtain multiple transactions to be executed. Specifically, the server restarts the service corresponding to the preset mapping object file to obtain the reloaded preset mapping object file; the server confirms the first mapping tag and the second mapping tag from the reloaded preset mapping object file; the server determines that the second mapping tag is used to restore the backup data, and the server sets the data operation statements identified by the first mapping tag and the second mapping tag as multiple transactions to be executed.
[0073] It is understandable that after modifying the mapper.xml file, you must restart the service corresponding to the preset mapping object file according to the preset command for the file modification to take effect.
[0074] 206. Execute multiple pending transactions through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancel operations, and confirm operations;
[0075] The server executes multiple pending transactions through preliminary operations in the preset transaction mechanism to obtain backup data. The preset transaction mechanism includes preliminary operations, cancellation operations and confirmation operations. Among them, the preset transaction mechanism is a TCC transaction mechanism, and the preliminary operation is a try statement block. The server attempts to execute the consistency judgment of the preset business according to the preset conditions and requests to reserve preset business resources according to the try statement block. Further, the server makes a consistency judgment on the preset business according to the preset conditions. For example, the server judges whether the account status of A, B and C is normal, the server judges whether the balance of account A is not less than 30 yuan, and the server judges whether the balance of account B is not less than 50 yuan; the server reserves preset business resources, for example, the frozen amount of account A increases by 30 yuan, and the frozen amount of account B increases by 50 yuan, to ensure that the transfer operations of these two accounts are not affected by other concurrent processes.
[0076] Specifically, first, the server reads the connection information of multiple databases and multiple transactions to be executed from the preset mapping object file; secondly, the server connects to multiple databases according to the preset connection class and the connection information of multiple databases. Further, the server sets the abstract method getConnection in the transaction interface Transaction of mybatis as the preset connection class; the server adds getConnection and the connection information of multiple databases to the preliminary operation; the server connects to multiple databases in the preliminary operation; finally, the server executes multiple transactions to be executed through the preliminary operation in the preset transaction mechanism, and adds distributed transaction locks to the multiple transactions to be executed, wherein the distributed transaction lock ensures that different processes mutually access shared resources. The preset transaction mechanism includes preliminary operation, confirmation operation and cancellation operation. It should be noted that the server applies for a distributed transaction lock during the execution of the try statement block, and logically locks the data of multiple databases. Further, when it is determined that at least two transaction-related data operations belong to different databases, the server generates an insert statement for the distributed transaction lock; the server executes the insert statement for the distributed transaction lock to obtain the distributed transaction lock. For example, the server logically locks the data corresponding to the A library and the data corresponding to the B library to ensure the consistency of the transaction.
[0077] Optionally, the server executes multiple transactions to be executed one by one according to different function names of the preset interface class through preliminary operations in the preset transaction mechanism to obtain a unique identifier of the transaction; the server executes a preset query statement corresponding to the first mapping label to obtain backup data; the server sets the unique identifier of the transaction and the backup data as a target key-value pair, and stores the target key-value pair in the cache; the server adds distributed transaction locks to multiple transactions to be executed, and executes data operation statements of multiple databases.
[0078] 207. When it is detected that all the transactions to be executed are successfully executed, all the transactions that are successfully executed are submitted through a confirmation operation;
[0079] When it is detected that all the pending transactions have been successfully executed, the server submits all the successfully executed transactions through a confirmation operation. The confirmation operation is a confirm statement block. The server executes the unfinished items of the preliminary operation by executing the confirm statement blocks specified by the preliminary operation one by one. Specifically, when it is detected that all of the multiple transactions to be executed are successfully executed, the server obtains the unique identifiers of all the successfully executed transactions through a confirmation operation; the transaction is submitted according to the unique identifiers of all the successfully executed transactions to obtain a submission status; the server determines whether the submission status is a success status, and further, the server compares the submission status with the target status value. If the submission status is equal to the target status value, the server determines that the submission status is a success status; if the submission status is not equal to the target status value, the server determines that the submission status is a failure status, for example, the target status value is 1, if the submission status is 1, the server determines that the submission status is a success status, and if the submission status is 0, the server determines that the submission status is a failure status; if the submission status is a success status, a release operation of the distributed transaction lock is triggered, and the reserved preset business resources are released at the same time; if the submission status is a failure status, the transaction in the failed status is resubmitted, and the number of submissions is counted until the number of submissions is not less than the preset number or the submission status is a success status. For example, if a piece of data is added to database A and a piece of data is reduced in database B, then after the transactions of databases A and B are successfully executed, the server commits the related transactions of A and B through confirmation operations and obtains the commit status S1 and S2. The commit is completed when both S1 and S2 are in the successful status.
[0080] 208. When it is detected that any one of the multiple pending transactions fails to execute, the executed transaction is rolled back according to the backup data by canceling the operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain a verification result;
[0081] When it is detected that any one of the multiple pending transactions fails to execute, the server rolls back the executed transaction according to the backup data through the cancel operation to obtain the rolled back data, and verifies the rolled back data according to the backup data to obtain the verification result. Among them, the cancel operation is used to cancel the execution of the preset business, and the cancel operation is a cancel statement block, which is used to release the reserved preset business resources and distributed transaction locks. For example, during the initial operation execution process, the server detects that the balance of account A meets the preset conditions and successfully freezes the corresponding amount, but the balance of account B does not meet the preset conditions and the freezing of the amount of account B fails, then the server uses the cancel statement block and backup data C to unfreeze the frozen amount of account A.
[0082] Specifically, when it is detected that any one of the multiple pending transactions fails to execute, the backup data is obtained according to the unique identifier of the transaction through the cancellation operation. For example, when the server executes the update transaction, the server first executes the before tag, caches the corresponding data, and obtains the backup data. When it is detected that the transaction fails to execute, and the server detects that the transaction includes the rollback tag, the server obtains the backup data according to the unique identifier of the transaction through the cancellation operation; the server rolls back the executed transaction according to the backup data, and releases the distributed transaction lock to obtain the rolled back data. Among them, rolling back the executed transaction is for the script being executed. For example, when the A database executes the A.update transaction operation, the server executes the local rollback, which is to execute A.rollback. The rollback of the B database is B.rollback. Further, the server releases the distributed transaction lock and the reserved preset business resources. Finally, the server performs data consistency verification on the rolled back data and the backup data to obtain the verification result. Further, the server calls the corresponding equals() function to perform consistency verification processing on the rolled back data and the backup data to obtain the verification result.
[0083] 209. Determine whether the verification result is equal to the target value;
[0084] The server determines whether the verification result is equal to the target value, wherein the verification result is used to indicate whether there is difference data between the rolled back data and the backup data. If the verification result is equal to the target value, the server executes step 210; if the verification result is not equal to the target value, step 211 is executed.
[0085] 210. If the verification result is equal to the target value, the remaining executed transactions are determined, and the data of the remaining executed transactions are rolled back according to the backup data;
[0086] If the verification result is equal to the target value, the server determines the remaining executed transactions and rolls back the remaining executed transactions according to the backup data. The remaining executed transactions are a set of transactions obtained by removing the rolled back transactions from the executed transactions. For example, the server executes transactions A and B in sequence. Transaction B has an exception during execution. The server rolls back B and A in sequence according to the backup data. After B is rolled back, the verification result C is obtained. If the verification result C is equal to the target value, the server continues to roll back the remaining executed transaction A.
[0087] 211. If the verification result is not equal to the target value, the difference data is determined, and the difference data is restored according to the backup data.
[0088] If the verification result is not equal to the target value, the differential data is determined and the differential data is restored based on the backup data. Furthermore, after the data recovery is successful, the remaining executed transactions are rolled back. That is to say, when the data recovery is successful, the data consistency verification passes, and the server ensures the consistency of the rolled back data with the backup data and the correctness of the rolled back data based on the verification result.
[0089] Furthermore, the server obtains different execution states of the transaction to be executed, including the execution success state of the transaction and the execution failure state of the transaction; the server records the execution success state and the execution failure state of the transaction in a preset transaction log according to the unique identifier of the transaction; the server sends a preset alarm message for the execution failure state of the transaction. For example, the server sends a real-time alarm for the execution failure state of the transaction via email or SMS, so that the target personnel can respond and handle it in time.
[0090] In an embodiment of the present invention, backup data is obtained by configuring and executing a distributed mapping object file across databases, and data rollback verification and transaction submission are performed on distributed transactions based on the transaction mechanism and the backup data to ensure the correctness of the rollback data and the consistency of business data of multiple concurrent cross-database business requests.
[0091] The above describes the cross-database transaction management method in the embodiment of the present invention. The following describes the cross-database transaction management device in the embodiment of the present invention. Figure 3 , an embodiment of a cross-database transaction management device in an embodiment of the present invention includes:
[0092] A configuration unit 301 is used to determine data operation statements of multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback;
[0093] An execution unit 302 is used to execute multiple transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, where the preset transaction mechanism includes preliminary operations, cancel operations, and confirm operations;
[0094] A commit unit 303, when it is detected that all the transactions to be executed are successfully executed, is used to commit all the transactions that are successfully executed through a confirmation operation;
[0095] The rollback verification unit 304 is used to roll back the failed transaction according to the backup data by canceling the operation when it is detected that any one of the multiple transactions to be executed fails to execute, obtain the rolled back data, and verify the rolled back data according to the backup data to obtain the verification result;
[0096] A judging unit 305 is used to judge whether the verification result is equal to the target value;
[0097] Processing unit 306, if the verification result is equal to the target value, is used to determine the remaining executed transactions and roll back the remaining executed transactions according to the backup data;
[0098] The recovery unit 307 is used to determine the difference data if the verification result is not equal to the target value, and recover the difference data according to the backup data.
[0099] In an embodiment of the present invention, backup data is obtained by configuring and executing a distributed mapping object file across databases, and data rollback verification and transaction submission are performed on distributed transactions based on the transaction mechanism and the backup data to ensure the correctness of the rollback data and the consistency of business data of multiple concurrent cross-database business requests.
[0100] See also Figure 4 Another embodiment of the cross-database transaction management device in the embodiment of the present invention includes:
[0101] A configuration unit 301 is used to determine data operation statements of multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback;
[0102] An execution unit 302 is used to execute multiple transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, where the preset transaction mechanism includes preliminary operations, cancel operations, and confirm operations;
[0103] A commit unit 303, when it is detected that all the transactions to be executed are successfully executed, is used to commit all the transactions that are successfully executed through a confirmation operation;
[0104] The rollback verification unit 304 is used to roll back the failed transaction according to the backup data by canceling the operation when it is detected that any one of the multiple transactions to be executed fails to execute, obtain the rolled back data, and verify the rolled back data according to the backup data to obtain the verification result;
[0105] A judging unit 305 is used to judge whether the verification result is equal to the target value;
[0106] Processing unit 306, if the verification result is equal to the target value, is used to determine the remaining executed transactions and roll back the remaining executed transactions according to the backup data;
[0107] The recovery unit 307 is used to determine the difference data if the verification result is not equal to the target value, and recover the difference data according to the backup data.
[0108] Optionally, the configuration unit 301 may also be specifically configured to:
[0109] Deploy the preset project framework and obtain the preset mapping object file;
[0110] Configuring connection information of multiple databases and data operation statements of multiple databases in a preset mapping object file, wherein the data operation statements of multiple databases are used to indicate association with different function names of the preset interface class according to the first preset attribute;
[0111] Adding a first mapping tag to data operation statements of multiple databases, and associating the first mapping tag with the preset query statement according to a second preset attribute, the first mapping tag being used to indicate triggering data backup;
[0112] Adding a second mapping tag to data operation statements of multiple databases, the second mapping tag is used to indicate triggering data rollback;
[0113] Reload the preset mapping object file to obtain multiple transactions to be executed.
[0114] Optionally, the execution unit 302 may further include:
[0115] The reading subunit 3021 is used to read connection information of multiple databases and multiple transactions to be executed from a preset mapping object file;
[0116] A connection subunit 3022, used to connect to multiple databases according to a preset connection class and connection information of multiple databases;
[0117] The execution subunit 3023 is used to execute multiple pending transactions through preliminary operations in the preset transaction mechanism, obtain backup data, and add distributed transaction locks to the multiple pending transactions. The preset transaction mechanism includes preliminary operations, confirmation operations, and cancellation operations.
[0118] Optionally, the execution subunit 3023 may be further specifically configured to:
[0119] Execute multiple pending transactions one by one according to different function names of preset interface classes through preliminary operations in the preset transaction mechanism, and obtain a unique identifier of the transaction. The preset transaction mechanism includes preliminary operations, confirmation operations, and cancellation operations.
[0120] Execute the preset query statement corresponding to the first mapping label to obtain the backup data;
[0121] Set the unique identifier of the transaction and the backup data as a target key-value pair, and store the target key-value pair in the cache;
[0122] Add distributed transaction locks to multiple pending transactions and execute data operation statements in multiple databases.
[0123] Optionally, the rollback verification unit 304 may also be specifically configured to:
[0124] When it is detected that any one of the multiple pending transactions fails to execute, the backup data is obtained according to the unique identifier of the transaction through the cancellation operation;
[0125] Roll back the failed transaction according to the backup data, release the distributed transaction lock, and obtain the rolled back data;
[0126] The rolled back data and the backup data are verified for data consistency to obtain a verification result.
[0127] Optionally, the submitting unit 303 may also be specifically configured to:
[0128] When it is detected that all the pending transactions are successfully executed, the unique identifiers of all the successfully executed transactions are obtained through a confirmation operation;
[0129] Submit the transaction according to the unique identifier of all successfully executed transactions and obtain the submission status;
[0130] Determine whether the submission status is successful;
[0131] If the submission status is successful, the release operation of the distributed transaction lock is triggered;
[0132] If the submission status is a failed state, the transaction in the failed state is resubmitted and the number of submissions is counted until the number of submissions is not less than the preset number or the submission status is a successful state.
[0133] Optionally, the cross-database transaction management device may further include:
[0134] An acquisition unit 308 is used to acquire different execution states of the transaction to be executed, where the different execution states include a transaction execution success state and a transaction execution failure state;
[0135] The recording unit 309 is used to record the execution success status and the execution failure status of the transaction into a preset transaction log according to the unique identifier of the transaction;
[0136] The sending unit 310 is used to send preset warning information for the execution failure status of the transaction.
[0137] In an embodiment of the present invention, backup data is obtained by configuring and executing a distributed mapping object file across databases, and data rollback verification and transaction submission are performed on distributed transactions based on the transaction mechanism and the backup data to ensure the correctness of the rollback data and the consistency of business data of multiple concurrent cross-database business requests.
[0138] above Figure 3 and Figure 4 The cross-database transaction management apparatus in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The cross-database transaction management device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0139] Figure 5 1 is a schematic diagram of the structure of a cross-database transaction management device provided by an embodiment of the present invention. The cross-database transaction management device 500 may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 501 (for example, one or more processors) and a memory 509, and one or more storage media 508 (for example, one or more mass storage devices) storing application programs 507 or data 506. Among them, the memory 509 and the storage medium 508 can be short-term storage or permanent storage. The program stored in the storage medium 508 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in cross-database transaction management. Furthermore, the processor 501 can be configured to communicate with the storage medium 508 to execute a series of instruction operations in the storage medium 508 on the cross-database transaction management device 500.
[0140] The cross-database transaction management device 500 may also include one or more power supplies 502, one or more wired or wireless network interfaces 503, one or more input and output interfaces 504, and / or one or more operating systems 505, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that Figure 5 The cross-database transaction management device structure shown in the figure does not constitute a limitation on the cross-database transaction management device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0141] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0142] In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods 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 interfaces, devices or units, which can be electrical, mechanical or other forms.
[0143] 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.
[0144] 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0145] If the integrated unit 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 is essentially or the part that contributes to the prior art or all or 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 a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0146] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A cross-database transaction management method, characterized in that: include: Determine data operation statements for multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements for the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback; Execute the multiple transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes a preliminary operation, a cancel operation, and a confirm operation; When it is detected that all the multiple transactions to be executed are successfully executed, submitting all the successfully executed transactions through the confirmation operation; When it is detected that any one of the multiple transactions to be executed fails to execute, the executed transaction is rolled back according to the backup data through the cancellation operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain a verification result; Determining whether the verification result is equal to the target value; If the verification result is equal to the target value, the remaining executed transactions are determined, and data of the remaining executed transactions are rolled back according to the backup data; If the verification result is not equal to the target value, differential data is determined, and data recovery is performed on the differential data according to the backup data.
2. The cross-database transaction management method according to claim 1, characterized in that: The method of determining data operation statements of multiple databases from a preset mapping object file and configuring a first mapping tag and a second mapping tag for the data operation statements of the multiple databases to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup and the second mapping tag is used to indicate triggering data rollback, includes: Deploy the preset project framework and obtain the preset mapping object file; Configuring connection information of multiple databases and data operation statements of the multiple databases in the preset mapping object file, wherein the data operation statements of the multiple databases are used to indicate association with different function names of the preset interface class according to the first preset attribute; Adding a first mapping tag to the data operation statements of the multiple databases, and associating the first mapping tag with the preset query statement according to a second preset attribute, wherein the first mapping tag is used to indicate triggering data backup; adding the second mapping tag to the data operation statements of the multiple databases, wherein the second mapping tag is used to indicate triggering data rollback; The preset mapping object file is reloaded to obtain a plurality of transactions to be executed.
3. The cross-database transaction management method according to claim 2, characterized in that: The multiple transactions to be executed are executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes preliminary operations, cancellation operations and confirmation operations, including: Reading the connection information of the plurality of databases and the plurality of transactions to be executed from the preset mapping object file; Connecting to the multiple databases according to the preset connection class and the connection information of the multiple databases; The multiple transactions to be executed are executed through preliminary operations in a preset transaction mechanism to obtain backup data, and distributed transaction locks are added to the multiple transactions to be executed. The preset transaction mechanism includes the preliminary operation, confirmation operation and cancellation operation.
4. The cross-database transaction management method according to claim 3, characterized in that: The multiple transactions to be executed are executed through the preliminary operation in the preset transaction mechanism to obtain backup data, and a distributed transaction lock is added to the multiple transactions to be executed, wherein the preset transaction mechanism includes the preliminary operation, the confirmation operation and the cancellation operation, including: Execute the multiple transactions to be executed one by one according to different function names of the preset interface class through preliminary operations in the preset transaction mechanism to obtain a unique identifier of the transaction, wherein the preset transaction mechanism includes the preliminary operation, the confirmation operation and the cancellation operation; Execute a preset query statement corresponding to the first mapping label to obtain backup data; Setting the unique identifier of the transaction and the backup data into a target key-value pair, and storing the target key-value pair in a cache; Add a distributed transaction lock to the multiple transactions to be executed, and execute data operation statements of the multiple databases.
5. The cross-database transaction management method according to claim 4, characterized in that: When it is detected that any one of the multiple transactions to be executed fails to execute, the executed transaction is rolled back according to the backup data through the cancellation operation to obtain the rolled back data, and the rolled back data is verified according to the backup data to obtain the verification result including: When it is detected that any one of the multiple transactions to be executed fails to execute, the backup data is obtained according to the unique identifier of the transaction through the cancellation operation; Rolling back the executed transaction according to the backup data, and releasing the distributed transaction lock to obtain the rolled back data; Data consistency verification is performed on the rolled back data and the backup data to obtain a verification result.
6. The cross-database transaction management method according to claim 4, characterized in that: When it is detected that all the transactions to be executed are successfully executed, submitting all the transactions that have been successfully executed through the confirmation operation includes: When it is detected that all the multiple transactions to be executed are successfully executed, obtaining unique identifiers of all the successfully executed transactions through the confirmation operation; Commit the transaction according to the unique identifiers of all successfully executed transactions, and obtain the commit status; Determine whether the submission status is a success status; If the submission status is a success status, a release operation of the distributed transaction lock is triggered; If the submission status is a failure status, the transaction in the failure status is resubmitted, and the number of submissions is counted until the number of submissions is not less than a preset number or the submission status is a success status.
7. The cross-database transaction management method according to any one of claims 1 to 6, characterized in that: When it is detected that all the multiple transactions to be executed are successfully executed, after all the successfully executed transactions are committed through the confirmation operation, the cross-database transaction management method further includes: Acquire different execution states of the transaction to be executed, wherein the different execution states include an execution success state of the transaction and an execution failure state of the transaction; Recording the successful execution status of the transaction and the failed execution status of the transaction in a preset transaction log according to the unique identifier of the transaction; Send a preset warning message for the execution failure status of the transaction.
8. A cross-database transaction management device, characterized in that: The cross-database transaction management device comprises: a configuration unit, configured to determine data operation statements of multiple databases from a preset mapping object file, and configure a first mapping tag and a second mapping tag for the data operation statements of the multiple databases, to obtain multiple transactions to be executed, wherein the first mapping tag is used to indicate triggering data backup, and the second mapping tag is used to indicate triggering data rollback; An execution unit, configured to execute the plurality of transactions to be executed through preliminary operations in a preset transaction mechanism to obtain backup data, wherein the preset transaction mechanism includes a preliminary operation, a cancel operation, and a confirm operation; a committing unit, for committing all the successfully executed transactions through the confirmation operation when it is detected that all the transactions to be executed are successfully executed; a rollback verification unit, for, when it is detected that any one of the multiple transactions to be executed fails to execute, rolling back the executed transaction according to the backup data through the cancellation operation to obtain the rolled back data, and verifying the rolled back data according to the backup data to obtain a verification result; A judging unit, used to judge whether the verification result is equal to the target value; a processing unit, for determining the remaining executed transactions if the verification result is equal to the target value, and performing data rollback on the remaining executed transactions according to the backup data; A recovery unit is used to determine difference data if the verification result is not equal to the target value, and to recover the difference data according to the backup data.
9. A cross-database transaction management device, characterized in that: The cross-database transaction management device includes: a memory and at least one processor, the memory stores instructions, and the memory and the at least one processor are interconnected via a line; The at least one processor calls the instructions in the memory to enable the cross-database transaction management device to execute the method according to any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
