CN112306995A - Method and device for realizing database operation - Google Patents

Method and device for realizing database operation Download PDF

Info

Publication number
CN112306995A
CN112306995A CN202011253440.XA CN202011253440A CN112306995A CN 112306995 A CN112306995 A CN 112306995A CN 202011253440 A CN202011253440 A CN 202011253440A CN 112306995 A CN112306995 A CN 112306995A
Authority
CN
China
Prior art keywords
database
version number
version
current
rollback
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
CN202011253440.XA
Other languages
Chinese (zh)
Other versions
CN112306995B (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.)
Beijing Oceanbase Technology Co Ltd
Original Assignee
Alipay Hangzhou Information Technology Co 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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN202011253440.XA priority Critical patent/CN112306995B/en
Publication of CN112306995A publication Critical patent/CN112306995A/en
Application granted granted Critical
Publication of CN112306995B publication Critical patent/CN112306995B/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2474Sequence data queries, e.g. querying versioned data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Probability & Statistics with Applications (AREA)
  • Fuzzy Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present specification provides a method and an apparatus for implementing database operations, wherein after receiving a rollback instruction, a rollback message is generated for a current database version without performing a rollback write operation on a database, and the rollback message is associated with a current database version number; the rollback information at least comprises: rolling back the version number of the target version; the method comprises the following steps: after receiving a database operation request, determining an initial version number corresponding to the operation request; and determining the initial version number as an alternative target version number, and circularly executing the following operations until a formal target version number is determined: judging whether the current alternative target version number is associated with rollback information or not; if so, determining a rollback target version number in the rollback information as an alternative target version number; if not, determining the current alternative target version number as a formal target version number; and after the formal target version number is determined, executing a database operation request aiming at the database version corresponding to the formal target version number.

Description

Method and device for realizing database operation
Technical Field
The present disclosure relates to the field of database technologies, and in particular, to a method and an apparatus for implementing database operations.
Background
When the database is in error, the database needs to be backed from the current version to a correct historical target version so as to be able to continue to use the database to process the service.
The database records data of each version so as to be convenient for follow-up handling of historical data query business, and meanwhile, the database also stores modification operation records so as to back up the database. At present, when a database is rolled back, the following method is generally adopted: when the database has errors, the database administrator can determine the correct target database version and send a rollback instruction to the database to indicate the database to rollback to the correct target database version, after the rollback instruction is received by the database, a modification operation record stored in the database can be called, the modification operation between the correct version and the current version in the record is obtained and converted into reverse modification operation, the data in the current database is modified by using the reverse modification operation, and then the data in the current database is rolled back to the correct target version.
By adopting the scheme, in the data rollback process, the modification operation records need to be acquired, the modification operation needs to be modified into the reverse modification operation, and the reverse modification operation needs to be sequentially executed, namely, the database needs to execute the rollback write-in operation, so that the whole process is complicated, the consumed time is long, the database can continue to process the service after the rollback is completed, and the database is consistently in a service processing interruption state before the rollback is completed, so that the service processing capacity of the database can be influenced by the current rollback mode.
Disclosure of Invention
In view of the above technical problems, the present specification provides a method and an apparatus for implementing database operations, and the technical scheme is as follows:
according to a first aspect of the present description, there is provided a method for implementing database operations, where after receiving a rollback instruction, a rollback message is generated for a current database version without performing a rollback write operation on a database, and the rollback message is associated with a current database version number; the rollback information at least comprises: rolling back the version number of the target version; the method comprises the following steps:
after receiving a database operation request, determining an initial version number corresponding to the operation request; and determining the initial version number as an alternative target version number, and circularly executing the following operations until a formal target version number is determined:
judging whether the current alternative target version number is associated with rollback information or not;
if so, determining a rollback target version number in the rollback information as an alternative target version number;
if not, determining the current alternative target version number as a formal target version number;
and after the formal target version number is determined, the database operation request is executed according to the database version corresponding to the formal target version number.
According to a second aspect of the present specification, there is provided an apparatus for implementing database operations, wherein after receiving a rollback instruction, in a case where a rollback write operation is not performed on a database, a piece of rollback information is generated for a current database version, and the rollback information is associated with a version number of the current database; the rollback information at least comprises: rolling back the version number of the target version; the device comprises:
the operation request receiving module is used for determining an initial version number corresponding to the operation request after receiving the database operation request;
a formal version determining module, configured to determine the initial version number as an alternative target version number, and perform the following operations in a loop until a formal target version number is determined:
judging whether the current alternative target version number is associated with rollback information or not;
if so, determining a rollback target version number in the rollback information as an alternative target version number;
if not, determining the current alternative target version number as a formal target version number;
and the operation request execution module is used for executing the database operation request aiming at the database version corresponding to the formal target version number after the formal target version number is determined.
By adopting the scheme of the specification, after the database receives the backspacing instruction, the database does not execute backspacing writing operation, but generates backspacing information for each backspacing instruction, associates the backspacing information with the current version, continues to process the business after the association is completed, determines a formal database version for executing operation according to the backspacing information in subsequent business processing, and further executes corresponding operation for the determined formal database version. Because the database can be operated based on the rollback information without executing the rollback writing operation, the time consumption of the rollback process is greatly shortened, and the interruption of the database service processing can be avoided as much as possible, namely the influence on the service processing capacity of the database is avoided as much as possible.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the specification.
Drawings
In order to more clearly illustrate the embodiments of the present specification or the technical solutions in the prior art, the drawings needed to be 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 described in the embodiments of the present specification, and other drawings can be obtained by those skilled in the art according to the drawings.
Fig. 1 is a schematic diagram of database version association rollback information according to an embodiment of the present specification;
FIG. 2 is a flow chart illustrating a method for implementing database operations according to an embodiment of the present disclosure;
FIG. 3 is a diagram illustrating another example of database version association fallback information in accordance with an embodiment of the present description;
FIG. 4 is a diagram illustrating further database version association rollback information, according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of an apparatus for implementing database operations according to an embodiment of the present disclosure;
FIG. 6 is a block diagram of an apparatus for implementing another database operation according to an embodiment of the present disclosure;
fig. 7 is a schematic structural diagram of an apparatus for configuring a device according to an embodiment of the present disclosure.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the embodiments of the present specification, the technical solutions in the embodiments of the present specification will be described in detail below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all the embodiments. All other embodiments that can be derived by one of ordinary skill in the art from the embodiments given herein are intended to be within the scope of protection.
The terminology used in the description herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the description. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the present specification. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
When the database is in error, the database needs to be backed from the current version to a correct historical target version so as to be able to continue to use the database to process the service.
The database records data of each version so as to be convenient for follow-up handling of historical data query business, and meanwhile, the database also stores modification operation records so as to back up the database. At present, when a database is rolled back, the following method is generally adopted: when the database has errors, the database administrator can determine the correct target database version, send a rollback instruction to the database and indicate the database to rollback to the correct target database version, after the rollback instruction is received by the database, call a modification operation record stored in the database, obtain the modification operation between the correct version and the current version in the record, convert the modification operation into reverse modification operation, modify the data in the current database by using the reverse modification operation, and then rollback the data in the current database to the correct target version.
For example, the version number of the current database version is 100, the administrator wants to rollback the database from the version with the current version number of 100 to the version with the version number of 50, after receiving the rollback instruction of the administrator, the database needs to call the modification operation record stored in the database, obtain the modification operation between the version 50 and the version 100 in the record, convert all the obtained operations into reverse operations, modify the data of the version 100 by using the reverse modification operation, and then rollback the data in the current database to the version 50. It can be seen that, in the data rollback process, modification operation records need to be acquired, and reverse modification operations need to be sequentially executed, that is, a database needs to execute rollback write-in operations, which is tedious in the overall process and long in consumed time.
In view of the above technical problems, the present specification provides the following solutions:
after receiving the backspacing instruction, the database does not execute backspacing writing operation on the database, generates backspacing information for each backspacing instruction, associates the backspacing information with the current version, continues to process the service after the association is completed, determines a formal database version for executing operation according to the backspacing information in subsequent service processing, and further executes corresponding operation aiming at the determined formal database version. Therefore, the time consumption of the rollback process is greatly shortened, the interruption of database service processing is avoided, and the influence on the database service processing is reduced.
Based on the above description, a method for processing a rollback instruction proposed in the present specification is first described:
in the solution provided in this specification, after receiving a rollback instruction sent by a database administrator, the database does not execute a rollback write operation, that is, does not acquire a modification operation record between a rollback target version and a current version and does not execute a reverse modification operation.
After receiving the rollback instruction, generating rollback information aiming at the current database version, and associating the rollback information with the version number of the current database; the rollback information includes at least a version number of the rollback target version.
For example, if the current version number is 100, the database administrator needs to rollback the database version to a version with a version number of 50, i.e., send a rollback instruction to the database for rolling back the current database version to a version with a version number of 50. After receiving the rollback instruction, the database does not execute rollback write operation, but generates a piece of rollback information for the current database version, that is, generates a piece of rollback information for the version with the current version number of 100, where the rollback information is used to describe that the current version is rolled back to the version number of 50, and associates the generated rollback information with the version number of the current database. As shown in fig. 1, a schematic diagram of associating rollback information with a current version, that is, a version with a version number of 100, where "50" is used to represent the rollback information, and the rollback information is used to describe that the current version, that is, the version with the version number of 100, is rolled back to a target rollback version, that is, the version with the version number of 50, and a specific form of the rollback information may be to identify a corresponding relationship between the current version number 100 and the version number 50; also, because the fallback information is associated with the current version number, only the version number of the fallback target version, i.e. version number 50, may be identified in the description information. The present specification does not limit the specific form of the fallback information.
After the association is complete, a rollback complete message may be returned to the database administrator so that the database administrator may allow the database to continue processing the business.
Therefore, in the process, after the database receives the rollback instruction, only the rollback information needs to be generated and associated with the version number of the current database, and the time consumption of the whole process is short.
Based on the above description, as shown in fig. 2, the present specification provides an implementation method of database operations, as follows:
s201, after receiving a database operation request, determining an initial version number corresponding to the operation request; determining the initial version number as an alternative target version number;
the operation request of the database may be mainly divided into a write operation request and a read operation request, where the read operation request may be a read operation performed on a historical version of the database or a read operation performed on a current version of the database. And the write operation request can only be a write operation performed on the current version of the database. Regardless of whether the operation is a read operation or a write operation, the operation request sent to the database contains an initial version number, i.e., a version number corresponding to the version that the data operator desires to read or write. For a write operation request, the initial version number is the current version number of the database.
After the database obtains the initial version number, the initial version number may be used as a candidate target version number, and subsequent operations may be performed. In connection with fig. 1, it is determined, for example, that the initial version number for which the operation request is directed is 100.
S202, judging whether the current alternative target version number is associated with rollback information or not;
in this step, different steps may be executed according to the determination result, and when it is determined that the current candidate target version number is not associated with the fallback information, S203 may be executed, and when it is determined that the current candidate target version number is associated with the fallback information, S204 may be executed.
Referring to fig. 1, for example, if the initial version number 100 is determined to be the alternative target version number, it may be determined whether the version number 100 is associated with fallback information by querying, as shown in fig. 1, where the version number 100 is associated with fallback information.
Referring to fig. 3, for example, if the initial version number 100 is determined to be the alternative target version number, it may be determined whether the version number 100 is associated with fallback information by querying, as shown in fig. 3, the version number 100 is not associated with fallback information.
S203, determining the current alternative target version number as the formal target version number
In this step, when the current candidate target version number is not associated with the rollback information, it may be directly determined as the formal target version number. In conjunction with the above example of fig. 3, if the current alternative target version number is 100, the version number 100 may be directly determined as the formal target version number.
S204, determining a rollback target version number in the rollback information as an alternative target version number;
in this step, when the current candidate target version number is associated with the fallback information, the fallback information may be further queried, and the fallback target version number in the fallback information may be determined as the new candidate target version number. With reference to fig. 1, when the current candidate target version number 100 is determined to be associated with the fallback information, it may further determine, by querying, that the fallback target version number in the fallback information is 50, replace the version number 100 with the version number 50, and determine that the current candidate target version number is the current candidate target version number, then continue to execute step S202 with the version number 50, and as can be seen from fig. 1, if the version number 50 is not associated with the fallback information, then execute S203 to determine that the version number 50 is the formal target version number.
After the formal target version number is determined, S205 may be performed.
And S205, after the formal target version number is determined, the database operation request is executed according to the database version corresponding to the formal target version number.
After the formal target version number is determined, the received operation request may be executed for the database version corresponding to the determined formal version number, and as described above, the operation request may be a read operation request or a write operation request. The manner in which operations are performed for different operation requests may be as described below and will not be described in detail herein.
Based on the scheme, after the database receives the rollback instruction, the database does not execute rollback writing operation, generates rollback information for each rollback instruction, associates the rollback information with the current version, can continue to process the business after the association is completed, can determine a formal database version for executing the operation according to the rollback information in subsequent business processing, and further executes corresponding operation for the determined formal database version. Because the database can be operated based on the rollback information without executing the rollback writing operation, the time consumption of the rollback process is greatly shortened, and the interruption of the database service processing can be avoided as much as possible, namely the influence on the service processing capacity of the database is avoided as much as possible.
In S205, a manner of executing the database operation request for the database version corresponding to the determined formal target version number is described as follows:
as can be seen from the above description in S201, the operation request of the database is mainly divided into a write operation request and a read operation request, where the read operation request may be a read operation performed on the historical version of the database or a read operation performed on the current version of the database.
First, when the operation request is a read operation request, the specific execution method in S205 is described as follows:
when the operation request is a read request for any database version, after the formal target version number is determined, the database version corresponding to the determined formal target version number can be read.
For example, when the formal target version determined in S203 is the current database version, the current database version may be directly read.
If the formal target version determined in S203 is a certain historical data version, the database version corresponding to the formal target version may be read from the history record in which the historical version is stored.
After the execution mode for the read operation request is introduced, when the operation request is a write operation request, a specific execution mode in S205 is described as follows:
when the operation request is a write operation request for a current database version, if the formal target version determined in S203 is the current database version number, directly writing the current database version according to the write request; for example, operations such as adding and deleting are directly performed on the current data of the database.
In conjunction with fig. 3, the current database version is 100 and has no associated rollback information. After the above processing, it may be determined that the formal target version is the current version number 100 of the database, and the current version of the database may be directly written according to the write operation request.
And if the formal target version number determined in the step S203 is not the current database version number, reading the database version corresponding to the formal target version number from the history record, updating the read version according to the write request, and replacing the current database version with the updated version.
With reference to fig. 1, if the determined final version number is 50 and is not the current database version number 100, the version corresponding to the version number 50 may be read into the memory from the storage location of the historical version, the version corresponding to the read version number 50 is updated according to the write request, after the update is completed, the updated version replaces the current database version, that is, the data corresponding to the current database version is globally replaced with the updated database version, and the version number of the updated version is recorded as the new version 101.
In order to facilitate the administrator to check each version of data or to rollback the current version to a certain historical version, the administrator needs to actively or passively generate the new version and record the corresponding relationship between the new version and the data in the database.
When the operation request is a write operation request, the current data stored in the database can be updated, so that after the database is written according to the database write operation, the current data in the database can be marked as a new version, and the new version is not associated with rollback information. With reference to the newly generated version 101 in the above example, since the new version does not have a rollback relationship with a certain version, rollback information is not associated with the new version.
In addition to generating the new version because of the write operation, the new version may be generated in other ways. For example, the current data in the database may be marked as the new version when the current version data in the database is not updated and a preset version generation condition is met.
For example, one version generation condition may be that, after the database performs data backup according to a manual backup operation of a database administrator, the version manually backed up by the database administrator needs to be marked as a new version even if the data of the current version in the database is not updated.
Another version generation condition may be that, when a preset version generation period is reached, the current data in the database is recorded as a new version, and the database will regularly backup the data in the database, and it can be understood that after each backup, even if there is no data update, the data is recorded as a new version. For example, every 2 hours, a new version is generated after each backup.
In order to apply the solution proposed in the present specification to the new version generated without updating the data in the database, the following processing method is proposed:
and recording the current data in the database as a new version under the condition that the current version data in the database is not updated and meets the preset version generation condition, and associating the rollback information associated with the current version number to the new version number.
As described above, the preset version generation condition may be that a version generation period is reached, a manual backup request of an administrator is received, and the like, and after the new version is generated, the rollback information of the current version of the database may be associated with the new version of the database, that is, in a case where data between the new version and the old version is unchanged, the new version is allowed to inherit the rollback information of the old version, and from this point of view, the new version and the old version are required to be kept "completely consistent".
Referring to fig. 1, if the current version number is 100, after a preset period is reached, the data in the current database is marked as a new version, the version number is 101, and the data corresponding to the version number 101 is identical to the data corresponding to the version 100. The rollback information associated with version number 100 may be associated with version number 101 at this point. It is understood that, in this embodiment, although the rollback information is associated with the version number 101, it does not mean that the rollback information associated with the version number 100 is deleted, and the version number 100 is associated with the rollback information, and in this case, the version corresponding to the version number 100 and the rollback information associated with the version number 101 have the same meaning, and all versions are backed back to the version corresponding to the version number 50.
With reference to the above description, since the rollback information may be in the form of a "corresponding relationship between the current version number and the rollback target version number", or may only include the "rollback target version number", in this embodiment, when the new version needs to inherit the rollback information of the old version, if the rollback information is in the form of a corresponding relationship, the current version number in the rollback information is directly modified to the new version number when the new version inherit the rollback information. If the rollback information is in the form of only including the rollback target version number, the rollback information can be directly inherited without any modification. As shown in fig. 1, if the version generation cycle is reached and the new version 101 is generated, the version number 101 may be directly associated with the rollback information "50".
In order to more clearly illustrate the solution proposed in this specification, the following describes an implementation method of the database operation proposed in this specification by taking fig. 4 as an example:
the current version of the database is 100, and the version number 100 and the version number 50 are respectively associated with rollback information.
For example, after receiving a database write request, the database determines that the initial version number is 100, determines that the initial version number 100 is an alternative target version number, and determines whether the current alternative target version number 100 is associated with rollback information; determining that the version number of the current alternative target is associated with rollback information through inquiry, and determining that the rollback target version number in the rollback information associated with the version number of the current alternative target 100 is 50, replacing 100 with the version number 50 as the version number of the current alternative target;
judging whether the current alternative target version number 50 is associated with rollback information or not; determining that the current alternative target version number 50 is associated with rollback information through inquiry, and determining that the rollback target version number in the rollback information associated with the current alternative target version number 50 is 30, replacing 50 with the version number 30 as the current alternative target version number;
judging whether the current alternative target version number 30 is associated with rollback information or not; and determining that the current alternative target version number 30 is not associated with rollback information through inquiry, determining that the current alternative target version number 30 is a formal target version number, further reading data corresponding to the version number 30 from the history record into a memory, updating the read data according to the received data writing operation request, replacing the currently stored data version of the database by using the updated result, and recording the replaced result as a new version 101, wherein the new version 101 is not associated with the rollback information. Subsequently, if a write operation for version 101 is received, the current version data of the database may be directly written.
Referring to fig. 5, corresponding to the foregoing method for implementing database operations, the present specification further provides an apparatus for implementing database operations, where after receiving a rollback instruction, a rollback message is generated for a current database version without performing a rollback write operation on the database, and the rollback message is associated with a current database version number; the rollback information at least comprises: rolling back the version number of the target version; the device comprises:
an operation request receiving module 510, configured to determine, after receiving a database operation request, an initial version number to which the operation request is directed;
a formal version determining module 520, configured to determine the initial version number as an alternative target version number, and perform the following operations in a loop until a formal target version number is determined:
judging whether the current alternative target version number is associated with rollback information or not;
if so, determining a rollback target version number in the rollback information as an alternative target version number;
if not, determining the current alternative target version number as a formal target version number;
an operation request executing module 530, configured to, after determining the formal target version number, execute the database operation request according to the database version corresponding to the formal target version number.
In an embodiment, the operation request is a read request for any database version, and the operation request executing module 530 is specifically configured to read, according to the database read request, the database version corresponding to the determined formal target version number.
In an embodiment, the operation request is a write request for a current database version, and the operation request executing module 530 is specifically configured to, when the determined formal target version number is the current database version number, write the current database version according to the write request;
and under the condition that the determined formal target version number is not the current version number of the database, reading the database version corresponding to the determined formal target version number, updating the read version according to the write request, and replacing the current version of the database by using the updated version.
As shown in fig. 6, in one embodiment, the apparatus further comprises: the version generation module 540 is configured to mark the current data in the database as a new version and associate the rollback information associated with the current version number to the new version number when the current version data in the database is not updated and a preset version generation condition is met.
In an embodiment, the version generation module 540 is further configured to, after the database is written according to the database writing operation, mark the current data in the database as a new version, and not associate the new version number with the rollback information.
The implementation processes of the functions and actions of the components in the above device are specifically described in the implementation processes of the corresponding steps in the above method, and are not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described apparatus embodiments are merely illustrative. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution in the specification. One of ordinary skill in the art can understand and implement it without inventive effort.
Embodiments of the present specification also provide a computer device, which at least includes a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the aforementioned method when executing the program. The method at least comprises an implementation method of the database operation as shown in fig. 2.
Fig. 7 is a more specific hardware structure diagram of a computing device provided in an embodiment of the present specification, where the device may include: a processor 1010, a memory 1020, an input/output interface 1030, a communication interface 1040, and a bus 1050. Wherein the processor 1010, memory 1020, input/output interface 1030, and communication interface 1040 are communicatively coupled to each other within the device via bus 1050.
The processor 1010 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more Integrated circuits, and is configured to execute related programs to implement the technical solutions provided in the embodiments of the present disclosure.
The Memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, or the like. The memory 1020 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present specification is implemented by software or firmware, the relevant program codes are stored in the memory 1020 and called to be executed by the processor 1010.
The input/output interface 1030 is used for connecting an input/output module to input and output information. The i/o module may be configured as a component in a device (not shown) or may be external to the device to provide a corresponding function. The input devices may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output devices may include a display, a speaker, a vibrator, an indicator light, etc.
The communication interface 1040 is used for connecting a communication module (not shown in the drawings) to implement communication interaction between the present apparatus and other apparatuses. The communication module can realize communication in a wired mode (such as USB, network cable and the like) and also can realize communication in a wireless mode (such as mobile network, WIFI, Bluetooth and the like).
Bus 1050 includes a path that transfers information between various components of the device, such as processor 1010, memory 1020, input/output interface 1030, and communication interface 1040.
It should be noted that although the above-mentioned device only shows the processor 1010, the memory 1020, the input/output interface 1030, the communication interface 1040 and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, those skilled in the art will appreciate that the above-described apparatus may also include only those components necessary to implement the embodiments of the present description, and not necessarily all of the components shown in the figures.
Embodiments of the present specification also provide a computer-readable storage medium on which a computer program is stored, which when executed by a processor implements the foregoing method. The method at least comprises an implementation method of the database operation as shown in fig. 2.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
From the above description of the embodiments, it is clear to those skilled in the art that the embodiments of the present disclosure can be implemented by software plus necessary general hardware platform. Based on such understanding, the technical solutions of the embodiments of the present specification may be essentially or partially implemented in the form of a software product, which may be stored in a storage medium, such as a ROM/RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments of the present specification.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the apparatus embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to some descriptions of the method embodiment for relevant points. The above-described apparatus embodiments are merely illustrative, and the modules described as separate components may or may not be physically separate, and the functions of the modules may be implemented in one or more software and/or hardware when implementing the embodiments of the present disclosure. And part or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The foregoing is only a specific embodiment of the embodiments of the present disclosure, and it should be noted that, for those skilled in the art, a plurality of modifications and decorations can be made without departing from the principle of the embodiments of the present disclosure, and these modifications and decorations should also be regarded as the protection scope of the embodiments of the present disclosure.

Claims (11)

1. After receiving a rollback instruction, generating rollback information aiming at a current database version under the condition of not executing rollback writing operation on a database, and associating the rollback information with the version number of the current database; the rollback information at least comprises: rolling back the version number of the target version; the method comprises the following steps:
after receiving a database operation request, determining an initial version number corresponding to the operation request; and determining the initial version number as an alternative target version number, and circularly executing the following operations until a formal target version number is determined:
judging whether the current alternative target version number is associated with rollback information or not;
if so, determining a rollback target version number in the rollback information as an alternative target version number;
if not, determining the current alternative target version number as a formal target version number;
and after the formal target version number is determined, the database operation request is executed according to the database version corresponding to the formal target version number.
2. The method according to claim 1, wherein the operation request is a read request for any database version, and the executing the database operation request for the database version corresponding to the formal target version number includes:
and reading the database version corresponding to the determined formal target version number according to the database reading request.
3. The method of claim 1, wherein the operation request is a write request for a current database version, and the executing the database operation request for the database version corresponding to the formal target version number includes:
if the determined formal target version number is the current version number of the database, writing the current version of the database according to the writing request;
and if the determined formal target version number is not the current version number of the database, reading the database version corresponding to the determined formal target version number, updating the read version according to the write request, and replacing the current version of the database with the updated version.
4. The method of claim 1, further comprising:
and recording the current data in the database as a new version under the condition that the current version data in the database is not updated and meets the preset version generation condition, and associating the rollback information associated with the current version number to the new version number.
5. The method of claim 4, further comprising:
and after the database is written according to the database writing operation, recording the current data in the database as a new version, and not associating the rollback information with the new version number.
6. After receiving a rollback instruction, generating rollback information aiming at a current database version under the condition of not executing rollback writing operation on a database, and associating the rollback information with the version number of the current database; the rollback information at least comprises: rolling back the version number of the target version; the device comprises:
the operation request receiving module is used for determining an initial version number corresponding to the operation request after receiving the database operation request;
a formal version determining module, configured to determine the initial version number as an alternative target version number, and perform the following operations in a loop until a formal target version number is determined:
judging whether the current alternative target version number is associated with rollback information or not;
if so, determining a rollback target version number in the rollback information as an alternative target version number;
if not, determining the current alternative target version number as a formal target version number;
and the operation request execution module is used for executing the database operation request aiming at the database version corresponding to the formal target version number after the formal target version number is determined.
7. The apparatus according to claim 6, wherein the operation request is a read request for any database version, and the operation request execution module is specifically configured to read, according to the database read request, a database version corresponding to the determined formal target version number.
8. The apparatus according to claim 6, wherein the operation request is a write request for a current database version, and the operation request execution module is specifically configured to write the current database version according to the write request when the determined formal target version number is the current database version number;
and under the condition that the determined formal target version number is not the current version number of the database, reading the database version corresponding to the determined formal target version number, updating the read version according to the write request, and replacing the current version of the database by using the updated version.
9. The apparatus of claim 6, the apparatus further comprising:
and the version generation module is used for recording the current data in the database as a new version and associating the rollback information associated with the current version number to the new version number under the condition that the current version data in the database is not updated and meets the preset version generation condition.
10. The apparatus of claim 9, wherein the first and second electrodes are disposed on opposite sides of the substrate,
and the version generation module is also used for recording the current data in the database as a new version after the database is written according to the database writing operation, and the rollback information is not associated with the new version number.
11. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the method of any one of claims 1 to 5 when executing the program.
CN202011253440.XA 2020-11-11 2020-11-11 Method and device for realizing database operation Active CN112306995B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011253440.XA CN112306995B (en) 2020-11-11 2020-11-11 Method and device for realizing database operation

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011253440.XA CN112306995B (en) 2020-11-11 2020-11-11 Method and device for realizing database operation

Publications (2)

Publication Number Publication Date
CN112306995A true CN112306995A (en) 2021-02-02
CN112306995B CN112306995B (en) 2023-06-27

Family

ID=74325757

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011253440.XA Active CN112306995B (en) 2020-11-11 2020-11-11 Method and device for realizing database operation

Country Status (1)

Country Link
CN (1) CN112306995B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033585A (en) * 2022-08-09 2022-09-09 北京奥星贝斯科技有限公司 Data merging processing method and device for target database

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106897306A (en) * 2015-12-21 2017-06-27 阿里巴巴集团控股有限公司 database operation method and device
CN109299194A (en) * 2018-09-25 2019-02-01 平安科技(深圳)有限公司 Multi-edition data memory management method and device, electronic equipment, storage medium
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium
CN110333880A (en) * 2018-03-29 2019-10-15 杭州海康威视数字技术股份有限公司 A kind of configuration update method, device, equipment and storage medium
US20200081697A1 (en) * 2018-09-06 2020-03-12 Arm Limited Methods for performing a rollback-capable software update at a device
CN111159160A (en) * 2019-12-31 2020-05-15 香港乐蜜有限公司 Version rollback method and device, electronic equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106897306A (en) * 2015-12-21 2017-06-27 阿里巴巴集团控股有限公司 database operation method and device
CN110333880A (en) * 2018-03-29 2019-10-15 杭州海康威视数字技术股份有限公司 A kind of configuration update method, device, equipment and storage medium
US20200081697A1 (en) * 2018-09-06 2020-03-12 Arm Limited Methods for performing a rollback-capable software update at a device
CN109299194A (en) * 2018-09-25 2019-02-01 平安科技(深圳)有限公司 Multi-edition data memory management method and device, electronic equipment, storage medium
CN110321254A (en) * 2019-07-09 2019-10-11 西安点告网络科技有限公司 Software version rollback method, device, server and storage medium
CN111159160A (en) * 2019-12-31 2020-05-15 香港乐蜜有限公司 Version rollback method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张伟燕,吴志杰,夏涛: "利用版本号保护数据库一致性的EJB设计模式", 信息与电子工程 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115033585A (en) * 2022-08-09 2022-09-09 北京奥星贝斯科技有限公司 Data merging processing method and device for target database
CN115033585B (en) * 2022-08-09 2022-11-15 北京奥星贝斯科技有限公司 Data merging processing method and device for target database

Also Published As

Publication number Publication date
CN112306995B (en) 2023-06-27

Similar Documents

Publication Publication Date Title
US11003438B2 (en) Method and device for incremental upgrade
CN111596863B (en) Data reading method, device and equipment and readable storage medium
CN109359118B (en) Data writing method and device
CN108932286B (en) Data query method and device
CN111158597A (en) Metadata reading method and device, electronic equipment and storage medium
CN108874441B (en) Board card configuration method, device, server and storage medium
CN110597552B (en) Configuration method, device, equipment and storage medium of project continuous integrated pipeline
CN111159160A (en) Version rollback method and device, electronic equipment and storage medium
CN111506580A (en) Transaction storage method based on centralized block chain type account book
CN111399857A (en) FRU data burning method, system, equipment and computer storage medium
CN112306995A (en) Method and device for realizing database operation
CN114461691A (en) Control method and device of state machine, electronic equipment and storage medium
CN114020193A (en) Cross-page checking determination method and device, electronic equipment and storage medium
US20120124429A1 (en) Apparatus and method for tracing memory access information
CN116126581B (en) Memory fault processing method, device, system, equipment and storage medium
CN111367710A (en) eMMC problem reduction method and device
CN115185458A (en) Data writing method and device, storage medium and computer equipment
CN115981617A (en) Code sentence recommendation method and device, electronic equipment and storage medium
CN115454570A (en) Disaster recovery method, virtual machine system, device, and storage medium
CN112784276B (en) Method and device for realizing trusted measurement
CN114443442A (en) Log storage method and electronic equipment
CN110046237B (en) Conversational interactive processing method and device
CN108712284B (en) Fault service positioning method and device and service server
CN113836154B (en) Database switching method and device
CN112948389A (en) MD 5-based database table data comparison method and equipment

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

Effective date of registration: 20210205

Address after: 801-10, Section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province 310000

Applicant after: Ant financial (Hangzhou) Network Technology Co.,Ltd.

Address before: 310000 801-11 section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province

Applicant before: Alipay (Hangzhou) Information Technology Co.,Ltd.

TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20210913

Address after: 100020 unit 02, 901, floor 9, unit 1, building 1, No.1, East Third Ring Middle Road, Chaoyang District, Beijing

Applicant after: Beijing Aoxing Beisi Technology Co.,Ltd.

Address before: 801-10, Section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province 310000

Applicant before: Ant financial (Hangzhou) Network Technology Co.,Ltd.

TA01 Transfer of patent application right
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40045469

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant