CN113138840A - Low-intrusion compensation method and device for distributed transactions - Google Patents

Low-intrusion compensation method and device for distributed transactions Download PDF

Info

Publication number
CN113138840A
CN113138840A CN202110448380.5A CN202110448380A CN113138840A CN 113138840 A CN113138840 A CN 113138840A CN 202110448380 A CN202110448380 A CN 202110448380A CN 113138840 A CN113138840 A CN 113138840A
Authority
CN
China
Prior art keywords
transaction
sub
sql statement
data snapshot
business
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110448380.5A
Other languages
Chinese (zh)
Inventor
李健
滕达
张丹枫
何佳存
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202110448380.5A priority Critical patent/CN113138840A/en
Publication of CN113138840A publication Critical patent/CN113138840A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1415Saving, restoring, recovering or retrying at system level
    • G06F11/1438Restarting or rejuvenating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Quality & Reliability (AREA)
  • Computing Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a low-intrusion compensation method and a low-intrusion compensation device for distributed transactions, which relate to the technical field of automatic program design, wherein the method comprises the following steps: intercepting a business SQL statement of each sub-transaction when a main transaction request is received; analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result; generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction; when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to a pre-data snapshot and a post-data snapshot corresponding to each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation. The invention can reduce the service intrusiveness and the development amount of workers and reduce the development cost.

Description

