CN112100001B - Data rollback method, device, server and readable storage medium - Google Patents
Data rollback method, device, server and readable storage medium Download PDFInfo
- Publication number
- CN112100001B CN112100001B CN202011275514.XA CN202011275514A CN112100001B CN 112100001 B CN112100001 B CN 112100001B CN 202011275514 A CN202011275514 A CN 202011275514A CN 112100001 B CN112100001 B CN 112100001B
- Authority
- CN
- China
- Prior art keywords
- rollback
- statement
- data
- identification information
- node
- 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.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 139
- 238000003860 storage Methods 0.000 title claims abstract description 15
- 230000008569 process Effects 0.000 claims abstract description 89
- 238000012217 deletion Methods 0.000 claims description 29
- 230000037430 deletion Effects 0.000 claims description 29
- 230000008859 change Effects 0.000 claims description 27
- 238000004590 computer program Methods 0.000 claims description 7
- 238000012986 modification Methods 0.000 claims description 5
- 230000004048 modification Effects 0.000 claims description 5
- 238000005096 rolling process Methods 0.000 claims description 3
- 238000012545 processing Methods 0.000 abstract description 5
- 239000004065 semiconductor Substances 0.000 abstract description 4
- 238000004519 manufacturing process Methods 0.000 description 17
- 238000004891 communication Methods 0.000 description 12
- 238000010586 diagram Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 6
- 230000003993 interaction Effects 0.000 description 6
- 239000004594 Masterbatch (MB) Substances 0.000 description 5
- 238000011161 development Methods 0.000 description 2
- 230000007246 mechanism Effects 0.000 description 2
- 238000011084 recovery Methods 0.000 description 2
- 238000011160 research Methods 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 230000004075 alteration Effects 0.000 description 1
- 230000005540 biological transmission Effects 0.000 description 1
- 238000004364 calculation method Methods 0.000 description 1
- 238000013479 data entry Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 239000002994 raw material Substances 0.000 description 1
- 238000012552 review Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 238000012360 testing method Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1471—Saving, restoring, recovering or retrying involving logging of persistent data for recovery
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1474—Saving, restoring, recovering or retrying in transactions
-
- 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/23—Updating
- G06F16/2358—Change logging, detection, and notification
-
- 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/23—Updating
- G06F16/2379—Updates performed during online database operations; commit processing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/80—Database-specific techniques
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)
- Quality & Reliability (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a data rollback method, a data rollback device, a server and a readable storage medium, and relates to the technical field of semiconductor data processing. According to the data rollback method, the data rollback device, the server and the readable storage medium, a rollback statement generated by the same product and the same service process is associated with the same first identification information to form a complete data rollback link, so that the continuity of service and the integrity of data are ensured, after the first identification information of the product transmitted by a client is received, all the rollback statements generated by the service process associated with the first identification information can be obtained according to the first identification information, and the rollback operation is performed on all the obtained rollback statements according to the time reversal order, so that the rollback of the whole process can be realized.
Description
Technical Field
The invention relates to the technical field of semiconductor data processing, in particular to a data rollback method, a data rollback device, a data rollback server and a readable storage medium.
Background
The coming of the enterprise informatization era makes the demand of the semiconductor industry for manufacturing execution systems indispensable, and the development of the execution manufacturing systems in China is relatively rapid, but software development companies do not always really know the largest problem pain point of the manufacturing industry, so that the generation and iteration of the system are in a repairing and repairing process, and operations such as data rollback, manufacturing process station rollback, data re-brushing and the like are often performed in the process.
The existing manufacturing system generally does not have a complete business process data recovery mechanism, only performs customized rollback aiming at partial customized modules, or only supports rollback among stations, and cannot perform full-process rollback.
Disclosure of Invention
Based on the above research, the present invention provides a data rollback method, apparatus, server, and readable storage medium to improve the above problems.
Embodiments of the invention may be implemented as follows:
in a first aspect, an embodiment of the present invention provides a data rollback method, which is applied to a server, where the method includes:
responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
and performing rollback operation on the searched rollback statement according to the time reverse order.
In an optional embodiment, the step of performing a rollback operation on the found rollback statement in a time reversed order includes:
acquiring second identification information of each node in the service flow;
inquiring a rollback statement associated with each piece of second identification information according to the second identification information of each node to obtain the rollback statement generated by each node;
and for each node, performing rollback operation on the rollback statement generated by the node according to the time reversal order.
In an alternative embodiment, the method further comprises:
and for each node in the business process, if the operation of the node fails, acquiring all rollback statements associated with the second identification information of the node according to the second identification information of the node, executing all rollback statements associated with the second identification information of the node according to a time reverse order, and rolling back the node.
In an alternative embodiment, the method further comprises:
receiving an operation event sent by a client, and acquiring an object of the operation event and attribute data information of the object; wherein the attribute data information includes field data information and a conditional statement of the object;
determining a primary key of the object according to the field data information of the object;
generating a rollback statement based on the obtained main key, conditional statement and field data information of the object according to the category of the operation statement generated by the operation event;
and associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
In an optional implementation manner, the category of the operation statement includes an addition statement, a deletion statement, and an alteration statement, and the step of generating a rollback statement based on the obtained primary key, conditional statement, and field data information of the object according to the category of the operation statement generated according to the operation event includes:
if the operation statement is a new addition statement, generating a rollback deletion statement according to the main key of the object and the conditional statement;
if the operation statement is a deletion statement, generating a rollback new addition statement according to the field data information;
and if the operation statement is a change statement, generating a rollback change statement according to the conditional statement of the object.
In an alternative embodiment, the method further comprises:
receiving an SQL execution statement sent by a client, and judging whether the SQL execution statement is an update statement;
if the SQL execution statement is an update statement, acquiring a conditional execution statement in the SQL execution statement;
acquiring a primary key value in the conditional execution statement according to a preset primary key field, and acquiring data information corresponding to the primary key value;
generating a rollback statement based on the obtained data information and the primary key value according to the type of the SQL execution statement;
and associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
In an optional implementation manner, the types of the SQL execution statements include an add statement, a delete statement, and a change statement, and the data information includes a data field; according to the type of the SQL execution statement, the step of generating the rollback statement based on the obtained data information and the primary key value comprises the following steps:
if the SQL execution statement is a deletion statement, generating a rollback new addition statement according to all data fields in the obtained data information;
if the SQL execution statement is a change statement, generating a rollback change statement according to all data fields in the obtained data information and the conditional execution statement;
and if the SQL execution statement is a new added statement, generating a rollback deletion statement according to the primary key value.
In a second aspect, an embodiment of the present invention provides a data rollback apparatus, which is applied to a server, where the data rollback apparatus includes a data query module and a data rollback module;
the data query module is used for responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
and the data rollback module is used for executing rollback operation on the found rollback statement according to a time reverse order.
In a third aspect, an embodiment of the present invention provides a server, where the server is configured to:
responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
and performing rollback operation on the searched rollback statement according to the time reverse order.
In a fourth aspect, an embodiment of the present invention provides a readable storage medium, where a computer program is stored, and the computer program, when executed, implements the data rollback method in any one of the foregoing embodiments.
According to the data rollback method, the data rollback device, the server and the readable storage medium, a complete data rollback link is formed by associating the rollback sentences generated by the same product and the same service process with the same first identification information, the continuity of the service and the integrity of the data are guaranteed, after the first identification information of the product transmitted by the client is received, all the rollback sentences generated by the service process associated with the first identification information can be obtained according to the first identification information, and the rollback operation is performed on all the obtained rollback sentences according to the time reversal order, so that the rollback of the whole process can be realized.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the embodiments will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and for those skilled in the art, other related drawings can be obtained according to the drawings without inventive efforts.
Fig. 1 is an interaction diagram of a server and a user terminal according to an embodiment of the present invention.
Fig. 2 is a schematic block diagram of a server according to an embodiment of the present invention.
Fig. 3 is an application framework diagram of a server according to an embodiment of the present invention.
Fig. 4 is a flowchart illustrating a data rollback method according to an embodiment of the present invention.
Fig. 5 is another schematic flow chart of the data rollback method according to the embodiment of the present invention.
Fig. 6 is a diagram illustrating an application example of the data rollback method according to an embodiment of the present invention.
Fig. 7 is a block diagram of a data rollback apparatus according to an embodiment of the present invention.
Icon: 100-a server; 10-data rollback means; 11-a data query module; 12-a data rollback module; 20-a memory; 30-a processor; 40-a communication unit; 200-a user terminal; 201-a client; 300-network.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. The components of embodiments of the present invention generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations.
Thus, the following detailed description of the embodiments of the present invention, presented in the figures, is not intended to limit the scope of the invention, as claimed, but is merely representative of selected embodiments of 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.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. indicate an orientation or a positional relationship based on that shown in the drawings or that the product of the present invention is used as it is, this is only for convenience of description and simplification of the description, and it does not indicate or imply that the device or the element referred to must have a specific orientation, be constructed in a specific orientation, and be operated, and thus should not be construed as limiting the present invention.
Furthermore, the appearances of the terms "first," "second," and the like, if any, are used solely to distinguish one from another and are not to be construed as indicating or implying relative importance.
It should be noted that the features of the embodiments of the present invention may be combined with each other without conflict.
In recent years, the arrival of enterprise information era makes the demand of the semiconductor industry for manufacturing execution systems indispensable, and the development of the execution manufacturing systems in China is relatively rapid, but software development companies do not necessarily really know the biggest problem pain point of the manufacturing industry, and a technical department which is not perfect in the initial manufacturing industry assists the manufacturing department to better interpret the problem key point, so that the system is generated and iterated in a repairing and repairing process, and operations such as data rollback, manufacturing process station rollback, data re-brushing and the like are often performed in the process. These processes are extremely dangerous, and there is a risk that the product manufacturing equipment may be mistakenly executed to damage the product due to some link data or parameter loss.
Traditional data rollback is based on an erroneous operation rollback of the database: collecting Structured Query Statements (SQL) of the whole business process, and performing transactional submission, wherein the whole business process module is rolled back when any SQL statement is wrong; when rollback is executed, developers need to repeatedly try to find out related specific error SQL, analyze related error nodes and check errors; a slightly robust program can analyze all execution SQL related to log query, but in this way, when some common flow step method call supports exist in a business flow, a unified submission way cannot be constructed, and this way cannot solve temporary data rollback, and is extremely low in efficiency.
At present, a manufacturing system is generally a production execution system purchased from a large enterprise, such as Siemens, Rockwell, Honeywell and other enterprises, and although the manufacturing system is more dynamic, the manufacturing system only has customized business process rollback (for example, raw material rollback) and cannot support full-process rollback. The manufacturing and executing system of a domestic manufacturer also focuses on customization, generally does not have a complete business process data recovery mechanism due to the fact that the hard coding degree of codes is high, only customizes and backs only on part of customization modules, or a circular record creating mode is adopted, for example, data rollback operation with an FT test station as a reference is adopted, but rollback between sites is only supported, and step rollback cannot be supported, namely data emptying processing of the current site of the process is performed, the process is reset to the previous site, a user is enabled to operate again, if input variables of method body steps between the sites are subjected to a large amount of calculation and entry, the cost is high, and meanwhile, rollback of the whole process cannot be supported.
Based on the above research, the present embodiment provides a data rollback method to improve the above problem.
Fig. 1 is an interaction diagram of a server 100 and at least one user terminal 200 provided in the present embodiment. The server 100 may communicate with the user terminal 200 through the network 300 to enable data communication or interaction between the server 100 and the user terminal 200.
In this embodiment, the server 100 may be a single physical server, or may be a server group composed of a plurality of physical servers for performing different data processing functions. The server group may be centralized or distributed. In some possible embodiments, such as where the server 100 employs a single physical server, the physical server may be assigned different logical server components based on different service functions.
The user terminal 200 may be, but is not limited to, a smart phone, a Personal Computer (PC), a tablet PC, a Personal Digital Assistant (PDA), a Mobile Internet Device (MID), and the like. The network 300 may be, but is not limited to, a wired network or a wireless network. The user terminal 200 may download a client 201, such as a browser or other various applications, required for installation from the server 100 through a network. The client 201 installed on the user terminal 200 can directly perform data communication and interaction with the server 100.
Referring to fig. 2, in the present embodiment, the server 100 includes a data rollback apparatus 10, a memory 20, a processor 30, and a communication unit 40. The elements of the memory 20, processor 30 and communication unit 40 are electrically connected to each other, directly or indirectly, to enable data transmission or interaction. For example, the components may be electrically connected to each other via one or more communication buses or signal lines. The data rollback apparatus 10 includes at least one software function module, which may be stored in the memory 20 in the form of software or firmware (firmware) or solidified in an Operating System (OS) of the server 100.
The processor 30 is used for executing executable modules stored in the memory 20, such as software functional modules and computer programs included in the data rollback apparatus 10.
The communication unit 40 is configured to establish a communication connection between the server 100 and the user terminal 200 through the network 300, and to transceive data through the network 300.
In the present embodiment, the user terminal 200 includes a display unit, an input-output unit, and a communication module. The display unit provides an interactive interface (e.g., a user operation interface) between the user terminal 200 and a user for displaying web page information. In this embodiment, the display unit may be a liquid crystal display or a touch display. The input and output unit is used for providing input data for a user to realize the interaction between the user and the user terminal 200. The input/output unit may be, but is not limited to, a mouse, a keyboard, and the like. The communication module is configured to establish a connection with the communication unit 40 of the server 100 through the network 300, so as to implement a communication connection between the server 100 and the user terminal 200.
It will be appreciated that the user terminal 200, the server 100 may also include more or fewer components than those described above, or have a different configuration.
Based on the configuration of the server 100, please refer to fig. 3, where fig. 3 is an application framework diagram of the server 100 provided in the present embodiment. In this embodiment, the server 100 includes a module framework layer, a logic execution layer, and a rollback control layer. The module framework layer comprises an SQL monitor, an SQL execution generator, a rollback log memory and a rollback operation executor.
Before the SQL monitor acts on the operation of the SQL statement, the SQL statement is asynchronously monitored, intercepted and transmitted to the SQL execution generator. The SQL execution generator is used for judging and analyzing the SQL sentences, and then generating and transferring the rollback SQL execution sentences to the rollback log storage for storage. And the rollback operation executor performs data rollback operation on the received rollback request.
The logic operation layer is mainly used for controlling the operation of the business process and comprises a business process module, an authority control module and the like.
The rollback control layer is mainly used for the business process and other related modules which need to rollback data. The rollback control layer comprises module rollback, function rollback, process rollback and step rollback. The module rollback is used for rollback of whole module operation (station operation), the function rollback is used for rollback of certain function operation, the process rollback is used for rollback of a process, and the step rollback is used for rollback of a method step.
It is to be understood that fig. 3 is only intended to illustrate one application framework of the server 100 provided by the present embodiment. The server 100 provided in this embodiment may be adapted to not only the SQL framework but also the orm (object Relational mapping) framework.
Based on the above implementation architecture, please refer to fig. 4 in combination, fig. 4 is a schematic flow chart of the data rollback method provided in the present embodiment, the data rollback method provided in the present embodiment is applied to the server 100, and the server 100 executes the data rollback method provided in the present embodiment. The flowchart shown in fig. 4 is explained in detail below.
Step S10: and responding to the rollback operation, and searching a rollback statement of the business process associated with the first identification information according to the first identification information of the product transmitted by the client.
Step S20: and performing rollback operation on the searched rollback statement according to the time reverse order.
The rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information. For example, if the business process a is executed on the product a, the first identification information of the product a is associated with the business process a and is associated with all rollback statements generated by the business process a.
Optionally, in this embodiment, the associated first identification information is different for the rollback statements generated by the same product and different business processes. For example, the service flow executed on the product a includes a service flow a and a service flow B, where the rollback statements generated by the service flow a and the service flow a are both associated with the first identification information a of the product a, and the rollback statements generated by the service flow B and the service flow B are both associated with the first identification information B of the product a.
Optionally, in this embodiment, the first identification information may be feature information of a product, such as a batch number, and for example, a unique code of a product set by a user, and specifically, this embodiment is not limited in particular.
In the embodiment, in the process of executing the business process by the product, the first identification information of the product is associated with the rollback statement generated by the business process, so that the first identification information of the product can run through the whole business process, each rollback statement generated by the business process is monitored, a complete data rollback link is formed, and meanwhile, the continuity and the integrity of the business can be ensured.
Optionally, in this embodiment, a rollback statement generated by each service flow is stored in the database, and meanwhile, an association relationship between the rollback statement and the corresponding service flow and between the rollback statement and the first identification information is also stored in the database, and further, after receiving the first identification information transmitted by the client, the server may obtain, from the database, the rollback statement of the service flow associated with the first identification information according to the first identification information. In the embodiment, the rollback statement generated by the business process is stored in the database, so that the rollback statement in the database can be called at any time to perform rollback of data while the integrity of the data is ensured, and temporary data rollback can be solved.
In the process of executing the business process, the generated rollback sentences all have generation time, so after all the rollback sentences of the business process associated with the first identification information are obtained, the obtained rollback sentences are executed according to the time reverse order, and the rollback of the whole process can be realized.
In an exemplary embodiment, a user inputs a batch number 01 of a certain product through a client, after receiving the batch number 01, a server searches a service flow associated with the batch number 01 as a flow a from a database, and all rollback statements associated with the batch number 01 as a rollback statement a _ generation time t1, a rollback statement b _ generation time t2 and a rollback statement c _ generation time t3, and performs a rollback operation on the found rollback statements according to a time reversal order, that is, performs a rollback operation on a rollback statement c, a rollback statement b and a rollback statement a according to the sequence of t3, t2 and t1, that is, performs a full-flow rollback on the flow a.
The data rollback method provided by this embodiment associates, for the same product, the rollback statements generated by the same service flow with the same first identification information to form a complete data rollback link, so as to ensure continuity of the service and integrity of the data, and further, after receiving the first identification information transmitted by the client, all the rollback statements generated by the service flow associated with the first identification information may be obtained according to the first identification information, and then rollback operations are performed on all the obtained rollback statements according to a time reversal order, so that rollback of the entire flow may be implemented.
In practical application, each service flow has a plurality of nodes, each node performs different operations, and the generated rollback statements are different, so as to improve the execution efficiency of the rollback operation, in this embodiment, the step of performing the rollback operation on the found rollback statement according to a time reversal order includes:
and acquiring second identification information of each node in the service flow.
And inquiring the rollback statement associated with each piece of second identification information according to the second identification information of each node to obtain the rollback statement generated by each node.
And for each node, performing rollback operation on the rollback statement generated by the node according to the time reversal order.
In the process of executing the service flow, a rollback statement generated by each node is not only associated with first identification information of a product, but also associated with second identification information of the node, so that after all rollback statements generated by the service flow are obtained through the first identification information, a rollback statement corresponding to each node can be obtained according to the second identification information of each node, and then, for each node, a rollback operation is executed on the rollback statement generated by the node according to a time reversal order, so that the node is rolled back.
After the rollback sentences corresponding to each node are obtained, the rollback operation can be executed in parallel through the rollback sentences of each node, and therefore the working efficiency is improved.
As an optional implementation manner, in this embodiment, after obtaining the rollback statement corresponding to each node, a rollback operation is also separately performed on a certain node, so as to implement rollback between the steps.
In an exemplary embodiment, a server obtains all rollback statements of an associated service flow through first identification information, that is, the rollback statements generated by each node can be obtained through second identification information of each node in the service flow, if a user needs to rollback the whole flow, the rollback operation is executed on all nodes in parallel, if the user needs to execute the rollback operation on a certain node or execute the rollback operation on some nodes, the node needing to execute the rollback operation is selected, and then the server responds to the operation of the user to execute the rollback operation on the selected node, so that the rollback operations between steps and between sites can be realized, and the cost is saved.
In practical application, an error occurs in the process of executing the business process by the product, so that rollback is required, based on which, the data rollback method provided in this embodiment may also be applicable to the process of executing the business process, that is, when an error is reported in the process of executing the business process, rollback is automatically implemented, and specifically, the method may be implemented by the following steps:
and aiming at each node in the service flow, if the operation of the node fails, acquiring all rollback statements associated with the second identification information of the node according to the second identification information of the node, executing all rollback statements associated with the second identification information of the node according to a time reverse order, and rolling back the node.
In the process of executing the business process, if operation fails at a certain node of the business process, all rollback statements related to the second identification information of the node are acquired from the database according to the second identification information of the node, and then rollback operation is executed on the acquired rollback statements according to a time reverse order, so that the node can be rolled back and restored to the initial state of the node.
It should be noted that, in this embodiment, the rollback statement is a reverse operation statement of the operation statements generated in the process of executing the business process. For example, in the process of executing the service flow a, a new added statement is generated, and a corresponding generated rollback statement is a deleted statement.
In order to ensure the integrity of the generated rollback statement, the data rollback method provided in this embodiment further includes a generating step of the rollback statement.
Optionally, referring to fig. 5 in combination, based on the ORM framework, the generating step of the rollback statement in this embodiment is:
step S1: and receiving an operation event sent by the client, and acquiring an object of the operation event and attribute data information of the object.
Step S2: and determining the primary key of the object according to the field data information of the object.
Step S3: and generating a rollback statement according to the type of the operation statement generated according to the operation event and based on the acquired main key, conditional statement and field data information of the object.
Step S4: and associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
Based on the ORM framework, after an operation event sent by a client is received, the latest data corresponding to the operation event can be acquired from the database, and the object of the operation event can be acquired by converting the latest data into the object.
After obtaining the latest data corresponding to the operation event, the obtained latest data may be filtered according to a preset condition, and then the filtered data may be converted to obtain the object of the operation event.
After the object of the operation event is obtained, the attribute data information of the object can be obtained in a reflection mode, the obtained attribute data information includes field data information of the object, namely included fields and data corresponding to each field, and the obtained attribute data information also includes a conditional statement of the object.
Optionally, according to fields included in the field data information, any field may be designated as a primary key of the object, and the primary key is a unique identifier of the object and may be used as a primary key of the object in the database table.
After the primary key and the conditional statement of the object are obtained, a rollback statement can be generated from the field data information, the primary key, and the conditional statement of the object according to the type of the operation statement generated by the operation event.
Optionally, in this embodiment, the operation event includes an addition event, a deletion event, and a modification event, and correspondingly, the category of the operation statement generated based on the operation event includes an addition statement, a deletion statement, and a modification statement. Therefore, in this embodiment, the step of generating a rollback sentence based on the obtained main key, conditional sentence, and field data information of the object according to the category of the operation sentence generated by the operation event may be:
and if the operation statement is a new addition statement, generating a rollback deletion statement according to the main key of the object and the conditional statement.
And if the operation statement is a deletion statement, generating a rollback new addition statement according to the field data information.
And if the operation statement is a change statement, generating a rollback change statement according to the conditional statement of the object.
It should be noted that, in this embodiment, the delete statement is divided into a software delete statement and a physical delete statement, where the software delete refers to changing a certain field of the object as an identification bit. For example, field 0 represents undeleted, field 1 represents deleted, and the object is field 0, which is deleted by software, and field 0 is changed to 1, indicating that the data has been deleted, and based on field 0, the data cannot be obtained, but the data is still stored in the database. And the physical deletion directly deletes the data from the database.
Therefore, in this embodiment, when the operation statement is a software delete statement, a rollback change statement is generated according to the conditional statement of the object, for example, when a certain object is deleted by software and its field is changed from field 0 to field 1, the generated rollback statement is a rollback change statement with field 1. And when the operation statement is a physical deletion statement, generating a rollback new addition statement according to the attribute data information of the object.
Optionally, in this embodiment, when the operation statement is a new addition statement and the corresponding data has only one piece of data, the rollback deletion statement may be generated only according to the primary key, and when the corresponding data is multiple pieces of data, the rollback deletion statement may be generated according to the conditional statement, or the multiple pieces of data are split, a unique primary key is set for each piece of data, and a corresponding rollback deletion statement is generated according to the primary key and the conditional statement, so that the integrity of the rollback statement may be ensured.
As an optional implementation manner, in this embodiment, when the operation statement is a new addition statement, a rollback change statement may be generated according to a conditional statement of the object, that is, in this embodiment, when the operation statement is a new addition statement, a rollback deletion statement may be generated according to a main key and a conditional statement of the object, or a rollback change statement may be generated according to a conditional statement of the object, and specifically, the generation manner may be set according to actual requirements.
According to the method and the device, the rollback statement is generated by obtaining the main key, the conditional statement and the field data information of the obtained object according to the category of the operation statement generated by the operation event, so that the integrity of the rollback statement generation is ensured, and errors are avoided in the subsequent rollback operation execution process.
After generating a rollback statement based on the main key, the conditional statement and the field data information of the object, associating the generated rollback statement with first identification information of a current corresponding product and second identification information of a current corresponding node. Therefore, in the subsequent rollback operation, the associated rollback statement can be obtained according to the first identification information and/or the second identification information, and rollback is performed.
It should be noted that, in this embodiment, when an operation statement is generated based on one operation event, a rollback statement in the reverse direction of the operation statement is generated in real time according to the type of the operation statement. Therefore, the one-to-one correspondence between the operation statements and the rollback statements can be ensured, and the continuity and the integrity of the business process are ensured.
As another optional implementation manner, based on the SQL framework, the generating step of the rollback statement included in this embodiment may further be:
firstly, receiving an SQL execution statement sent by a client, and judging whether the SQL execution statement is an update statement.
And if the SQL execution statement is an update statement, acquiring a conditional execution statement in the SQL execution statement.
And secondly, acquiring a primary key value in the conditional execution statement according to a preset primary key, and acquiring data information corresponding to the primary key value.
Then according to the type of the SQL execution statement, generating a rollback statement based on the obtained data information and the primary key value;
and finally, associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
The method comprises the steps that based on an SQL frame, a client side sends an SQL execution statement to a server, the server analyzes the type of the received SQL execution statement after receiving the SQL execution statement and judges whether the SQL execution statement is an update statement, and if not, the SQL execution statement is stored in an operation log in a database.
If the SQL execution statement is an update statement, intercepting the conditional execution statement in the SQL execution statement, namely acquiring the conditional execution statement in the SQL execution statement, and then executing primary key search on the conditional execution statement according to a preset primary key field to acquire a primary key value in the conditional execution statement. The primary key field is a uniform identification field set in the database design level.
And after the primary key value is obtained, corresponding data information is obtained from the database according to the primary key value.
Optionally, in this embodiment, in order to ensure accuracy of obtaining the obtained data, before obtaining the data information corresponding to the primary key value, the data needs to be checked to ensure that the data is the latest data.
Optionally, the database stores version information of each piece of data correspondingly, and when the data is updated once, the version information is updated once correspondingly, so that the latest data information corresponding to the primary key value can be obtained based on the version information. Accordingly, in this embodiment, the latest data corresponding to the operation event may also be acquired based on the version information.
After the corresponding latest data information is obtained, a rollback statement can be generated based on the obtained data information and the primary key value according to the type of the SQL execution statement.
Optionally, in this embodiment, the types of the UPDATE statement include an addition statement (INSERT statement), a deletion statement (DELETE statement), and a modification statement (UPDATE statement), and the data information includes a data field, and the data field includes a field and data corresponding to each field, so in this embodiment, the step of generating the rollback statement based on the obtained data information and the primary key value according to the type of the SQL execution statement includes:
and if the SQL execution statement is a deletion statement, generating a rollback new addition statement according to all data fields in the obtained data information.
And if the SQL execution statement is a change statement, generating a rollback change statement according to all data fields in the obtained data information and the conditional execution statement.
And if the SQL execution statement is a new added statement, generating a rollback deletion statement according to the primary key value.
And when the SQL execution statement is an update statement and the SQL execution statement is a deletion statement in the update statement, generating a rollback new addition statement according to all data fields in the obtained data information. And when the SQL execution statement is a change statement in the update statement, generating a rollback change statement according to all data fields in the obtained data information and the conditional execution statement. And if the SQL execution statement is a new addition statement, generating a rollback deletion statement according to the primary key value.
Accordingly, in the present embodiment, under the SQL framework, the delete operation also includes a software delete operation and a physical delete operation. The software deleting operation is realized by changing a statement, namely, the identification bit of the data bit is changed by the changing statement.
When the SQL execution statement is a deletion statement in the update statement, namely, when the physical deletion operation is executed, the rollback new addition statement is generated according to all data fields in the obtained data information. And when the SQL execution statement is a change statement in the update statement and the software deleting operation is executed, generating a rollback change statement according to all data fields in the obtained data information and the conditional execution statement.
It should be noted that, when the SQL execution statement is a delete statement in the update statement, when the rollback new add statement is generated according to all data fields in the obtained data information, the main key field and some automatically generated information, such as new add time, modification time, etc., need to be excluded.
According to the method and the device, the rollback statement is generated by the obtained data information and the primary key value according to the type of the SQL execution statement, so that the integrity of the rollback statement generation is ensured, and errors are avoided in the subsequent rollback operation execution process.
Correspondingly, after the rollback statement is generated based on the obtained data information and the primary key value according to the type of the update statement, the generated rollback statement is associated with the first identification information of the current corresponding product and the second identification information of the current corresponding node. Therefore, in the subsequent rollback operation, the associated rollback statement can be obtained according to the first identification information and/or the second identification information, and rollback is performed.
It should be noted that, in this embodiment, when the SQL execution statement is an update statement, a rollback statement is generated in real time according to the type of each SQL execution statement when each SQL execution statement is executed, so that the SQL execution statements and the rollback statements can be ensured to be in one-to-one correspondence, and continuity and integrity of the business process can be ensured.
The generated rollback statement is stored in a rollback log in a database, and the operation statement and the SQL statement are stored in an operation log in the database.
Because the operation log is provided with all operation statements or SQL execution statements, the operation log can be used for assisting in analyzing the flow and processing logic of the rollback operation, so that specific error nodes can be quickly obtained, the efficiency is high, and developers do not need to write the rollback statements after carrying out a large amount of inquiry and logic review.
Referring to fig. 6, an application example is illustrated to describe the generation of the rollback statement in the present embodiment. FIG. 6 shows a batch splitting business process for a product. In the batch splitting business process, a mother batch number and an SQL execution statement are received firstly, mother batch information of a corresponding product is obtained according to the mother batch number, and the SQL execution statement is executed after the mother batch information of the product is obtained. The parent batch number is a unique identifier before batch splitting. Then, judging whether the inner box information exists in the parent batch information, if so, acquiring a rollback statement associated with the inner box number and the ID of the current node, executing a rollback operation, returning to the previous step, if not, judging whether the station meets the execution requirement, if not, acquiring the rollback statement associated with the ID of the current node, executing the rollback operation, returning to the previous step, if so, judging whether a hold record exists, if not, executing an unbatch flow operation, inserting a newly-added statement, simultaneously acquiring complete batch information, generating a deleted rollback statement or a rollback change statement, associating the generated deleted rollback statement or rollback change statement with the identification code of the current station, the ID of the current node and the parent batch number, storing the deleted rollback statement or the rollback change statement in a rollback log in a database, refreshing data, generating a child batch number, and executing an SQL (structured query language), judging whether the batch splitting quantity of the master batch meets the preset batch splitting quantity, if not, acquiring a rollback statement associated with the current node ID, executing rollback operation, if so, updating the master batch information, storing the slave batch information, generating a master batch rollback change statement according to a conditional execution statement (where condition is intercepted) in the SQL execution statement, and automatically generating an identification (SYSID) according to the slave batch unique identifier to generate a slave batch rollback deletion statement, associating the generated master batch rollback change statement and the slave batch rollback deletion statement with the identification code of the current site, the ID of the current node and the master batch number, and storing the association into a rollback log in a database.
In the execution process, an operation log exists for the operation information, and the operation log includes all SQL statements, the name of an execution method, the station of the process and other information.
The data rollback method provided by this embodiment can perform staged process recording on the operation flow executed by the business process and generate a rollback statement in real time, can cope with execution interruption caused by most of abnormal logic method execution according to actual requirements, and can suspend subsequent processes due to data entry problems in a controlled manner, and can perform rollback operation of the whole business process to the extent of guaranteeing data integrity.
On the basis, please refer to fig. 7 in combination, the present embodiment further provides a data rollback apparatus 10, where the data rollback apparatus 10 is applied to a server, and the data rollback apparatus 10 includes a data query module 11 and a data rollback module 12.
The data query module 11 is configured to respond to a rollback operation, and search a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by the client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information.
The data rollback module 12 is configured to perform a rollback operation on the found rollback statement according to a time reverse order.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working process of the data rollback apparatus 10 described above may refer to the corresponding process in the foregoing method, and will not be described in too much detail herein.
Based on the same inventive concept, the present embodiment further provides a server, where the server is configured to:
responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of the product transmitted by the client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information.
And performing rollback operation on the searched rollback statement according to the time reverse order.
On the basis of the foregoing, the present embodiment further provides a readable storage medium, in which a computer program is stored, and the computer program is executed to implement the data rollback method according to any one of the foregoing embodiments.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the server and the readable storage medium described above may refer to corresponding processes in the foregoing method, and will not be described in detail herein.
In summary, according to the data rollback method, apparatus, server, and readable storage medium provided in this embodiment, a complete data rollback link is formed by associating the rollback statements generated by the same service flow with the same first identification information, so as to ensure continuity of the service and integrity of the data, and after receiving the first identification information transmitted by the client, all the rollback statements generated by the service flow associated with the first identification information may be obtained according to the first identification information, and then rollback operations are performed on all the obtained rollback statements according to a time reversal order, so that rollback of the full flow may be implemented.
The above description is only for the specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the appended claims.
Claims (9)
1. A data rollback method, applied to a server, the method comprising:
responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
performing rollback operation on the found rollback statement according to a time reverse order;
the step of performing rollback operation on the found rollback statement according to the time reversal comprises the following steps:
acquiring second identification information of each node in the service flow;
inquiring a rollback statement associated with each piece of second identification information according to the second identification information of each node to obtain the rollback statement generated by each node;
and for each node, performing rollback operation on the rollback statement generated by the node according to the time reversal order.
2. The data rollback method of claim 1, wherein the method further comprises:
and for each node in the business process, if the operation of the node fails, acquiring all rollback statements associated with the second identification information of the node according to the second identification information of the node, executing all rollback statements associated with the second identification information of the node according to a time reverse order, and rolling back the node.
3. The data rollback method of claim 1, wherein the method further comprises:
receiving an operation event sent by a client, and acquiring an object of the operation event and attribute data information of the object; wherein the attribute data information includes field data information and a conditional statement of the object;
determining a primary key of the object according to the field data information of the object;
generating a rollback statement based on the obtained main key, conditional statement and field data information of the object according to the category of the operation statement generated by the operation event;
and associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
4. The data rollback method according to claim 3, wherein the categories of the operation sentences include an addition sentence, a deletion sentence, and a modification sentence, and the step of generating the rollback sentence based on the obtained primary key, the conditional sentence, and the field data information of the object according to the category of the operation sentences generated by the operation events comprises:
if the operation statement is a new addition statement, generating a rollback deletion statement according to the main key of the object and the conditional statement;
if the operation statement is a deletion statement, generating a rollback new addition statement according to the field data information;
and if the operation statement is a change statement, generating a rollback change statement according to the conditional statement of the object.
5. The data rollback method of claim 1, wherein the method further comprises:
receiving an SQL execution statement sent by a client, and judging whether the SQL execution statement is an update statement;
if the SQL execution statement is an update statement, acquiring a conditional execution statement in the SQL execution statement;
acquiring a primary key value in the conditional execution statement according to a preset primary key field, and acquiring data information corresponding to the primary key value;
generating a rollback statement based on the obtained data information and the primary key value according to the type of the SQL execution statement;
and associating the generated rollback statement with the first identification information of the current corresponding product and the second identification information of the current corresponding node.
6. The data rollback method according to claim 5, wherein the types of the SQL execution statement include an add statement, a delete statement, and a change statement, and the data information includes a data field; according to the type of the SQL execution statement, the step of generating the rollback statement based on the obtained data information and the primary key value comprises the following steps:
if the SQL execution statement is a deletion statement, generating a rollback new addition statement according to all data fields in the obtained data information;
if the SQL execution statement is a change statement, generating a rollback change statement according to all data fields in the obtained data information and the conditional execution statement;
and if the SQL execution statement is a new added statement, generating a rollback deletion statement according to the primary key value.
7. The data rollback device is applied to a server and comprises a data query module and a data rollback module;
the data query module is used for responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
the data rollback module is used for performing rollback operation on the found rollback sentences according to a time reverse order;
the data rollback module is used for acquiring second identification information of each node in the service process;
inquiring a rollback statement associated with each piece of second identification information according to the second identification information of each node to obtain the rollback statement generated by each node;
and for each node, performing rollback operation on the rollback statement generated by the node according to the time reversal order.
8. A server, wherein the server is configured to:
responding to a rollback operation, and searching a rollback statement of a business process associated with first identification information according to the first identification information of a product transmitted by a client; the rollback sentences generated aiming at the same product and the same business process are all associated with the same first identification information;
performing rollback operation on the found rollback statement according to a time reverse order;
the server is configured to obtain second identification information of each node in the service flow, query, according to the second identification information of each node, a rollback statement associated with each second identification information to obtain a rollback statement generated by each node, and perform a rollback operation on the rollback statement generated by each node according to a time reversal order for each node.
9. A readable storage medium, characterized in that a computer program is stored in the readable storage medium, which computer program, when executed, implements the data rollback method of any one of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011275514.XA CN112100001B (en) | 2020-11-16 | 2020-11-16 | Data rollback method, device, server and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011275514.XA CN112100001B (en) | 2020-11-16 | 2020-11-16 | Data rollback method, device, server and readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112100001A CN112100001A (en) | 2020-12-18 |
CN112100001B true CN112100001B (en) | 2021-02-05 |
Family
ID=73784620
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011275514.XA Active CN112100001B (en) | 2020-11-16 | 2020-11-16 | Data rollback method, device, server and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112100001B (en) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114461454A (en) * | 2022-02-11 | 2022-05-10 | 京东科技信息技术有限公司 | Data recovery method and device, storage medium and electronic equipment |
CN114756573B (en) * | 2022-06-16 | 2022-10-04 | 恒生电子股份有限公司 | Data processing method, device and system |
CN115309536B (en) * | 2022-10-12 | 2023-01-24 | 青岛民航凯亚系统集成有限公司 | Data consistency method in high-concurrency lottery transaction scene |
CN115796801A (en) * | 2022-12-21 | 2023-03-14 | 中国建设银行股份有限公司 | Process work order management method and device, storage medium and electronic equipment |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104636401B (en) * | 2013-11-15 | 2018-04-06 | 中国石油天然气股份有限公司 | Method and device for data rollback of SCADA (supervisory control and data acquisition) system |
CN106557514A (en) * | 2015-09-29 | 2017-04-05 | 中兴通讯股份有限公司 | A kind of distributed transaction rollback method and device |
-
2020
- 2020-11-16 CN CN202011275514.XA patent/CN112100001B/en active Active
Also Published As
Publication number | Publication date |
---|---|
CN112100001A (en) | 2020-12-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112100001B (en) | Data rollback method, device, server and readable storage medium | |
US11714629B2 (en) | Software dependency management | |
US20170139806A1 (en) | Automated Anomaly Detection Service on Heterogeneous Log Streams | |
US11960443B2 (en) | Block data storage system in an event historian | |
US9842134B2 (en) | Data query interface system in an event historian | |
CN112699151B (en) | Data processing method, device, equipment and medium | |
CN105930390B (en) | Relational database expansion method and system | |
CN111240955A (en) | Automatic testing method and device for Http interface, storage medium and electronic device | |
US11442796B2 (en) | System and method for creating or updating an API configuration | |
CN110688305B (en) | Test environment synchronization method, device, medium and electronic equipment | |
CN118885336B (en) | Data recovery method, device and equipment | |
CN110377588B (en) | Database object access monitoring method, server and terminal | |
CN115033592A (en) | SQL statement processing method, device, equipment and storage medium based on database | |
JP7381290B2 (en) | Computer system and data management method | |
JP7216794B2 (en) | Method, program and apparatus for managing multiple systems including multiple sensors | |
CN115658524A (en) | Test case generation method and device, storage medium and electronic device | |
CN115292313A (en) | Pseudo-column implementation method and device, electronic equipment and storage medium | |
US10579601B2 (en) | Data dictionary system in an event historian | |
CN114518899A (en) | Reverse software package tracking management method, system and storage medium | |
CN112765188A (en) | Configuration information processing method, configuration management system, electronic device, and storage medium | |
US11468026B2 (en) | Information processing apparatus, information processing method, and recording medium recording information processing program | |
CN112883695A (en) | Method, device, equipment and medium for generating report template and displaying data report | |
US12367030B2 (en) | Software dependency management | |
CN114547404B (en) | Big data platform system | |
CN113986305B (en) | B/S model upgrade detection method, device, 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |