Data verification method and device, computing equipment and computer system

By verifying the correctness of the operations of redo logs and rollback logs in the database, the problem of reducing database reliability caused by the inability to effectively judge the correctness of the logs in the prior art is solved, and the effect of improving database reliability is achieved.

CN119441233APending Publication Date: 2025-02-14HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310964664.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-01
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

In the prior art, when data is lost in the database, when data is restored by redo logs and rollback logs, it is impossible to effectively judge the correctness of the redo logs and rollback logs, resulting in a decrease in database reliability.

Method used

By verifying the correctness of operations in the redo log and rollback log, ensure the correctness of the redo log and rollback log, avoiding incorrect redo or rollback operations without knowing it.

Benefits of technology

Improves the accuracy of redo logs and rollback logs, enhances the reliability of the database, and prevents database unreliability problems caused by error logs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119441233A_ABST
    Figure CN119441233A_ABST
Patent Text Reader

Abstract

The invention provides a data verification method and device, computing equipment and a computer system, relates to the field of computers, and can improve the reliability of a database. The method comprises the steps that first operation in a redo log is verified according to first data and second data, and the first operation is used for indicating redo of the first data; and outputting a verification result, wherein the verification result comprises successful first operation verification or failed first operation verification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computers, and in particular to a data verification method, apparatus, computing device, and computer system. Background Art

[0002] At present, when data is lost in a database, redo logs and rollback logs are generally used to recover the lost data in the database. However, when the update operation stored in the redo log is different from the update operation actually performed on the data to be updated, and / or when the rollback operation stored in the rollback log is different from the rollback operation corresponding to the update operation actually performed on the data to be updated; the redo logs and rollback logs cannot be used to recover the lost data, resulting in reduced reliability of the database. Summary of the invention

[0003] The present application provides a data verification method, device, computing equipment and computer system, thereby improving the reliability of the database.

[0004] In a first aspect, an embodiment of the present application provides a data verification method, the method comprising: verifying a first operation in a redo log based on first data and second data, the first operation being used to indicate redoing the first data; outputting the verification result, the verification result comprising: verification of the first operation succeeded or verification of the first operation failed.

[0005] Since the redo log may contain errors, when it is impossible to determine whether the redo log is correct, the data is redone using the wrong redo log, and naturally the correct data cannot be obtained. However, the embodiment of the present application performs a correctness check on the operations in the redo log, thereby ensuring the correctness of the redo log. This avoids the problem of database unreliability caused by unknowingly treating the redo log with errors as a normal redo log.

[0006] In a possible implementation, the above-mentioned verification of the first operation in the redo log based on the first data and the second data specifically includes: when a result obtained by performing the first operation on the backup data of the first data is the second data, determining that the verification of the first operation is successful; when a result obtained by performing the first operation on the backup data of the first data is not the second data, determining that the verification of the first operation has failed.

[0007] In a possible implementation, before the above-mentioned output verification result, it also includes: verifying the second operation in the rollback log based on the first data and the second data, the second operation is used to indicate the rollback of the second data, and the verification result also includes: the second operation verification is successful or the second operation verification fails.

[0008] The embodiment of the present application performs a correctness check on the operations in the rollback log, thereby ensuring the correctness of the rollback log, and avoiding the problem of database unreliability caused by unknowingly treating an erroneous rollback log as a normal rollback log.

[0009] In a possible implementation, the second operation in the rollback log is verified based on the first data and the second data, specifically including: when a result obtained by performing the second operation on the second data is not the first data, determining that the second operation verification has failed; when a result obtained by performing the second operation on the second data is the first data, determining that the second operation verification has succeeded.

[0010] In a possible implementation, before verifying the first operation in the redo log according to the first data and the second data, the method further includes: updating the first data to obtain the second data.

[0011] The embodiment of the present application verifies the update operation of the updated data stored in the redo log and the rollback operation corresponding to the update operation of the updated data stored in the rollback log after updating the data, and outputs the verification result; so that the user can promptly obtain the erroneous operation in the redo log and / or the rollback log, and handle the erroneous operation, thereby improving the accuracy of the redo log and the rollback log, and further improving the reliability of the database.

[0012] In one possible implementation, the above-mentioned updating of the first data to obtain the second data includes: locking the first data, updating the first data to obtain the second data, the lock being used to prohibit threads other than the first thread from accessing the first data, and the first thread being used to update the first data; after verifying the second operation in the rollback log based on the first data and the second data, it also includes: releasing the lock.

[0013] The present application locks the first data to be updated, thereby solving the problem of first data update errors caused by other threads performing update operations on the data during the process of updating the first data, thereby improving the reliability of the database.

[0014] In one possible implementation, the second operation in the rollback log is verified based on the first data and the second data, including: performing the second operation on the second data to obtain fourth data; when the fourth data is different from the backup data of the first data, determining that the second operation verification has failed; when the fourth data is the same as the backup data of the first data, determining that the second operation verification has succeeded.

[0015] In a possible implementation, before verifying the first operation in the redo log according to the first data and the second data, the method further includes: obtaining the first operation from the redo log according to a first initial position and a first end position; wherein the first initial position is used to indicate the starting position of the first operation in the redo log; and the first end position is used to indicate the end position of the first operation in the redo log.

[0016] In one possible implementation, before verifying the second operation in the rollback log based on the first data and the second data, the method also includes: obtaining the second operation from the rollback log based on a second initial position and a second end position; the second initial position is used to indicate the starting position of the second operation in the rollback log; and the second end position is used to indicate the end position of the second operation in the rollback log.

[0017] In a second aspect, the present application provides a data verification device, which includes: a processing unit and a communication unit; the processing unit is used to verify a first operation in a redo log based on first data and second data, the first operation being used to indicate redoing the first data; the communication unit is used to output a verification result, the verification result including: the first operation verification is successful or the first operation verification fails.

[0018] In one possible implementation, the processing unit is specifically used to determine that the first operation verification is successful when the result obtained by performing the above-mentioned first operation on the backup data of the first data is the second data; the processing unit is also specifically used to determine that the first operation verification has failed when the result obtained by performing the above-mentioned first operation on the backup data of the first data is not the second data.

[0019] In one possible implementation, the processing unit is further used to verify the second operation in the rollback log based on the first data and the second data, the second operation is used to indicate the rollback of the second data, and the verification result also includes: the second operation verification is successful or the second operation verification fails.

[0020] In one possible implementation, the processing unit is specifically used to determine that the second operation verification has failed when a result obtained by performing the second operation on the second data is not the first data; the processing unit is also specifically used to determine that the second operation verification has succeeded when a result obtained by performing the second operation on the second data is the first data.

[0021] In a possible implementation manner, the processing unit is further configured to update the first data to obtain the second data.

[0022] In a possible implementation, the processing unit is specifically used to: lock the first data, update the first data to obtain the second data, the lock is used to prohibit threads other than the first thread from accessing the first data, the first thread is used to update the first data; release the lock.

[0023] In a possible implementation, the processing unit is specifically configured to: when the verification state of the database is on, verify the first operation and the second operation according to the first data and the second data.

[0024] In one possible implementation, the processing unit is further used to obtain a first operation from the redo log based on a first initial position and a first end position; wherein the first initial position is used to indicate a starting position of the first operation in the redo log; and the first end position is used to indicate an end position of the first operation in the redo log.

[0025] In one possible implementation, the processing unit is also used to obtain a second operation from the rollback log based on a second initial position and a second end position; the second initial position is used to indicate the starting position of the second operation in the rollback log; and the second end position is used to indicate the end position of the second operation in the rollback log.

[0026] In a third aspect, the present application provides a computer device, comprising a memory and a processor, wherein the memory is coupled to the processor; the memory is used to store computer program code, wherein the computer program code comprises computer instructions; when the computer instructions are executed by the processor, the computer device executes the method described in the first aspect and any one of its possible implementations.

[0027] In a fourth aspect, the present application provides a computer system, the system comprising at least one computer device, each computer device comprising a processor and a memory; the processor of the at least one computer device is used to execute instructions stored in the memory of the at least one computer device, so that the computer device cluster executes the method described in the first aspect above and any one of its possible implementation methods.

[0028] In a fifth aspect, the present application provides a computer-readable storage medium having computer instructions stored thereon. When the computer instructions are executed on a computing device, the computing device executes the method described in the first aspect above and any one of its possible implementations.

[0029] In a sixth aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect and any one of its possible implementations.

[0030] It should be understood that the beneficial effects achieved by the technical solutions of the second to sixth aspects of the present application and the corresponding possible implementation methods can be referred to the technical effects of the first aspect and its corresponding possible implementation methods mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1A schematic diagram of the hardware structure of a computer device provided in an embodiment of the present application;

[0032] Figure 2 A schematic diagram of a data verification method flow provided in an embodiment of the present application;

[0033] Figure 3 A schematic flow chart of a method for verifying a first operation provided in an embodiment of the present application;

[0034] Figure 4 A schematic flow chart of a method for verifying a second operation provided in an embodiment of the present application;

[0035] Figure 5 A schematic diagram of a database setting interface provided in an embodiment of the present application;

[0036] Figure 6 A schematic diagram of another data verification method flow chart provided in an embodiment of the present application;

[0037] Figure 7 A schematic diagram of the structure of a data verification device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0039] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, first data and second data are used to distinguish different data rather than to describe a specific order of data.

[0040] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0041] First, some concepts involved in a data verification method, device, computing device, and computer system provided in an embodiment of the present application are explained as follows:

[0042] Database: It is a "warehouse that organizes, stores and manages data according to data structure"; it is a collection of large amounts of data that is stored in a computer for a long time, organized, shareable and uniformly managed.

[0043] Rollback: Rollback refers to the act of restoring a program or data to its last correct state when a program or data processing error occurs.

[0044] Redo log: It is a log generated by the storage engine layer. It stores data update operations, including adding data, deleting data, or modifying data. Redo log is also called redo log.

[0045] Rollback log (undo): It is a log generated by the storage engine layer, which stores the rollback operations corresponding to the data update operations; the rollback log is also called the undo log.

[0046] Data block: It is the smallest storage and processing unit in the database.

[0047] Page: The unit of storage and processing data in a storage device. The size of a page can be 16k, and a page can also be called a data page.

[0048] Data extent: A unit for storing data in a storage device, wherein the storage space occupied by a data extent is larger than the storage space occupied by a page, that is, a data extent includes multiple data pages.

[0049] As is known to all, the process of updating the data to be updated in the database includes: the central processing unit (CPU) in the storage device where the database is located caches the data to be updated in the memory of the storage device, and then the CPU performs an update operation on the data to be updated in the memory to obtain the updated data; subsequently, the CPU will periodically persist (store) the non-persistent data in the memory to the database. In the case that there is non-persistent data in the memory, once the storage device fails, the non-persistent data in the memory will be lost; at this time, the lost data needs to be recovered.

[0050] A common data recovery method is to use redo logs and rollback logs to recover lost data in the database. However, when the operations stored in the redo logs and / or rollback logs are inaccurate, the redo logs and rollback logs cannot be used to recover the lost data, resulting in reduced reliability of the database. For example, when there is a logical failure in the system that writes update operations to the redo log, the update operations performed on the data to be updated stored in the redo log are different from the actual update operations performed on the data to be updated, that is, the update operations stored in the redo log are inaccurate. Similarly, when there is a logical failure in the system that writes rollback operations to the rollback log, the rollback operations stored in the rollback log are different from the rollback operations corresponding to the actual update operations performed on the data to be updated, that is, the rollback operations stored in the rollback log are inaccurate.

[0051] Based on this, the embodiment of the present application performs correctness verification on the operations in the redo log, thereby ensuring the correctness of the redo log, and avoiding the problem of database unreliability caused by unknowingly treating the redo log with errors as normal redo logs.

[0052] The implementation of the data verification method provided by the present application is described in detail below with reference to the accompanying drawings.

[0053] Figure 1 is a hardware schematic diagram of a computer device provided in an embodiment of the present application, such as Figure 1 As shown, the computer device may include a processor 101 , a memory 102 , and a communication interface 103 .

[0054] The processor 101 includes one or more CPUs, which may be single-core CPUs (single-CPU) or multi-core CPUs (multi-CPU).

[0055] In the present application, the processor 101 is used to verify the first operation in the redo log according to the first data and the second data; the processor 101 is also used to verify the second operation in the redo log according to the first data and the second data.

[0056] The memory 102 includes, but is not limited to, random access memory (RAM), read only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical memory or magnetic disk memory.

[0057] Optionally, the processor 101 implements the data verification method provided in the embodiment of the present application by reading the instructions stored in the memory 102. When the processor 101 implements the method in the above embodiment by reading the instructions stored in the memory 102, the memory 102 stores instructions for implementing the data verification method provided in the embodiment of the present application.

