Data damage recovery method and device based on tuple, equipment and medium

By defining historical tuple data files and mapping files in the database, recording and storing historical records and location information of data tuples, data recovery with data elements as the smallest recovery unit is realized, solving the problems of insufficient recovery granularity and affecting production business systems in the prior art, and improving the efficiency and accuracy of data recovery.

CN119961054APending Publication Date: 2025-05-09SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510039364.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-10
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

Existing data recovery methods cannot reduce the recovery granularity to a certain row of data, which also requires backtracking when the error occurs, affecting the recovery efficiency, and the database needs to be stopped or locked to recover, affecting the normal operation of the production business system.

Method used

By defining historical tuple data files and mapping files, recording and storing the history and location information of the data tuple, when a data modification event is detected, the CSN number of the corrupted tuple is determined through the mapping file, and data recovery of the currently tampered data page is performed according to the CSN number.

Benefits of technology

Data recovery with data elements as the minimum recovery unit is realized, and can automatically restore to the latest state, improving the efficiency and accuracy of data recovery, and avoiding the need for database downtime or locking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119961054A_ABST
    Figure CN119961054A_ABST
Patent Text Reader

Abstract

The invention provides a tuple-based data damage recovery method and device, equipment and a medium. The method comprises the steps that a historical tuple data file and a mapping file are defined, the historical tuple data file records historical records of data tuples, and the mapping file stores position information of a data source group when the data source group is inserted in the historical tuple data file for the first time; when a data modification event is detected, determining a CSN number of tuple data of which the data is damaged through the mapping file; and performing data recovery on the currently tampered data page according to the CSN number. According to the scheme, data damage based on tuples can be recovered, the granularity is small, data recovery is rapid, and the data recovery efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing, and in particular to a tuple-based data damage recovery method, device, equipment and medium. Background Art

[0002] When it is detected that the data has been tampered with or the data page structure has been damaged, the data on the data page can be self-recovered through corresponding means, or the damaged page structure can be self-repaired.

[0003] Commonly used data recovery methods include: timeline-based recovery, flashback tools, and recycle bin mechanisms. The above methods can restore the database to a certain point in time. Since the entire database is backtracked, it is all done through operations on the entire database, and the minimum unit is a certain data page. It is impossible to narrow the scope to a certain row of data. If the erroneous operation is interspersed with normal operations, the normal operation also needs to be backtracked, affecting the recovery efficiency. Summary of the invention

[0004] The embodiments of the present invention provide a tuple-based data damage recovery method, device, equipment and medium, which can recover tuple-based data damage with small granularity and fast data recovery.

[0005] According to one aspect of the present invention, a tuple-based data corruption recovery method is provided, comprising: defining a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of data tuples, and the mapping file stores the position information of a data source group when it is first inserted into the historical tuple data file; when a data modification event is detected, determining the CSN number of the tuple data whose data is damaged through the mapping file; and performing data recovery on the currently tampered data page according to the CSN number.

[0006] Optionally, when a data modification event is detected, the CSN number of the damaged tuple of the data is searched through the mapping file, including: when a data table is created and a DML operation is performed, detecting whether damaged tuple data exists; if so, determining the ctid of the tuple data, where the ctid represents the physical location of the tuple data, including a physical block number and a row number in the physical block; loading the mapping file into the memory, and searching for the CSN number of the damaged tuple data according to the ctid.

[0007] Optionally, searching for the CSN number of the destroyed tuple data according to the ctid includes: determining at least one preset hash bucket, wherein the hash bucket is used to store the CSN, and using the first tuple in each block as the main structure of the hash bucket; determining the hash bucket where the CSN number is located through the ctid, and determining the position of the physical block number in the mapping file according to the hash bucket; determining the CSN number according to the number of bytes of the CSN number and the row number of the ctid.

[0008] Optionally, data recovery is performed on the currently tampered data page based on the CSN number, including: obtaining the data value of the first insertion taken by the historical tuple data file through the offset of the CSN number; finding the last set of data in the linked list composed of New_CSN after the CSN number slice, and overwriting the data to the currently tampered data page for data recovery.

[0009] Optionally, the method also includes: when inserting data, organizing the data into tuple data according to the SQL statement in the data, and flushing the tuple data to the disk; recording the change record of the tuple data in a sequential form in the historical tuple data file and generating a CSN number; and the CSN of the tuple data in the historical tuple data file is also recorded in the mapping file.

[0010] Optionally, the method also includes: when data is updated, the changed ctid value is appended to the historical tuple data file, placed at the end of the file, and the current CSN_NEXT is changed to the new value; when data is deleted, the ctid value and the data corresponding to the ctid are deleted in the data page; when filling in new values ​​for data, it is appended to the historical tuple data file and the current CSN_NEXT is changed to the new value.

[0011] Optionally, the method further includes: when the frequency of data modification exceeds a preset frequency, according to a preset cleaning time, when the data in the data link exceeds the cleaning time, cleaning the data from the link.

[0012] According to another aspect of the present invention, a tuple-based data corruption recovery device is provided, comprising: a definition unit, used to define a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of data tuples, and the mapping file stores the position information of the data source group when it is first inserted into the historical tuple data file; a determination unit, used to determine the CSN number of the tuple data whose data is damaged through the mapping file when a data modification event is detected; and a recovery unit, used to recover the data page that is currently tampered with according to the CSN number.

[0013] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:

[0014] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the tuple-based data corruption recovery method described in any embodiment of the present invention.

[0015] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the tuple-based data corruption recovery method described in any embodiment of the present invention when executed.

[0016] The embodiment of the present invention provides a tuple-based data damage recovery method, device, equipment and medium. In a database, important data in the database may be damaged or tampered with due to hardware or software reasons. The embodiment of the present invention recovers tuple-based data damage with small granularity and fast data recovery, thereby improving data recovery efficiency.

[0017] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 is a flow chart of a tuple-based data damage recovery method provided by an embodiment of the present invention;

[0020] Figure 2 is a schematic diagram of a hash bucket provided by an embodiment of the present invention;

[0021] Figure 3 It is a schematic diagram of the structure of HISTUP.data provided by one embodiment of the present invention;

[0022] Figure 4 It is a schematic diagram of the structure of a CTID.map provided by an embodiment of the present invention;

[0023] Figure 5 It is a schematic diagram of the correspondence between CTID.map and HISTUP.data provided by an embodiment of the present invention;

[0024] Figure 6 It is a structural schematic diagram of a tuple-based data damage recovery device provided by an embodiment of the present invention;

[0025] Figure 7 It is a structural schematic diagram of an electronic device for implementing the tuple-based data corruption recovery method of an embodiment of the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0028] Currently, there are several methods for data recovery as follows:

[0029] 1. Timeline-based recovery: The database administrator can specify a time point in the past and restore the current database state to the specified time point through the database basic backup and write-ahead log (Write Ahead Log).

[0030] 2. Flashback tool: It can restore the database status to a certain point in the past or undo specific database operations, and use the database transaction log (such as MySQL's binlog or Oracle's redo log / flashback log) to achieve data backtracking.

[0031] 3. Recycle Bin Mechanism: When an object is deleted by a DROP command, it is not immediately permanently deleted from the disk, but is moved to the Recycle Bin. In this way, the space occupied by the object is marked as reusable, but the actual data is still retained. The database administrator can restore the DROP data through the data in the Recycle Bin.

[0032] The above database recovery methods can restore the database to the state at a certain point in time, which is equivalent to database state backtracking, but have the following shortcomings:

[0033] 1. The above database recovery methods are relatively rough. All of them are to backtrack the entire database. They are all through operations on the entire database. The smallest unit is a certain data page. It is impossible to narrow the scope to a certain row of data. If the erroneous operation is interspersed with normal operations, the normal operation also needs to be backtracked, which will affect the recovery efficiency.

[0034] 2. The database needs to be stopped or locked for recovery. During the recovery process, the database needs to be shut down, or the table to be recovered needs to be exclusively locked before recovery can be performed. If it is a production business system, this operation is unacceptable.

[0035] 3. Most of the current recovery relies on pre-write logs, but the pre-write logs are cleaned up regularly. Once the pre-write logs are cleaned up, recovery cannot be performed.

[0036] The current recovery method requires the database administrator to be informed of the compensation process after the database data is abnormal. For example, a user finds that the database query is incorrect, data is missing or there is redundant data; or the database administrator finds that the database has been accidentally deleted. Manual recovery is then performed through the above methods, and the database cannot automatically recover data after detecting an abnormality.

[0037] In summary, in the database, important data in the database may be damaged or tampered with due to hardware or software reasons. Therefore, tuple-based data damage can be recovered with small granularity and fast data recovery.

[0038] The explanations of some terms in the technical solutions of the embodiments of the present invention are as follows:

[0039] Data page: page is the smallest I / O unit of the database, which is generally 8K. When the database performs data I / O, it assembles the data written by the user into data pages, and then performs disk I / O to write the data into the data file of the storage medium.

[0040] Data element: the smallest storage unit of the database, that is, tuple, will assemble the data inserted by the user, then write it to the data page, and finally write the data page to the data file.

[0041] CTID: The physical location of the data, which consists of two numbers. The first number indicates the physical block number, and the second number indicates the row number in the physical block. For example, (1, 100) means the 100th row in physical block 1. It can uniquely determine the location of the data in the physical file.

[0042] like Figure 1 As shown, an embodiment of the present invention provides a tuple-based data corruption recovery method, which may include the following steps:

[0043] S110. Define a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of the data tuples, and the mapping file stores the position information of the data source group when it is first inserted into the historical tuple data file.

[0044] When data is inserted, it will be grouped into tuples inside the database. Tuples are assembled into minimum I / O units and stored in data files. In order to enable the database to have the ability to restore tuple-level granularity data, we define two new files to store historical data.

[0045] Historical tuple data file: HISTUP.data, this file records all historical records of data tuples and is written to the file in an appended form. One table corresponds to one HISTUP.data file. For example, if the physical file name of the test table is 12345, then the HISTUP.data file name is 12345_HISTUP.data file.

[0046] The mapping file is the CTID.map file, which is a mapping file for the data storage location in the data file (i.e. CITD); the mapping file stores the location information of the current ctid when it is first inserted into HISTUP.data. This location is recorded with CSN (ctid sequence number), i.e. the citd sequence number. Each CSN is represented by an 8-byte unsigned integer, so the offset address of each ctid occupies 8 bytes. Through this mapping file, you can quickly find the first insertion of the tuple, and then query the data information you want to restore based on the historical data linked list. One table corresponds to one CTID.map file. For example, if the physical file name of the test table is 12345, then the CTID.map file name is 12345_CTID.map file.

[0047] S120: When a data modification event is detected, the CSN number of the tuple data whose data is destroyed is determined through a mapping file.

[0048] In the embodiment of the present invention, when a data modification event is detected, the CSN number of the data-destroyed tuple is searched through the mapping file, including:

[0049] When creating a data table and performing DML operations, it is detected whether there is damaged tuple data;

[0050] If it exists, determine the ctid of the tuple data, where ctid represents the physical location of the tuple data, including the physical block number and the row number in the physical block;

[0051] Load the mapping file into memory and find the CSN number of the damaged tuple data based on ctid.

[0052] When we detect that the data has been modified for some reason, we need to restore the data.

[0053] When a table is created and some DML operations are performed on it, if a data tuple is detected to be damaged, for example, if the data of ctid(23, 25) is detected to be tampered with, our recovery process will perform the following series of actions to recover the data.

[0054] In the embodiment of the present invention, searching for the CSN number of the damaged tuple data according to the ctid includes:

[0055] Determine at least one preset hash bucket, where the hash bucket is used to store the CSN, and the first tuple in each block is used as the main structure of the hash bucket;

[0056] Determine the hash bucket where the CSN number is located through ctid, and determine the location of the physical block number in the mapping file based on the hash bucket;

[0057] The CSN number is determined based on the number of bytes in the CSN number and the row number of the ctid.

[0058] First, we need to load CTID.map into memory. Since HISTUP.data may not be stored in memory temporarily due to the large amount of data. When loading CTID.map, in order to facilitate searching in memory, we set up a hash bucket structure to store CSN. We will use the main structure of the first tuple bucket in each block. When we need to find an element, we calculate through this hash bucket and shift the elements in it, and we can get the desired CSN value. We set up an 8-bucket hash table to store the data of CTID.map.

[0059] Figure 2This is a schematic diagram of a hash bucket provided by an embodiment of the present invention. For example, the CSN value of ctid(23,25) needs to be obtained. Through hash(23,8)=7, it first finds the position of ctid(23,1) in CTID.map in the 7th bucket according to the bucket position, and then adds the offset of 25 to the value of CSN_NEXT. Because each CSN occupies 8 bytes, starting from the position of ctid(23,1), offset 26*8 bytes to find the desired CSN number.

[0060] S130: Perform data recovery on the currently tampered data page according to the CSN number.

[0061] In an embodiment of the present invention, data recovery is performed on the currently tampered data page according to the CSN number, including:

[0062] Obtain the first inserted data value of the historical tuple data file through the offset of the CSN number;

[0063] According to the linked list composed of New_CSN after the CSN number piece, the last set of data in the linked list is found and the data is overwritten to the currently tampered data page for data recovery.

[0064] After finding the CSN number, we use the offset of the CSN number to get the first inserted data value from HISTUP.data. Then, based on the linked list composed of New_CSN, we can find the last group of the linked list. This group is the latest data before tampering. We overwrite this group of data with the data page that has been tampered with to achieve data recovery.

[0065] Since HISTUP.data needs to save all the change history of the tuple, it may cause the HISTUP.data file to be large and occupy too much disk, so we narrow this recovery mechanism to the table instead of the entire database. We set up a recovery mechanism for more important tables. We do not set a recovery mechanism for unimportant tables. In order to refine the recovery to the table, we need to set the keyword AUTO RESTORE when creating the table, so that it can be refined to CREATE TABLE test (parameter list) AUTO RESTORE.

[0066] In an embodiment of the present invention, the method may further include the following steps:

[0067] When inserting data, the data is grouped into tuple data according to the SQL statement in the data, and the tuple data is flushed to the disk;

[0068] Record the change records of the tuple data in the historical tuple data file in a sequential manner and generate a CSN number;

[0069] The mapping file also records the CSN of the tuple data in the historical tuple data file.

[0070] First, create a test table and insert data as follows:

[0071] The first one: INSERT INTO test VALUES(1,'1',20240101);

[0072] Article 2: INSERT INTO test VALUES(2,'2',20240102);

[0073] Article 3: INSERT INTO test VALUES(3,'3',20240103);

[0074] At this time, the data will be grouped into tuples. The three SQL statements in the example will be grouped into three tuples. At this time, the tuples will be flushed to the disk through the database's buffer layer minimum I / O flushing strategy. At this time, the database will capture the changes to the current database tuples, and these three records will also be recorded in sequence in the HISTUP.data historical tuple data file. Figure 3 is a schematic diagram of the structure of HISTUP.data provided by an embodiment of the present invention, such as Figure 3 As shown, the historical tuple data recorded in HISTUP.data is recorded in an appended manner, that is, all tuples in this file are sequential. When data is appended, a CSN number is generated to record the location information of the current tuple. This CSN number will be recorded in CTID.map for quick search.

[0075] Figure 4 It is a structural diagram of a CTID.map provided by an embodiment of the present invention. Figure 5 This is a schematic diagram of the correspondence between CTID.map and HISTUP.data provided by an embodiment of the present invention. At this time, the CTID.map file will also record the location information of this tuple in HISTUP.data, that is, CSN. CSN is stored sequentially in CTID.map, such as ctid(0,1) occupies the 1st to 8th bytes, ctid(0,2) occupies the 9th to 16th bytes, and so on. Since the number of tuples contained in each block is related to the data size of the tuple, the first value in the ctid in each CTID.map, such as ctid(0,1), ctid(1,1), ctid(2,1), will record the next starting value.

[0076] In an embodiment of the present invention, the method may further include the following steps:

[0077] When the data is updated, the changed ctid value is appended to the historical tuple data file, placed at the end of the file, and the current CSN_NEXT is changed to the new value;

[0078] When data is deleted, the ctid value and the data corresponding to ctid in the data page are deleted;

[0079] When new values ​​are filled into the data, an append is made to the historical tuple data file, and the current CSN_NEXT is changed to the new value.

[0080] When data is updated, for example:

[0081] UPDATE test SET info='2'WHERE id=1;

[0082] At this point, the value of ctid changes from '1' to '2'. We need to append the new value to HISTUP.data, put it at the end of the file, and then change the current CSN_NEXT to the new value.

[0083] When data is deleted, for example:

[0084] DELETE FROM test where id=1;

[0085] At this time, the value of this ctid will be deleted, and we will not add a new value to HISTUP.data. Since the data is deleted, the data corresponding to this ctid will also be cleared in the data page, and new values ​​will be filled in the future. When we fill in new values, we append them to HISTUP.data and then change the current CSN_NEXT to the new value.

[0086] In an embodiment of the present invention, the method may further include the following steps:

[0087] When the frequency of data modification exceeds a preset frequency, according to a preset cleaning time, when the data in the data link exceeds the cleaning time, the data is cleaned from the link.

[0088] When the frequency of data modification is too high, the data link will be too long. Data that is too old is no longer valid in this link and does not need to be restored. You can set a cleanup time. When the data in the data link exceeds this time, it will be cleaned up from this link. First, it saves storage space, and second, it can save the query link length and speed up the query.

[0089] The solution of the embodiment of the present invention has at least the following advantages and improvements:

[0090] 1. Data can be recovered with the data element as the minimum recovery unit. When tampering is found, it can be automatically restored to the latest state.