Low-intrusion compensation method and device for distributed transactions
Technical Field
The invention relates to the technical field of automatic program design, in particular to a low-intrusion compensation method and device for distributed transactions.
Background
This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. The description herein is not admitted to be prior art by inclusion in this section.
Although the existing Saga model and TCC model each have their own emphasis, both of the distributed transaction models are somewhat intrusive to the service. The Saga model requires that each business method has a corresponding business compensation method, and the TCC model requires that the existing business design is disassembled and a matched set of three methods, namely try, confirm and cancel, is needed for replacing one business method after the disassembly. Therefore, the two existing distributed transaction models increase the complexity of the system and the workload of developers, which results in the increase of development cost. Therefore, the existing two distributed transaction models have the problems of high invasiveness and high reconstruction cost.
Disclosure of Invention
The embodiment of the invention provides a low intrusion compensation method for distributed transactions, which is used for reducing the intrusion of services and the development amount of workers, and comprises the following steps:
intercepting a business SQL statement of each sub-transaction when a main transaction request is received;
analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result;
generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction;
when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
The embodiment of the invention also provides a low intrusion compensation device for distributed transactions, which is used for reducing the intrusiveness of services and the development amount of workers, and comprises the following components:
the intercepting unit is used for intercepting the business SQL statement of each sub-business when receiving the main business request;
the analysis unit is used for analyzing the business SQL statement of each sub-transaction and obtaining the SQL statement type and the condition of each sub-transaction as analysis results;
the data snapshot generating unit is used for generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction;
the compensation unit is used for generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction when receiving the rollback request of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
The embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the method for compensating for low intrusion of the distributed transaction.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program for executing the method for compensating for low intrusion into a distributed transaction is stored in the computer-readable storage medium.
In the embodiment of the invention, compared with the technical scheme that the distributed transaction model in the prior art can increase the complexity of the system and the workload of developers, the low-intrusion compensation scheme of the distributed transaction comprises the following steps: intercepting a business SQL statement of each sub-transaction when a main transaction request is received; analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result; generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction; when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction; the rollback SQL statement is used for completing the rollback operation, so that the service invasiveness and the development amount of workers can be reduced, and the development cost is reduced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts. In the drawings:
FIG. 1 is a flow chart illustrating a method for low-intrusion compensation of distributed transactions according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a method for executing a distributed transaction by a client in an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for executing a server side of a distributed transaction according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a method for low-intrusion compensation of distributed transactions according to yet another embodiment of the invention;
fig. 5 is a schematic structural diagram of a distributed transaction low-intrusion compensation apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the embodiments of the present invention are further described in detail below with reference to the accompanying drawings. The exemplary embodiments and descriptions of the present invention are provided to explain the present invention, but not to limit the present invention.
Before describing the embodiments of the present invention, terms referred to in the embodiments of the present invention will be described.
1. The Saga transaction model is a distributed transaction model that is mainstream in the industry. Through analysis of business logic, the Saga business model decomposes a business logic method into two methods, one is a square method and the other is an inverse method:
the method comprises the following steps: business logic operations are defined and data falls to the ground immediately after execution.
The reverse method comprises the following steps: business logic operation of rollback corresponding to the square method is defined.
2. The TCC (Try-Confirm-Cancel) transaction model is a two-phase distributed transaction model that is mainstream in the industry. Through the decomposition of the business logic, the TCC model decomposes the business logic into two phases, wherein one phase is a Try phase, and the two phases are Confirm or Cancel phases:
try: and finishing all service checks, reserving necessary service resources, and ensuring that the Confirm can be successfully completed after the Try is finished.
Confirm: the really executed service logic does not perform any service check, and only uses the service resources reserved in the try stage.
Cancel: and releasing the reserved service resources in the try stage.
the three words try, confirm, cancel are the three letters of the TCC transaction model and are referred to in English. And try is one-stage resource reservation, and whether the database resource can meet the service operation or not is checked in one stage, and if the database resource can meet the service operation, the resource is locked. And (4) confirm is two-stage resource submission, if the resource reservation of each link of the whole distributed transaction in one stage is successful, the two stages initiate the resource submission and process the reserved resources. Cancel is two-stage resource revocation, and if the whole distributed transaction fails to reserve resources of a certain link in one stage, the two stages initiate resource revocation to revoke the resources which are reserved successfully.
3. JDBC represents a component of the java-level operation database, and general items are introduced to operate the database.
4. The SQL statement represents a language that can be recognized and executed by the database, and essentially all business operations operate on data in the database through the SQL statement.
5. Connection (commit, rollback) and Statement, the two classes are two classes in the JDBC component, each time the database is operated by an application, the Connection is acquired, then the specific SQL Statement needs to use the Statement to perform execution processing, and then a commit method or a rollback method of the database Connection is called to persist the operation in the database or roll back the operation.
6. Connection proxy and StatementProxy, which are also the english names of classes, are the proxy class of the Connection class and the proxy class of the Statement, respectively.
7. Invasiveness refers to the cost of retrofitting an application with a framework. For example, the transformation cost of using the spring boot framework by a mature application is very low, the spring boot framework can be accessed without modifying the service code and the database structure, and only a few notes need to be made. If the use of a framework requires extensive modifications to existing business code or even disassembly of existing database table structures, the framework is very intrusive.
Aiming at the problems of high intrusiveness and high transformation cost of the two existing distributed transaction models, the invention overcomes the two problems and provides a low-intrusion compensation scheme of distributed transactions, and the scheme is a low-intrusion automatic compensation transformation scheme of distributed transactions. Specifically, the business SQL is intercepted in the agent method based on the native database component of the agent JDBC, then the business SQL is analyzed to obtain the SQL statement type and conditions, and front and back data snapshots are generated and stored through the analysis result and serve as data bases for the subsequent fault-tolerant method. The low-intrusion compensation scheme for the distributed transaction is described in detail below.
Fig. 1 is a schematic flow chart of a method for compensating for low-intrusion of distributed transactions according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step 101: intercepting a business SQL statement of each sub-transaction when a main transaction request is received;
step 102: analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result;
step 103: generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction;
step 104: when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
The distributed transaction low-intrusion compensation method in the embodiment of the invention is based on the primary database component of the proxy JDBC, intercepts the business SQL in the proxy method, analyzes the business SQL to obtain the SQL statement type and condition, generates and stores the front and back data snapshots through the analysis result, and provides data basis as a subsequent fault-tolerant method, thereby reducing the intrusion of the business and the development amount of workers and reducing the development cost. The individual steps involved in the method are described in detail below.
First, the above step 101 is described.
In specific implementation, as shown in fig. 2, when a main transaction request is received, a business SQL statement for each sub-transaction is intercepted.
Next, step 102 and step 103 are also described for ease of understanding.
In specific implementation, the step 102 and the step 103 are logic of a state agent object, as shown in fig. 2:
1. and analyzing the business SQL statement, and extracting the type and the condition of the SQL statement. Wherein: the types may include three types, update, delete, insert, and the condition may be a where simple condition.
2. And before the business SQL is executed, executing the pre-data snapshot query according to the analysis result to obtain the pre-data snapshot before the business SQL statement is executed.
3. And executing the business SQL statement.
4. And after the business SQL is executed, executing the post data snapshot query according to the analysis result to obtain the post data snapshot after the business SQL statement is executed.
5. And returning the combination of the pre-data snapshot and the post-data snapshot to the Connection proxy object.
From the above, in one embodiment, the native database component Statement proxy object of proxy JDBC may be utilized to perform: analyzing the business SQL statement of each sub-transaction, obtaining the SQL statement type and the condition of each sub-transaction as an analysis result, and generating a pre-data snapshot before the business SQL statement of each sub-transaction is executed and a post-data snapshot after the business SQL statement is executed according to the analysis result of each sub-transaction, i.e., analyzing the business SQL statement of each sub-transaction, obtaining the SQL statement type and the condition of each sub-transaction as an analysis result, and generating a pre-data snapshot before the business SQL statement of each sub-transaction is executed and a post-data snapshot after the business SQL statement of each sub-transaction is executed according to the analysis result of each sub-transaction, which may include: analyzing the business SQL Statement of each sub-transaction by using a primary database component State agent object of the agent JDBC, obtaining the SQL Statement type and the condition of each sub-transaction as analysis results, and generating a preposed data snapshot before the business SQL Statement of each sub-transaction is executed and a postpositional data snapshot after the business SQL Statement is executed according to the analysis results of each sub-transaction.
Next, preferred steps subsequent to the above step 103 will be described.
In specific implementation, the logic of the Connection proxy object is as shown in fig. 2:
1. registering the sub-transaction information with the server.
2. And after the registration is successful, acquiring a native State object, and storing the previous and next data snapshots into a local database of the application. That is, in one embodiment, the method for low-intrusion compensation of distributed transactions may further include: and after the sub-transaction information is successfully registered to the server, storing the preposed data snapshot and the postpositional data snapshot of each sub-transaction in a local database.
3. The commit method is executed, and in order to achieve transaction consistency, the business SQL and the snapshot storage SQL are submitted as one transaction. That is, in one embodiment, the method for low-intrusion compensation of distributed transactions may further include: and after the registration of the sub-transaction information to the server is successful, submitting the business SQL statement and the snapshot storage SQL statement as a transaction.
Additionally, as can be seen from the above, in one embodiment, a native database component Connection proxy object of proxy JDBC may be utilized to perform: and after the sub-transaction information is successfully registered to the server, storing the preposed data snapshot and the postpositional data snapshot of each sub-transaction in a local database.
Additionally, as can be seen from the above, in one embodiment, a native database component Connection proxy object of proxy JDBC may be utilized to perform: and after the sub-transaction information is successfully registered to the server, taking the business SQL statement and the snapshot storage SQL statement as a transaction submitting step.
Fourth, next, the above step 104 is described.
In specific implementation, the above-mentioned one-stage operation of the sub-transaction is mainly modified to obtain front and back data snapshots before and after the execution of the business SQL, and then the snapshot storage and the business SQL execution are used as one transaction. The two-phase operation of the sub-transaction is initiated by the server. When the main transaction reports a commit request (persistent operation request), as shown in fig. 3, the server (server) queries all sub-transaction information under the main transaction and then initiates a commit request to all sub-transactions, and after the sub-transaction commit request reaches the application side, the application side deletes the previous and subsequent data snapshots corresponding to the sub-transactions. When a rollback request (rollback request) is reported by a main transaction, as shown in fig. 3, a server side queries all sub-transaction information under the main transaction and then initiates the rollback request to all sub-transactions, after the rollback request of a sub-transaction reaches an application side, the application side (application side and client side) analyzes front and back data snapshots of the sub-transaction into rollback SQL statements for execution, and performs rollback on a stage of operation, that is, when a rollback request of each sub-transaction is received, a rollback SQL statement of each sub-transaction is generated according to the front data snapshot and the back data snapshot of each sub-transaction, and the rollback SQL statement is used for completing the rollback operation.
From the above, in one embodiment, as shown in fig. 4, the method for compensating for low-intrusion of distributed transactions may further include step 105: and when each sub-transaction persistence operation request is received, deleting the pre-data snapshot and the post-data snapshot corresponding to each sub-transaction.
The following description is given by way of example to facilitate an understanding of how the invention may be practiced.
For example, there are 1000 pieces of money in a current bank card with a surname zhangsan and 1000 pieces of money in a bank card with a surname lisi. Because one is a north person and one is a south person, the data of the two are stored in a north central database and a south central database
The table name of the north central data is normal-account (as shown in table 1 below), and the table structure has only two fields, i.e., id and amount.
The table name of the south-center data is south-account (as shown in table 2 below), and only two fields of the table structure are id and amount respectively.
A transaction is now performed that subtracts 100 from zhangsan's bank card and then adds 100 to lisi's bank card.
TABLE 1
id amout
zhangsan 1000
TABLE 2
id amout
lisi 1000
First, a first child transaction, zhangsan deduct money, is executed. Registering the sub-transaction with the server, generating a front snapshot, executing the business SQL, generating a back snapshot, and reporting the success state of the sub-transaction. The pre-and post-snapshots are then stored in a local database.
Pre-snapshot:
a map structure, the key in the map is id, amout, tableName, SQLType
Figure BDA0003037681880000071
Figure BDA0003037681880000081
Post snapshot:
a map structure, the key in the map is id, amout, tableName, SQLType
Figure BDA0003037681880000082
Then a second sub-transaction, lisi plus, is executed. The same operation is executed, but when the business SQL is executed, the database fails, the application code side (the application end and the client) obtains an exception, and then the sub-transaction fails to be reported to the server end.
Then, after receiving the information that the sub-transaction fails, the server determines that the main transaction fails, initiates a rollback request to all sub-transactions under the main transaction, generates a reverse SQL statement (rollback SQL statement) for execution by the zhangsan account according to the generated front and back snapshots, and cancels the original successfully executed business SQL operation.
In summary, the invention intercepts the business SQL by acting the database component of the native JDBC, generates the front and back data snapshots and stores the data snapshots in the local database, thereby reducing the invasiveness of the business and the development amount of the staff. The key points are as follows:
1. the traffic intrusiveness is small. A layer of proxy is made on the database level for generating front and back data snapshots (a front data snapshot and a back data snapshot), so that the service imperceptibility is basically achieved.
2. The rollback logic of the two-stage method can be automatically generated (namely, the rollback SQL statement is automatically generated), so that unnecessary work is saved, and the workload of workers is reduced.
The embodiment of the present invention further provides a device for compensating for low intrusion of distributed transactions, as described in the following embodiments. Because the principle of the device for solving the problems is similar to the method for compensating for the low intrusion of the distributed transaction, the implementation of the device can be referred to the implementation of the method for compensating for the low intrusion of the distributed transaction, and repeated details are not repeated.
Fig. 5 is a schematic structural diagram of an apparatus for compensating for low-intrusion of distributed transactions in an embodiment of the present invention, as shown in fig. 5, the apparatus includes:
the intercepting unit 01 is used for intercepting the business SQL statement of each sub-business when receiving the main business request;
the analysis unit 02 is used for analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as analysis results;
the data snapshot generating unit 03 is configured to generate a pre-data snapshot before the execution of the service SQL statement and a post-data snapshot after the execution of the service SQL statement for each sub-transaction according to the analysis result of each sub-transaction;
the compensation unit 04 is configured to generate a rollback SQL statement for each sub-transaction according to the pre-data snapshot and the post-data snapshot of each sub-transaction when receiving the rollback request of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
In one embodiment, the apparatus for low-intrusion compensation for distributed transactions may further include: and the deleting unit is used for deleting the preposed data snapshot and the postpositional data snapshot corresponding to each sub-transaction when the persistent operation request of each sub-transaction is received.
In one embodiment, the apparatus for low-intrusion compensation for distributed transactions may further include: and the storage unit is used for storing the preposed data snapshot and the postpositional data snapshot of each sub-transaction in the local database after the sub-transaction information is successfully registered to the server.
In an embodiment, the storage unit may specifically store the pre-data snapshot and the post-data snapshot of each sub-transaction in a local database by using a Connection proxy object of a native database component of proxy JDBC after the registration of the sub-transaction information with the server is successful.
In one embodiment, the method for low-intrusion compensation of distributed transactions may further include: and the submitting unit is used for submitting the business SQL statement and the snapshot storage SQL statement as a transaction after the sub-transaction information is successfully registered to the server.
In an embodiment, the submitting unit may specifically submit the service SQL statement and the snapshot storage SQL statement as one transaction by using a Connection proxy object of a native database component of proxy JDBC after registering the sub-transaction information to the server successfully.
In an embodiment, the parsing unit and the data snapshot generating unit may specifically parse the business SQL Statement of each sub-transaction by using a state agent object of a native database component of the agent JDBC, obtain an SQL Statement type and a condition of each sub-transaction as parsing results, and generate a pre-data snapshot before the business SQL Statement of each sub-transaction is executed and a post-data snapshot after the business SQL Statement of each sub-transaction is executed according to the parsing results of each sub-transaction.
The embodiment of the present invention further provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements the method for compensating for low intrusion of the distributed transaction.
An embodiment of the present invention further provides a computer-readable storage medium, where a computer program for executing the method for compensating for low intrusion into a distributed transaction is stored in the computer-readable storage medium.
In the embodiment of the invention, compared with the technical scheme that the distributed transaction model in the prior art can increase the complexity of the system and the workload of developers, the low-intrusion compensation scheme of the distributed transaction comprises the following steps: intercepting a business SQL statement of each sub-transaction when a main transaction request is received; analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result; generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction; when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction; the rollback SQL statement is used for completing the rollback operation, so that the service invasiveness and the development amount of workers can be reduced, and the development cost is reduced.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A method for low-intrusion compensation of distributed transactions, comprising:
intercepting a business SQL statement of each sub-transaction when a main transaction request is received;
analyzing the business SQL statement of each sub-transaction, and obtaining the SQL statement type and the condition of each sub-transaction as an analysis result;
generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction;
when a rollback request of each sub-transaction is received, generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
2. The method for low-intrusion compensation of distributed transactions according to claim 1, further comprising: and when each sub-transaction persistence operation request is received, deleting the pre-data snapshot and the post-data snapshot corresponding to each sub-transaction.
3. The method for low-intrusion compensation of distributed transactions according to claim 1, further comprising: and after the sub-transaction information is successfully registered to the server, storing the preposed data snapshot and the postpositional data snapshot of each sub-transaction in a local database.
4. The method of low-intrusion compensation for distributed transactions according to claim 3, wherein the proxy JDBC native database component Connection proxy object is utilized to perform: and after the sub-transaction information is successfully registered to the server, storing the preposed data snapshot and the postpositional data snapshot of each sub-transaction in a local database.
5. The method for low-intrusion compensation of distributed transactions according to claim 3, further comprising: and after the registration of the sub-transaction information to the server is successful, submitting the business SQL statement and the snapshot storage SQL statement as a transaction.
6. The method of low-intrusion compensation for distributed transactions according to claim 5, wherein the proxy JDBC native database component Connection proxy object is utilized to perform: and submitting the business SQL statement and the snapshot storage SQL statement as a transaction after the registration of the sub-transaction information to the server is successful.
7. The method of low-intrusion compensation for distributed transactions according to claim 1, wherein the proxy object of stateful, a native database component that utilizes proxy JDBC, performs: analyzing the business SQL statement of each sub-transaction, obtaining the SQL statement type and the condition of each sub-transaction as an analysis result, and generating a preposed data snapshot before the business SQL statement of each sub-transaction is executed and a postpositional data snapshot after the business SQL statement is executed according to the analysis result of each sub-transaction.
8. A distributed transaction low-intrusion compensation apparatus, comprising:
the intercepting unit is used for intercepting the business SQL statement of each sub-business when receiving the main business request;
the analysis unit is used for analyzing the business SQL statement of each sub-transaction and obtaining the SQL statement type and the condition of each sub-transaction as analysis results;
the data snapshot generating unit is used for generating a preposed data snapshot before the execution of the business SQL statement of each sub-transaction and a postpositional data snapshot after the execution of the business SQL statement according to the analysis result of each sub-transaction;
the compensation unit is used for generating a rollback SQL statement of each sub-transaction according to the preposed data snapshot and the postpositional data snapshot of each sub-transaction when receiving the rollback request of each sub-transaction; and the rollback SQL statement is used for finishing the rollback operation.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program for executing the method of any one of claims 1 to 7.
CN202110448380.5A 2021-04-25 2021-04-25 Low-intrusion compensation method and device for distributed transactions Pending CN113138840A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110448380.5A CN113138840A (en) 2021-04-25 2021-04-25 Low-intrusion compensation method and device for distributed transactions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110448380.5A CN113138840A (en) 2021-04-25 2021-04-25 Low-intrusion compensation method and device for distributed transactions

Publications (1)

Publication Number Publication Date
CN113138840A true CN113138840A (en) 2021-07-20

Family

ID=76811960

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110448380.5A Pending CN113138840A (en) 2021-04-25 2021-04-25 Low-intrusion compensation method and device for distributed transactions

Country Status (1)

Country Link
CN (1) CN113138840A (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106033439A (en) * 2015-03-13 2016-10-19 阿里巴巴集团控股有限公司 Method and system for processing distributed transaction
CN106156119A (en) * 2015-04-07 2016-11-23 阿里巴巴集团控股有限公司 A kind of distributed transaction communication means, system and device
CN111259083A (en) * 2020-02-13 2020-06-09 神州数码融信软件有限公司 Distributed transaction processing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106033439A (en) * 2015-03-13 2016-10-19 阿里巴巴集团控股有限公司 Method and system for processing distributed transaction
CN106156119A (en) * 2015-04-07 2016-11-23 阿里巴巴集团控股有限公司 A kind of distributed transaction communication means, system and device
CN111259083A (en) * 2020-02-13 2020-06-09 神州数码融信软件有限公司 Distributed transaction processing method and device

Similar Documents

Publication Publication Date Title
CN111522631B (en) Distributed transaction processing method, device, server and medium
CN105608086B (en) Transaction processing method and device for distributed database system
CN106445644B (en) Treating method and apparatus based on the distributed transaction that an improved stage submits
US7146386B2 (en) System and method for a snapshot query during database recovery
US7720992B2 (en) Tentative update and confirm or compensate
CN110765178B (en) Distributed transaction processing method and device and computer storage medium
CN111259083A (en) Distributed transaction processing method and device
US8037103B2 (en) Accessing a non-relational store with a container-managed persistence bean via a web service function
Bornea et al. One-copy serializability with snapshot isolation under the hood
EP3408763B1 (en) Guaranteed commit outcome in a distributed transaction processing system
US9251199B2 (en) Stateless database cache
CN110888718A (en) Method and device for realizing distributed transaction
JP2023509035A (en) Transaction processing method, apparatus, computer device and computer program
CN101350022B (en) Changing process method based on database logical lock
CN111062684A (en) System and method for realizing consistent processing of business data and process data under cloud process platform
Zhang et al. GRIT: consistent distributed transactions across polyglot microservices with multiple databases
US7752225B2 (en) Replication and mapping mechanism for recreating memory durations
US7827135B2 (en) Method and apparatus for relaxed transactional isolation in a client-server caching architecture
CN113138840A (en) Low-intrusion compensation method and device for distributed transactions
WO2023124242A1 (en) Transaction execution method and apparatus, device, and storage medium
Younas et al. A formal treatment of a SACReD protocol for multidatabase web transactions
CN114579260A (en) Transaction processing method and system
CN111831455A (en) Distributed transaction processing system and method under industrial Internet of things
US7395264B2 (en) Promotable transactions with promotable single phase enlistments
US20240126780A1 (en) Data processing during data replication

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination