CN111159160A - Version rollback method and device, electronic equipment and storage medium - Google Patents

Version rollback method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111159160A
CN111159160A CN201911415713.3A CN201911415713A CN111159160A CN 111159160 A CN111159160 A CN 111159160A CN 201911415713 A CN201911415713 A CN 201911415713A CN 111159160 A CN111159160 A CN 111159160A
Authority
CN
China
Prior art keywords
version
data
rollback
request
preset database
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.)
Granted
Application number
CN201911415713.3A
Other languages
Chinese (zh)
Other versions
CN111159160B (en
Inventor
戴硕
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuomi Private Ltd
Original Assignee
Hong Kong LiveMe Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hong Kong LiveMe Corp Ltd filed Critical Hong Kong LiveMe Corp Ltd
Priority to CN201911415713.3A priority Critical patent/CN111159160B/en
Publication of CN111159160A publication Critical patent/CN111159160A/en
Application granted granted Critical
Publication of CN111159160B publication Critical patent/CN111159160B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/21Design, administration or maintenance of databases
    • G06F16/219Managing data history or versioning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the invention provides a version rollback method, a version rollback device, electronic equipment and a storage medium. The scheme is as follows: receiving a version rollback request, wherein each version of the preset database is determined according to each data updating operation performed on data stored in the preset database, and based on the received version rollback request, rolling back the current version to a target version according to a reverse operation record corresponding to each version, wherein the reverse operation record corresponding to each version is generated according to a data updating operation corresponding to a previous version of the version. According to the technical scheme provided by the embodiment of the invention, because the reverse operation record is generated according to the data updating operation, the operation process is relatively simple when the data rollback is carried out, the cost of the data rollback is effectively reduced, the data volume of the reverse operation record is relatively small, and the dependence on the memory is relatively small, so that the data rollback mode can be suitable for different types of databases, and the universality of the data rollback method is improved.

Description

Version rollback method and device, electronic equipment and storage medium
Technical Field
The present invention relates to the field of data storage technologies, and in particular, to a method and an apparatus for version rollback, an electronic device, and a storage medium.
Background
When data is stored in the block chain field, data rollback is inevitably needed to be performed on the database, namely data stored in the database at a certain moment before is rolled back, so that the influence of data abnormality, data untrustworthiness and the like on the database is reduced.
Most databases do not support data rollback, for example, commonly used remote dictionary service (Redis) or Memcached type databases do not support data rollback. In part of data supporting data rollback, the data rollback method adopted cannot be applied to different types of databases. The partial database can realize rollback on data stored in the database in a hard branching manner, that is, data corresponding to the abnormal block after recalculation is performed based on data in the current main chain of the regional chain, without using data originally in the abnormal block, for example, Bitcoin (BTC) in the regional chain. In addition, data rollback is completely based on a memory, for example, a chain base (Chainbase) mode adopted by a grapefruit (EOS) block chain is a data rollback mode completely based on a memory. However, the data rollback method using hard forking is complicated in operation, and data in partial forks in the block chain after rollback may be lost, which is costly in data rollback. The data rollback method based on the memory is limited by the content capacity, so that the method cannot be applied to different types of databases, namely the data rollback method is poor in universality.
Disclosure of Invention
The embodiment of the invention aims to provide a version rollback method, a version rollback device, electronic equipment and a storage medium, so that the cost of data rollback is reduced, and the universality of the data rollback method is improved. The specific technical scheme is as follows:
the embodiment of the invention provides a version rollback method, which comprises the following steps:
receiving a version rollback request for a current version of a preset database, wherein each version of the preset database is determined according to each data updating operation performed on data stored in the preset database;
and rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version roll-back request, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
Optionally, the version rollback request includes a target version number of the target version;
the step of rolling back the current version to the target version based on the received version rolling back request according to the reverse operation record corresponding to each version comprises the following steps:
determining a plurality of reverse operation records between the current version and the target version based on a target version number included in the version rollback request;
and rolling back the current version to the target version according to the plurality of reverse operation records.
Optionally, before rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request, the method further includes:
judging whether the generation time of the version number of the target version is earlier than the generation time of a preset version number; the preset version number is the earliest version number of the rollback of a preset version;
the step of rolling back the current version to the target version based on the received version rolling back request according to the reverse operation record corresponding to each version comprises the following steps:
and if the generation time is not earlier than the generation time of the preset version number, rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rolling back request.
Optionally, the method further includes:
receiving an adjustment request aiming at the preset version number, wherein the adjustment request comprises a version number to be adjusted;
and adjusting the preset version number to the version number to be adjusted based on the adjustment request.
Optionally, the method further includes:
receiving a data updating operation request aiming at the data stored in the preset database;
updating the data stored in the preset database based on the data updating operation request;
and generating a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation.
Optionally, the data update operation request is a batch write operation request; the batch write operation request comprises a plurality of data to be written;
the step of generating a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation includes:
and generating the version number of the corresponding version of the preset database after the batch writing operation, and indicating to delete the reverse operation records of the data to be written in batch.
Optionally, the step of rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version roll-back request includes:
and if the current version is the version obtained after the batch writing operation is carried out on the target version, deleting a plurality of written data to be written in batch from a preset database corresponding to the current version based on the received version rollback request according to the reverse operation record corresponding to the current version.
An embodiment of the present invention further provides a version rollback apparatus, where the apparatus includes:
the system comprises a first receiving module, a second receiving module and a third receiving module, wherein the first receiving module is used for receiving a version rollback request aiming at a current version of a preset database, and each version of the preset database is determined according to each data updating operation performed on data stored in the preset database;
and the rollback module is used for rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
Optionally, the version rollback request includes a target version number of the target version;
the rollback module is specifically configured to determine, based on a target version number included in the version rollback request, a plurality of reverse operation records between the current version and the target version; and rolling back the current version to the target version according to the plurality of reverse operation records.
Optionally, the apparatus further comprises:
the judging module is used for judging whether the generation time of the version number of the target version is earlier than the generation time of a preset version number; the preset version number is the earliest version number of the rollback of a preset version;
the rollback module is specifically configured to, when the determination result of the determination module is negative, rollback the current version to a target version according to the reverse operation record corresponding to each version based on the received version rollback request.
Optionally, the apparatus further comprises:
a second receiving module, configured to receive an adjustment request for the preset version number, where the adjustment request includes a version number to be adjusted;
and the adjusting module is used for adjusting the preset version number to the version number to be adjusted based on the adjusting request.
Optionally, the apparatus further comprises:
the third receiving module is used for receiving a data updating operation request aiming at the data stored in the preset database;
the updating module is used for updating the data stored in the preset database based on the data updating operation request;
and the generating module is used for generating the version number of the version corresponding to the updated preset database and the reverse operation record corresponding to the data updating operation.
Optionally, the data update operation request is a batch write operation request; the batch write operation request comprises a plurality of data to be written;
the generating module is specifically configured to generate a version number of a version corresponding to the preset database after the batch write operation, and instruct to delete the reverse operation records of the multiple data to be written in batch.
Optionally, the rollback module is specifically configured to, if the current version is a version obtained after performing a batch write operation on a target version, based on the received version rollback request, delete a plurality of pieces of data to be written in a batch manner from a preset database corresponding to the current version according to a reverse operation record corresponding to the current version.
The embodiment of the invention also provides electronic equipment which comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete mutual communication through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any one of the steps of the version rollback method when executing the program stored in the memory.
An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method implements any of the above-mentioned version rollback method steps.
Embodiments of the present invention also provide a computer program product containing instructions, which when run on a computer, cause the computer to perform any of the above-described version rollback methods.
The embodiment of the invention has the following beneficial effects:
the version rollback method, the device, the electronic device and the storage medium provided by the embodiments of the present invention can generate a corresponding version and a reverse operation record according to each data update operation on data stored in a preset database, and receive a version rollback request for a current version when data in the preset database needs to be rolled back, so as to roll back the current version to a target version according to the reverse operation record corresponding to each version, which enables data stored in the preset database to be rolled back along with the rolling back of the version of the preset database, and since the reverse operation record is generated according to the data update operation, the operation process is relatively simple when data is rolled back, the cost of data rolling back is effectively reduced, and the data volume of the reverse operation record is relatively small, the dependence on a memory is small, so that the data rollback mode can be applied to different types of databases, the universality of the data rollback method is improved.
Of course, not all of the advantages described above need to be achieved at the same time in the practice of any one product or method of the invention.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a first flowchart of a version rollback method according to an embodiment of the present invention;
fig. 2 is a second flowchart of a version rollback method according to an embodiment of the present invention;
fig. 3 is a third flowchart illustrating a version rollback method according to an embodiment of the present invention;
fig. 4 is a fourth flowchart illustrating a version rollback method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a version rollback apparatus according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
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 only a part of the embodiments of the present invention, and not all of the embodiments. 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.
In order to solve the problem that the existing data rollback method is not suitable for different types of databases, the embodiment of the invention provides a version rollback method. The method may be applied to any electronic device. In the method provided by the embodiment of the present invention, the electronic device may receive a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database, and based on the received version rollback request, roll back the current version to a target version according to a reverse operation record corresponding to each version, where the reverse operation record corresponding to each version is generated according to a data update operation corresponding to a previous version of the version.
By the method provided by the embodiment of the invention, the corresponding version and the reverse operation record are generated according to each data updating operation on the data stored in the preset database, when the data in the preset database needs to be rolled back, the version roll-back request aiming at the current version is received, so that the current version is rolled back to the target version according to the reverse operation record corresponding to each version, the data stored in the preset database can be rolled back along with the roll-back of the version of the preset database, because the reverse operation record is generated according to the data updating operation, the operation process is relatively simple when the data is rolled back, the cost of the data roll-back is effectively reduced, the data volume of the reverse operation record is relatively small, the dependence on the memory is small, and the data roll-back mode can be suitable for different types of databases, the universality of the data rollback method is improved.
The following examples illustrate the present invention.
As shown in fig. 1, fig. 1 is a first flowchart of a version rollback method according to an embodiment of the present invention. The method comprises the following steps.
Step S101, receiving a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database.
In this step, when performing a data update operation on data stored in the preset database, the electronic device may generate a version number of a version of the preset database after the data update operation of this time and a reverse operation record corresponding to the data update operation of this time. The electronic device may receive a version rollback request for a current version of preset data. For version update of the preset database and generation of the reverse operation record, reference may be made to the following description, and no specific description is made here.
In an optional embodiment, when an abnormal condition that data stored in the preset database is abnormal or the data is not trusted is detected, the electronic device may automatically trigger the version rollback operation. At this point, the electronic device may receive a version rollback request for the current version of the pre-set database. Here, the detection of abnormal data in the preset database is not specifically described.
In another alternative embodiment, the user may trigger the rollback operation according to his or her own needs, for example, the user may click a predetermined rollback button or input a predetermined rollback instruction. At this point, the electronic device may receive a version rollback request for the current version of the preset database.
In an alternative embodiment, the predetermined database includes, but is not limited to, a key-value database and a block chain database.
In an optional embodiment, the version rollback request may include a target version number of the target version.
Step S102, based on the received version rollback request, rolling back the current version to the target version according to the reverse operation record corresponding to each version, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
In this step, after receiving the version rollback request, the electronic device may perform version rollback operation on the current version of the preset database according to the stored reverse operation record corresponding to each version, so as to rollback the current version to the target version, thereby implementing data rollback on the data stored in the current version of the preset database. The specific process of the version rollback operation can be referred to the following description, and is not specifically described here.
In this embodiment of the present invention, the target version may be a previous version of the current version. That is, the electronic device receives a version rollback request, the current version may be rolled back to a previous version of the current version. Alternatively, the target version may be any version before the current version. That is, the electronic device receives a version rollback request, and may rollback the current version to any version before the current version.
In an optional embodiment, after the data rollback is performed, the data corresponding to the version whose generation time is later than that of the current version is discarded. That is, after rolling back the current version to the target version, the data of the corresponding version between the target version and the current version will be discarded and cannot be retrieved. Specifically, the user may discard the data of the version after the current version after the rollback according to the user requirement, the application scenario, and the like. The present invention is not particularly limited in the examples.
By using the method shown in fig. 1, according to each data updating operation on the data stored in the preset database, a corresponding version and a reverse operation record are generated, when data rollback needs to be carried out on data in a preset database, a version rollback request for a current version is received, so that the current version is rolled back to the target version according to the reverse operation record corresponding to each version, this allows the data stored in the preset database to be rolled back as the version of the preset database is rolled back, since the reverse operation record is generated according to the data update operation, the operation process is relatively simple when data rollback is carried out, the cost of data rollback is effectively reduced, the data volume recorded by reverse operation is relatively small, the dependence on the memory is small, so that the data rollback method can be suitable for different types of databases, and the universality of the data rollback method is improved.
In an optional embodiment, when the version rollback request includes a target version number of the target version, the step S102 of rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request may include the following steps.
Step one, based on the target version number included in the version rollback request, determining a plurality of reverse operation records between the current version and the target version.
In this step, when the received version rollback request includes the target version number, the electronic device may determine that the preset database needs to be rolled back from the current version to the target version corresponding to the target version number. At this time, the electronic device may select, according to the target version number included in the version rollback request, a plurality of reverse operation records corresponding to the current version of the preset database and the target version of the preset database from the stored reverse operation records corresponding to each version.
For example, the current version of the preset database is a fourth version, the target version of the preset database is a second version, and when the version number including the second version is received, the electronic device may obtain, from the stored reverse operation records corresponding to each version, a plurality of reverse operation records corresponding to versions between the current version and the target version, that is, obtain the current version, that is, the reverse operation record corresponding to the fourth version, and the reverse operation instruction corresponding to the third version.
And step two, rolling back the current version to the target version according to the plurality of reverse operation records.
In this step, after determining a plurality of reverse operation records between the current version and the target version, the electronic device may sequentially execute the reverse operation corresponding to each reverse operation record according to the generation time of each reverse operation record, that is, sequentially execute the reverse operation corresponding to each reverse operation record according to the sequence from late to early of the generation time, and roll back the current version to the target version.
For convenience of understanding, the current version of the preset database is a version obtained through 5 data updating operations. The preset database has 5 versions, which are respectively A1, A2, A3, A4 and A5 in sequence, wherein the current version is A5.
When the target version is the previous version of the current version, that is, the version number included in the version rollback request is the version number of the previous version of the current version, that is, a 4. The electronic device may obtain the reverse operation record corresponding to the current version, and roll back the current version to the previous version of the current version according to the reverse operation record, that is, roll back a5 to a 4. At this point, the current version of the default database will be changed to a 4. The data stored in the preset database is the data corresponding to the preset database with the version number of A4.
When the target version is any version before the current version, and the target version number included in the version rollback request is A3, the electronic device may select the reverse operation record corresponding to a5 and the reverse operation record corresponding to a4 from the stored reverse operation records corresponding to each version according to A3 included in the version rollback request. The electronic device may execute the reverse operation record corresponding to a5 according to the generation time of the selected reverse operation record, roll back the version of the preset database from a5 to a4, then execute the reverse operation record corresponding to a4, roll back the version of the preset database from a4 to A3, and thus complete the process of rolling back the preset database from version a5 to version A3.
In the above embodiment, by carrying the target version number of the target version in the version rollback request, the current version of the preset database can be rolled back to the target version only by receiving the version rollback request once, so that the receiving times of the version rollback request are effectively reduced, the time consumed by the version rollback is shortened, and the efficiency of the version rollback is improved.
In another optional embodiment, when the version rollback request does not include the target version number of the target version, the target version defaults to a previous version of a current version of a preset database. At this time, when the version rollback request is received, the electronic device defaults to roll back the preset database from the current version to a previous version of the current version.
In an alternative embodiment, according to the method shown in fig. 1, an embodiment of the present invention further provides a version rollback method. As shown in fig. 2, fig. 2 is a second flowchart of a version rollback method according to an embodiment of the present invention. The method comprises the following steps.
Step S201, receiving a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database.
Step S201 is the same as step S101.
Step S202, judging whether the generation time of the version number of the target version is earlier than the generation time of the preset version number; the preset version number is the earliest version number of the preset version rollback. If not, go to step S203.
In this step, the electronic device may compare the generation time of the version number of the target version with the generation time of the preset version number, thereby determining whether the generation time of the version number of the target version is earlier than the generation time of the preset version number. That is, it is determined whether the target version is generated before the preset version corresponding to the preset version number.
In the embodiment of the present invention, the electronic device may further determine whether the target version is generated before the preset version corresponding to the preset version number in other manners. For example, each time the electronic device generates a version number of a version corresponding to the data update operation, the electronic device may generate the version number of each version according to an increasing rule, such as a1-a5 described above. The electronic device may determine whether the target version is generated before the preset version corresponding to the preset version number according to the target version number and the preset version number of the target version. That is, when the target version number of the target version is less than the preset version number, the electronic device may determine that the target version is generated before the preset version. When the target version number of the target version is greater than the preset version number, the electronic device may determine that the target version is generated after the preset version. When the target version number of the target version is equal to the preset version number, the electronic device may determine that the target version is the preset version.
Step S203, based on the received version rollback request, rollback the current version to the target version according to the reverse operation record corresponding to each version.
In this step, when the generation time of the version number of the target version is not earlier than the generation time of the preset version number, that is, when it is determined that the target version is generated after the preset version, the electronic device may rollback the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request. The specific version rollback mode may refer to step S102, which is not specifically described herein.
In an alternative embodiment, when the generation time of the version number of the target version is earlier than the generation time of the preset version number, that is, when it is determined that the target version is not generated after the preset version, the electronic device rolls back the current version to the preset version.
For example, when the target version is any version other than the current version and the previous version of the current version, the preset version is the previous version of the current version, and at this time, the electronic device may determine that the generation time of the version number of the target version is earlier than the generation time of the preset version, that is, the target version is generated before the preset version. The electronic device may rollback the current version to a previous version of the current version. In addition, the electronic device may send a prompt message to the user, for example, to display that the electronic device has rolled back to the preset version in a display screen of the electronic device, thereby prompting the user that the electronic device may not roll back to the target version.
By adopting the method shown in fig. 2, the preset version is set, that is, the earliest version number capable of performing the version rollback is set, so that each version before the preset version is irreversibility is ensured, and the stability of the data stored in the preset database is ensured.
In an alternative embodiment, according to the method shown in fig. 1, an embodiment of the present invention further provides a version rollback method. As shown in fig. 3, fig. 3 is a third flowchart of a version rollback method according to an embodiment of the present invention. The method comprises the following steps.
Step S301, receiving a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database.
Step S302, based on the received version rollback request, according to the reverse operation record corresponding to each version, rollback the current version to the target version, where the reverse operation record corresponding to each version is generated according to the data update operation corresponding to the previous version of the version.
The above steps S301 to S302 are the same as the above steps S101 to S102.
Step S303, receiving an adjustment request for a preset version number, where the adjustment request includes a version number to be adjusted.
In an optional embodiment, a user may send an adjustment request for a preset version number to the electronic device according to a requirement of the user, where the adjustment request includes a version number to be adjusted. The electronic device receives the adjustment request.
In another alternative embodiment, the electronic device may trigger the adjustment operation of the preset version number according to a preset adjustment rule. At this time, the electronic device will receive an adjustment request for a preset version number, where the adjustment request includes a version number to be adjusted. For example, the preset adjustment rule may be that when the data update operation in the preset database reaches a preset update time threshold, the adjustment operation on the preset version number is automatically triggered. The preset adjustment rule is not particularly limited.
In the embodiment of the present invention, the execution sequence of the steps S301 and S303 is not particularly limited.
Step S304, based on the adjustment request, adjusting the preset version number to the version number to be adjusted.
In this step, upon receiving the adjustment request, the electronic device may adjust the preset version number to the version number to be adjusted, that is, the preset version is changed to the version corresponding to the version number to be adjusted.
By adopting the method shown in fig. 3, the electronic device can adjust the preset version in time according to factors such as user requirements or application scenes, and the like, so that the flexibility of the preset version is improved, and the flexibility of the version rollback method is improved.
In an alternative embodiment, according to the method shown in fig. 1, an embodiment of the present invention further provides a version rollback method. As shown in fig. 4, fig. 4 is a fourth flowchart illustrating a version rollback method according to an embodiment of the present invention. The method comprises the following steps.
Step S401, receiving a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database.
Step S402, based on the received version rollback request, rolling back the current version to the target version according to the reverse operation record corresponding to each version, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
The above-described steps S401 to S402 are the same as the above-described steps S101 to S102.
In step S403, a data update operation request for data stored in a preset database is received.
In this step, the user may perform a data update operation on the data stored in the preset database. When a user performs data updating operation on data stored in a preset database, the electronic equipment receives a data updating operation request aiming at the data stored in the preset database. Wherein, the data operation request includes operation information indicating data updating operation.
In an alternative embodiment, the data updating operation may include an adding operation, a deleting operation, and a modifying operation on the preset database. The data update operations that may be employed vary for different types of databases. For example, if the predetermined database is a key-value database, the data update operation may be any one of an add operation, a delete operation, and a modify operation. For another example, if the predetermined database is a blockchain database, the data update operation may be an add operation.
In the embodiment of the present invention, the data operation request includes operation information indicating the data update operation, which is different for different data update operations. For example, the data updating operation is the adding operation, and the operation information may include information such as the data to be added and the storage address corresponding to the data to be added. For another example, the data updating operation is the deleting operation, and the operation information may be information such as data to be deleted in a preset database, and a storage address of the data to be deleted. For another example, the data updating operation is the above modifying operation, and the operation information may be information such as data before modification, the data storage address, and modified data. Here, the data operation request includes operation information indicating a data update operation, which is not particularly limited.
Step S404, updating the data stored in the preset database based on the data updating operation request.
In this step, after receiving the data update operation request, the electronic device may update the data stored in the preset database according to operation information indicating a data update operation included in the data update operation request. Taking the operation information as the data to be added and the storage address corresponding to the data to be added as an example, the electronic device may store the data to be added to the storage address corresponding to the preset database according to the operation information, and complete the data updating operation on the preset database to obtain the preset database after the updating.
Step S405, generating a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation.
In this step, after the data update operation on the data stored in the preset database is completed, the electronic device may generate, according to the data update operation on the preset database this time, a version number of a version corresponding to the updated preset database and a reverse operation record corresponding to the data update operation this time.
The reverse operation record records reverse operation information corresponding to the reverse operation of the data updating operation. The data update operation is exemplified as the above-mentioned add operation, the delete operation, and the modify operation, respectively. When the data update operation is the above-described addition operation, such as adding the data a to the position a of the preset database, the reverse operation record may be recorded with reverse operation information for deleting the data a at the position a of the preset database. When the data updating operation is the above-described deleting operation, such as deleting the data B at the position B of the preset database, the reverse operation record may be recorded with the reverse operation information of adding the data B to the position B of the preset database. When the data updating operation is the above modifying operation, such as modifying the data C at the position C of the preset database into the data D, the reverse operation record may be recorded with reverse operation information that modifies the data D at the position C of the preset database into the data C.
In the embodiment of the invention, the electronic device abstracts each data updating operation on the preset database into the change of the version state. The version number of the preset database and the version number of each version are only marks of the preset database after one data updating operation. That is, each new version is generated to indicate that only one data update occurred to the data in the predetermined database. In the process, the electronic equipment represents each data updating operation on the preset database by using the change of the version of the preset database, and does not need to record or store the data stored in the preset database before and after the data updating operation, so that the data volume of the stored data is effectively reduced, and the storage resources are saved.
By using the method shown in fig. 4, after updating the data stored in the preset database, the electronic device may generate a version number of a corresponding version and a reverse operation record corresponding to the data updating operation, so as to facilitate the rollback of the version at a later stage.
In an alternative embodiment, in the above embodiment, the data update operation is a single update operation on stored single data of the preset data. It is contemplated that the default database may provide an interface for batch writes, i.e., the default database may provide bulk write functionality. At this time, the data update operation request may be a batch write operation request; the bulk write operation request includes a plurality of data to be written.
In step S405, a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation are generated, which may be specifically represented as: and generating a version number of a corresponding version of the preset database after the batch writing operation, and indicating a reverse operation record for batch deletion of a plurality of data to be written.
Specifically, due to the influence of factors such as a network environment, when performing batch writing, the time for writing each data to be written into the preset database may be the same or may be different. In this embodiment of the present invention, the electronic device may regard an adding operation of writing the plurality of pieces of data to be written into the preset database in batch as a data updating operation, so that when the plurality of pieces of data to be written are written into the preset database, according to the version number of the version corresponding to the preset database after the batch writing operation is generated, and a batch deletion operation record opposite to the batch writing operation at this time, that is, an inverse operation record indicating to delete the plurality of pieces of data to be written in batch.
In the embodiment of the invention, the electronic equipment regards the batch write operation as a complete data update operation, so that the version number and the reverse operation record corresponding to the batch write operation are generated, and the version can be directly rolled back to the version of the preset database before the batch write operation when the version is rolled back at the later stage.
In an optional embodiment, for the batch write operation, the electronic device may further determine, according to factors such as user requirements and application scenarios, whether to generate a version number of a version corresponding to each piece of data to be written after being written in the preset database, and a corresponding reverse operation record.
In an optional embodiment, when the current version is a version obtained by performing a batch write operation on the target version, in step S402, based on the received version rollback request, according to the reverse operation record corresponding to each version, the rollback of the current version to the target version may specifically be represented as: based on the received version rollback request, according to the reverse operation record corresponding to the current version, namely the reverse operation record indicating that the plurality of data to be written are deleted in batch, the plurality of written data to be written are deleted in batch from the preset database corresponding to the current version, so that the current version is rolled back to the version corresponding to the preset database before the batch writing operation.
In the embodiment of the invention, the reverse operation records of the data to be written are deleted in batch according to the indication, the electronic device can directly rollback the current version to the version corresponding to the preset database before the batch write operation, and the batch write data in the preset database does not need to be rolled back one by one, so that the efficiency of rolling back the version of the preset database is improved, and the efficiency of rolling back the data stored in the preset database is improved.
Based on the same inventive concept, according to the version rollback method provided by the embodiment of the invention, the embodiment of the invention also provides a version rollback device. Fig. 5 is a schematic structural diagram of a version rollback apparatus according to an embodiment of the present invention, as shown in fig. 5. The apparatus also includes the following modules.
A first receiving module 501, configured to receive a version rollback request for a current version of a preset database, where each version of the preset database is determined according to each data update operation performed on data stored in the preset database;
a rollback module 502, configured to rollback the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request, where the reverse operation record corresponding to each version is generated according to a data update operation corresponding to a previous version of the version.
Optionally, the version rollback request may include a target version number of the target version;
the rollback module 502 may be specifically configured to determine, based on a target version number included in the version rollback request, a plurality of reverse operation records between the current version and the target version; and rolling back the current version to the target version according to a plurality of reverse operation records.
Optionally, the version rollback apparatus may further include:
the judging module is used for judging whether the generation time of the version number of the target version is earlier than the generation time of the preset version number; the preset version number is the earliest version number of the preset version rollback;
the rollback module 502 may be specifically configured to, when the determination result of the determining module is negative, rollback the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request.
Optionally, the version rollback apparatus may further include:
the second receiving module is used for receiving an adjustment request aiming at a preset version number, and the adjustment request comprises a version number to be adjusted;
and the adjusting module is used for adjusting the preset version number into the version number to be adjusted based on the adjusting request.
Optionally, the version rollback apparatus may further include:
the third receiving module is used for receiving a data updating operation request aiming at data stored in a preset database;
the updating module is used for updating the data stored in the preset database based on the data updating operation request;
and the generating module is used for generating the version number of the version corresponding to the updated preset database and the reverse operation record corresponding to the data updating operation.
Optionally, the data update operation request is a batch write operation request; the batch write operation request comprises a plurality of data to be written;
the generating module may be specifically configured to generate a version number of a version corresponding to the preset database after the batch write operation, and instruct to delete the reverse operation records of the multiple data to be written in batch.
Optionally, the rollback module 502 may be specifically configured to, if the current version is a version obtained after performing a batch write operation on the target version, based on the received version rollback request, delete the written multiple data to be written in batch from the preset database corresponding to the current version according to the reverse operation record corresponding to the current version.
By the device provided by the embodiment of the invention, the corresponding version and the reverse operation record are generated according to each data updating operation on the data stored in the preset database, when the data in the preset database needs to be rolled back, the version roll-back request aiming at the current version is received, so that the current version is rolled back to the target version according to the reverse operation record corresponding to each version, the data stored in the preset database can be rolled back along with the roll-back of the version of the preset database, because the reverse operation record is generated according to the data updating operation, the operation process is relatively simple when the data is rolled back, the cost of the data roll-back is effectively reduced, the data volume of the reverse operation record is relatively small, the dependence on the memory is small, and the data roll-back mode can be suitable for different types of databases, the universality of the data rollback method is improved.
Based on the same inventive concept, according to the version rollback method provided by the above embodiment of the present invention, an embodiment of the present invention further provides an electronic device, as shown in fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 complete mutual communication through the communication bus 604;
a memory 603 for storing a computer program;
the processor 601 is configured to implement the following steps when executing the program stored in the memory 603:
receiving a version rollback request for a current version of a preset database, wherein each version of the preset database is determined according to each data updating operation performed on data stored in the preset database;
and rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version roll-back request, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
Through the electronic equipment provided by the embodiment of the invention, the corresponding version and the reverse operation record are generated according to each data updating operation on the data stored in the preset database, when the data in the preset database needs to be rolled back, the version roll-back request aiming at the current version is received, so that the current version is rolled back to the target version according to the reverse operation record corresponding to each version, the data stored in the preset database can be rolled back along with the roll-back of the version of the preset database, because the reverse operation record is generated according to the data updating operation, the operation process is relatively simple when the data is rolled back, the cost of the data roll-back is effectively reduced, the data volume of the reverse operation record is relatively small, the dependence on the memory is small, and the data roll-back mode can be suitable for different types of databases, the universality of the data rollback method is improved.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
Based on the same inventive concept, according to the version rollback method provided in the above embodiment of the present invention, an embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above-described version rollback methods.
Based on the same inventive concept, according to the version rollback method provided in the above embodiment of the present invention, an embodiment of the present invention further provides a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the version rollback methods in the above embodiments.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for embodiments such as the apparatus, the electronic device, the computer-readable storage medium, and the computer program product, since they are substantially similar to the method embodiments, the description is simple, and for relevant points, reference may be made to part of the description of the method embodiments.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (10)

1. A method of version rollback, the method comprising:
receiving a version rollback request for a current version of a preset database, wherein each version of the preset database is determined according to each data updating operation performed on data stored in the preset database;
and rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version roll-back request, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
2. The method of claim 1, wherein the version rollback request comprises a target version number of a target version;
the step of rolling back the current version to the target version based on the received version rolling back request according to the reverse operation record corresponding to each version comprises the following steps:
determining a plurality of reverse operation records between the current version and the target version based on a target version number included in the version rollback request;
and rolling back the current version to the target version according to the plurality of reverse operation records.
3. The method of claim 1, further comprising, before rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version roll back request:
judging whether the generation time of the version number of the target version is earlier than the generation time of a preset version number; the preset version number is the earliest version number of the rollback of a preset version;
the step of rolling back the current version to the target version based on the received version rolling back request according to the reverse operation record corresponding to each version comprises the following steps:
and if the generation time is not earlier than the generation time of the preset version number, rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rolling back request.
4. The method of claim 3, further comprising:
receiving an adjustment request aiming at the preset version number, wherein the adjustment request comprises a version number to be adjusted;
and adjusting the preset version number to the version number to be adjusted based on the adjustment request.
5. The method of claim 1, further comprising:
receiving a data updating operation request aiming at the data stored in the preset database;
updating the data stored in the preset database based on the data updating operation request;
and generating a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation.
6. The method of claim 5, wherein the data update operation request is a bulk write operation request; the batch write operation request comprises a plurality of data to be written;
the step of generating a version number of the updated version corresponding to the preset database and a reverse operation record corresponding to the data updating operation includes:
and generating the version number of the corresponding version of the preset database after the batch writing operation, and indicating to delete the reverse operation records of the data to be written in batch.
7. The method according to claim 6, wherein the step of rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rolling back request comprises:
and if the current version is the version obtained after the batch writing operation is carried out on the target version, deleting a plurality of written data to be written in batch from a preset database corresponding to the current version based on the received version rollback request according to the reverse operation record corresponding to the current version.
8. A version rollback apparatus, characterized in that the apparatus comprises:
the system comprises a first receiving module, a second receiving module and a third receiving module, wherein the first receiving module is used for receiving a version rollback request aiming at a current version of a preset database, and each version of the preset database is determined according to each data updating operation performed on data stored in the preset database;
and the rollback module is used for rolling back the current version to the target version according to the reverse operation record corresponding to each version based on the received version rollback request, wherein the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1 to 7 when executing a program stored in the memory.
10. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of claims 1 to 7.
CN201911415713.3A 2019-12-31 2019-12-31 Version rollback method and device, electronic equipment and storage medium Active CN111159160B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911415713.3A CN111159160B (en) 2019-12-31 2019-12-31 Version rollback method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911415713.3A CN111159160B (en) 2019-12-31 2019-12-31 Version rollback method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111159160A true CN111159160A (en) 2020-05-15
CN111159160B CN111159160B (en) 2023-06-20

Family

ID=70560159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911415713.3A Active CN111159160B (en) 2019-12-31 2019-12-31 Version rollback method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111159160B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625262A (en) * 2020-05-28 2020-09-04 广东浪潮大数据研究有限公司 Rollback method, system, equipment and storage medium of workload resources
CN112306995A (en) * 2020-11-11 2021-02-02 支付宝(杭州)信息技术有限公司 Method and device for realizing database operation

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101526957A (en) * 2009-04-09 2009-09-09 北京四方继保自动化股份有限公司 Pattern-model integrated version management method applied in power automatization system
CN103744936A (en) * 2013-12-31 2014-04-23 华为技术有限公司 Multi-version concurrency control method in database and database system
CN108052681A (en) * 2018-01-12 2018-05-18 毛彬 The synchronous method and system of structural data between a kind of relevant database
US10025943B1 (en) * 2014-10-13 2018-07-17 Amazon Technologies, Inc. Commit and rollback of data streams provided by partially trusted entities
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101526957A (en) * 2009-04-09 2009-09-09 北京四方继保自动化股份有限公司 Pattern-model integrated version management method applied in power automatization system
CN103744936A (en) * 2013-12-31 2014-04-23 华为技术有限公司 Multi-version concurrency control method in database and database system
US10025943B1 (en) * 2014-10-13 2018-07-17 Amazon Technologies, Inc. Commit and rollback of data streams provided by partially trusted entities
CN108052681A (en) * 2018-01-12 2018-05-18 毛彬 The synchronous method and system of structural data between a kind of relevant database
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625262A (en) * 2020-05-28 2020-09-04 广东浪潮大数据研究有限公司 Rollback method, system, equipment and storage medium of workload resources
CN111625262B (en) * 2020-05-28 2023-08-22 广东浪潮大数据研究有限公司 Rollback method, system, equipment and storage medium of workload resource
CN112306995A (en) * 2020-11-11 2021-02-02 支付宝(杭州)信息技术有限公司 Method and device for realizing database operation
CN112306995B (en) * 2020-11-11 2023-06-27 北京奥星贝斯科技有限公司 Method and device for realizing database operation

Also Published As

Publication number Publication date
CN111159160B (en) 2023-06-20

Similar Documents

Publication Publication Date Title
CN110113393B (en) Message pushing method and device, electronic equipment and medium
CN110851308A (en) Test method, test device, electronic equipment and storage medium
CN108932286B (en) Data query method and device
CN109359118B (en) Data writing method and device
EP3244320A1 (en) File path storing and local file accessing method and device
US10635575B2 (en) Testing of enterprise resource planning systems
CN111506580B (en) Transaction storage method based on centralized block chain type account book
CN111159160B (en) Version rollback method and device, electronic equipment and storage medium
CN107577775B (en) Data reading method and device, electronic equipment and readable storage medium
CN111782440A (en) Data processing method and device and electronic equipment
CN111796766A (en) Data storage method and device and computer system
JP2021157259A (en) Optimal object placement device and method
CN114020193A (en) Cross-page checking determination method and device, electronic equipment and storage medium
CN111125240B (en) Distributed transaction realization method and device, electronic equipment and storage medium
CN111399849A (en) Method and system for determining application program installation package
WO2020029588A1 (en) Data reading method, device, system, and distributed system
CN111309693A (en) Data synchronization method, device and system, electronic equipment and storage medium
CN110727895A (en) Sensitive word sending method and device, electronic equipment and storage medium
CN115858668A (en) Distributed transaction processing method, device, electronic device and storage medium
JP2012089049A (en) Computer system and server
CN112306995B (en) Method and device for realizing database operation
CN110083509B (en) Method and device for arranging log data
CN111625500A (en) File snapshot method and device, electronic equipment and storage medium
CN111078418B (en) Operation synchronization method, device, electronic equipment and computer readable storage medium
CN113849133B (en) Processing method and device of privacy data, electronic 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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210531

Address after: 25, 5th floor, shuangjingfang office building, 3 frisha street, Singapore

Applicant after: Zhuomi Private Ltd.

Address before: Room 1101, Santai Commercial Building, 139 Connaught Road, Hong Kong, China

Applicant before: HONG KONG LIVE.ME Corp.,Ltd.

GR01 Patent grant
GR01 Patent grant