Data processing method and related device

By recording only the initial page before the first modification to the flashback log within the target cycle of the database page, and combining the redo log replay, the problem of large disk space in the database flashback is solved, and efficient database recovery is achieved.

CN120371597APending Publication Date: 2025-07-25HUAWEI TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410101131.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-24
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

Existing database flashback technology requires recording a large amount of undo data during busy business, resulting in excessive disk space and long time to find the target page.

Method used

Only record the initial page to the flashback log before the first modification of the database page is made during the target cycle, and replays it in combination with the redo log to reduce disk space overhead and increase flashback speed.

Benefits of technology

It effectively reduces disk space overhead, shortens database flashback time, and improves database recovery efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371597A_ABST
    Figure CN120371597A_ABST
Patent Text Reader

Abstract

The invention provides a data processing method and a related device, which can be applied to a database flash-back scene. The method comprises the steps of receiving a first flashback instruction, and recording a first page to a flashback log before the first page in a database is modified for the first time in a target period in response to the first flashback instruction. And receiving a second flash-back instruction, and in response to the second flash-back instruction, restoring the database to a state at a specified moment based on the flash-back log and the redo log of the database. In the application, the first page is recorded in the flash-back log only before the first page is modified for the first time in the target period. In other words, for the first page with the modification operation, only one initial page is recorded in the target period, and the subsequent modification version in the target period is not recorded, so that the overhead of the disk space can be effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technologies, and in particular, to a data processing method and related devices. Background Art

[0002] Database flashback is a database recovery technology that can restore a database to a state at a previous moment. The database flashback technology has very wide application scenarios and can be used in business processes such as upgrades, fault recovery, and undoing logical errors. For example, when preparing to upgrade a database, the flashback function is enabled. If an error occurs during the upgrade process, the database can be restored to the state before the upgrade through the flashback function. Currently, the industry generally uses the method of physical backup to achieve an effect similar to database flashback. When an exception occurs in the database, the database is rebuilt using the physical backup. Physical backup essentially copies the current data of the database and then uses the copied data for recovery. Therefore, physical backup will occupy a very large amount of disk space.

[0003] In response to the above problems, some solutions have been proposed in the industry, such as achieving the flashback effect by rolling back (undo) data. Specifically, in this solution, there are an undo module and a flashback module. During the execution of a business, the undo module is responsible for recording and maintaining the undo data of the database. When a flashback command needs to be executed, the flashback module selects the corresponding data from the undo data and flashes back the database to the specified moment based on the relevant data.

[0004] The undo data records the data changes of the database at each moment. Therefore, it is possible to effectively implement the database flashback function without physically backing up the database. However, when the business is relatively busy, the data changes will be very large, and a large amount of undo data needs to be recorded, which will also consume a large amount of disk space. Even in extreme scenarios, the disk space occupied by the undo data will be greater than the disk space required for physical backup. Summary of the Invention

[0005] This application provides a data processing method and related devices, which can effectively reduce the disk space overhead while implementing the database flashback function.

[0006] In a first aspect of this application, a data processing method is provided, which can be applied to a data processing device. The method includes: receiving a first flashback instruction; in response to the first flashback instruction, before the first modification of the first page in the database within the target period, recording the first page in the flashback log; receiving a second flashback instruction; in response to the second flashback instruction, restoring the database to the state at the specified moment based on the flashback log and the redo log of the database.

[0007] When the user selects to enable the flashback function, a first flashback instruction is issued. After receiving the first flashback instruction, the data processing device, for the first page with modification operations, records it in the flashback log only before the first modification to this first page within the target period. That is to say, even if the first page is modified multiple times within the target period (usually it will be modified multiple times), only one initial page is recorded. For pages without modification operations within the target period, no processing is performed. The target period can be any specified period of time. For example, 5 minutes is a target period, or one hour is a target period. The target period can also be a fixed period. For example, the target period is one CKPT period, or the target period includes multiple CKPT periods.

[0008] When the user needs to perform a database recovery operation, a second flashback instruction is sent, and the specified time to be recovered is carried in the second flashback instruction. Among them, the specified time can be the time point when the flashback function is enabled, or any time point after the flashback function is enabled. Specifically, it is not limited here. After receiving the second flashback instruction, the data processing device performs a flashback operation on the database. Specifically, based on the specified time carried in the second flashback instruction, the corresponding target page is determined from the first pages recorded in the flashback log. For example, the specified time is 9 am, that is, the database needs to be restored to the state at 9 am. At this time, the target page with the recording time closest to 9 am is found from the flashback log, and a flashback operation is performed according to the target page to restore the data to the state of the target page. Subsequently, a replay is performed according to the redo log, so as to restore the database to the state at the specified time. The closer the recording time of the page is to the specified time, the shorter the duration required for the subsequent replay according to the redo log. For uncommitted transactions, a rollback operation is performed by rolling back the undo data.

[0009] In the first aspect of this application, within the target period, the first page is recorded in the flashback log only before the first modification. That is to say, for the first page with modification operations, only one initial page is recorded within the target period, and subsequent modified versions within the target period are not recorded, thereby effectively reducing the disk space overhead. Moreover, only recording one initial page within the target period also results in fewer versions of this page recorded in the flashback log, thereby enabling the corresponding target page to be quickly determined and reducing the duration of database flashback.

[0010] In a possible implementation of the first aspect, the target cycle is the checkpoint (CKPT) cycle when the first page is modified for the first time after receiving the first flashback instruction. That is to say, only the first page will be recorded within the first CKPT cycle when there is a modification operation on the first page after receiving the first flashback instruction, and the first page is the original page after receiving the first flashback instruction. In other words, even if the first page is modified in multiple CKPT cycles or modified multiple times in one CKPT cycle after receiving the first instruction, only the first page (i.e., the original page) before the first modification is recorded in the flashback log.

[0011] In this possible implementation, for multiple modifications of a page, only one copy of the original page will be recorded, which can greatly save the disk space overhead. Moreover, since only the original page of a page is recorded, the process of finding the corresponding page at a specified moment from multiple historical versions can be reduced, greatly improving the flashback speed.

[0012] In a possible implementation of the first aspect, the target cycle is a single checkpoint cycle, and the flashback log includes multiple first pages, where each first page corresponds to a checkpoint cycle. That is, in each CKPT cycle when there is a modification operation on the first page, the first page will be recorded in the flashback log before the first modification in that CKPT cycle. In other words, for each CKPT cycle when there is a modification operation on the first page, the initial page of the first page in that cycle will be recorded in the flashback log, and the flashback log will include multiple versions of the first page, each first page corresponding to a CKPT cycle.

[0013] In this possible implementation, for multiple modifications of the first page in one CKPT cycle, it will only be recorded in the flashback log before the first modification in that CKPT cycle, that is, only one copy of the page is recorded in one CKPT cycle, which can reduce the disk space overhead. Moreover, since a copy of the page is recorded in each CKPT cycle with a modification operation, a version page closer to the user-specified time point can be found, so that the database can be quickly restored to the state at the specified moment.

[0014] In a possible implementation of the first aspect, the target period includes N checkpoint periods, and the flashback log includes multiple first pages, where each first page corresponds to N checkpoint periods, and N is an integer greater than 1. That is, in the CKPT period where there is a modification operation for every N first pages, the first page will only be recorded in the flashback log before the first modification of the first page within these N CKPT periods. That is to say, one copy of the first page will be recorded in the flashback log every N CKPT periods, and the flashback log will include versions of multiple first pages, and each copy of the first page corresponds to N CKPT periods. Exemplarily, if N is 5, then only one initial page (i.e., the first page itself) will be recorded within every 5 CKPT periods.

[0015] In this possible implementation, compared with recording one first page in each CKPT period, recording only one first page within multiple CKPT periods can further save the disk space overhead. And compared with recording only one initial page in the first CKPT period with a modification, recording one initial page every N CKPT periods can find a version page closer to the user-specified time point, thereby reducing the replay time.

[0016] In a possible implementation of the first aspect, the above step: restoring the database to the state at the specified moment based on the flashback log and the redo log of the database includes: constructing a fast lookup structure in the form of an index structure based on multiple first pages; determining the target page corresponding to the specified moment from multiple first pages based on the fast lookup structure; and restoring the database to the state at the specified moment based on the target page and the redo log.

[0017] When the target period is a single CKPT period or N CKPT periods, multiple versions of the first page may be recorded in the flashback log. For example, when the target period is a single CKPT period and page A has modification operations in 20 CKPT periods, then 20 versions of page A will be recorded in the flashback log. In order to find the target page from the 20 versions of the page, the currently widely adopted solution in the industry is to read the pages sequentially until the required version is found, and this solution will consume a lot of time.

[0018] In this possible implementation, the fast lookup structure is constructed to quickly determine the target page from numerous versions. Specifically, an index structure is established for the numerous versions recorded in the flashback log. Among them, the index structure can be a linked list or a balanced tree (such as a B-tree), and the balanced tree can be a B-tree, a B* - tree, or a B+ - tree. The index structure can provide an effect similar to a directory, so that the required target page can be quickly determined from multiple pages.

[0019] In a possible implementation of the first aspect, after receiving the first flashback instruction, the method further includes: recording the log between the recovery point (RCY) and the least recovery point (LRP) in the redo log into the flashback log.

[0020] In this possible implementation, the redo log from the RCY point to the LRP point is recorded into the flashback log. In this way, even if the redo log is archived and cleared, the replay operation can be performed based on this part of the redo log cached in the flashback log, ensuring the stability of the solution.

[0021] In a possible implementation of the first aspect, the method further includes: modifying the first page to obtain a second page; writing the second page to disk. The second page that has not been written to disk can be called a dirty page and is placed in the dirty page queue. When the disk write operation is to be performed, the second page is retrieved from the dirty page queue and written to the disk.

[0022] In a possible implementation of the first aspect, the above step of recording the page into the flashback log includes: copying the page to the flashback buffer; recording the page from the flashback buffer into the flashback log; before the above step of writing the second page to disk, the method further includes: checking whether the first page exists in the flashback buffer; if it exists, writing the first page from the flashback buffer to the flashback log.

[0023] To ensure that the database can perform the flashback operation normally, before the second page is written to disk, it is first checked whether the corresponding first page still exists in the flashback buffer. If it exists, it means that the first page has not been recorded in the flashback log, then the first page is read from the flashback buffer and written to the flashback log, thus fully ensuring that the initial page has been recorded in the flashback log.

[0024] In a possible implementation of the first aspect, modifying the first page and recording the first page into the flashback log are parallel operations. That is to say, the flashback log disk write and the modification and disk write of the page are asynchronous mechanisms. Multiple threads work asynchronously and do not block the database service, thus ensuring that the database service performance does not decline.

[0025] The second aspect of the present application provides a data processing device, including a receiving unit, a recording unit, and a recovery unit. The receiving unit is used to receive the first flashback instruction; the recording unit is used to record the first page in the database into the flashback log for the first time within the target period before modifying the first page in response to the first flashback instruction; the receiving unit is further used to receive the second flashback instruction; the recovery unit is used to restore the database to the state at a specified moment based on the flashback log and the redo log of the database in response to the second flashback instruction.

[0026] In a possible implementation of the second aspect, the target period is the checkpoint period when the first page is modified for the first time after receiving the first flashback instruction.

[0027] In a possible implementation of the second aspect, the target period is a single checkpoint period, and the flashback log includes multiple first pages, where each first page corresponds to a checkpoint period.

[0028] In a possible implementation of the second aspect, the target period includes N checkpoint periods, and the flashback log includes multiple first pages, where each first page corresponds to N checkpoint periods, and N is an integer greater than 1.

[0029] In a possible implementation of the second aspect, the recovery unit is specifically configured to: construct a fast lookup structure based on multiple first pages in an index structure manner; determine a target page corresponding to a specified moment from the multiple first pages based on the fast lookup structure; and restore the database to the state at the specified moment based on the target page and the redo log.

[0030] In a possible implementation of the second aspect, the recording unit is further configured to: record the log between the recovery point and the minimum recovery point in the redo log to the flashback log.

[0031] In a possible implementation of the second aspect, the apparatus further includes: a modification unit, configured to modify the first page to obtain a second page; and a disk writing unit, configured to write the second page to disk.

[0032] In a possible implementation of the second aspect, the recording unit is specifically configured to: copy the page to the flashback buffer; record the page from the flashback buffer to the flashback log; the apparatus further includes: an inspection unit, configured to inspect whether there is a first page in the flashback buffer; and a writing unit, configured to write the first page from the flashback buffer to the flashback log when there is a first page.

[0033] In a possible implementation of the second aspect, modifying the first page and recording the first page to the flashback log are parallel operations.

[0034] The data processing apparatus provided in the second aspect of the present application is used to execute the method described in the first aspect or any possible implementation of the first aspect.

[0035] The third aspect of the present application provides a data processing apparatus, including a processor and a memory. The memory is used to store instructions, and the processor is used to obtain the instructions stored in the memory to execute the method described in the first aspect or any possible implementation of the first aspect.

[0036] The fourth aspect of this application provides a computer-readable storage medium, which includes instructions that, when run on a computer, cause the computer to execute the method described in the first aspect or any possible implementation of the first aspect.

[0037] The fifth aspect of this application provides a computer program product containing instructions that, when run on a computer, cause the computer to execute the method described in the first aspect or any possible implementation of the first aspect.

[0038] The sixth aspect of this application provides a chip system, which includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instructions to execute the method described in the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 It is a schematic diagram of an architecture of the database system applied in the embodiments of this application;

[0040] Figure 2 It is a schematic diagram of an embodiment of the data processing method provided in the embodiments of this application;

[0041] Figure 3 It is another schematic diagram of an embodiment of the data processing method provided in the embodiments of this application;

[0042] Figure 4 It is a schematic diagram of an embodiment of enabling flashback at a flashback point in the embodiments of this application;

[0043] Figure 5 It is a schematic diagram of an embodiment of enabling flashback at a point in time in the embodiments of this application;

[0044] Figure 6 It is a schematic diagram of an embodiment of the data processing method provided in the embodiments of this application in the scenario of database upgrade;

[0045] Figure 7 It is another schematic diagram of an architecture of the database system applied in the embodiments of this application;

[0046] Figure 8 It is a schematic diagram of an embodiment of the data processing method provided in the embodiments of this application in the scenario of recovery from misoperation;

[0047] Figure 9 It is a schematic diagram of a structure of the data processing device provided in the embodiments of this application;

[0048] Figure 10Another structural schematic diagram of the data processing device provided by the embodiment of the present application. Detailed implementation manners

[0049] The embodiment of the present application provides a data processing method, which can effectively reduce the disk space overhead while implementing the database flashback function, and reduce the time required for flashback. The embodiment of the present application also provides a corresponding device, computer-readable storage medium, computer program product, etc. The following will be described separately.

[0050] Next, in conjunction with the accompanying drawings, the embodiments of the present application will be described. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Those of ordinary skill in the art know that with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0051] In the specification, claims and above-mentioned drawings of the present application, terms such as "system" and "network", "redo log" and "redo log", "rollback data" and "undo data" can be used interchangeably. Unless otherwise specified, ordinal numbers such as "first" and "second" are used to distinguish multiple objects, and are not used to limit the order, timing, priority or importance of multiple objects. It should be understood that such terms can be interchanged under appropriate circumstances so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these process, method, product or device.

[0052] For ease of understanding, the following first introduces the relevant terms and concepts mainly involved in the embodiments of the present application.

[0053] 1. Checkpoint

[0054] A checkpoint (CKPT) is a database event. After a modification operation is performed during the CKPT cycle, dirty pages will be placed in the dirty page queue, and then the dirty pages will be picked from the dirty page queue and written to the disk later.

[0055] 2. Database flashback technology

[0056] The database flashback technology is a full-database flashback technology, which can restore the database to a specific point in time or the end point of a specific transaction. By using the database flashback technology, incorrect operations on the database can be revoked or restored to the previous state.

[0057] 3. Page

[0058] A page is the smallest unit for managing data in the storage engine, and the data inserted into the database is stored in pages.

[0059] 4. Recovery Point

[0060] A recovery point (RCY) is a log point in the database. The changes before this log point have been applied to the database, and the changes after this time point need to be restored through recovery operations. Recovery points are usually used for database backup and recovery operations. During recovery, replay starts from the RCY point.

[0061] 5. Least Recovery Point

[0062] The least recovery point (LRP) is a log point in the database. When the redo logs before this log point have all been replayed, the database has been restored to a consistent state. The least recovery point is usually used for database failure recovery and transaction rollback operations.

[0063] 6. X Lock

[0064] An exclusive lock (X lock) is a database locking mechanism. The characteristics of the X lock are as follows: Exclusivity: After a transaction acquires an X lock, other transactions cannot acquire an X lock or an S lock simultaneously. This means that only one transaction can perform write operations on the locked resource, and other transactions must wait for the transaction to release the lock; Write operation: A transaction that has acquired an X lock can perform read and modify operations on the locked resource; Blocking: If a transaction is holding an X lock and another transaction requests to acquire an X lock or an S lock, the transaction requesting the lock will be blocked until the transaction holding the lock releases the lock. The usage scenarios of the X lock include: Modification operation: When a transaction needs to modify a certain resource, it needs to acquire an X lock to ensure that other transactions cannot modify the resource simultaneously; Data consistency: By acquiring an X lock, it can ensure that other transactions cannot read inconsistent data during the modification operation.

[0065] 7. Balanced Tree

[0066] A balanced tree (B-tree), also known as a B-number, is a self-balancing tree that can keep data in order. This data structure enables operations such as data searching, sequential access, data insertion, and deletion to be completed in logarithmic time. Generally speaking, a B-tree is a generalized binary search tree that can have more than two child nodes. Different from a self-balancing binary search tree, a B-tree is optimized for the read and write operations of large chunks of data in the system. A B-tree reduces the intermediate processes experienced when locating records, thus accelerating the access speed.

[0067] Database flashback is a database recovery technique that can restore the database to a state at a previous moment. Currently, the industry generally uses the method of physical backup to achieve an effect similar to database flashback. Physical backup is to copy the current data of the database. When flashback is needed, the copied data is used to reconstruct the database. Since physical backup copies all the data of the database at the current moment, it requires a very large amount of disk space, takes the same long time for recovery, and can only restore the database to the state at the moment when the physical backup was taken (newly generated data after the backup is not recorded).

[0068] To solve the above problems, some solutions have been proposed in the industry, such as implementing database flashback through undo data, and implementing flashback through the combination of physical backup and point in time recover (PITR). The solution to implement flashback through undo data includes an undo module and a flashback module. During the execution of business operations, the undo module is responsible for recording the undo data of the database. When a flashback command needs to be executed, the flashback module then selects the corresponding data from the undo data and flashes back the database to the specified moment according to the relevant data. Since the undo data records the data changes of the database at each moment, the flashback function can be effectively implemented, and it can be restored to any time point with undo data records. However, when the business is busy, the data changes will be very large, and a large amount of undo data needs to be recorded, which will also occupy a large amount of disk space. And there are often multiple historical versions of a page, and it takes more time to select the page at the corresponding moment from numerous historical pages, so it also takes a long time for flashback.

[0069] Implementing flashback through physical backup combined with PITR is an enhanced implementation of physical backup. Specifically, first, the data at the current moment is backed up through physical backup, and then the redo log is continuously recorded into the log file. When the flashback command is executed, the database is reconstructed based on the backup data to restore the data at the backup moment, and then the recorded log is replayed to restore the database to the specified moment. This solution can achieve flashback to any point in time, but since physical backup is also required, it cannot solve the problems of large space overhead and long backup and recovery times.

[0070] In view of this, the embodiments of the present application provide a data processing method. During the target period, the database page is only recorded before the first modification to the page. Through the recorded page, the database can be flashed back to the state before the first modification, and then combined with the redo log for replay to achieve restoring the database to the state at the specified moment. That is to say, even if the page is modified multiple times during the target period, only the initial page of the page during the target period is recorded. For the pages that are not modified during the target period, there is no need to record them, so that the flashback function of the database can be realized with very little disk space overhead. And since only one page is recorded during the target period, the required page can be quickly determined during flashback, thereby reducing the duration of database flashback and improving the efficiency of flashback.

[0071] It can be understood that the data processing method provided by the embodiments of the present application can be applied to various databases, such as MySQL, Oracle, and SQL Server, etc. For the convenience of description, MySQL is used as an example in the embodiments of the present application, and there is no specific limitation.

[0072] Please refer to the following Figure 1 , Figure 1 which is an architecture schematic diagram of the database system applied in the embodiments of the present application.

[0073] As shown in Figure 1As shown in the figure, the database system is deployed in a database server, which specifically includes a software part and a hardware part. The hardware part is a disk, which is the physical medium for storing data in the database. The software part is the database platform software, which is used to manage data files on the disk, including operations such as reading, writing, updating, and deleting data. The database platform software includes a storage engine, and the program code of the embodiments of the present application exists in the storage engine. The storage engine includes a flashback module, and the flashback module is used to implement the flashback function of the database. Specifically, the flashback module can be subdivided into a flashback log sub-module and a flashback recovery sub-module. After the flashback function is enabled, for the page that is modified for the first time within the target period, the flashback log sub-module records its corresponding initial page (i.e., the page before the first modification) within the target period into the flashback log. When a flashback instruction is executed, the flashback recovery sub-module performs a flashback operation on the database according to the initial page recorded in the flashback log.

[0074] It should be noted that the target period can be any specified period of time. For example, 5 minutes can be a target period, or one hour can be a target period. The target period can also be a fixed period. For example, the target period is a CKPT period, or the target period includes multiple CKPT periods. For the sake of clarity, in the embodiments of the present application, the target period is taken as an example of a CKPT period or including multiple CKPT periods for description, and there is no specific limitation.

[0075] Based on Figure 1 the system architecture shown above, the overall process of the embodiments of the present application will be described below in conjunction with Figure 2 As shown in Figure 2 the figure, the overall process includes a page modification thread, a dirty page disk write thread, and a flashback thread for recording the initial page. Optionally, the dirty page disk write thread can also be used to ensure that the initial page has been recorded in the flashback log. Among them, steps 201 and 202 are the business logics of the modification thread, steps 203 and 204 are the business logics when the disk write thread writes the dirty page to the disk, steps 205 to 207 are the business logics of the flashback thread, and steps 208 and 209 are the business logics of the disk write thread to ensure that the initial page is recorded in the flashback log. Disk write means writing data to the disk. The process from page modification to disk write is a CKPT period. That is to say, steps 201 to 204 are a CKPT period. It should be understood that within a CKPT period, there are usually many pages modified and written to the disk, and a page can be modified multiple times. Each step will be described separately below.

[0076] 201. Modify the thread to read the first page from the disk in the way of X lock. A transaction that has obtained the X lock can perform read and modification operations on the locked resource, and can ensure that other transactions cannot modify the page simultaneously. A transaction refers to a complete logical process composed of a series of database operations.

[0077] 202. The modifying thread modifies the first page to obtain the second page. A page that has been modified but not yet written to disk can be called a dirty page. The page will not be written to disk immediately after modification, but will be written to disk collectively at the end of a CKPT cycle. The modified page is first cached in the dirty page queue. There are usually multiple dirty pages in the dirty page queue. Exemplarily, in Figure 2 the dirty page queue includes page 1 - 10, page 2 - 3, and page 3 - 7. Among them, page 1 - 10 is the 10th page of file 1, page 2 - 3 is the 3rd page of file 2, and page 3 - 7 is the 7th page of file 3.

[0078] After modifying the first page to obtain the second page, the modifying thread adds the second page to the dirty page queue.

[0079] 203. When it is necessary to write the dirty page to disk, the disk - writing thread extracts the second page from the dirty page queue.

[0080] 204. The disk - writing thread writes the second page to the disk.

[0081] 205. Before the first modification of the first page within the target cycle, the flashback thread copies the first page to the flashback buffer. For modifications to the first page after the target cycle, the flashback thread does not process them. That is to say, for multiple modifications to the first page within the target cycle, the flashback thread only records the page before the first modification (i.e., the initial page within the target cycle). For example, if page B is modified 3 times, the flashback log only copies the initial page of page B within the target cycle to the flashback buffer.

[0082] The target period can be one CKPT period or include multiple CKPT periods, such as two CKPT periods or five CKPT periods. That is, the flashback log only records the first page before the first modification of the first page within one CKPT period, or only records the first page before the first modification of the first page within multiple CKPT periods. Assume that the first page is modified in each CKPT period. When the target period is one CKPT period, each CKPT period will record one first page. At this time, the recorded first page is the initial page of the first page in each CKPT period, and five CKPT periods will record five pages. When the target period is multiple (such as five) CKPT periods, only one first page will be recorded in five CKPT periods. At this time, the recorded first page is the initial page of the first page in the first CKPT period. Therefore, compared with the target period being a single CKPT period, when the target period is multiple CKPT periods, the disk space overhead can be further saved, but usually more time is required for replay according to the redo log.

[0083] It can be understood that step 205 and step 202 can be carried out simultaneously. That is to say, the modification operation of the first page and the copy operation of the first page are asynchronous mechanisms, and the modification thread and the flashback thread can execute in parallel.

[0084] 206. The flashback thread reads the first page from the flashback buffer. After the first page is read, the first page no longer exists in the flashback buffer.

[0085] 207. The flashback thread records the first page to the flashback log. Both the flashback log and the redo log are stored on the disk.

[0086] 208. The disk write thread checks whether there is a corresponding initial page (i.e., the first page) in the flashback buffer for the dirty page (i.e., the second page) to be written to disk. Usually, the time of one CKPT period is relatively long. When the second page is to be written to disk, the first page in the flashback buffer has already been recorded to the flashback log by the flashback thread. However, it is also possible that the first page has not been written to disk. In view of this, before writing the second page to disk (i.e., step 204), the disk write thread first checks whether the first page corresponding to the second page still exists in the flashback buffer. If not, it means that the first page has been recorded to the flashback log, and step 204 is executed. If it exists, step 209 is executed.

[0087] 209. The disk write thread triggers the flashback thread to record the first page to the flashback log (i.e., steps 206 and 207). After the flashback thread executes, the disk write thread continues to execute step 204, so as to fully ensure that the initial page is recorded in the flashback log, and further ensure the normal implementation of the database flashback function.

[0088] Combined Figure 2 with the overall flowchart shown below, please refer to Figure 3 , Figure 3 which is a schematic diagram of an embodiment of the data processing method provided for the application embodiment. As Figure 3 shown, this embodiment includes steps 301 to 306.

[0089] 301. Receive the first flashback instruction.

[0090] When the user selects to enable the flashback function, the first flashback instruction is issued.

[0091] 302. In response to the first flashback instruction, before the first modification of the first page in the database within the target period, record the first page in the flashback log.

[0092] After the data processing device receives the first flashback instruction, for the page to be modified (i.e., the page read with an X lock), the page before modification is recorded through the flashback thread. Specifically, for the first page to be modified within the target period, it is only recorded in the flashback log before the first modification. That is to say, even if the first page is modified multiple times within the target period, only one initial page is recorded. For the pages that have no modification operations within the target period, no processing is performed. It should be noted that the specific process of recording the first page is to first copy the first page to the flashback buffer, and then read the first page from the flashback buffer and record it in the flashback log. After reading the first page from the flashback buffer, the first page no longer exists in the flashback buffer.

[0093] In a possible solution, the target period is the CKPT period when the first modification of the first page is made after receiving the first flashback instruction. That is to say, the first page at this time is the original page after receiving the first flashback instruction. This possible solution can be applied to the scenario where the database needs to be restored to the moment when the flashback is enabled. Exemplarily, the user issues the first instruction before upgrading the system, and an error occurs during the system upgrade. At this time, the database can be quickly restored to the state before the system upgrade through the original page recorded in the flashback log before the system upgrade.

[0094] In another possible solution, the target period is a single CKPT period. That is, in each CKPT period when there is a modification operation on the first page, the first page will be recorded in the flashback log before the first modification of the first page within the CKPT period. In other words, for each CKPT period with a modification operation on the first page, an initial page of the first page in that period will be recorded in the flashback log. The flashback log will include versions of multiple first pages, and each first page corresponds to a CKPT period. In this possible solution, the flashback log records the initial page of the first page in each CKPT period, so that the page closer to the user-specified time point for restoring the database can be found, and then the database can be quickly restored to the state at the specified moment.

[0095] In another possible solution, the target period includes N CKPT periods, where N is an integer greater than 1. That is, in every N CKPT periods with a modification operation on the first page, the first page will only be recorded in the flashback log before the first modification of the first page within these N CKPT periods. That is to say, every N CKPT periods will record a first page in the flashback log, and the flashback log will also include multiple versions of the first page, and each version of the first page corresponds to N CKPT periods. Exemplarily, if N is 5, then only an initial page (i.e., the first page itself) will be recorded every 5 CKPT periods. Compared with recording a first page in each CKPT period, recording one first page in multiple CKPT periods can further save the disk space overhead. However, it may also cause the time interval between the first page recorded in the flashback log and the user-specified time point to be relatively long, thus requiring a longer time to restore the database.

[0096] It can be understood that during the operation of the flashback function, the user can also adjust the value of N. For example, when the user enables the flashback function, N is set to 3, that is, a first page is recorded every 3 CKPT periods. During the operation of the flashback function, N can be adjusted to 5, that is, a first page is recorded every 5 CKPT periods. Or, it can also be combined with the solution where the target period is a single CKPT period. For example, when the database flashback operation is more likely to occur when the flashback function is just enabled, an initial page will be recorded in each CKPT period during this part of the CKPT periods. For the subsequent CKPT periods, an initial page will be recorded every N CKPT periods, so as to improve the speed of database restoration and reduce the disk space occupied.

[0097] 303. Modify the first page.

[0098] After reading the first page from the disk through an exclusive lock (X-lock), the first page is modified to obtain a second page. A page that has been modified but not yet flushed to disk can be called a dirty page. Instead of flushing the page immediately after modification, it is flushed collectively at the end of a CKPT cycle. The modified page is first cached in the dirty page queue. There are usually multiple dirty pages in the dirty page queue.

[0099] After modifying the first page to obtain the second page, the second page is added to the dirty page queue.

[0100] 304. Flush the second page to disk.

[0101] When it is time to flush to disk, the second page is removed from the dirty page queue and written to the disk.

[0102] Optionally, to ensure that the database can perform flashback operations properly, before flushing the second page to disk, check whether the corresponding first page still exists in the flashback buffer. If it exists, it means that the first page has not been recorded in the flashback log. The data processing device executes the flashback thread to read the first page from the flashback buffer and write it to the flashback log, thus fully ensuring that the initial page has been recorded in the flashback log.

[0103] It should be noted that modifying the first page and recording the first page in the flashback log can be executed in parallel. That is to say, steps 303, 304 (i.e., page modification and flushing) and steps 301, 302 (i.e., flashback log flushing) are asynchronous mechanisms. Multiple threads work asynchronously, which will not block database operations, thus ensuring that the performance of database operations does not decline.

[0104] 305. Receive a second flashback instruction.

[0105] After the user enables the flashback function, when the database needs to be restored, a second flashback instruction is sent. The second flashback instruction carries the time point that needs to be restored.

[0106] 306. In response to the second flashback instruction, restore the database to the state at the specified moment based on the flashback log and the database's redo log.

[0107] After the data processing device receives the second flashback instruction, it performs a flashback operation on the database. Specifically, based on the specified time carried in the second flashback instruction, the corresponding target page is determined from the flashback log. For example, if the specified time is 9:00 am, it is necessary to restore the database to the state at 9:00 am. At this time, the target page with the recording time closest to 9:00 am is found from the flashback log, and a flashback operation is performed according to the target page to restore the data to the state of the target page. Then, replay is performed according to the redo log, so as to restore the database to the state at the specified time. The closer the recording time of the page is to the specified time, the shorter the duration required for subsequent replay according to the redo log. It should be noted that in the embodiments of the present application, if there are uncommitted transactions during the flashback operation, it is also necessary to perform a rollback operation through undo data.

[0108] It should be understood that the pages that need to be restored are numerous pages with modification operations before the specified time, and the target page is the version of each page in the numerous pages that is closest to the specified time.

[0109] Optionally, when the target period is a single CKPT period or N CKPT periods, multiple versions of the first page may be recorded in the flashback log. For example, when the target period is a single CKPT period, page A has modification operations in 20 CKPT periods, then 20 versions of page A will be recorded in the flashback log. In order to find the target page from the 20 versions of the page, the currently widely used solution in the industry is to read the pages in sequence until the required version is found, and this solution will consume a lot of time.

[0110] In order to quickly determine the target page from multiple versions, a fast search structure is proposed in this embodiment. Specifically, an index structure is established for multiple versions of a page. The index structure can be a linked list or a balanced tree, etc. Among them, the balanced tree can be a B-tree, a B* tree or a B+ tree. The index structure can provide an effect similar to a directory, so that the required target page can be quickly determined from multiple pages.

[0111] Optionally, in order to ensure the consistency of the database, the redo log from the RCY point to the LRP point is recorded in the flashback log, so that even if the redo log is archived and cleaned, the replay operation can be performed according to this part of the redo log cached in the flashback log, ensuring the stability of the solution.

[0112] It can be understood that steps 305 and 306 may occur before step 304, that is, flashback is performed according to the flashback log before writing the modified page to the disk, and after the flashback, it is no longer necessary to execute step 304 to write the dirty pages in this CKPT period to the disk.

[0113] In this embodiment, in the target period, the first page is recorded in the flashback log only before the first modification to the first page. Based on this first page, the database can be flashed back to the state before the first modification of the page in the target period, and then replayed according to the redo log, so that the database can be quickly restored to the state at a specified moment. Since only one initial page of the page with modification operations is recorded in the target period, the overhead of disk space can be greatly saved. Moreover, only recording one initial page in the target period also results in fewer historical versions of the page recorded in the flashback log, so that the target page needed can be quickly determined, improving the flashing-back rate of the database. In addition, in this embodiment, a fast search structure is constructed through a linked list or a balanced tree, which can further improve the speed of searching for the target page, and thus further improve the flashing-back efficiency of the database. Furthermore, recording the first page in the flashback log and modifying the first page can be executed in parallel, so as to ensure that the database service performance does not decline.

[0114] As can be seen from Figure 3 the embodiment shown, when the target period is the CKPT period when the first modification to the first page is made after receiving the first flashback instruction, the database can be flashed back to the moment when the flashback function is enabled. When the target period is a single CKPT period or multiple CKPT periods, the database can be flashed back to any specified moment. Thus, the flashback function in the embodiments of the present application can be divided into two categories, or rather, the embodiments of the present application provide two interfaces for the flashback function. One is flashback point flashback. In this function, the database can be restored to the state at the moment when the flashback function is enabled (i.e., the moment when the user sends the first instruction), and only the initial page in the first CKPT period with modification operations needs to be recorded, which can greatly reduce the occupied disk space. The other is time point flashback. In this function, the database can be quickly restored to the state at any time point after the flashback moment is enabled. It can be understood that the database can actually be restored to any time point through the flashback point flashback function, that is, after flashing back to the moment when the flashback function is enabled, and then replayed according to the redo log, but this will take more time. And through the time point flashback function, the database can also be restored to the state at the flashback function opening point, that is, find the page before the first modification of the first page recorded in the flashback log after the flashback function is enabled (i.e., the original page), and then restore the database to the state before the first modification based on the original page. The state before the first modification is the state at the flashback function opening point. Although the time point flashback can also implement the function of flashback point flashback, in the scenario where only the flashback function opening point needs to be restored, this will cause additional overhead of disk space and consume more time. The flashback point flashback function can be applied to the database upgrade scenario, and the time period flashback function can be applied to the scenario of being attacked externally or the scenario of recovering from misoperations. In the embodiments of the present application, the functions of these two interfaces are not specifically limited.

[0115] The following, in conjunction with Figure 4 and Figure 5 will describe these two interfaces. Please first refer to Figure 4 , which is a schematic diagram of an embodiment under the flashback function of the flashback point. As Figure 4 shown, this embodiment includes steps 401 to 405.

[0116] 401. The user sends a first flashback instruction to enable the flashback function of the flashback point.

[0117] 402. After receiving the first flashback instruction, the data processing device records the redo log between the RCY point and the LRP point into the flashback log, so that even if the redo log is archived and cleared, the replay operation can be performed according to this part of the redo log cached in the flashback log, ensuring the stability of the solution.

[0118] 403. Before the first modification of the first page after receiving the first flashback instruction, record the first page into the flashback log. That is to say, for a page with modification operations, only one original page will be recorded into the flashback log.

[0119] 404. The user sends a second flashback instruction. In response to the second flashback instruction, the data processing device flashes back the page in the database to the state before the first modification according to the first page recorded in the flashback log.

[0120] 405. Subsequently, replay is performed according to the relevant redo log to make the database reach a consistent state. The relevant redo log can be read from the flashback log or from the redo log. For uncommitted transactions, rollback is performed through undo data.

[0121] In this embodiment, for multiple modifications of a page, only one original page will be recorded, effectively reducing the space overhead. In the scenario of frequently modifying the database, compared with the solution for implementing the database flashback function based on undo data described above, more than 90% of the space can be saved. Compared with the solution of physical backup combined with PITR described above, more than 99% of the space can be saved.

[0122] Moreover, in this embodiment, only one original version is recorded for a page, and there is no need to construct historical pages. The recorded original page is the target page, thus reducing the process of determining the target page from multiple historical versions, which can greatly improve the flashback speed. Compared with the above two solutions (i.e., flashback based on undo data and flashback based on physical backup combined with PITR), more than 90% of the time can be saved.

[0123] Next, please refer to Figure 5, which is a schematic diagram of an embodiment under the time point flashback function. As Figure 5 shown, this embodiment includes steps 501 to 505.

[0124] 501. The user sends a first flashback instruction to enable the time point flashback function.

[0125] 502. After receiving the first flashback instruction, before the first modification of the first page within a single CKPT cycle, or before the modification of the first page within N CKPT cycles, record the first page in the flashback log. That is, after receiving the first flashback instruction, an initial page will be recorded for each CKPT cycle with a modification operation on the first page, or an initial page will be recorded for every N CKPT cycles with a modification operation on the first page.

[0126] 503. As can be seen from step 502, multiple different versions of the first page will be recorded, corresponding to different CKPT cycles respectively. To quickly find the target page corresponding to the specified moment by the user, a fast search structure is constructed through a linked list or a balanced tree. The linked list or the balanced tree will include multiple versions of a page, and the linked list or the balanced tree can provide a function similar to a directory, so that the target page can be quickly determined from multiple versions.

[0127] 504. The user sends a second flashback instruction. In response to the second flashback instruction, the data processing device flashes the page in the database back to the state of the target page.

[0128] 505. Then replay according to the redo log to make the database reach a consistent state. For uncommitted transactions, roll back through the undo data.

[0129] In this embodiment, no matter how many times the first page is modified in each CKPT cycle or every N CKPT cycles, only one initial page is recorded in each CKPT cycle or every N CKPT cycles, so that the space overhead can be effectively reduced. In the scenario of frequently modifying the data library, compared with the scheme of implementing the database flashback function based on undo data described above, more than 50% of the space can be saved. Compared with the scheme of physical backup combined with PITR described above, more than 99% of the space can be saved.

[0130] Recording one initial page in each CKPT cycle or every N CKPT cycles also greatly reduces the number of page versions, thereby reducing the flashback duration. And, in this embodiment, a fast search structure is also constructed, so that the flashback speed can be further improved. Compared with the above two schemes (i.e., flashing back based on undo data and flashing back based on physical backup combined with PITR), more than 90% of the time can be saved.

[0131] Combining the above content, the typical application scenarios of the embodiments of the present application will be described below. Please first refer to Figure 6 , which is the application of the flashback point flashback function in the scenario of offline database upgrade. In this scenario, when the database upgrade fails, the database can be quickly flashed back to the state before the upgrade. Figure 6 The embodiments shown can be applied to Figure 1 the system architecture shown in Figure 6 As shown, this embodiment includes steps 601 to 606.

[0132] 601. Shut down the database software and perform file replacement (binary replacement) of the database software.

[0133] 602. Start up the database to the running state.

[0134] 603. Send the first flashback instruction to enable the flashback point flashback function.

[0135] 604. Execute the upgrade process of the database to complete the upgrade.

[0136] 605. During the execution of the upgrade process, if an error occurs or the upgrade fails, etc., flash back the pages in the database to the state before the first modification through the flashback point flashback function.

[0137] 606. After shutting down the database software again, perform file replacement (old version binary replacement) of the database software and restart the database.

[0138] Next, please refer to Figure 7 and Figure 8 , which is the application of the time point flashback function in the scenario of restoring from incorrect operations in the primary and standby dual-machine. In this scenario, when an incorrect logical operation occurs in the database, the database can be quickly flashed back to the state at a specified moment. Figure 8 The embodiments shown can be applied to Figure 7 the system architecture shown in Figure 7 The system architecture shown will be described first.

[0139] As Figure 7 shown, this database system includes two database servers, namely the primary database server and the standby database server. Among them, the primary database server is used to execute database operations, and the standby database server serves as the disaster recovery standby of the primary database server. Compared with Figure 1 the system architecture shown in Figure 7The database system shown has added a high availability (HA) module to the primary database server and the standby database server. Through the HA module, redo logs and acknowledge character (ACK) messages can be transmitted, thus ensuring the consistency of the primary and standby servers. For Figure 7 the remaining modules of the database system shown, they are the same as Figure 1 the system architecture type shown. Details are not elaborated here.

[0140] Next, in combination with Figure 8 the application of the point-in-time flashback function in the scenario of recovering from misoperations on the primary and standby servers will be described. As Figure 8 shown, this embodiment includes steps 801 to 806.

[0141] 801. To minimize the impact on the services on the primary database server, the point-in-time flashback function is only enabled on the standby database server. Of course, the point-in-time flashback function can also be enabled on both the primary and standby servers. Details are not limited here.

[0142] 802. Execute business logic on the primary database server.

[0143] 803. The standby database server receives the redo logs transmitted by the primary database server through the HA module and synchronizes the data according to the redo logs.

[0144] 804. When a business logic error occurs on the primary database server, shut down the primary database server.

[0145] 805. Specify a time point before the error occurred for the standby database server, and use the point-in-time flashback function to flash back the standby database server to the state before the error occurred.

[0146] 806. Convert the standby database server to the primary database server and continue business processing, thus ensuring the continuity of the business.

[0147] The embodiments of the present application have been described from the perspective of methods above. Next, the related devices in the embodiments of the present application will be introduced from the perspective of specific device implementation.

[0148] Please refer to Figure 9 , a schematic diagram of a data processing device 900 is provided in the embodiments of the present application. Among them, the data processing device 900 includes a receiving unit 901, a recording unit 902, and a recovery unit 903.

[0149] The receiving unit 901 is configured to receive a first flashback instruction.

[0150] A recording unit 902, configured to, in response to a first flashback instruction, record a first page in a database to a flashback log before the first modification of the first page in a target period for the first time.

[0151] A receiving unit 901 is further configured to receive a second flashback instruction.

[0152] A recovery unit 903, configured to, in response to the second flashback instruction, restore the database to a state at a specified moment based on the flashback log and a redo log of the database.

[0153] Optionally, the target period is a checkpoint period when the first modification of the first page occurs for the first time after receiving the first flashback instruction.

[0154] Optionally, the target period is a single checkpoint period, and the flashback log includes multiple first pages, where each first page corresponds to a checkpoint period.

[0155] Optionally, the target period includes N checkpoint periods, the flashback log includes multiple first pages, where each first page corresponds to N checkpoint periods, and N is an integer greater than 1.

[0156] Optionally, the recovery unit 903 is specifically configured to construct a fast lookup structure in an index structure based on multiple first pages; determine a target page corresponding to a specified moment from the multiple first pages based on the fast lookup structure; and restore the database to the state at the specified moment based on the target page and the redo log.

[0157] Optionally, the recording unit 902 is further configured to record log records between a recovery point and a minimum recovery point in the redo log to the flashback log.

[0158] Optionally, the data processing device 900 further includes a modification unit 904, configured to modify the first page to obtain a second page; and a disk writing unit 905, configured to write the second page to disk.

[0159] Optionally, the recording unit 902 is specifically configured to copy a page to a flashback buffer; record the page from the flashback buffer to the flashback log; the data processing device 900 further includes an inspection unit 906, configured to inspect whether a first page exists in the flashback buffer; and a writing unit 907, configured to, when the first page exists, write the first page from the flashback buffer to the flashback log.

[0160] Optionally, modifying the first page and recording the first page to the flashback log are parallel operations.

[0161] Each module in the data processing device 900 executes the operations of the data processing device in the foregoing Figures 2 to 6 and Figure 8 the operations of the data processing device in the illustrated embodiments, which are not specifically described herein.

[0162] Please refer to the following Figure 10 , which is a possible structural schematic diagram of the data processing device 1000 provided by the embodiment of the present application, including a processor 1001, a communication interface 1002, a memory 1003, and a bus 1004. The processor 1001, the communication interface 1002, and the memory 1003 are interconnected through the bus 1004. In the embodiment of the present application, the processor 1001 is used to control and manage the actions of the data processing device. For example, the processor 1001 is used to execute Figure 3 the steps executed by the data processing device in the method embodiment shown. The communication interface 1002 is used to support the data processing device to communicate. The memory 1003 is used to store the program code and data of the data processing device.

[0163] Among them, the processor 1001 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array, or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute various exemplary logical blocks, modules, and circuits described in combination with the disclosure of the present application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, and so on. The bus 1004 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, Figure 10 only a thick line is shown in

[0164] but it does not mean that there is only one bus or one type of bus. Figures 2 to 6 and Figure 8 the method in the embodiments shown.

[0165] The embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium includes instructions. When the instructions run on a computer, the computer is caused to execute the foregoing Figures 2 to 6 and Figure 8 the method in the embodiments shown.

[0166] An embodiment of the present application also provides a chip system, which includes at least one processor and a communication interface. The communication interface and the at least one processor are interconnected by a line. The at least one processor is configured to run a computer program or instruction to execute the method in the foregoing Figures 2 to 6 and Figure 8 method in the illustrated embodiment.

[0167] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.

[0168] Those skilled in the art can clearly understand that for the convenience and brevity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be elaborated herein.

[0169] In several embodiments provided by the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces. The indirect couplings or communication connections of devices or units can be in electrical, mechanical, or other forms.

[0170] The units described as separate components may or may not be physically separated. The components displayed as units may or may not be physical units, that is, they can be located in one place, or they can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0171] In addition, the functional units in each embodiment of the present application can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.

[0172] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, read-only memory), random access memories (RAM, random access memory), magnetic disks, or optical discs.

Claims

1. A data processing method, characterized in that, including: Receiving a first flashback instruction; In response to the first flashback instruction, before the first modification of the first page in the database within a target period, recording the first page to a flashback log; Receiving a second flashback instruction; In response to the second flashback instruction, restoring the database to the state at a specified moment based on the flashback log and the redo log of the database.

2. The method according to claim 1, wherein The target period is the checkpoint period when the first page is first modified after receiving the first flashback instruction.

3. The method according to claim 1, wherein The target period is a single checkpoint period, and the flashback log includes multiple first pages, where each first page corresponds to one checkpoint period.

4. The method according to claim 1, characterized in that, The target period includes N checkpoint periods, and the flashback log includes multiple first pages, where each first page corresponds to the N checkpoint periods, and N is an integer greater than 1.

5. The method according to claim 3 or 4, characterized in that, The restoring the database to the state at a specified moment based on the flashback log and the redo log of the database includes: Constructing a fast lookup structure in an index structure based on multiple first pages; Determining a target page corresponding to the specified moment from multiple first pages based on the fast lookup structure; Restoring the database to the state at the specified moment based on the target page and the redo log.

6. The method according to any one of claims 1 to 5, characterized in that, After receiving the first flashback instruction, the method further includes: Recording the log records between the recovery point and the minimum recovery point in the redo log to the flashback log.

7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Modifying the first page to obtain a second page; Flushing the second page to disk.

8. The method according to claim 7, characterized in that, The recording the page to the flashback log includes: Copying the page to a flashback buffer; Recording the page from the flashback buffer to the flashback log; Before flushing the second page to disk, the method further includes: Checking whether the first page exists in the flashback buffer; If it exists, writing the first page from the flashback buffer to the flashback log.

9. The method according to any one of claims 1 to 8, characterized in that, Modifying the first page and recording the first page to the flashback log are parallel operations.

10. A data processing device, characterized in that, including: A receiving unit for receiving a first flashback instruction; A recording unit for, in response to the first flashback instruction, before the first modification of the first page in the database within a target period, recording the first page to a flashback log; The receiving unit is further configured to receive a second flashback instruction; A restoring unit for, in response to the second flashback instruction, restoring the database to the state at a specified moment based on the flashback log and the redo log of the database.

11. The device according to claim 10, characterized in that, The target period is the checkpoint period when the first page is first modified after receiving the first flashback instruction.

12. The device according to claim 10, characterized in that The target period is a single checkpoint period, and the flashback log includes multiple first pages, where each first page corresponds to one checkpoint period.

13. The device according to claim 10, characterized in that, The target period includes N checkpoint periods, and the flashback log includes a plurality of the first pages, where each of the first pages corresponds to the N checkpoint periods, and N is an integer greater than 1.

14. The device according to claim 12 or 13, characterized in that, The recovery unit is specifically configured to: Construct a fast lookup structure based on the plurality of the first pages in an index structure manner; Determine a target page corresponding to the specified moment from the plurality of the first pages based on the fast lookup structure; Restore the database to the state at the specified moment based on the target page and the redo log.

15. The device according to any one of claims 10 to 14, characterized in that, The recording unit is further configured to: Record the log between the recovery point and the minimum recovery point in the redo log into the flashback log.

16. The device according to any one of claims 10 to 15, characterized in that, The apparatus further includes: A modification unit, configured to modify the first page to obtain a second page; A disk writing unit, configured to write the second page to disk.

17. The device according to claim 16, characterized in that, The recording unit is specifically configured to: Copy the page to the flashback buffer; Record the page from the flashback buffer to the flashback log; The apparatus further includes: A checking unit, configured to check whether the first page exists in the flashback buffer; A writing unit, configured to write the first page from the flashback buffer to the flashback log when the first page exists.

18. The device according to any one of claims 10 to 17, characterized in that Modifying the first page and recording the first page to the flashback log are parallel operations.

19. A data processing device, characterized in that, Includes: A processor and a memory; The memory is used to store instructions; The processor is used to execute the instructions stored in the memory to implement the method according to any one of claims 1 to 9.

20. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program, when executed by one or more processors, implements the method according to any one of claims 1 to 9.

21. A computer program product comprising instructions, characterized in that, When the computer program product runs on a computer, the computer is caused to execute the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Data processing method and related apparatus

    WO2025156637A1