CN111159160B - 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
CN111159160B
CN111159160B CN201911415713.3A CN201911415713A CN111159160B CN 111159160 B CN111159160 B CN 111159160B CN 201911415713 A CN201911415713 A CN 201911415713A CN 111159160 B CN111159160 B CN 111159160B
Authority
CN
China
Prior art keywords
version
data
rollback
preset
request
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
Application number
CN201911415713.3A
Other languages
Chinese (zh)
Other versions
CN111159160A (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
Zhuomi Private 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 Zhuomi Private Ltd filed Critical Zhuomi Private 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: and 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, rolling back the current version to the target version according to a reverse operation record corresponding to each version based on the received version rollback request, and the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version. According to the technical scheme provided by the embodiment of the invention, the reverse operation record is generated according to the data updating operation, so that 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 smaller, and the dependence on the memory is smaller, so that the data rollback mode can be suitable for databases of different types, 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 version rollback method, a device, an electronic apparatus, and a storage medium.
Background
When the data is stored in the blockchain field, the data is inevitably required to be rolled back to the database, namely, the data currently stored in the database is rolled back to the data stored at a certain moment before, so that the influence of the conditions of abnormal data or unreliable data and the like on the database is reduced.
Most databases do not support data rollback at present, e.g., neither the usual remote dictionary services (Remote Dictionary Server, dis) nor Memcached type databases support data rollback. In some data supporting data rollback, the data rollback method employed is not applicable to different types of databases. The partial database may implement rollback of data stored in the database by hard forking, that is, based on data in the current backbone of the regional chain, recalculating the data corresponding to the abnormal block after the recalculation without using the data that is original to the abnormal block, for example, bitcoin (BTC) in the regional chain. Also, a fully memory-based data rollback, such as a chain base (Chainbase) scheme used by a grapefruit (EOS) blockchain, is a fully memory-based data rollback scheme. However, the data rollback method by hard forking is more complicated in operation and the data in part of the forking in the blockchain after rollback may be lost, which is costly. The memory-based data rollback method is limited by content capacity, so that the method cannot be applied to different types of databases, that is, the data rollback method has poor 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, which can reduce the cost of data rollback and improve the universality of the data rollback method. 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, each version of the preset database being determined according to each data update operation performed on data stored in the preset database;
based on the received version rollback request, the current version is rolled back to the target version according to the reverse operation record corresponding to each version, and 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 according to the reverse operation record corresponding to each version based on the received version rollback request 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 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 preset version rollback;
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 rollback request comprises the following steps:
and if the generation time of the preset version number 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 rollback request.
Optionally, the method further comprises:
receiving an adjustment request for 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 comprises:
Receiving a data update operation request for 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 a version corresponding to the updated 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 the version number of the version corresponding to the updated preset database and the reverse operation record corresponding to the data updating operation comprises the following steps:
and generating version numbers of corresponding versions of the preset databases after the batch write operation, and indicating to delete the reverse operation records of the plurality of data to be written in batches.
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 rollback request includes:
and if the current version is a version obtained after batch writing operation is performed on the target version, based on the received version rollback request, deleting the written plurality of data to be written in batches from a preset database corresponding to the current version according to the reverse operation record corresponding to the current version.
The embodiment of the invention also provides a version rollback device, which comprises:
the first receiving module is used for receiving a version rollback request aiming at the current version of a preset database, and each version of the preset database is determined according to each data updating operation 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, and 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 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 reverse operation records.
Optionally, the apparatus further includes:
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 preset version rollback;
The rollback module is specifically configured to rollback the current version to a target version based on the received version rollback request according to a reverse operation record corresponding to each version when the judgment result of the judgment module is negative.
Optionally, the apparatus further includes:
the second receiving module is used for receiving an adjustment request aiming at the preset version number, wherein the adjustment request comprises 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 includes:
a third receiving module, configured to receive a data update operation request for 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;
the generation 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 generation module is specifically configured to generate version numbers of versions corresponding to the preset databases after the batch write operation, and instruct batch deletion of reverse operation records of the plurality of data to be written.
Optionally, the rollback module is specifically configured to, if the current version is a version obtained after performing a batch write operation on the target version, delete, in batch, the written plurality of data to be written from a preset database corresponding to the current version based on the received version rollback request 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 and the communication interface, and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any version rollback method step when executing the program stored in the memory.
The embodiment of the invention also provides a computer readable storage medium, wherein a computer program is stored in the computer readable storage medium, and the computer program realizes the steps of the version rollback method when being executed by a processor.
Embodiments of the present invention also provide a computer program product comprising 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 beneficial effects that:
according to the version rollback method, the device, the electronic equipment and the storage medium, corresponding versions and reverse operation records can be generated according to each data updating operation on data stored in the preset database, when the data in the preset database needs to be rolled back, a version rollback 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 rollback of the version of the preset database, and 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 rollback is effectively reduced, the data volume of the reverse operation record is relatively small, the dependence on a memory is small, and the data rollback mode can be suitable for databases of different types, and the universality of the data rollback method is improved.
Of course, it is not necessary for any one product or method of practicing the invention to achieve all of the advantages set forth above at the same time.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic flow chart 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 of a version rollback method according to an embodiment of the present invention;
fig. 4 is a fourth flowchart of 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 following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order to solve the problem that the existing data rollback method is not suitable for databases of different types, the embodiment of the invention provides a version rollback method. The method can be applied to any electronic device. In the method provided by the embodiment of the invention, the electronic device can receive the version rollback request aiming at the current version of the preset database, each version of the preset database is determined according to each data updating operation performed on the data stored in the preset database, the current version is rolled back to the target version according to the reverse operation record corresponding to each version based on the received version rollback request, and the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
According to the method provided by the embodiment of the invention, corresponding versions and reverse operation records are generated according to each data updating operation of the data stored in the preset database, when the data in the preset database is required to be rolled back, a version rolling 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 rolling back of the version of the preset database, and the reverse operation records are generated according to the data updating operation, so that the operation process is relatively simple when the data is rolled back, the cost of the data rolling back is effectively reduced, the data quantity of the reverse operation records is relatively small, and the dependence on a memory is small, so that the data rolling back mode can be suitable for different types of databases, and the universality of the data rolling back method is improved.
The following describes embodiments of the present invention by way of specific examples.
Fig. 1 is a schematic flow chart 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 the data stored in the preset database is subjected to the data update operation, the electronic device may generate a version number of the version of the preset database after the current data update operation, and a reverse operation record corresponding to the current data update operation. The electronic device may receive a version rollback request for a current version of the preset data. For version updating of the preset database and generation of the reverse operation record, reference will be made to the following description, which will not be described in detail.
In an alternative embodiment, the electronic device may automatically trigger the version rollback operation when an abnormal condition such as an abnormal condition of data stored in the preset database or unreliable data is detected. At this point, the electronic device may accept a version rollback request for the current version of the preset database. Here, the detection of abnormal data in the preset database is not specifically described.
In another alternative embodiment, the user may trigger a version rollback operation according to his own needs, e.g., the user may click a predetermined version rollback button, or input a predetermined version 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 preset database includes, but is not limited to, a key value database, and a blockchain database.
In an alternative embodiment, the version rollback request may include a target version number of the target version.
Step S102, based on the received version rollback request, the current version is rolled back to the target version according to the reverse operation record corresponding to each version, and 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 above version rollback request, the electronic device may perform a 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 correspondence to the current version of the preset database. The specific procedure for the version rollback operation is described below and is not specifically described herein.
In the embodiment of the present invention, the target version may be a version previous to the current version. That is, the electronic device receives a version rollback request, and may rollback the current version to a version that is previous to the current version. Alternatively, the target version may be any version preceding the current version. That is, the electronic device receives a version rollback request once, and may rollback the current version to any version prior to the current version.
In an alternative embodiment, after the data rollback, the data corresponding to the version having a time of generation later than the current version is discarded. That is, after the current version is rolled back to the target version, the data of the corresponding version between the target version and the current version is discarded and cannot be retrieved. Specifically, the user may discard the version data after the current version after rollback according to the user requirement, the application scenario, and the like. The embodiment of the present invention is not particularly limited.
By adopting 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 the data in the preset database needs to be rolled back, a version rolling 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 rolling back of the version of the preset database, and because the reverse operation record is generated according to the data updating operation, the operation process is relatively simple when the data rolling back is carried out, the cost of the data rolling back is effectively reduced, the data quantity of the reverse operation record is relatively smaller, and the dependence on the memory is smaller, so that the data rolling back mode can be suitable for databases of different types, and the universality of the data rolling back method is improved.
In an alternative embodiment, when the version rollback request includes the target version number of the target version, step S102, based on the received version rollback request, of rolling back the current version to the target version according to the reverse operation record corresponding to each version, may include the following steps.
Step one, a plurality of reverse operation records between the current version and the target version are determined based on the target version number included in the version rollback request.
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 between the current version of the preset database and the target version of the preset database from the reverse operation records corresponding to each version stored.
For example, when the current version of the preset database is the fourth version and the target version of the preset database is the second version, and 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 the version between the current version and the target version, that is, obtain the reverse operation record corresponding to the current version, that is, the fourth version, and obtain 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 order of the generation time from late to early, and roll back the current version to the target version.
For ease of understanding, the description will be given taking, as an example, a version in which the current version of the preset database is obtained through 5 times of data update operations. The preset database has 5 versions, namely A1, A2, A3, A4 and A5 in sequence, wherein the current version is A5.
When the target version is the version previous to the current version, that is, the version number included in the version rollback request is the version number of the version previous to the current version, that is, A4. The electronic device may obtain a reverse operation record corresponding to the current version, and roll back the current version to a version previous to the current version according to the reverse operation record, i.e. roll back A5 to A4. At this time, the current version of the preset database will be changed to A4. The data stored in the preset database is the data stored corresponding to the preset database when the version number is A4.
When the target version is any version before the current version, and when the target version number included in the version rollback request is A3, the electronic device may select, according to A3 included in the version rollback request, a reverse operation record corresponding to A5 and a reverse operation record corresponding to A4 from reverse operation records corresponding to each stored version. The electronic device may execute the reverse operation record corresponding to A5 first according to the generation time of the selected reverse operation record, roll back the version of the preset database from A5 to A4, execute the reverse operation record corresponding to A4, and roll back the version of the preset database from A4 to A3, thereby completing the process of rolling back the preset database from the version A5 to the version A3.
In the embodiment, the target version number of the target version is carried in the version rollback request, so that the current version of the preset database can be rolled back to the target version only through one-time receiving of the version rollback request, the receiving times of the version rollback request are effectively reduced, the time consumed by version rollback is shortened, and the efficiency of version rollback is improved.
In another alternative embodiment, when the version rollback request does not include the target version number of the target version, the target version defaults to a version previous to the current version of the preset database. At this time, when receiving the version rollback request, the electronic device rollbacks the preset database from the current version to the version previous to the current version by default.
In an alternative embodiment, according to the method shown in fig. 1, an embodiment of the present invention further provides a version rollback method. Fig. 2 is a schematic diagram of a second flow chart 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, step S203 is performed.
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. I.e. it is determined whether the target version was generated before the preset version corresponding to the preset version number.
In the embodiment of the invention, the electronic device can also determine whether the target version is generated before the preset version corresponding to the preset version number in other manners. For example, when the electronic device generates the version number of the version corresponding to the data update operation each time, the version number of each version may be generated according to an increasing rule, such as A1-A5 described above. The electronic device may determine, according to the target version number and the preset version number of the target version, whether the target version is generated before a preset version corresponding to the preset version number. 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 was 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, the current version is rolled back 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 roll 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 specific version rollback method may refer to step S102, which is not described herein.
In an alternative embodiment, the electronic device rolls back the current version to the preset version when the generation time of the version number of the target version is earlier than the generation time of the preset version number, i.e. it is determined that the target version is not generated after 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 number, that is, the target version is generated before the preset version. The electronic device may roll back the current version to a version that is previous to the current version. In addition, the electronic device may send a prompt message to the user, for example, to display in a display screen of the electronic device that the user has rolled back to the preset version, thereby prompting the user that the user cannot roll back to the target version.
By adopting the method shown in fig. 2, by setting the preset version, that is, setting the earliest version number which can be used for version rollback, each version before the preset version is irreversible, and the stability of the stored data 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. Fig. 3 is a schematic diagram of a third flow chart 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, the current version is rolled back to the target version according to the reverse operation record corresponding to each version, and 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 steps S301 to S302 are the same as the steps S101 to S102.
In step S303, an adjustment request for a preset version number is received, where the adjustment request includes a version number to be adjusted.
In an alternative embodiment, the user may send an adjustment request for a preset version number to the electronic device according to its own requirement, where the adjustment request includes the version number to be adjusted. The electronic device receives the adjustment request.
In another alternative embodiment, the electronic device may trigger the adjustment operation for the preset version number according to a preset adjustment rule. At this time, the electronic device receives 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 the preset update frequency threshold, the adjustment operation on the preset version number is automatically triggered. The preset adjustment rules are not particularly limited herein.
In the embodiment of the present invention, the execution sequence of the step S301 and the step S303 is not specifically limited.
Step S304, based on the adjustment request, the preset version number is adjusted to the version number to be adjusted.
In this step, after 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 timely adjust the preset version according to factors such as user requirements or application scenes, and the flexibility of the preset version is improved, so that 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. Fig. 4 is a schematic diagram of a fourth flow chart of a version rollback method according to an embodiment of the present invention, as shown in fig. 4. The method comprises the following steps.
In step S401, a version rollback request for a current version of the preset database is received, and each version of the preset database is determined according to each data update operation performed on the data stored in the preset database.
Step S402, based on the received version rollback request, the current version is rolled back to the target version according to the reverse operation record corresponding to each version, and 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 steps S401 to S402 are the same as the steps S101 to S102.
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 with respect to the data stored in the preset database. When the user performs data updating operation on the data stored in the preset database, the electronic device receives a data updating operation request aiming at the data stored in the preset database. Wherein the data operation request includes operation information indicating a data update operation.
In an alternative embodiment, the data updating operation may include an add operation, a delete operation and a modify operation to a preset database. The data update operations that may be employed for different types of databases also vary. For example, if the preset database is a key 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 invention, for different data updating operations, the data operation request includes different operation information indicating the data updating operation. For example, the data update operation is the above-mentioned adding operation, and the operation information may include information such as data to be added, and a storage address corresponding to the data to be added. For another example, the data update operation is the deletion 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 update operation is the modification operation, and the operation information may be information such as data before modification, the data storage address, and data after modification. Here, the operation information indicating the data update operation included in the data operation request is not particularly limited.
Step S404, based on the data updating operation request, updating the data stored in the preset database.
In this step, after receiving the data update operation request, the electronic device may update the data stored in the preset database according to the operation information indicating the 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 can store the data to be added to the storage address corresponding to the preset database according to the operation information, so as to finish the data updating operation of the preset database and 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 completing the data update operation on the data stored in the preset database, the electronic device may generate, according to the data update operation on the preset database at this time, the version number of the version corresponding to the updated preset database, and the reverse operation record corresponding to the data update operation at this time.
The reverse operation record records reverse operation information corresponding to a reverse operation of the data update operation. The above-described addition operation, deletion operation and modification operation are exemplified as the data update 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 update operation is the above-described deletion operation, if the data B at the position B of the preset database is deleted, the reverse operation record may be recorded with reverse operation information to add the data B to the position B of the preset database. When the data update operation is the above-described modification operation, for example, modifying the data C at the position C of the preset database by the data D, the reverse operation record may be recorded with reverse operation information modifying the data D at the position C of the preset database by the data C.
In the embodiment of the invention, the electronic equipment abstracts each data updating operation of the preset database into the change of the version state. The version number of each version of the preset database is merely a flag of the preset database after one data update operation. That is, the generation of each new version only indicates that one data update has occurred to the data in the pre-set database. In the process, the electronic equipment utilizes the change of the version of the preset database to indicate each data updating operation of the preset database, and data stored in the preset database before and after the data updating operation is not required to be recorded or stored, so that the data quantity of the stored data is effectively reduced, and the storage resources are saved.
After updating the data stored in the preset database by adopting the method shown in fig. 4, the electronic device can generate the version number of the corresponding version and the reverse operation record corresponding to the data updating operation, so that the version rollback is convenient to carry out in the later period.
In an alternative embodiment, in the foregoing embodiment, the data update operation is a single update operation of stored single data of the preset data. It is contemplated that the pre-set database may provide a batch write interface, i.e., the pre-set database may provide batch write functionality. At this time, the data update operation request may be a batch write operation request; the batch write operation request includes a plurality of data to be written.
In the step S405, the version number of the version corresponding to the updated preset database and the reverse operation record corresponding to the data updating operation may be specifically expressed as: and generating version numbers of corresponding versions of the preset databases after batch writing operation, and indicating batch deletion of reverse operation records of a plurality of data to be written.
Specifically, due to the influence of factors such as network environment, when batch writing is performed, the time for writing each data to be written into the preset database may be the same or different. In the embodiment of the invention, the electronic device may consider the adding operation of batch writing of the plurality of data to be written into the preset database as a data updating operation, so that the plurality of data to be written into the preset database is written into the preset database, and according to the version number of the corresponding version of the preset database after the batch writing operation is generated, and the batch deleting operation record opposite to the batch writing operation, namely the reverse operation record indicating batch deleting of the plurality of data to be written.
In the embodiment of the invention, the electronic equipment regards 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 into the version of the preset database before the batch write operation when the version is rolled back in the later stage.
In an optional embodiment, for the batch writing operation, the electronic device may further determine whether to generate a version number corresponding to a version of each data to be written after being written into the preset database and a corresponding reverse operation record according to factors such as a user requirement and an application scenario.
In an alternative embodiment, when the current version is a version obtained after performing a batch write operation on the target version, the step S402 of rolling back the current version to the target version based on the received version rollback request according to the reverse operation record corresponding to each version may be specifically expressed as: based on the received version rollback request, according to the reverse operation record corresponding to the current version, that is, the reverse operation record indicating to delete the plurality of data to be written in batches, the written plurality of data to be written in batches are deleted 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.
According to the embodiment of the invention, the reverse operation records of the data to be written are deleted in batches according to the indication, the electronic equipment can directly roll back the current version to the version corresponding to the preset database before the batch writing operation, the data written in batches in the preset database do not need to be rolled back one by one, the rollback efficiency of the version of the preset database is improved, and therefore the rollback efficiency of the data stored in the preset database is improved.
Based on the same inventive concept, the embodiment of the invention also provides a version rollback device according to the version rollback method provided by the embodiment of the invention. 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;
the rollback module 502 is 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 the data update operation corresponding to the 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 a plurality of reverse operation records between the current version and the target version based on the target version number included in the version rollback request; and rolling back the current version to the target version according to a plurality of reverse operation records.
Optionally, the version rollback device 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 rollback the current version to the target version based on the received version rollback request according to the reverse operation record corresponding to each version when the determination result of the determination module is no.
Optionally, the version rollback device may further include:
the second receiving module is used for receiving an adjustment request aiming at a preset version number, wherein the adjustment request comprises a version number to be adjusted;
and the adjusting module is used for adjusting the preset version number to be the version number to be adjusted based on the adjusting request.
Optionally, the version rollback device may further include:
a third receiving module, configured to receive a data update operation request for 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;
the generation 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 includes a plurality of data to be written;
the generating module may be specifically configured to generate version numbers of versions corresponding to the preset databases after the batch write operation, and instruct batch deletion of reverse operation records of the plurality of data to be written.
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, delete, in batch, the written plurality of data to be written from a preset database corresponding to the current version based on the received version rollback request according to a reverse operation record corresponding to the current version.
According to 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 of the data stored in the preset database, when the data in the preset database is required to be rolled back, the version rolling 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 rolling back of the version of the preset database, and the reverse operation record is generated according to the data updating operation, so that the operation process is relatively simple when the data is rolled back, the cost of the data rolling back is effectively reduced, the data quantity of the reverse operation record is relatively small, and the dependence on the memory is small, so that the data rolling back mode can be suitable for different types of databases, and the universality of the data rolling back method is improved.
Based on the same inventive concept, according to the version rollback method provided by the above embodiment of the present invention, as shown in fig. 6, the embodiment of the present invention further provides an electronic device, which includes 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 communication with each other through the communication bus 604;
a memory 603 for storing a computer program;
the processor 601 is configured to execute the program stored in the memory 603, and implement the following steps:
receiving a version rollback request for a current version of a preset database, each version of the preset database being determined according to each data update operation performed on data stored in the preset database;
based on the received version rollback request, the current version is rolled back to the target version according to the reverse operation record corresponding to each version, and the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version.
According to 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 of the data stored in the preset database, when the data in the preset database needs to be rolled back, the version rolling 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 rolling back of the version of the preset database, and the reverse operation record is generated according to the data updating operation, so that the operation process is relatively simple when the data is rolled back, the cost of the data rolling back is effectively reduced, the data quantity of the reverse operation record is relatively small, and the dependence on the memory is small, so that the data rolling back mode can be suitable for different types of databases, and the universality of the data rolling back method is improved.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include 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 aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
Based on the same inventive concept, according to the version rollback method provided by the embodiment of the present invention, the embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the version rollback methods are implemented.
Based on the same inventive concept, according to the version rollback method provided by the above embodiment of the present invention, the embodiment of the present invention further provides a computer program product containing instructions, which when run on a computer, cause the computer to perform any one of the version rollback methods of the above embodiment.
In the above embodiments, it may be implemented in whole or in part 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, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more 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)), etc.
It is noted that relational terms such as first and second, and the like are 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. Moreover, 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 one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for embodiments of the apparatus, electronic device, computer readable storage medium, and computer program product, which are substantially similar to method embodiments, the description is relatively simple, and reference is made to the section of the method embodiments for relevance.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (10)

