CN111722946A - Distributed transaction processing method and device, computer equipment and readable storage medium - Google Patents
Distributed transaction processing method and device, computer equipment and readable storage medium Download PDFInfo
- Publication number
- CN111722946A CN111722946A CN202010595057.6A CN202010595057A CN111722946A CN 111722946 A CN111722946 A CN 111722946A CN 202010595057 A CN202010595057 A CN 202010595057A CN 111722946 A CN111722946 A CN 111722946A
- Authority
- CN
- China
- Prior art keywords
- transaction
- calling
- remote equipment
- rpc request
- operation result
- 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
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 31
- 238000000034 method Methods 0.000 claims abstract description 79
- 230000000977 initiatory effect Effects 0.000 claims abstract description 51
- 238000012544 monitoring process Methods 0.000 claims description 34
- 238000012545 processing Methods 0.000 claims description 17
- 238000004364 calculation method Methods 0.000 claims description 11
- 238000004590 computer program Methods 0.000 claims description 11
- 239000003999 initiator Substances 0.000 claims description 5
- 230000003993 interaction Effects 0.000 abstract description 10
- 230000008878 coupling Effects 0.000 abstract description 6
- 238000010168 coupling process Methods 0.000 abstract description 6
- 238000005859 coupling reaction Methods 0.000 abstract description 6
- 238000005516 engineering process Methods 0.000 abstract description 4
- 230000009545 invasion Effects 0.000 abstract description 3
- 238000004891 communication Methods 0.000 description 5
- 238000004422 calculation algorithm Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000006870 function Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000010276 construction Methods 0.000 description 2
- 238000013500 data storage Methods 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 238000002360 preparation method Methods 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 238000012546 transfer Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000001413 cellular effect Effects 0.000 description 1
- 238000006243 chemical reaction Methods 0.000 description 1
- 230000001419 dependent effect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 239000000835 fiber Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/547—Remote procedure calls [RPC]; Web services
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, 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)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Retry When Errors Occur (AREA)
Abstract
The invention relates to a cloud storage technology, and discloses a distributed transaction processing method, a device, computer equipment and a readable storage medium, wherein the method comprises the following steps: calling an AOP component to intercept a local transaction and writing the local transaction into a preset transaction table; calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table; calling remote equipment to calculate local affairs through an affair manager; judging whether an operation result sent by the remote equipment is received or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through the transaction manager; and if the operation result is received, deleting the local transaction and the RPC request, and sending the operation result to the transaction initiating terminal. The invention reduces the system coupling, and avoids the invasion of service codes and the low efficiency caused by frequent interaction; the stability and reliability of submitting local affairs and calling remote equipment are ensured, and the atomicity and consistency of the obtained operation result are ensured.
Description
Technical Field
The invention relates to the technical field of cloud storage, in particular to a distributed transaction processing method and device, computer equipment and a readable storage medium.
Background
With the increasing complexity of IT systems, the number of subsystems in the micro-service architecture is increasing. When business operations are carried out, a request is often followed by cooperative cooperation of a plurality of subsystems to complete ordered promotion of a series of dependent services. Especially for stateful services, in a distributed environment, how to ensure the state consistency of each subsystem and the validity of data in the coordinated conversion of multiple systems in multiple states is a problem to be solved urgently by the current distributed transaction.
The industry has multiple sets of solutions for distributed transactions, and the mainstream functions of XA protocol, two-phase commit, three-phase commit, TCC and the like can solve the needs of most distributed transactions.
However, these schemes generally have the problems of strong system coupling and high code intrusiveness, and once the server fails to submit to the remote device, the transaction initiator is also triggered to send the local transaction and the RPC request again, which causes frequent interaction between the transaction initiator and the server of the local transaction and the RPC request, resulting in system inefficiency.
Disclosure of Invention
The invention aims to provide a distributed transaction processing method, a distributed transaction processing device, computer equipment and a readable storage medium, which are used for solving the problems of strong system coupling, high code intrusiveness and low system efficiency caused by frequent interaction of local transactions and RPC (remote procedure call) requests between a transaction initiating terminal and a server in the prior art; the method and the system can be applied to intelligent government affair scenes, and therefore construction of intelligent cities is promoted.
To achieve the above object, the present invention provides a distributed transaction processing method, including:
monitoring whether a local transaction is started by a transaction initiating end, if so, calling an AOP component to intercept the local transaction and writing the local transaction into a preset transaction table;
monitoring whether an affair initiating end calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table;
calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request;
judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
In the above scheme, before monitoring whether the transaction initiator starts the local transaction, the method includes:
and constructing a spring framework of a transaction manager and an AOP component, and a database with a transaction table and a method table.
In the above scheme, after the calling the AOP component to intercept the RPC request and write it into the preset method table, the method includes:
calling the remote equipment according to the RPC request to judge whether all the remote equipment is ready; if all the remote devices are ready, extracting the instant execution thread; if at least one remote device is not ready, a delay judgment thread is extracted.
In the above solution, the step of invoking a remote device to operate the local transaction through a transaction manager according to the RPC request includes:
extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote equipment;
after the generating of the operation result, the method further includes:
and uploading the operation result to a block chain.
In the above scheme, after the extraction of the delay judging thread, the method includes:
and calling a delay judgment thread to call the remote equipment again according to the RPC request after a preset delay time so as to judge whether all the remote equipment is ready.
In the above scheme, the rollback thread includes the following steps:
extracting local affairs in the affair table and RPC requests in the method table;
extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote equipment;
after the generating of the operation result, the method further includes:
and uploading the operation result to a block chain.
In the above scheme, after the rollback thread is invoked by the transaction manager, the method further includes:
recording the calling times of the rollback thread, and judging whether the submission times exceed a preset retry threshold; if yes, executing the rollback thread again; if not, alarm information is generated.
To achieve the above object, the present invention further provides a distributed transaction processing apparatus, including:
the monitoring module is used for monitoring whether the transaction initiating end starts a local transaction, if so, the AOP component is called to intercept the local transaction and write the local transaction into a preset transaction table;
the monitoring module is used for monitoring whether the transaction initiating terminal calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and write the RPC request into a preset method table;
the calling module is used for calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request;
the judging module is used for judging whether the operation result sent by the remote equipment is received within the preset monitoring time; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
To achieve the above object, 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, wherein the processor of the computer device implements the steps of the distributed transaction processing method when executing the computer program.
To achieve the above object, the present invention further provides a computer readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the steps of the distributed transaction processing method.
According to the distributed transaction processing method, the distributed transaction processing device, the computer equipment and the readable storage medium, the transaction manager and the AOP component are loaded into the server in an annotation form, so that the system coupling is reduced, and the intrusion of service codes is avoided; whether a local transaction is started by a transaction initiating terminal is monitored, an AOP component is called to intercept the local transaction and store the local transaction in a transaction table, so that a transaction manager submits the local transaction to a remote terminal again through a rollback thread, whether an RPC request is generated by the transaction initiating terminal is monitored, the AOP component is called to intercept the RPC request and store the RPC request in a method table, so that the transaction manager submits the RPC request to the remote terminal again through the rollback thread, and the problem of low efficiency caused by frequent interaction between the transaction initiating terminal and a server is avoided; the transaction manager provides the rollback thread to ensure the submission of the local transaction and the stability and reliability of the task of calling the remote equipment, and the transaction manager obtains the prestored local transaction and RPC request from the transaction table and the method table to ensure the atomicity and consistency of the operation result obtained by calling the rollback thread.
Drawings
FIG. 1 is a flow chart of a first embodiment of a distributed transaction processing method of the present invention;
FIG. 2 is a schematic diagram of an environment application of a distributed transaction processing method according to a second embodiment of the distributed transaction processing method of the present invention;
FIG. 3 is a flowchart of a distributed transaction processing method according to a second embodiment of the distributed transaction processing method of the present invention;
FIG. 4 is a block diagram of a third embodiment of a distributed transaction processing apparatus;
fig. 5 is a schematic diagram of a hardware structure of a computer device according to a fourth embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a distributed transaction processing method, a distributed transaction processing device, computer equipment and a readable storage medium, which are suitable for the technical field of cloud storage and are based on a monitoring module, a calling module and a judging module. The method comprises the steps of monitoring whether a local transaction is started by a transaction initiating end, if so, calling an AOP assembly to intercept the local transaction and writing the local transaction into a preset transaction table; monitoring whether an affair initiating end calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table; calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request; judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
The noun explains:
AOP: the AOP component is a component changed from a plane tangent plane.
RPC: remote Procedure Call protocol (RPC), which is a protocol for requesting services from a remote computer program over a network without knowledge of underlying network technology, is based on the request information of the remote Procedure Call protocol.
The first embodiment is as follows:
referring to fig. 1, a distributed transaction processing method of the present embodiment includes:
s102: monitoring whether a local transaction is started by a transaction initiating end, if so, calling an AOP component to intercept the local transaction and writing the local transaction into a preset transaction table;
s103: monitoring whether an affair initiating end calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table;
s105: calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request;
s107: judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
In an exemplary embodiment, the transaction manager and the AOP component are loaded into the server in an annotation form, so that the server can call the AOP component and the transaction manager in the spring framework through the annotation, the system coupling is reduced, the intrusion of business codes is avoided, and the problem of how to avoid the intrusion of the codes in the server is solved;
whether the local affair is started by the affair initiating end is monitored, the AOP component is called to intercept the local affair and store the local affair in the affair table, so that the affair manager submits the local affair to the remote terminal again through the rollback thread, the problem of low efficiency caused by frequent interaction between the affair initiating end and the server is avoided, and the problem of low efficiency caused by frequent interaction between the affair initiating end and the server due to the fact that the affair initiating end repeatedly sends the local affair due to submission failure is solved.
Whether the RPC request is generated by the transaction initiating terminal is monitored, the AOP component is called to intercept the RPC request and store the RPC request in the method table, so that the transaction manager can submit the RPC request to the remote terminal again through the rollback thread, the problem of low efficiency caused by frequent interaction between the transaction initiating terminal and the server is avoided, and the problem of low efficiency caused by frequent interaction between the transaction initiating terminal and the server due to repeated RPC request sending by the transaction initiating terminal due to failure in submission is solved.
The RPC request comprises host information defining a communication address and/or an equipment ID of remote equipment and call information recording a call method of the remote equipment, a local transaction is submitted to the remote equipment corresponding to the host information, and the remote equipment is called according to the call method to calculate the local transaction to generate an operation result.
The transaction manager provides the rollback thread to obtain the local transaction and the RPC request from the transaction table and the method table, and calls the remote equipment to calculate the local transaction according to the RPC request again to obtain a calculation result, so that the submission of the local transaction and the stability and reliability of a task for calling the remote equipment are ensured, and the pre-stored local transaction and RPC request are obtained from the transaction table and the method table, so that the atomicity and consistency of the calculation result obtained by calling the rollback thread are ensured, and the problems of how to ensure that the remote equipment can obtain the local transaction and how to calculate the local transaction and return the calculation result are solved.
Wherein the atomicity refers to: the database operations which form a transaction are an atomic unit which can not be divided, and the whole transaction is submitted only if all the operations are successfully executed. Any database operation in a transaction fails and any operations that have been performed must be undone to return the database to the original state.
The consistency is that: after the transaction operation is successful, the state of the database is consistent with the business rule of the database, namely the data cannot be damaged. If the account A transfers 100 yuan to the account B, the total deposit amount of the account A and the account B is unchanged whether the operation is successful or not.
The method and the system can be applied to intelligent government affair scenes, and therefore construction of intelligent cities is promoted.
In fig. 1, the step S107 includes the following steps:
s71: judging whether an operation result sent by the remote equipment is received within preset monitoring time or not;
s72: if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result;
s73: and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
Example two:
the embodiment is a specific application scenario of the first embodiment, and the method provided by the present invention can be more clearly and specifically explained through the embodiment.
Next, the method provided in this embodiment is specifically described by taking an example in which, in a server running a distributed transaction processing method, a local transaction and an RPC request are intercepted and written into a preset transaction table and a preset method table, a remote device is called by a transaction manager to calculate the local transaction, the local transaction and the RPC request are deleted, and a calculation result is sent to the transaction initiation end. It should be noted that the present embodiment is only exemplary, and does not limit the protection scope of the embodiments of the present invention.
Fig. 2 schematically shows an environment application diagram of the distributed transaction processing method according to the second embodiment of the present application.
In an exemplary embodiment, the server 2 in which the distributed transaction processing method is located is respectively connected to the transaction initiating terminal 3, the transaction manager 4 and the remote device 5 through a network, and the transaction manager 4 also calls the remote device 5 through the network; the server 2 may provide services through one or more networks, which may include various network devices, such as routers, switches, multiplexers, hubs, modems, bridges, repeaters, firewalls, proxy devices, and/or the like. The network may include physical links, such as coaxial cable links, twisted pair cable links, fiber optic links, combinations thereof, and/or the like. The network may include wireless links, such as cellular links, satellite links, Wi-Fi links, and/or the like; the transaction initiating terminal 3, the transaction manager 4 and the remote device 5 may be a server, or may be a computer device such as a smart phone, a tablet computer, a notebook computer, or a desktop computer.
Fig. 3 is a flowchart of a specific method of a distributed transaction processing method according to an embodiment of the present invention, where the method specifically includes steps S201 to S208.
S201: and constructing a spring framework of a transaction manager and an AOP component, and a database with a transaction table and a method table.
In order to avoid the invasion of codes in the server, the server can call the AOP component and the transaction manager in the spring frame through the annotation by constructing the spring frame of the transaction manager and the AOP component and loading the transaction manager and the AOP component into the server in the form of annotation, so that the system coupling is reduced, and the invasion of service codes is avoided.
S202: monitoring whether a local transaction is started by a transaction initiating end, if so, calling an AOP component to intercept the local transaction and writing the local transaction into a preset transaction table;
in the step, whether the local transaction is started by the transaction initiating end is monitored, and the AOP component is called to intercept the local transaction and store the local transaction in the transaction table, so that the transaction manager can submit the local transaction to the remote terminal again through the rollback thread, and the problem of low efficiency caused by frequent interaction between the transaction initiating end and the server is avoided.
S203: monitoring whether an affair initiating end calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table;
in the step, whether the transaction initiating terminal generates the RPC request or not is monitored, an AOP component is called to intercept the RPC request and store the RPC request in a method table, so that a transaction manager can submit the RPC request to a remote terminal again through a rollback thread, and the problem of low efficiency caused by frequent interaction between the transaction initiating terminal and the server is avoided.
S204: calling the remote equipment according to the RPC request to judge whether all the remote equipment is ready; if all the remote devices are ready, extracting the instant execution thread; if at least one remote device is not ready, a delay judgment thread is extracted.
In order to avoid submitting a local transaction to a remote device which cannot provide service to a transaction initiating terminal, which causes that a communication link between the remote device or a server and the remote device cannot work normally, even causes that the remote device crashes, the remote device is called by an RPC request to judge whether all the remote devices are ready, so that all the remote devices corresponding to the RPC request can provide service to the transaction initiating terminal.
In fig. 3, the step S204 includes the following steps:
s41: calling the remote equipment according to the RPC request to judge whether all the remote equipment is ready;
s42: if all the remote devices are ready, extracting the instant execution thread;
s43: if at least one remote device is not ready, a delay judgment thread is extracted.
Specifically, the step of calling the remote device according to the RPC request to determine whether all the remote devices are ready includes:
s204-1: extracting host information in the RPC request, and sending a preparation signal to remote equipment corresponding to the host information; wherein the host information comprises a communication address and/or a device ID of the remote device;
s204-2: receiving a feedback signal returned by the remote equipment according to the preparation signal;
s204-3: judging whether the received feedback signal has an abnormal signal; if yes, determining that at least one remote device is not ready; if not, all the remote devices are judged to be ready.
S205: and calling an instant execution thread to call remote equipment to calculate the local transaction through a transaction manager according to the RPC request.
The RPC request comprises host information defining a communication address and/or an equipment ID of remote equipment and call information recording a call method of the remote equipment, a local transaction is submitted to the remote equipment corresponding to the host information, and the remote equipment is called according to the call method to calculate the local transaction to generate an operation result.
In a preferred embodiment, the step of invoking the remote device to compute the local transaction through the transaction manager according to the RPC request includes:
s205-1: extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
s205-2: extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote device.
It should be noted that the calling method at least includes the class and/or the function to be included.
In this embodiment, the local transaction is submitted to the remote device by calling an interface of the transaction manager, where the interface is: spring frame transfer platform across this interface, Spring is for each platform such as: JDBC, Hibernate, etc. all provide corresponding transaction managers.
Specifically, the code of the interface may be as follows:
preferably, after the generating the operation result, the method further includes:
and uploading the operation result to a block chain.
The corresponding digest information is obtained based on the operation result, and specifically, the digest information is obtained by hashing the operation result, for example, using the sha256s algorithm. Uploading summary information to the blockchain can ensure the safety and the fair transparency of the user. The user equipment can download the summary information from the blockchain so as to verify whether the operation result is tampered. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
S206: and calling a delay judgment thread to call the remote equipment again according to the RPC request after a preset delay time so as to judge whether all the remote equipment is ready.
In order to avoid submitting a local transaction to a remote device that is unable to serve the transaction initiator, causing the communication link between the remote device or server and the remote device to fail to work properly, and even causing the remote device to crash,
when at least one remote device is not ready, the submission is temporarily stopped, and after a preset delay time elapses, whether all the remote devices are ready is judged again, and a buffer time is provided for the remote devices which cannot provide services temporarily until all the remote devices are ready, and S205 is executed to ensure the stability of the server and the remote devices.
S207: judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
In order to ensure that the remote equipment can obtain the local transaction and operate the local transaction to return an operation result, the transaction manager provides a rollback thread to obtain the local transaction and the RPC request from the transaction table and the method table, and calls the remote equipment to operate the local transaction again according to the RPC request to obtain the operation result, so that the submission of the local transaction and the stability and reliability of a task calling the remote equipment are ensured, and the pre-saved local transaction and RPC request are obtained from the transaction table and the method table, so that the atomicity and consistency of the operation result obtained by calling the rollback thread are ensured.
In a preferred embodiment, the rollback thread comprises the steps of:
s207-1: extracting local affairs in the affair table and RPC requests in the method table;
s207-2: extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
s207-3: extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote device.
Preferably, after the generating the operation result, the method further includes:
and uploading the operation result to a block chain.
The corresponding digest information is obtained based on the operation result, and specifically, the digest information is obtained by hashing the operation result, for example, using the sha256s algorithm. Uploading summary information to the blockchain can ensure the safety and the fair transparency of the user. The user equipment can download the summary information from the blockchain so as to verify whether the operation result is tampered. The blockchain referred to in this example is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, encryption algorithm, and the like. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
In fig. 3, the step S207 includes the following steps:
s71: judging whether an operation result sent by the remote equipment is received within preset monitoring time or not;
s72: if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result;
s73: and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
S208: recording the calling times of the rollback thread, and judging whether the submission times exceed a preset retry threshold; if yes, executing the rollback thread again; if not, alarm information is generated.
In order to identify the remote equipment with a fault so as to avoid the situation that the remote equipment cannot calculate the local affair later and the calculation task of the local affair cannot be carried out, the calling times of the rollback thread are compared with a preset retry threshold, once the calling times exceed the retry threshold, the remote equipment needing to be called has a fault, and alarm information is generated so that a worker can conveniently check the fault equipment, and the overall reliability of a system consisting of the affair initiating end, the server and the remote equipment is improved.
In fig. 3, the step S208 comprises the following steps:
s81: recording the calling times of the rollback thread;
s82: judging whether the number of submission times exceeds a preset retry threshold value;
s83: if yes, executing the rollback thread again;
s84: if not, alarm information is generated.
Example three:
referring to fig. 4, a distributed transaction processing apparatus 1 of the present embodiment includes:
the monitoring module 12 is configured to monitor whether a local transaction is started by a transaction initiating end, and if yes, invoke an AOP component to intercept the local transaction and write the local transaction into a preset transaction table;
the monitoring module 13 is configured to monitor whether the transaction initiating terminal calls an RPC and generates an RPC request, and if so, call the AOP component to intercept the RPC request and write the RPC request into a preset method table;
the calling module 15 is used for calling the remote equipment to calculate the local transaction through the transaction manager according to the RPC request;
the judging module 17 is configured to judge whether an operation result sent by the remote device is received within a preset monitoring time; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
Optionally, the distributed transaction processing apparatus 1 further includes:
and the building module 11 is used for building a spring framework of the transaction manager and the AOP component and a database with a transaction table and a method table.
Optionally, the distributed transaction processing apparatus 1 further includes:
a preparing module 14, configured to call the remote device according to the RPC request to determine whether all the remote devices are ready; if all the remote devices are ready, extracting the instant execution thread; if at least one remote device is not ready, a delay judgment thread is extracted.
Optionally, the distributed transaction processing apparatus 1 further includes:
and the delay module 16 is configured to call a delay judgment thread to call the remote devices again according to the RPC request after a preset delay time is passed to judge whether all the remote devices are ready.
Optionally, the distributed transaction processing apparatus 1 further includes:
the alarm module 18 is used for recording the calling times of the rollback thread and judging whether the submission times exceed a preset retry threshold value; if yes, executing the rollback thread again; if not, alarm information is generated.
The technical scheme is applied to the field of cloud storage of cloud services, and the local transaction is intercepted and written into a preset transaction table by calling an AOP component, and the RPC request is intercepted and written into a preset method table; calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request; judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; if the operation result is received, deleting the local affair in the affair table and the RPC request in the method table, and sending the operation result to the affair initiating end, so that the application is applied to the technical field of virtualization data synchronization of virtualization storage through the affair manager to achieve the technical effect of virtualization data synchronization of the remote equipment and the affair initiating end.
Example four:
in order to achieve the above object, the present invention further provides a computer device 6, components of the distributed transaction processing apparatus 1 according to the third embodiment may be distributed in different computer devices 6, and the computer device 6 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server, or a rack server (including an independent server or a server cluster formed by a plurality of application servers) that executes a program. The computer device of the embodiment at least includes but is not limited to: a memory 61, a processor 62, which may be communicatively coupled to each other via a system bus, as shown in FIG. 5. It should be noted that fig. 5 only shows a computer device with components, but it should be understood that not all of the shown components are required to be implemented, and more or fewer components may be implemented instead.
In the present embodiment, the memory 61 (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the memory 61 may be an internal storage unit of the computer device, such as a hard disk or a memory of the computer device. In other embodiments, the memory 61 may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the computer device. Of course, the memory 61 may also include both internal and external storage devices of the computer device. In this embodiment, the memory 61 is generally used for storing an operating system and various application software installed in the computer device, such as the program code of the distributed transaction processing apparatus in the third embodiment. Further, the memory 61 may also be used to temporarily store various types of data that have been output or are to be output.
Processor 62 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 62 is typically used to control the overall operation of the computer device. In this embodiment, the processor 62 is configured to execute the program code stored in the memory 61 or process data, for example, execute a distributed transaction processing apparatus, so as to implement the distributed transaction processing method according to the first embodiment and the second embodiment.
Example five:
to achieve the above objects, the present invention also provides a computer-readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application store, etc., on which a computer program is stored, which when executed by a processor 62, implements corresponding functions. The computer readable storage medium of this embodiment is used for storing a distributed transaction processing apparatus, and when executed by the processor 62, implements the distributed transaction processing method of the first embodiment and the second embodiment.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. A distributed transaction processing method, comprising:
monitoring whether a local transaction is started by a transaction initiating end, if so, calling an AOP component to intercept the local transaction and writing the local transaction into a preset transaction table;
monitoring whether an affair initiating end calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and writing the RPC request into a preset method table;
calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request;
judging whether an operation result sent by the remote equipment is received within preset monitoring time or not; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
2. The distributed transaction processing method of claim 1, wherein before monitoring whether the local transaction is started by the transaction initiator, the method comprises:
and constructing a spring framework of a transaction manager and an AOP component, and a database with a transaction table and a method table.
3. The distributed transaction processing method of claim 1, wherein after the calling AOP component intercepts the RPC request and writes the RPC request into a preset method table, the method comprises:
calling the remote equipment according to the RPC request to judge whether all the remote equipment is ready; if all the remote devices are ready, extracting the instant execution thread; if at least one remote device is not ready, a delay judgment thread is extracted.
4. The distributed transaction processing method of claim 1, wherein the step of invoking the remote device to compute the local transaction via a transaction manager according to the RPC request comprises:
extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote equipment;
after the generating of the operation result, the method further includes:
and uploading the operation result to a block chain.
5. The distributed transaction processing method of claim 3, wherein after extracting the delay time determination thread, the method comprises:
and calling a delay judgment thread to call the remote equipment again according to the RPC request after a preset delay time so as to judge whether all the remote equipment is ready.
6. The distributed transaction processing method of claim 1, wherein the rollback thread comprises the steps of:
extracting local affairs in the affair table and RPC requests in the method table;
extracting host information in the RPC request, obtaining remote equipment corresponding to the host information, and calling a transaction manager to submit the local transaction to the remote equipment;
extracting calling information in the RPC request, calling the remote equipment to calculate the local transaction according to the calling information and generating a calculation result; wherein, the calling information is recorded with a calling method for the remote equipment;
after the generating of the operation result, the method further includes:
and uploading the operation result to a block chain.
7. The distributed transaction processing method of claim 1, after invoking the rollback thread by the transaction manager, further comprising:
recording the calling times of the rollback thread, and judging whether the submission times exceed a preset retry threshold; if yes, executing the rollback thread again; if not, alarm information is generated.
8. A distributed transaction processing apparatus, comprising:
the monitoring module is used for monitoring whether the transaction initiating end starts a local transaction, if so, the AOP component is called to intercept the local transaction and write the local transaction into a preset transaction table;
the monitoring module is used for monitoring whether the transaction initiating terminal calls RPC and generates an RPC request, if so, calling an AOP component to intercept the RPC request and write the RPC request into a preset method table;
the calling module is used for calling remote equipment to calculate the local transaction through a transaction manager according to the RPC request;
the judging module is used for judging whether the operation result sent by the remote equipment is received within the preset monitoring time; if the operation result is not received or the submission failure information sent by the remote equipment is received, calling a rollback thread through a transaction manager so as to call the remote equipment to operate the local transaction according to the RPC request and generate an operation result; and if the operation result is received, deleting the local transaction in the transaction table and the RPC request in the method table, and sending the operation result to the transaction initiating terminal.
9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the steps of the distributed transaction processing method according to any of claims 1 to 7 are implemented by the processor of the computer device when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, the computer program stored in the computer-readable storage medium, when being executed by a processor, implementing the steps of the distributed transaction processing method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010595057.6A CN111722946A (en) | 2020-06-28 | 2020-06-28 | Distributed transaction processing method and device, computer equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010595057.6A CN111722946A (en) | 2020-06-28 | 2020-06-28 | Distributed transaction processing method and device, computer equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN111722946A true CN111722946A (en) | 2020-09-29 |
Family
ID=72568937
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010595057.6A Pending CN111722946A (en) | 2020-06-28 | 2020-06-28 | Distributed transaction processing method and device, computer equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111722946A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113778699A (en) * | 2020-10-23 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | Distributed transaction processing method, device, computer system and readable storage medium |
CN114066476A (en) * | 2021-11-30 | 2022-02-18 | 武汉众邦银行股份有限公司 | Method, device and storage medium for solving issue-first issue of distributed application transaction |
CN114090194A (en) * | 2021-11-24 | 2022-02-25 | 中国银行股份有限公司 | Method and device for realizing distributed transaction consistency |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050027871A1 (en) * | 2003-06-05 | 2005-02-03 | William Bradley | Interoperable systems and methods for peer-to-peer service orchestration |
US20100100689A1 (en) * | 2008-10-20 | 2010-04-22 | Microsoft Corporation | Transaction processing in transactional memory |
CN111045794A (en) * | 2019-12-17 | 2020-04-21 | 深圳前海环融联易信息科技服务有限公司 | Distributed transaction processing method, device, system, computer equipment and storage medium |
-
2020
- 2020-06-28 CN CN202010595057.6A patent/CN111722946A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050027871A1 (en) * | 2003-06-05 | 2005-02-03 | William Bradley | Interoperable systems and methods for peer-to-peer service orchestration |
US20100100689A1 (en) * | 2008-10-20 | 2010-04-22 | Microsoft Corporation | Transaction processing in transactional memory |
CN111045794A (en) * | 2019-12-17 | 2020-04-21 | 深圳前海环融联易信息科技服务有限公司 | Distributed transaction processing method, device, system, computer equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
黄雅萍;刘晓强;吴成义;: "基于MySQL和PHP的分布式事务处理", 东华大学学报(自然科学版), no. 01 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113778699A (en) * | 2020-10-23 | 2021-12-10 | 北京沃东天骏信息技术有限公司 | Distributed transaction processing method, device, computer system and readable storage medium |
CN114090194A (en) * | 2021-11-24 | 2022-02-25 | 中国银行股份有限公司 | Method and device for realizing distributed transaction consistency |
CN114066476A (en) * | 2021-11-30 | 2022-02-18 | 武汉众邦银行股份有限公司 | Method, device and storage medium for solving issue-first issue of distributed application transaction |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111756601B (en) | Microservice architecture monitoring method and device, computer equipment and readable storage medium | |
CN111722946A (en) | Distributed transaction processing method and device, computer equipment and readable storage medium | |
CN112035472B (en) | Data processing method, device, computer equipment and storage medium | |
WO2019179026A1 (en) | Electronic device, method for automatically generating cluster access domain name, and storage medium | |
CN109857580B (en) | Block chain cross-chain contract calling method and device and storage medium | |
WO2020224100A1 (en) | Blockchain configuration file processing apparatus, system, and method, and storage medium | |
CN111585805B (en) | Smooth release upgrading method and device, computer system and readable storage medium | |
CN112099843A (en) | Code hosting platform management method and device, computer equipment and storage medium | |
WO2021174882A1 (en) | Data fragment verification method, apparatus, computer device, and readable storage medium | |
CN110210845B (en) | Method, apparatus, medium, and computing device for blockchain data migration | |
WO2019169763A1 (en) | Electronic apparatus, service system risk control method, and storage medium | |
WO2024021861A1 (en) | Data recovery method and electronic device | |
WO2019169771A1 (en) | Electronic device, access instruction information acquisition method and storage medium | |
CN112148387A (en) | Method and device for preloading feedback information, computer equipment and storage medium | |
CN111679892A (en) | Distributed transaction processing method, device, equipment and medium | |
CN111698227B (en) | Information synchronization management method, device, computer system and readable storage medium | |
CN108241616B (en) | Message pushing method and device | |
CN112749124A (en) | Page information management method and device, computer equipment and readable storage medium | |
CN112015563A (en) | Message queue switching method and device, electronic equipment and storage medium | |
US20230168816A1 (en) | Systems, methods and computer readable media for software defined storage security protection | |
CN113360172B (en) | Application deployment method, device, computer equipment and storage medium | |
CN111666132B (en) | Distributed transaction implementation method, device, computer system and readable storage medium | |
CN113420050B (en) | Data query management method, device, computer equipment and readable storage medium | |
CN115374098A (en) | High concurrent payment order anti-duplication method, apparatus, system, device, medium, and program product | |
CN114143308A (en) | File uploading information processing method and device, computer equipment and storage medium |
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 | ||
AD01 | Patent right deemed abandoned | ||
AD01 | Patent right deemed abandoned |
Effective date of abandoning: 20240621 |