A data recovery method and device, and a storage medium

By generating a list of uncommitted transactions and undoing write operations of uncommitted transactions, the problem of low data recovery efficiency during database system failures is solved, achieving fast and efficient data recovery.

CN115374213BActive Publication Date: 2026-01-27CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110547867.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-05-19
Publication Date
2026-01-27
Estimated Expiration
2041-05-19

AI Technical Summary

Technical Problem

Existing database systems have low data recovery efficiency in the event of failure, making it difficult to quickly recover lost data.

Method used

Data recovery is achieved by generating a list of uncommitted transactions and utilizing the batch write dirty page log in non-volatile internal memory to identify and uncommitted write operations of uncommitted transactions.

Benefits of technology

It improves the efficiency of data recovery, enabling data in non-volatile external storage to be restored to the state before a write operation was performed, thus quickly recovering database data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115374213B_ABST
    Figure CN115374213B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a data recovery method and device, and a storage medium, the method comprising: when receiving a data recovery request, generating a list of undo transactions according to a batch write dirty page log stored in a nonvolatile internal storage; the batch write dirty page log is a log recorded when a write operation corresponding to a database transaction performed on a volatile internal storage is synchronized to a nonvolatile external storage when a data synchronization condition is met; in turn, judging whether the database transaction in the list of undo transactions is an uncommitted transaction; in the case where the database transaction is an uncommitted transaction, undoing the write operation on the nonvolatile external storage of the uncommitted transaction, so as to realize data recovery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of databases, and more particularly to a data recovery method, device, and storage medium. Background Technology

[0002] Database systems are a type of ideal data processing system developed to meet the needs of data processing. They are mainly used to store data. However, when a database system fails, previously stored data may be lost. Usually, after data loss, data recovery is achieved by first analyzing the data and then redoing it. However, this method of data recovery is inefficient. Summary of the Invention

[0003] This application provides a data recovery method, device, and storage medium that can quickly recover data when a database system fails, thereby improving data recovery efficiency.

[0004] The technical solution of this application is implemented as follows:

[0005] In a first aspect, embodiments of this application provide a data recovery method, the method comprising:

[0006] When a data recovery request is received, a list of undoable transactions is generated based on the batch dirty page write log stored in the non-volatile internal memory. The batch dirty page write log is the log recorded when the write operation corresponding to the database transaction is executed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization conditions are met.

[0007] The database transactions in the list of uncommitted transactions are sequentially determined to be uncommitted transactions. If a database transaction is an uncommitted transaction, the write operations on the uncommitted transaction on the non-volatile external memory are uncommitted to achieve data recovery.

[0008] In the above data recovery method, before generating a list of undoable transactions based on the batch dirty page log stored in non-volatile internal memory when a data recovery request is received, the method further includes:

[0009] A write operation corresponding to a database transaction is executed on the volatile internal memory, and the write operation and its inverse operation are recorded in a preset undo log of the non-volatile internal memory.

[0010] In the above data recovery method, the step of performing the write operation corresponding to the database transaction on the volatile internal memory includes:

[0011] Determine the data to be written corresponding to the write operation and the page to which the data to be written belongs;

[0012] If the data page to be written is found in the volatile memory, the write operation on the data page to be written is performed.

[0013] If the data page to be written is not found in the volatile internal memory but is found in the non-volatile external memory, the data page to be written is loaded from the non-volatile external memory into the volatile internal memory, and the write operation on the data page to be written is performed.

[0014] If the data page to be written is not found in the volatile internal memory and the non-volatile external memory, a new data page to be written is created in the volatile internal memory, and the write operation on the data to be written is performed in the data page to be written.

[0015] In the above data recovery method, the step of sequentially determining whether the database transactions in the uncommitted transaction list are uncommitted transactions includes:

[0016] Obtain the database operation sequence corresponding to the database transaction;

[0017] Determine the first position of the write operation in the database operation sequence;

[0018] Based on the first position, determine whether the database transaction is an uncommitted transaction;

[0019] Accordingly, when the database transaction is an uncommitted transaction, reversing the write operation on the uncommitted transaction includes:

[0020] If the first position is not at the end of the database operation sequence, the database transaction is determined to be an uncommitted transaction.

[0021] The write operation in the non-volatile external memory is undone based on the inverse operation.

[0022] In the above data recovery method, the step of undoing the write operation in the non-volatile external memory based on the inverse operation includes:

[0023] Obtain the list of inverse operations of the uncommitted transaction from the preset uncommit log;

[0024] The reverse operations in the reverse operation list are executed in reverse order to undo write operations in the non-volatile external memory; the reverse operations in the reverse operation list are arranged in the execution order.

[0025] In the above data recovery method, after sequentially determining whether the database transactions in the uncommitted transaction list are uncommitted transactions, the method further includes:

[0026] If the database transaction is not a commit transaction, it is determined that the database transaction has been completed, and the write operation and reverse operation corresponding to the database transaction are deleted from the preset undo log.

[0027] In the above data recovery method, the method further includes:

[0028] Upon receiving a database transaction commit instruction or upon the arrival of a preset time, it is determined that the data synchronization conditions are met.

[0029] Secondly, embodiments of this application provide a data recovery device, the device comprising:

[0030] The processing unit is used to generate a list of undoable transactions based on the batch dirty page log stored in the non-volatile internal memory when a data recovery request is received; the batch dirty page log is the log recorded when the write operation corresponding to the database transaction is performed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization conditions are met.

[0031] The undo unit is used to sequentially determine whether the database transactions in the undo transaction list are uncommitted transactions; if the database transaction is an uncommitted transaction, the write operation on the uncommitted transaction on the non-volatile external memory is undone to achieve data recovery.

[0032] Thirdly, embodiments of this application provide a data recovery device, characterized in that the device includes: a processor, a memory, and a communication bus; the processor executes a running program stored in the memory to implement the data recovery method as described in any of the above claims.

[0033] Fourthly, embodiments of this application provide a storage medium storing a computer program thereon, characterized in that the computer program, when executed by a processor, implements the data recovery method as described in any of the preceding claims.

[0034] This application provides a data recovery method, device, and storage medium. The data recovery method includes: upon receiving a data recovery request, generating a list of undoable transactions based on a batch dirty page log stored in non-volatile internal memory; when the batch dirty page log meets the data synchronization conditions, synchronizing the logs recorded when the write operations corresponding to the database transactions performed on the volatile internal memory are synchronized to the non-volatile external memory; sequentially determining whether the database transactions in the undoable transaction list are uncommitted transactions; if the database transactions are uncommitted transactions, undoing the write operations on the non-volatile external memory for the uncommitted transactions to achieve data recovery; by adopting the above implementation scheme, when it is determined that there are no uncommitted transactions in the undoable transaction list, the write operations in the non-volatile external memory are undoed, so that the data in the non-volatile external memory is restored to the data before the write operations were performed, thereby achieving the purpose of quickly recovering database data and improving data recovery efficiency. Attached Figure Description

[0035] Figure 1 A flowchart of a data recovery method provided in this application embodiment;

[0036] Figure 2 An exemplary write operation flowchart is provided for an embodiment of this application;

[0037] Figure 3 A schematic diagram of an exemplary database system architecture provided for embodiments of this application;

[0038] Figure 4 This is an exemplary write operation diagram provided for an embodiment of this application;

[0039] Figure 5 An exemplary read operation flowchart is provided for an embodiment of this application;

[0040] Figure 6 A schematic diagram of the composition structure of a data recovery device 1 provided in this application embodiment. Figure 1 ;

[0041] Figure 7 A schematic diagram of the composition structure of a data recovery device 1 provided in this application embodiment. Figure 2 . Detailed Implementation

[0042] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit the scope of this application.

[0043] Example 1

[0044] This application provides a data recovery method applied to a data recovery device. Figure 1A flowchart of a data recovery method provided in this application embodiment is shown below. Figure 1 As shown, data recovery methods may include:

[0045] S101. When a data recovery request is received, a list of undoable transactions is generated based on the batch dirty page write log stored in the non-volatile internal memory. When the batch dirty page write log meets the data synchronization conditions, the log recorded when the write operation corresponding to the database transaction is executed on the volatile internal memory is synchronized to the non-volatile external memory.

[0046] The data recovery method proposed in this application can be applied to scenarios involving the recovery of database data.

[0047] In this embodiment of the application, when the data recovery device receives a data recovery request, it generates a list of undoable transactions based on the batch dirty page write log stored in the non-volatile internal memory; when the batch dirty page write log meets the data synchronization conditions, it synchronizes the log recorded when the write operation corresponding to the database transaction is executed on the volatile internal memory to the non-volatile external memory.

[0048] It should be noted that a database transaction is a sequence of database operations that access and potentially manipulate various data items. These operations are either all executed or none are executed; it is an indivisible unit of work.

[0049] For example, if a database transaction consists of a sequence of operations including adding, deleting, and modifying, then for a data item, the database transaction for that data item is considered complete only after all three operations have been executed once. Conversely, if any operation is not executed, the database transaction for that data item is not considered complete. The specific database transaction is determined according to the actual situation, and this application embodiment does not limit it here.

[0050] In this embodiment of the application, when a database transaction commit instruction is received or a preset time is reached, it is determined that the data synchronization conditions are met.

[0051] It should be noted that database transaction commit can be performed to commit the completed database transaction when it comes to the end of its execution.

[0052] It should be noted that the preset time can be a fixed preset time, such as completing the data synchronization operation from volatile internal memory to non-volatile external memory after 1 hour, or it can be a preset loop time, such as completing the data synchronization operation from volatile internal memory to non-volatile external memory every 10 minutes, or completing this data synchronization operation at 12 o'clock every night. The specific preset time is determined according to the actual situation, and this application embodiment does not limit it here.

[0053] It should be noted that the data synchronization condition can also be a preset number of write operations. After the preset number of write operations is met, the data synchronization operation from the volatile internal memory to the non-volatile external memory is completed. For example, after every 10 write operations, the data synchronization operation from the volatile internal memory to the non-volatile external memory is completed. The specific data synchronization condition is determined according to the actual situation, and this application embodiment does not limit it here.

[0054] It should be noted that when data in volatile internal memory and non-volatile external memory is out of sync, the data page corresponding to the write operation in volatile internal memory is called a dirty page. Therefore, the data synchronization process can also be called the process of writing dirty pages. Furthermore, during data synchronization, this data synchronization process needs to be recorded in the preset dirty page write log of non-volatile internal memory.

[0055] Understandably, performing batch data synchronization operations by pre-setting data synchronization conditions can improve database performance, so that the database does not need to synchronize to non-volatile external storage every time a write operation is performed.

[0056] It should be noted that the write operation corresponding to the database transaction in volatile internal memory is the write operation performed by volatile internal memory until the data synchronization condition is met.

[0057] For example, suppose the data synchronization condition is to perform a data synchronization operation every 10 minutes. During these 10 minutes, 8 write operations are performed on the volatile memory. In this case, the write operations in the volatile memory are these 8 write operations within these 10 minutes.

[0058] It should be noted that before receiving the data recovery request, the process also includes performing the write operation corresponding to the database transaction on the volatile internal memory. Specifically, the write operation corresponding to the database transaction is performed on the volatile internal memory, and the write operation and the reverse operation of the write operation are recorded in the preset undo log of the non-volatile internal memory.

[0059] It should be noted that a write operation in non-volatile external memory is an operation in which a data item is written to a data item in volatile internal memory and then synchronized to the non-volatile external memory. Specifically, assuming that the write operation on the data page to be written in volatile internal memory is to add data A, then after data synchronization, the data page to be written in non-volatile external memory will be updated accordingly with data A, which is the write operation in non-volatile external memory.

[0060] It should be noted that during data synchronization operations between volatile internal memory and non-volatile external memory, the data synchronization process is recorded in the preset dirty page log of the non-volatile internal memory. At this time, a list of undoable transactions is generated based on this preset dirty page log.

[0061] It should be noted that the write operation in this application can be an addition, deletion, or modification operation, and the specific write operation is determined according to the actual situation. This application embodiment does not limit it here.

[0062] Specifically, assuming the write operation in this application is to add data A, the corresponding inverse operation is to delete data A. Or, assuming the write operation is to delete data B, the corresponding inverse operation is to add data B. The specific inverse operation is determined according to the actual situation, and this embodiment of the application does not limit it here.

[0063] In the embodiments of this application, Figure 2 An exemplary write operation flowchart is provided for this application, such as... Figure 2 As shown, the method includes:

[0064] S201. Determine the data to be written corresponding to the write operation and the page to which the data to be written belongs.

[0065] Specifically, the data recovery device determines the data to be written corresponding to the write operation and the data page to which the data to be written belongs.

[0066] It should be noted that a data page is a unit used to store data in memory. When storing data, the data can be stored in its corresponding data page.

[0067] S202. If a data page to be written is found in the volatile memory, perform the write operation on the data page to be written.

[0068] It should be noted that this application describes a data recovery method based on a database system architecture comprising volatile internal memory, non-volatile internal memory, and non-volatile external memory. Figure 3 As shown in the diagram, this application provides an exemplary database system architecture. When searching for data in the database system, the system first searches in volatile internal memory. If the search is successful, the searched data is returned. If the search fails, the system then searches in non-volatile external memory. If the search is successful, the searched data and its associated data page are loaded into volatile internal memory and the searched data is returned. If the search fails, a message indicating that the data being searched does not exist is returned.

[0069] For example, Figure 4 An exemplary write operation diagram provided for this application, such as... Figure 4As shown, the system includes volatile internal memory and non-volatile external memory. The data page buffer pool of the volatile internal memory stores data pages 1, 3, and 4, while the non-volatile external memory stores data pages 1, 2, 3, 4, 5, and 6. Assuming the data page to be written is page 3, the system searches for page 3 in the volatile internal memory data page buffer pool. If page 3 is found in the volatile internal memory, the write operation is performed directly on page 3 in the volatile internal memory.

[0070] S203. If the data page to be written is not found in the volatile internal memory, but is found in the non-volatile external memory, load the data page to be written from the non-volatile external memory into the volatile internal memory, and perform the write operation on the data page to be written.

[0071] For example, such as Figure 4 As shown, assuming the data page to be written is page 2, if the data page 2 to be written is not found in the volatile internal memory data page buffer pool, then the data page 2 to be written is searched in the non-volatile external memory. If page 2 is found in the non-volatile external memory, the data page 2 to be written is loaded from the non-volatile external memory into the volatile internal memory data page buffer pool, and the write operation of the data to be written is performed in the data page 2 to be written.

[0072] It should be noted that the loading process at this point involves copying the data page to be written from the non-volatile external memory to the volatile internal memory. After loading, the data page to be written will still exist in the non-volatile external memory.

[0073] S204. If the data page to be written is not found in the volatile internal memory or the non-volatile external memory, a new data page to be written is created in the volatile internal memory, and the write operation of the data to be written is performed in the data page to be written.

[0074] For example, suppose the page to be written is page 7, such as Figure 4 As shown, if the data page 7 to be written is not found in the volatile internal memory and the non-volatile external memory, then a space of the size of page 7 is allocated in the volatile internal memory data page buffer pool, and then a new data page 7 to be written is created. The write operation on the data to be written is then performed in the data page 7 to be written.

[0075] In this embodiment of the application, when the data recovery device performs a write operation corresponding to a database transaction on the volatile internal memory, it records the write operation in a preset record log of the non-volatile internal memory and records the reverse operation of the write operation in a preset undo log of the non-volatile internal memory.

[0076] In this embodiment of the application, the data recovery device can also read the target data, specifically... Figure 5 An exemplary read operation flowchart is provided for this application, such as... Figure 5As shown, the method includes:

[0077] S301. Determine the data to be read and the page to which the data to be read belongs, corresponding to the read operation.

[0078] Specifically, the data recovery device determines the data to be read and the page to which the data to be read belongs, corresponding to the read operation.

[0079] S302. If the data page to be read is found in the volatile internal memory, the read operation of the data to be read is performed in the data page to be read.

[0080] Specifically, such as Figure 4 As shown, assuming the data page to be read is page 1, page 1 is searched in the volatile memory data page buffer pool. If the search is successful, the data to be read is read in the data page 1.

[0081] S303. If the data page to be read is not found in the volatile internal memory, search for the data page to be read in the non-volatile external memory, load the data page to be read from the non-volatile external memory into the volatile internal memory, and perform the read operation on the data page to be read.

[0082] Specifically, such as Figure 4 As shown, assuming the data page to be read is page 2, page 2 is searched in the volatile internal memory data page buffer pool. At this time, the data page 2 to be read is not found in the volatile internal memory data page buffer pool. Then, the data page 2 to be read is searched in the non-volatile external memory. The data page 2 to be read is loaded from the non-volatile external memory into the volatile internal memory data page buffer pool, and the read operation of the data to be read is performed in the data page 2 to be read.