1. A version rollback method, the method comprising:
receiving a version rollback request for a current version of a preset database, each version of the preset database being determined according to each data update operation performed on data stored in the preset database;
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;
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 the last version of the version;
receiving a data update operation request for data stored in the preset database;
updating the data stored in the preset database based on the data updating operation request;
Generating a version number of a version corresponding to the updated preset database and a reverse operation record corresponding to the data updating operation;
receiving an adjustment request for the preset version number, wherein the adjustment request comprises a version number to be adjusted;
based on the adjustment request, adjusting the preset version number to the version number to be adjusted;
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 rollback request comprises the following steps:
and if the generation time of the preset version number 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 rollback request.
2. The method of claim 1, wherein the version rollback request includes a target version number of a target version;
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 rollback request 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 reverse operation records.
3. The method of claim 1, wherein 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 the version number of the version corresponding to the updated preset database and the reverse operation record corresponding to the data updating operation comprises the following steps:
and generating version numbers of corresponding versions of the preset databases after the batch write operation, and indicating to delete the reverse operation records of the plurality of data to be written in batches.
4. The method of claim 3, wherein the step of rolling back the current version to the target version based on the received version rollback request according to the reverse operation record corresponding to each version comprises:
and if the current version is a version obtained after batch writing operation is performed on the target version, based on the received version rollback request, deleting the written plurality of data to be written in batches from a preset database corresponding to the current version according to the reverse operation record corresponding to the current version.
5. A version rollback apparatus, the apparatus comprising:
the first receiving module is used for receiving a version rollback request aiming at the current version of a preset database, and each version of the preset database is determined according to each data updating operation on data stored in the preset database;
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 is used for 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, and the reverse operation record corresponding to each version is generated according to the data updating operation corresponding to the last version of the version;
a third receiving module, configured to receive a data update operation request for 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;
the generation module is used for generating a version number of a version corresponding to the updated preset database and a reverse operation record corresponding to the data updating operation;
The second receiving module is used for receiving an adjustment request aiming at the preset version number, wherein the adjustment request comprises a version number to be adjusted;
the adjusting module is used for adjusting the preset version number to the version number to be adjusted based on the adjusting request;
the rollback module is specifically configured to rollback the current version to a target version based on the received version rollback request according to a reverse operation record corresponding to each version when the judgment result of the judgment module is negative.
6. The apparatus of claim 5, wherein the version rollback request includes a target version number of a target version;
the rollback module is specifically configured to determine 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 reverse operation records.
7. The apparatus of claim 5, wherein 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 generation module is specifically configured to generate version numbers of versions corresponding to the preset databases after the batch write operation, and instruct batch deletion of reverse operation records of the plurality of data to be written.
8. The apparatus of claim 7, wherein the rollback module is 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 plurality of data to be written in batch from a preset database corresponding to the current version according to a reverse operation record corresponding to the current version.
9. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for carrying out the method steps of any one of claims 1-4 when executing a program stored on a memory.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-4.
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 CN111159160A (en) 2020-05-15
CN111159160B true 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)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111625262B (en) * 2020-05-28 2023-08-22 广东浪潮大数据研究有限公司 Rollback method, system, equipment and storage medium of workload resource
CN112306995B (en) * 2020-11-11 2023-06-27 北京奥星贝斯科技有限公司 Method and device for realizing database operation
CN113034254A (en) * 2021-03-19 2021-06-25 北京字跳网络技术有限公司 Data processing method and device and electronic equipment

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

Also Published As

Publication number Publication date
CN111159160A (en) 2020-05-15

Similar Documents

Publication Publication Date Title
CN111159160B (en) Version rollback method and device, electronic equipment and storage medium
US9836346B2 (en) Error troubleshooting using a correlated knowledge base
CN110113393B (en) Message pushing method and device, electronic equipment and medium
CN106031127B (en) Method and apparatus for management of applications
CN111427859B (en) Message processing method and device, electronic equipment and storage medium
CN110018884B (en) Distributed transaction processing method, coordination device, database and electronic equipment
WO2019100853A1 (en) Page query method, device, and electronic apparatus
CN111506580B (en) Transaction storage method based on centralized block chain type account book
TW202008162A (en) Data monitoring method and device, electronic device, and computer readable storage medium
CN111125240B (en) Distributed transaction realization method and device, electronic equipment and storage medium
CN107577775B (en) Data reading method and device, electronic equipment and readable storage medium
WO2020029588A1 (en) Data reading method, device, system, and distributed system
CN114020193A (en) Cross-page checking determination method and device, electronic equipment and storage medium
CN111078418B (en) Operation synchronization method, device, electronic equipment and computer readable storage medium
CN110727895B (en) Sensitive word sending method and device, electronic equipment and storage medium
CN112558872A (en) Data processing method and device, storage medium and electronic equipment
US20100287331A1 (en) Electronic device and method for recording power-on time thereof
WO2020207008A1 (en) Data verification method, apparatus, electronic device and storage medium
CN108984124B (en) Method and device for reducing write amplification, computer equipment and storage medium
CN115858668A (en) Distributed transaction processing method, device, electronic device and storage medium
CN114185804A (en) Interface testing method and device and terminal equipment
CN111666020B (en) Method and device for switching document pages, electronic equipment and storage medium
CN113986921A (en) Blacklist query method, system, electronic equipment and storage medium
CN113282619A (en) Data rapid query method and system
CN111552548A (en) Task processing method and device, electronic equipment and machine-readable 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