[0091] 2. Data can be restored to any previously set time using the data element as the minimum recovery unit.

[0092] like Figure 6 As shown, an embodiment of the present invention provides a tuple-based data damage recovery device, comprising:

[0093] A definition unit 610 is used to define a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of the data tuples, and the mapping file stores the position information of the data source group when it is first inserted into the historical tuple data file;

[0094] A determination unit 620, configured to determine, when a data modification event is detected, the CSN number of the tuple data of the destroyed data through the mapping file;

[0095] The recovery unit 630 is used to recover the data page that is currently tampered with according to the CSN number.

[0096] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the tuple-based data damage recovery device. In other embodiments of the present invention, the tuple-based data damage recovery device may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0097] The information interaction, execution process and other contents between the units in the above-mentioned device are based on the same concept as the embodiment of the method of the present invention. For specific contents, please refer to the description in the embodiment of the method of the present invention, and no further description is given here.

[0098] Figure 7A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0099] like Figure 7 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0100] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0101] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a tuple-based data corruption recovery method.

[0102] In some embodiments, the tuple-based data corruption recovery method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the tuple-based data corruption recovery method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the tuple-based data corruption recovery method in any other appropriate manner (e.g., by means of firmware).

[0103] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0104] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0105] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0106] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0107] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0108] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0109] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0110] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A tuple-based data corruption recovery method, characterized in that: include: Define a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of the data tuples, and the mapping file stores the position information of the data source group when it is first inserted into the historical tuple data file; When a data modification event is detected, the CSN number of the tuple data of the destroyed data is determined through the mapping file; The data page that has been tampered with is restored according to the CSN number.

2. The method according to claim 1, characterized in that When a data modification event is detected, searching the CSN number of the data-destroyed tuple through the mapping file includes: When creating a data table and performing DML operations, it is detected whether there is damaged tuple data; If it exists, determine the ctid of the tuple data, where the ctid represents the physical location of the tuple data, including the physical block number and the row number in the physical block; The mapping file is loaded into the memory, and the CSN number of the destroyed tuple data is searched according to the ctid.

3. The method according to claim 2, characterized in that The step of searching for the CSN number of the damaged tuple data according to the ctid includes: Determine at least one preset hash bucket, wherein the hash bucket is used to store the CSN, and the first tuple in each block is used as the main structure of the hash bucket; Determine the hash bucket where the CSN number is located through the ctid, and determine the position of the physical block number in the mapping file according to the hash bucket; The CSN number is determined according to the number of bytes of the CSN number and the row number of the ctid.

4. The method according to claim 2, characterized in that: The data recovery of the currently tampered data page according to the CSN number includes: Obtaining the first inserted data value of the historical tuple data file through the offset of the CSN number; According to the linked list composed of New_CSN after the CSN number piece, the last set of data in the linked list is found, and the data is overwritten to the currently tampered data page to perform data recovery.

5. The method according to claim 2, characterized in that: Further including: When inserting data, the data is grouped into tuple data according to the SQL statement in the data, and the tuple data is flushed to the disk; Record the change records of the tuple data in the historical tuple data file in a sequential manner and generate a CSN number; The mapping file also records the CSN of the tuple data in the historical tuple data file.

6. The method according to claim 2, characterized in that Further including: When the data is updated, the changed ctid value is appended to the historical tuple data file, placed at the end of the file, and the current CSN_NEXT is changed to the new value; When data is deleted, the ctid value and the data corresponding to ctid in the data page are deleted; When new values ​​are filled into the data, an append is made to the historical tuple data file, and the current CSN_NEXT is changed to the new value.

7. The method according to claim 1, characterized in that Further including: When the frequency of data modification exceeds a preset frequency, according to a preset cleaning time, when the data in the data link exceeds the cleaning time, the data is cleaned from the link.

8. A tuple-based data corruption recovery device, characterized in that: include: A definition unit, used to define a historical tuple data file and a mapping file, wherein the historical tuple data file records the historical records of the data tuples, and the mapping file stores the position information of the data source group when it is first inserted into the historical tuple data file; A determination unit, configured to determine, when a data modification event is detected, the CSN number of the tuple data of the destroyed data through the mapping file; The recovery unit is used to recover the data page that has been tampered with according to the CSN number.

9. An electronic device, characterized in that include: at least one processor; And a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the tuple-based data corruption recovery method described in any one of claims 1-7.

10. A computer readable medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the tuple-based data corruption recovery method according to any one of claims 1 to 7 when executed.