[0083] It should be noted that when performing write operations corresponding to database transactions, either the write operation is performed directly in volatile internal memory or the data page to be written is loaded from non-volatile external memory into volatile internal memory, and then the write operation is performed in volatile internal memory. Therefore, after the write operation is performed in volatile internal memory, the corresponding write operation in non-volatile external memory has not yet been performed, resulting in data in volatile internal memory and non-volatile external memory being out of sync. At this time, the data page corresponding to the write operation in volatile internal memory is called a dirty page, and a data synchronization operation needs to be performed to synchronize the data in volatile internal memory and non-volatile external memory.

[0084] S102. Sequentially determine whether the database transactions in the uncommitted transaction list are uncommitted transactions; if the database transaction is an uncommitted transaction, undo the write operations on the uncommitted transaction on the non-volatile external storage to achieve data recovery.

[0085] In this embodiment of the application, when reversing a write operation on an uncommitted transaction, it is necessary to determine whether the database transaction in the transaction reversal list is an uncommitted transaction.

[0086] Specifically, obtain the database operation sequence corresponding to the database transaction; determine the first position of the write operation in the database operation sequence; and determine whether the database transaction is an uncommitted transaction based on the first position.

[0087] For example, suppose the database operation sequence consists of operations of adding, deleting, and modifying, and suppose the write operation at this time is an add operation in the database operation sequence. In this case, the add operation corresponding to the write operation is the first position in the operation sequence consisting of adding, deleting, and modifying.

[0088] In this embodiment of the application, after determining the first position, it is necessary to determine whether the database transaction is an uncommitted transaction or the database transaction has been completed based on the determined first position.

[0089] In this embodiment of the application, when the first position is not at the end of the database operation sequence, it is determined that the database transaction is an uncommitted transaction.

[0090] For example, if the write operation corresponds to an insert operation that is the first position in the sequence of operations consisting of insert, delete, and modify, then the database transaction is determined to be an uncommitted transaction.

[0091] In this embodiment of the application, when the first position is at the end of the database operation sequence, it is determined that the database transaction has been completed.

[0092] For example, if the modification operation corresponding to the write operation is the first position in the sequence of operations consisting of add, delete, and modify, and is at the end of the database operation sequence, then it is determined that the database transaction has been completed.

[0093] In this embodiment of the application, the data recovery device cancels the write operation on the uncommitted transaction when the database transaction is an uncommitted transaction, so as to realize the data recovery.

[0094] Specifically, in this application, if the first position is not at the end of the database operation sequence, it is determined that the database transaction is an uncommitted transaction, and the write operation in the non-volatile external memory is undone based on the inverse operation recorded in the preset undo log in the non-volatile internal memory. In the embodiments of this application, it is determined that the write operation in the non-volatile external memory is undone based on the inverse operation.

[0095] Specifically, the reverse operation list of uncommitted transactions is obtained from the preset undo log; the reverse operations in the reverse operation list are executed in reverse order to undo write operations in non-volatile external storage; the reverse operations in the reverse operation list are arranged in the execution order.

[0096] It should be noted that after generating the undo transaction list based on this preset dirty page log, the reverse operation list of the database transactions in the undo transaction list is obtained from the preset undo log. For example, assuming that the undo transaction list contains database transaction 1, and the database operation sequence corresponding to this database transaction 1 is an operation sequence consisting of adding data A, deleting data B, and modifying data C, and the write operation has already executed up to the deletion operation B, then the execution order of the reverse operation list stored in the preset undo log should be deleting data A and adding data B. Then, according to this reverse operation list, the write operation in the non-volatile external storage is reversed to add data B and delete data A to achieve undo.

[0097] Understandably, by pre-setting the list of reverse operations recorded in the undo log, data can be recovered quickly.

[0098] In this embodiment of the application, when the execution progress of a database transaction is that the database transaction has been completed, the list of reverse operations corresponding to the database transaction is deleted from the preset undo log.

[0099] In this embodiment of the application, a garbage collection function can be preset in the database system. When it is determined that the execution progress of the database transaction is that the database transaction has been completed, the write operations and reverse operations related to this database transaction are deleted in the preset undo log of the non-volatile internal memory.

[0100] Understandably, the garbage collection function can improve the efficiency of analyzing preset undo logs.