[0058] Optionally, the above-mentioned storage 102 includes a memory 1021, and the memory 1021 includes a cache of redo logs (redo cache for short) and a cache of rollback logs (rollback cache for short); wherein the memory 1021 includes but is not limited to a random access memory (RAM) or a flash memory (flash memory).

[0059] Optionally, the memory 102 further includes a hard disk 1022; the hard disk 1022 includes a redo log and a rollback log; wherein the hard disk 1022 includes but is not limited to a solid state drive or a mechanical hard disk.

[0060] In one embodiment, when the processor 101 needs to store an update operation in the redo log, the processor 101 first stores the update operation in the redo cache, and then the processor 101 periodically persists the update operation that is not persisted in the redo cache to the redo log. Similarly, when the processor 101 needs to store a rollback operation in the rollback log, the processor 101 first stores the rollback operation in the rollback cache, and then the processor 101 periodically persists the rollback operation that is not persisted in the rollback cache to the redo log.

[0061] The communication interface 103 is a wired interface (port), such as a fiber distributed data interface (FDDI) or a gigabit Ethernet (GE) interface. Alternatively, the communication interface 103 is a wireless interface. It should be understood that the communication interface 103 includes a plurality of physical ports, and the communication interface 103 is used to output the verification result.

[0062] Optionally, the computer device further includes a bus 104 , and the processor 101 , the memory 102 , and the communication interface 103 are usually interconnected via the bus 104 , or are interconnected in other ways.

[0063] It should be noted that the embodiments of the present application are based on Figure 1 The processor 101 (abbreviated as: CPU) in the figure is used as the execution subject for explanation and will not be described in detail later.

[0064] The present application embodiment provides a data verification method, such as Figure 2 As shown, the data verification method may include: S110-S130.

[0065] S110: The CPU verifies a first operation in a redo log according to first data and second data.

[0066] The second data is data obtained after the CPU performs an update operation (ie, the first operation) on the first data; wherein the update operation includes at least one of a adding operation, a deleting operation, or a modifying operation.

[0067] It should be noted that the above-mentioned first data can be data in a data page in the database, or data in a data area in the database. The specific embodiment of the present application does not limit the data unit of the first data. The embodiment of the present application takes the first data as all the data in a data page as an example for explanation, and will not be repeated later.

[0068] The redo log is used to store update operations for updating data in the database; for example, when the CPU modifies the value of the data C in the above-mentioned first data from x to m, the CPU stores the modification operation in the redo log.

[0069] The database may be a relational database, such as MySQL or Oracle; or a non-relational database, such as MongoDB or Redis. The specific embodiments of the present application do not limit the types of the above databases.

[0070] The first operation is an update operation stored (or recorded) in the redo log to update the first data to the second data; that is, the first operation is used to instruct to redo the first data.

[0071] In one implementation, the specific implementation process of the above S110 is as follows: Figure 3 As shown, it includes: S110a-S110b.

[0072] S110a: The CPU obtains a first operation from a redo log.

[0073] It should be noted that the update operation stored in the redo log may be different from the update operation actually performed by the CPU on the first data. For example, when a logical fault occurs when the CPU stores the first operation in the redo log (such as a crawler bug in the code), the first operation stored in the redo log may be different from the update operation actually performed by the CPU on the first data.

[0074] In some embodiments, the CPU obtains the first operation from the redo log according to the first initial position and the first end position.

[0075] The first initial position is used to indicate the starting position of the first operation in the redo log. The first end position is used to indicate the end position of the first operation in the redo log.

[0076] Exemplarily, assuming that the redo log includes update operations 1-2, as shown in Table 1 below, update operation 1 is used to indicate the deletion of data with index 1 in data page numbered 001 in physical address 1. Update operation 2 is used to indicate the addition of third data to data page 010 in physical address 2. After the CPU modifies the value of the age field in the record with index 1 in page 011 in physical address 3 to 17, the CPU stores the update operation 3 in the redo log; assuming that update operation 3 is the first operation, then at this time, the first initial position is the position after update operation 2 and before update operation 3; the first end position is the position after update operation 3.

[0077] Table 1

[0078]

[0079] Optionally, when the first operation does not exist in the redo log (ie, the first initial position is the same as the first end position), the CPU determines that the first operation check fails.

[0080] S110b: The CPU determines whether a result obtained by performing the first operation on the backup data of the first data is the second data.

[0081] The above-mentioned backup data is the first data backed up by the CPU before updating the first data. The backup data can be stored in the cache of the current thread (i.e., the cache of the current thread in the CPU) or in the memory of the device where the CPU is located. The specific embodiment of the present application does not limit the storage location of the backup data.

[0082] It should be noted that the essence of the above S110b is to determine whether the execution result of the first operation is the same as the second data. The specific implementation of S110b can be to perform the first operation on the backup data of the first data to obtain the third data, and then, by comparing whether the third data is the same as the above second data, to determine whether the execution result of the first operation is the same as the second data. The specific implementation of S110b can also be to predict the possibility that the result obtained by performing the first operation on the above first data is the same as the second data through artificial intelligence (AI) process prediction, wherein when the possibility is greater than or equal to a threshold, it is determined that the execution result of the first operation is the same as the second data; when the possibility is less than the threshold, it is determined that the execution result of the first operation is different from the second data. The specific embodiment of the present application does not limit the implementation method of the above S110b.

[0083] When a result obtained by performing the first operation on the backup data of the first data is the second data, the CPU determines that the first operation verification is successful.

[0084] When a result obtained by performing the first operation on the backup data of the first data is not the second data, the CPU determines that the first operation verification fails.

[0085] S120: The CPU verifies the second operation in the rollback log according to the first data and the second data.

[0086] The rollback log is used to store the rollback operation corresponding to the update operation (such as the first operation) performed by the CPU on the data in the database; that is, the second operation is the rollback operation corresponding to the first operation; wherein the rollback operation is the reverse operation of the update operation performed by the CPU on a data.

[0087] For example, when the first operation is to insert data A into the database, the second operation is to delete the data A from the database; when the first operation is to delete data B in the database, the second operation is to insert data B into the database; when the first operation is to modify the value x of data C in the database to m, the second operation is to modify the value of data C in the database to x.

[0088] The second operation is a rollback operation stored in the rollback log to roll back the second data to the first data; that is, the second operation is used to instruct to roll back the second data.

[0089] In one implementation, the specific implementation process of the above S120 is as follows: Figure 4 As shown, it includes S120a-S120b.

[0090] S120a: The CPU obtains a second operation from the rollback log.

[0091] It should be noted that the second operation stored in the rollback log may be different from the rollback operation corresponding to the update operation actually performed by the CPU on the first data. For example, when a logical failure occurs during the process of the CPU storing the second operation in the rollback log, the second operation stored in the rollback log may be different from the rollback operation corresponding to the update operation actually performed by the CPU on the first data in S120.

[0092] The implementation process of the above S120a includes: the CPU obtains the second operation from the rollback log according to the second initial position and the second end position.

[0093] The second initial position is used to indicate the starting position of the second operation in the rollback journal; that is, the second initial position is the position when the second operation is not stored in the rollback journal.

[0094] The second end position is used to indicate the end position of the second operation in the rollback journal; that is, the second end position is the position after the second operation is stored in the rollback journal.

[0095] Optionally, when the second operation does not exist in the rollback log (ie, the second initial position is the same as the second end position), the CPU determines that the second operation verification fails.

[0096] S120b: The CPU determines whether a result obtained by performing the second operation on the second data is the first data.

[0097] It should be noted that the essence of the above S120b is to determine whether the execution result of the second operation is the same as the first data. The specific implementation of S120b can be: perform the second operation on the second data to obtain the fourth data; then, by comparing whether the fourth data is the same as the above first data, determine whether the execution result of the second operation is the same as the first data. The specific implementation of S120b can also be to predict the possibility that the result obtained by performing the second operation on the above second data is the same as the first data through AI process prediction, wherein when the possibility is greater than or equal to a threshold, it is determined that the execution result of the second operation is the same as the first data; when the possibility is less than the threshold, it is determined that the execution result of the second operation is different from the first data. The specific embodiment of the present application does not limit the implementation method of the above S120b.

[0098] When a result obtained by performing the second operation on the second data is the first data, the CPU determines that the second operation verification is successful.

[0099] When a result obtained by performing the second operation on the second data is not the first data, the CPU determines that the second operation verification fails.

[0100] It should be noted that the above-mentioned CPU may execute S110 first and then execute S120; or may execute S120 first and then execute S110. Specifically, the embodiment of the present application does not limit the order in which the CPU executes the above-mentioned S110 and S120.

[0101] In one embodiment, the CPU executes S110-S120 when determining that the verification state of the above database is on; the verification state is used to indicate whether the CPU verifies the relevant operations of the data stored in the redo log and the rollback log after the data is updated.

[0102] Optionally, the specific state of the verification state may be specified by the user through the client, or may be obtained by the CPU by reading a configuration file of the database. The specific embodiment of the present application does not limit the specific state acquisition method of the verification state.

[0103] For example, assuming that the specific status of the verification status is specified by the user through the client; then the client interface displays the following Figure 5 The database setting interface shown in the figure includes a verification status label, and an on-state selection box and a off-state selection box corresponding to the verification status label. When the user selects the on-state selection box of the verification status, the verification status of the database is in the on-state, and at this time, the CPU executes the above S110-S120. When the user selects the off-state selection box of the verification status, the verification status of the database is in the off-state, and at this time, the CPU does not execute the above S110-S120.

[0104] S130: The CPU outputs a verification result of the first operation in the redo log and / or a verification result of the second operation in the rollback log.

[0105] The verification result includes: the first operation verification is successful or the first operation verification fails, and / or the second operation verification is successful or the second operation verification fails.

[0106] In one implementation, the specific implementation of the above S130 includes: when the first operation verification fails and / or the second operation verification fails, outputting an alarm message indicating the verification failure; that is, when the operation (such as: the first operation) verification fails, outputting the verification result, and when the verification succeeds, directly terminating the method without outputting the verification result indicating the verification success. The details are as follows:

[0107] In the case where the first operation verification fails, the first alarm information indicating the first operation verification failure is output; that is, when the third data obtained after executing the first operation stored in the redo log on the first data is different from the second data obtained after the CPU actually updates the first data, the first alarm information is output. The first alarm information is used to indicate that the first operation (i.e., update operation) stored in the redo log is wrong; that is, the first operation stored in the redo log at this time is different from the update operation actually performed by the CPU on the first data. For example: the first alarm information output by the CPU is: "In the process of updating the first data to the second data, the first operation stored in the redo log is an incorrect operation. Please handle it in time!".

[0108] In the case where the second operation verification fails, a second alarm message is output to indicate that the second operation verification has failed; that is, when the fourth data obtained after executing the second operation stored in the rollback log on the updated second data is different from the first data before the update, the second alarm message is output. The second alarm message is used to indicate that the rollback operation stored in the rollback log is wrong; that is, the second operation stored in the rollback log at this time is different from the rollback operation corresponding to the first operation actually executed by the CPU on the above-mentioned first data. For example: the second alarm message output by the CPU is: "In the process of updating the first data to the second data, the operation stored in the rollback log is an erroneous operation. Please handle it in time!".

[0109] Since redo logs and rollback logs may contain errors, if it is impossible to determine whether the redo logs and rollback logs are correct, using incorrect redo logs and rollback logs for data recovery will naturally fail to recover the correct data. However, this solution verifies the correctness of the operations in the redo logs and rollback logs, thereby ensuring the correctness of the redo logs and rollback logs. This avoids the problem of database unreliability caused by unknowingly treating incorrect redo logs and rollback logs as normal redo logs and rollback logs.

[0110] In one embodiment, in combination Figure 2 ,like Figure 6 As shown, before the above S110, the data verification method provided by the embodiment of the present application also includes S210.

[0111] S210: The CPU updates the first data to obtain the second data.

[0112] The specific implementation of S210 includes: the CPU performs the first operation on the first data to obtain updated second data.

[0113] Optionally, when the CPU updates the data in the database, the CPU caches all data in the data page where the data to be updated is located into the memory, and then the CPU updates the data to be updated in the memory; finally, the CPU periodically persists the non-persisted data cached in the memory to the database; that is, the above-mentioned first data is the data to be updated cached in the memory.

[0114] It should be noted that when the CPU performs a delete operation on the first data, the obtained second data is null.

[0115] It should be understood that before the CPU executes the above S210, the CPU stores the rollback operation (i.e., the second operation) corresponding to the first operation to be executed on the first data in the rollback log; and after the CPU executes the above S210, the CPU stores the first operation in the redo log. The specific implementation of the above CPU storing the second operation in the rollback log includes: the CPU obtains a structured query language (SQL) statement for updating the first data; then, by parsing and compiling the SQL statement, the update operation (i.e., the first operation) indicated by the SQL statement is determined; finally, based on the SQL grammar rules and the first operation, the rollback operation (i.e., the second operation) corresponding to the first operation is determined, and the second operation is stored in the rollback log. The specific implementation details are referred to the prior art and will not be repeated here.

[0116] It should be noted that in a high-concurrency scenario, if two different threads update the same data (such as the first data) at the same time, it will cause the first data to be updated incorrectly.

[0117] Based on this, in one embodiment, before the above S210, the CPU adds a lock to the first data to be updated, and the lock is used to prohibit threads other than the first thread from accessing the above first data. The first thread is used to execute the above S210 and S110-S120, that is, the thread is used to update the above first data. The lock is released after S120, thereby avoiding the first data update error caused by high concurrency, and thus providing high reliability of the database.

[0118] It should be noted that the above lock can be any one of a mutex lock, a spin lock or a pessimistic lock, and the specific embodiment of the present application does not limit the specific type of the above lock.

[0119] The embodiment of the present application verifies the update operation of the updated data stored in the redo log and the rollback operation corresponding to the update operation of the updated data stored in the rollback log after each data update, and outputs the verification result; so that the user can promptly obtain the erroneous operation in the redo log and / or the rollback log, and handle the erroneous operation, thereby improving the accuracy of the redo log and the rollback log, and further improving the reliability of the database.

[0120] The above mainly introduces the scheme provided by the embodiment of the present application from the perspective of method. In order to realize the above functions, the data verification device (such as: CPU) includes a hardware structure and / or software module corresponding to each function. It should be easily appreciated by those skilled in the art that the present application can be implemented in the form of hardware or a combination of hardware and computer software in conjunction with the units and algorithm steps of each example described in the embodiments disclosed herein. Whether a certain function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but this implementation should not be considered to exceed the scope of the present application.

[0121] The embodiment of the present application can divide the functional modules of the data verification device according to the above method. For example, the data verification device can include various functional modules corresponding to the various functional divisions, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.

[0122] In the case of dividing each functional module into corresponding functional modules, Figure 7 A possible structural diagram of the data verification device involved in the above embodiment is shown. Figure 7 As shown, the data verification device includes: a processing unit 110 and a communication unit 120.

[0123] The processing unit 110 is configured to verify the first operation in the redo log according to the first data and the second data; for example, executing step S110 in the above method embodiment.

[0124] The communication unit 120 is used to output the verification result; for example, to execute step S130 in the above method embodiment.

[0125] Optionally, the processing unit 110 is specifically used to determine that the first operation verification is successful when a result obtained by performing the first operation on the backup data of the first data is second data; and to determine that the first operation verification has failed when a result obtained by performing the first operation on the backup data of the first data is not second data; for example, executing step S110b in the above method embodiment.

[0126] Optionally, the processing unit 110 is configured to verify the second operation in the rollback log according to the first data and the second data; for example, executing step S120 in the above method embodiment.

[0127] Optionally, the processing unit 110 determines that the second operation verification has failed when the result obtained by performing the second operation on the second data is not the first data; and determines that the second operation verification has succeeded when the result obtained by performing the second operation on the second data is the first data; for example, executing step S120b in the above method embodiment.

[0128] Optionally, the processing unit 110 is further configured to update the first data to obtain the second data; for example, executing step S210 in the above method embodiment.

[0129] Optionally, the processing unit 110 is specifically configured to lock the first data, update the first data to obtain the second data, and determine whether to lock it.

[0130] Optionally, the processing unit 110 is specifically configured to verify the first operation and the second operation according to the first data and the second data when the verification state of the database is on.

[0131] Each module of the above-mentioned data verification method can also be used to perform other actions in the above-mentioned method embodiment. All relevant contents of each step involved in the above-mentioned method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.

[0132] Part or all of the steps in the processing unit 110 may be performed by Figure 1 The processor 101 in the memory 102 executes the code to achieve. The communication unit 120 is the Figure 2 The functional module in the communication interface 103.

[0133] The embodiment of the present application also provides a computer device, including: a processor and a memory, the processor is connected to the memory. The memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions stored in the memory, thereby implementing any method executed by the above-mentioned data verification device.

[0134] An embodiment of the present application also provides a computer system, which includes at least one computer device, each computer device including a processor and a memory; the processor of the at least one computer device is used to execute instructions stored in the memory of the at least one computer device, so that the computer device cluster executes any one of the methods executed by the above-mentioned data verification device.

[0135] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed on a computer, the computer is caused to execute any one of the methods executed by the above-mentioned data verification device.

[0136] The embodiment of the present application also provides a computer program product, which, when executed on a computer, enables the computer to execute any one of the methods executed by the above-mentioned data verification device.

[0137] For the explanation of the relevant contents and description of the beneficial effects of any of the above-mentioned computer-readable storage media, reference may be made to the above-mentioned corresponding embodiments, which will not be repeated here.

[0138] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using a software program, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instruction is loaded and executed on a computer, the process or function in accordance with the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) mode or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that includes one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a magnetic disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state drive (SSD)).

[0139] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0140] In the several embodiments provided in 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 only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as 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 mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

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

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

[0143] If 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 the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, or all or part of the technical solution. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) or a processor to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: flash memory, mobile hard disk, read-only memory, random access memory, disk or optical disk, and other media that can store program codes.

[0144] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data verification method, characterized in that: The method comprises: Verifying a first operation in a redo log according to the first data and the second data, wherein the first operation is used to instruct to redo the first data; The verification result is output, where the verification result includes: the first operation verification is successful or the first operation verification fails.

2. The method according to claim 1, characterized in that The verifying the first operation in the redo log according to the first data and the second data specifically includes: When a result obtained by performing the first operation on the backup data of the first data is the second data, determining that the verification of the first operation is successful; When a result obtained by performing the first operation on the backup data of the first data is not the second data, it is determined that the verification of the first operation has failed.

3. The method according to claim 1 or 2, characterized in that: Before outputting the verification result, the method further includes: A second operation in the rollback log is verified according to the first data and the second data, where the second operation is used to indicate rolling back the second data, and the verification result further includes: verification of the second operation succeeds or verification of the second operation fails.

4. The method according to claim 3, characterized in that The verifying the second operation in the rollback log according to the first data and the second data specifically includes: When a result obtained by performing the second operation on the second data is not the first data, determining that the second operation verification fails; When a result obtained by performing the second operation on the second data is the first data, it is determined that verification of the second operation succeeds.

5. The method according to claim 3 or 4, characterized in that: Before verifying the first operation in the redo log according to the first data and the second data, the method further includes: The first data is updated to obtain the second data.

6. The method according to claim 5, characterized in that The updating the first data to obtain the second data includes: Locking the first data, updating the first data to obtain the second data, wherein the lock is used to prohibit threads other than the first thread from accessing the first data, and the first thread is used to update the first data; After verifying the second operation in the rollback log according to the first data and the second data, the method further includes: Release the lock.

7. A data verification device, characterized in that: The device comprises: a processing unit and a communication unit; The processing unit is used to verify a first operation in a redo log according to the first data and the second data, wherein the first operation is used to instruct to redo the first data; The communication unit is used to output the verification result, where the verification result includes: the first operation verification is successful or the first operation verification fails.

8. The device according to claim 7, characterized in that The processing unit is specifically used for When a result obtained by performing the first operation on the backup data of the first data is the second data, determining that the verification of the first operation is successful; When a result obtained by performing the first operation on the backup data of the first data is not the second data, it is determined that the verification of the first operation has failed.

9. The device according to claim 7 or 8, characterized in that The processing unit is further used to verify a second operation in the rollback log based on the first data and the second data, where the second operation is used to indicate rolling back the second data, and the verification result also includes: verification of the second operation is successful or verification of the second operation fails.

10. The device according to claim 9, characterized in that The processing unit is specifically used for When a result obtained by performing the second operation on the second data is not the first data, determining that the second operation verification fails; When a result obtained by performing the second operation on the second data is the first data, it is determined that verification of the second operation succeeds.

11. The device according to claim 9 or 10, characterized in that The first data is updated to obtain the second data.

12. The device according to claim 10, characterized in that The processing unit is specifically used for: Locking the first data, updating the first data to obtain the second data, wherein the lock is used to prohibit threads other than the first thread from accessing the first data, and the first thread is used to update the first data; Release the lock.

13. A computer device, characterized in that: It comprises a memory and a processor, the memory is coupled to the processor; the memory is used to store computer program code, the computer program code comprises computer instructions; when the computer instructions are executed by the processor, the computer device executes the method as described in any one of claims 1 to 6.

14. A computer system, characterized in that: comprising at least one computer device, each computer device comprising a processor and a memory; The processor of the at least one computer device is configured to execute instructions stored in the memory of the at least one computer device, so that the computer device cluster executes the method according to any one of claims 1 to 6.