[0101] This application provides a data recovery method, which includes: upon receiving a data recovery request, generating a list of undoable transactions based on a batch dirty page log stored in non-volatile internal memory; when the batch dirty page log meets the data synchronization conditions, synchronizing the logs recorded when the write operations corresponding to the database transactions performed on the volatile internal memory are synchronized to the non-volatile external memory; sequentially determining whether the database transactions in the undoable transaction list are uncommitted transactions; if the database transactions are uncommitted transactions, undoing the write operations on the non-volatile external memory for the uncommitted transactions to achieve data recovery; by adopting the above implementation scheme, when it is determined that there are no uncommitted transactions in the undoable transaction list, the write operations in the non-volatile external memory are undoed, so that the data in the non-volatile external memory is restored to the data before the write operations were performed, thereby achieving the purpose of quickly recovering database data and improving data recovery efficiency.

[0102] Example 2

[0103] In another embodiment of this application, a data recovery device 1 is provided. Figure 6A schematic diagram of the composition structure of a data recovery device 1 provided in this application. Figure 1 ,like Figure 6 As shown, the data recovery device 1 includes:

[0104] Processing unit 10 is used to generate a list of undoable transactions based on the batch dirty page log stored in non-volatile internal memory when a data recovery request is received; the batch dirty page log is the log recorded when the write operation corresponding to the database transaction is performed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization condition is met.

[0105] The undo unit 11 is used to sequentially determine whether the database transactions in the undo transaction list are uncommitted transactions; if the database transaction is an uncommitted transaction, the write operation on the uncommitted transaction on the non-volatile external memory is undone to achieve data recovery.

[0106] Optionally, the data recovery device 1 further includes: a recording unit;

[0107] The recording unit is used to perform write operations corresponding to database transactions on the volatile internal memory, and to record the write operation and the inverse operation of the write operation in a preset undo log of the non-volatile internal memory.

[0108] Optionally, the data recovery device 1 further includes: a determining unit;

[0109] The determining unit is used to determine the data to be written corresponding to the write operation and the data page to which the data to be written belongs;

[0110] The processing unit 10 is further configured to: if the data page to be written is found in the volatile internal memory, perform the write operation on the data page to be written; if the data page to be written is not found in the volatile internal memory but is found in the non-volatile external memory, load the data page to be written from the non-volatile external memory into the volatile internal memory, and perform the write operation on the data page to be written; if the data page to be written is not found in either the volatile internal memory or the non-volatile external memory, create a new data page to be written in the volatile internal memory, and perform the write operation on the data page to be written.

[0111] Optionally, the data recovery device 1 further includes: an acquisition unit;

[0112] The acquisition unit is used to acquire the database operation sequence corresponding to the database transaction;

[0113] The determining unit is further configured to determine the first position of the write operation in the database operation sequence; determine whether the database transaction is an uncommitted transaction based on the first position; correspondingly, the step of canceling the write operation on the uncommitted transaction when the database transaction is an uncommitted transaction includes: determining that the database transaction is an uncommitted transaction when the first position is not at the end of the database operation sequence;

[0114] The cancellation unit 11 is also used to cancel the write operation in the non-volatile external memory based on the inverse operation.

[0115] The acquisition unit is further configured to acquire the list of inverse operations of the uncommitted transaction from the preset uncommit log;

[0116] The undo unit 11 is also used to execute the reverse operations in the reverse operation list in reverse order to undo the write operations in the non-volatile external memory; the reverse operations in the reverse operation list are arranged in the execution order.

[0117] Optionally, the data recovery device 1 further includes: a deletion unit;

[0118] The deletion unit is used to determine that the database transaction has been completed when the database transaction is not a commit transaction, and to delete the write operation and reverse operation corresponding to the database transaction from the preset undo log.

[0119] Optionally, the data recovery device 1 further includes: a judgment unit;

[0120] The judgment unit is used to determine whether the data synchronization conditions are met when a database transaction commit instruction is received or a preset time is reached.

[0121] This application provides a data recovery device, which includes: upon receiving a data recovery request, generating a list of undoable transactions based on a batch dirty page log stored in non-volatile internal memory; when the batch dirty page log meets the data synchronization conditions, synchronizing the logs recorded when the write operations corresponding to the database transactions performed on the volatile internal memory are synchronized to the non-volatile external memory; sequentially determining whether the database transactions in the undoable transaction list are uncommitted transactions; if the database transactions are uncommitted transactions, undoing the write operations on the non-volatile external memory for the uncommitted transactions to achieve data recovery; by adopting the above implementation scheme, when it is determined that there are no uncommitted transactions in the undoable transaction list, the write operations in the non-volatile external memory are undoed, so that the data in the non-volatile external memory is restored to the data before the write operations were performed, thereby achieving the purpose of quickly recovering database data and improving data recovery efficiency.

[0122] Figure 7 A schematic diagram of the composition structure of a data recovery device 1 provided in this application embodiment. Figure 2 In practical applications, based on the same disclosed concept of the above embodiments, such as Figure 7 As shown, the data recovery device 1 in this embodiment includes: a processor 12, a memory 13, and a communication bus 14.

[0123] In a specific embodiment, the processing unit 10, the undo unit 11, the recording unit, the determining unit, the acquiring unit, the deleting unit, and the judging unit described above can be implemented by a processor 12 located on the data recovery device 1. The processor 12 can be at least one of the following: an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field-programmable gate array (FPGA), a CPU, a controller, a microcontroller, or a microprocessor. It is understood that for different data recovery devices, the electronic device used to implement the above processor functions can also be other types; this embodiment does not specifically limit this.

[0124] In this embodiment, the communication bus 14 is used to realize the connection communication between the processor 12 and the memory 13; when the processor 12 executes the running program stored in the memory 13, it implements the following data recovery method:

[0125] Perform write operations corresponding to database transactions on volatile internal memory, and record the write operation and the inverse operation of the write operation;

[0126] When a data recovery request is received, a list of undoable transactions is generated based on the batch dirty page write log stored in the non-volatile internal memory. The batch dirty page write log is the log recorded when the write operation corresponding to the database transaction is executed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization conditions are met.

[0127] The database transactions in the list of uncommitted transactions are sequentially determined to be uncommitted transactions. If a database transaction is an uncommitted transaction, the write operations on the uncommitted transaction on the non-volatile external memory are uncommitted to achieve data recovery.

[0128] Optionally, the processor 12 is further configured to perform write operations corresponding to database transactions on the volatile internal memory, and record the write operation and the inverse operation of the write operation in a preset undo log of the non-volatile internal memory.

[0129] Optionally, the processor 12 is further configured to determine the data to be written corresponding to the write operation and the data page to which the data to be written belongs; if the data page to be written is found in the volatile internal memory, the write operation on the data to be written is performed in the data page to be written; if the data page to be written is not found in the volatile internal memory but is found in the non-volatile external memory, the data page to be written is loaded from the non-volatile external memory into the volatile internal memory, and the write operation on the data to be written is performed in the data page to be written; if the data page to be written is not found in either the volatile internal memory or the non-volatile external memory, the data page to be written is created in the volatile internal memory, and the write operation on the data to be written is performed in the data page to be written.

[0130] Optionally, the processor 12 is further configured to obtain the database operation sequence corresponding to the database transaction; determine the first position of the write operation in the database operation sequence; determine whether the database transaction is an uncommitted transaction based on the first position; accordingly, the step of canceling the write operation on the uncommitted transaction when the database transaction is an uncommitted transaction includes: determining that the database transaction is an uncommitted transaction when the first position is not at the end of the database operation sequence; and canceling the write operation in the non-volatile external memory based on the inverse operation.

[0131] Optionally, the processor 12 is further configured to obtain the reverse operation list of the uncommitted transaction from the preset uncommit log; execute the reverse operations in the reverse operation list in reverse order to undo the write operation in the non-volatile external memory; the reverse operations in the reverse operation list are arranged in the execution order.

[0132] Optionally, the processor 12 is further configured to, if the database transaction is not a commit transaction, determine that the database transaction has been completed and delete the write operation and reverse operation corresponding to the database transaction from the preset undo log.

[0133] Optionally, the processor 12 is further configured to determine whether the data synchronization conditions are met upon receiving a database transaction commit instruction or upon the arrival of a preset time.

[0134] This application provides a storage medium storing a computer program thereon. The computer-readable storage medium stores one or more programs, which can be executed by one or more processors and applied in a data recovery device. The computer program implements the data recovery method described above.

[0135] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0136] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause an image display device (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the data recovery methods described in the various embodiments of this disclosure.

[0137] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application.

Claims

1. A data recovery method, characterized in that, The method includes: When a data recovery request is received, a list of undoable transactions is generated based on the batch dirty page write log stored in the non-volatile internal memory. The batch dirty page write log is the log recorded when the write operation corresponding to the database transaction is executed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization conditions are met. The database transactions in the list of uncommitted transactions are sequentially determined to be uncommitted transactions. If a database transaction is an uncommitted transaction, the write operations on the uncommitted transaction on the non-volatile external memory are uncommitted to restore the data. The method further includes, before generating a list of undoable transactions based on the batch dirty page log stored in non-volatile internal memory when a data recovery request is received: Perform a write operation corresponding to a database transaction on the volatile internal memory, and record the write operation and its inverse operation in a preset undo log of the non-volatile internal memory; The write operation corresponding to the database transaction performed on the volatile internal memory includes: Determine the data to be written corresponding to the write operation and the page to which the data to be written belongs; If the data page to be written is found in the volatile memory, the write operation on the data page to be written is performed. If the data page to be written is not found in the volatile internal memory but is found in the non-volatile external memory, the data page to be written is loaded from the non-volatile external memory into the volatile internal memory, and the write operation on the data page to be written is performed. If the data page to be written is not found in the volatile internal memory and the non-volatile external memory, a new data page to be written is created in the volatile internal memory, and the write operation on the data to be written is performed in the data page to be written.

2. The method according to claim 1, characterized in that, The step of sequentially determining whether the database transactions in the list of uncommitted transactions are uncommitted transactions includes: Obtain the database operation sequence corresponding to the database transaction; Determine the first position of the write operation in the database operation sequence; Based on the first position, determine whether the database transaction is an uncommitted transaction; Accordingly, when the database transaction is an uncommitted transaction, reversing the write operation on the uncommitted transaction includes: If the first position is not at the end of the database operation sequence, the database transaction is determined to be an uncommitted transaction. The write operation in the non-volatile external memory is undone based on the inverse operation.

3. The method according to claim 2, characterized in that, The reversal of the write operation in the non-volatile external memory based on the inverse operation includes: Obtain the list of inverse operations of the database transaction from the preset undo log; The reverse operations in the reverse operation list are executed in reverse order to undo write operations in the non-volatile external memory; the reverse operations in the reverse operation list are arranged in the execution order.

4. The method according to claim 3, characterized in that, After sequentially determining whether the database transactions in the uncommitted transaction list are uncommitted transactions, the process further includes: If the database transaction is not a commit transaction, it is determined that the database transaction has been completed, and the write operation and reverse operation corresponding to the database transaction are deleted from the preset undo log.

5. The method according to claim 1, characterized in that, The method further includes: Upon receiving a database transaction commit instruction or upon the arrival of a preset time, it is determined that the data synchronization conditions are met.

6. A data recovery device, characterized in that, The device includes: The processing unit is used to generate a list of undoable transactions based on the batch dirty page log stored in the non-volatile internal memory when a data recovery request is received; the batch dirty page log is the log recorded when the write operation corresponding to the database transaction is performed on the volatile internal memory and synchronized to the non-volatile external memory when the data synchronization conditions are met. The undo unit is used to sequentially determine whether the database transactions in the undo transaction list are uncommitted transactions; if the database transaction is an uncommitted transaction, the write operation on the uncommitted transaction on the non-volatile external memory is undone to achieve data recovery; The device further includes: a recording unit; The recording unit is used to perform write operations corresponding to database transactions on the volatile internal memory, and record the write operation and the inverse operation of the write operation in the preset undo log of the non-volatile internal memory. The device further includes: a determining unit; The determining unit is used to determine the data to be written corresponding to the write operation and the data page to which the data to be written belongs; The processing unit is further configured to: if the data page to be written is found in the volatile internal memory, perform the write operation on the data page to be written; if the data page to be written is not found in the volatile internal memory but is found in the non-volatile external memory, load the data page to be written from the non-volatile external memory into the volatile internal memory, and perform the write operation on the data page to be written; if the data page to be written is not found in either the volatile internal memory or the non-volatile external memory, create a new data page to be written in the volatile internal memory, and perform the write operation on the data page to be written.

7. A data recovery device, characterized in that, The device includes a processor, a memory, and a communication bus; when the processor executes the running program stored in the memory, it implements the data recovery method as described in any one of claims 1-5.

8. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the data recovery method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Log management method and device

    CN103678608A

  • Transaction recovery method in database system, and database management system

    CN105930500A