WO2020143240A1 - 一种闪存数据库快速进行数据恢复的方法 - Google Patents

一种闪存数据库快速进行数据恢复的方法 Download PDF

Info

Publication number
WO2020143240A1
WO2020143240A1 PCT/CN2019/104085 CN2019104085W WO2020143240A1 WO 2020143240 A1 WO2020143240 A1 WO 2020143240A1 CN 2019104085 W CN2019104085 W CN 2019104085W WO 2020143240 A1 WO2020143240 A1 WO 2020143240A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
transaction
log
log record
record
Prior art date
Application number
PCT/CN2019/104085
Other languages
English (en)
French (fr)
Inventor
李玉亭
Original Assignee
江苏华存电子科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 江苏华存电子科技有限公司 filed Critical 江苏华存电子科技有限公司
Publication of WO2020143240A1 publication Critical patent/WO2020143240A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1446Point-in-time backing up or restoration of persistent data
    • G06F11/1458Management of the backup or restore process

Definitions

  • the invention relates to the technical field of flash memory data recovery, in particular to a method for fast data recovery of a flash memory database.
  • Flash memory is a long-life non-volatile memory (which can retain the stored data information in the event of a power failure), and the data deletion is not in single bytes but in fixed blocks In units (note: NORFlash is byte storage.), the block size is generally 256KB to 20MB. Flash memory is a variant of electronically erasable read-only memory (EEPROM). The difference between flash memory and EEPROM is that EEPROM can be deleted and rewritten at the byte level instead of the entire chip erase, and most chips of flash memory require block erase except. Because it can still save data when power is off, flash memory is usually used to save setting information, such as saving information in the computer's BIOS (basic program), PDA (personal digital assistant), digital camera, etc.
  • BIOS basic program
  • PDA personal digital assistant
  • the database can be regarded as an electronic file cabinet-a place where electronic files are stored, and users can perform operations such as adding, intercepting, updating, and deleting data in the files.
  • database is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of applications.
  • An object of the present invention is to provide a method for quickly performing data recovery of a flash memory database to solve the problems raised in the background art.
  • a method for quickly performing data recovery of a flash memory database including the following steps:
  • Step 1 Scan the log file in the database to confirm whether there are still valid transaction commit log records or transaction logs in the log file;
  • Step 2 According to the current status of the log file, respectively perform the following processing: If there is a valid transaction commit log record, it indicates that all changes related to the transaction have not been completely written into the data file, and the data file must be rewritten according to the log record , Check whether there is a valid rollback log record, if it exists, then find all log records according to the transaction ID, and perform a rollback operation, there is no valid transaction commit log record to enter the next step;
  • Step 3 If there is no valid transaction commit log record, and there is no valid rollback log, but there is still a valid log record, indicating that the transaction has not been completed, check whether there are some log records written to the data file, and part If it is not written, if it exists, a rollback operation is performed.
  • the rollback operation first finds out all log records about the transaction corresponding to the transaction ID from the log file according to the transaction ID, and then sequentially determines the type of log recording operation. According to different operation types, the completion is as follows Operation: If it is an insert operation, the currently inserted data element is deleted; if it is a delete operation, the deleted data element is reinserted; if it is an update operation, the value of the data element is restored to the original state.
  • the log records in the first step include a linked list and a data table.
  • the linked list sequentially stores log records of different data operations generated by each transaction.
  • the data table includes a different version of each data member in the log record.
  • the linked list contains the address of the specified data table; the log record in the data table contains four fields: transaction ID, data member, former member and data address table, where the transaction ID is the ID number of the transaction to which the current log record belongs; the data member is The name of the data member pointed to by the current data operation; the former member is the former member that has changed in the current transaction; the data address table is the address of all version data of the data member.
  • Each version data is connected in a chronological order with a linked list. When the transaction commits or After the rollback, the data address field is set to blank.
  • the data file in the second step is configured to store data stored in the database.
  • the method of constructing the log file in the first step is: when a new transaction starts and the first data change occurs, a log record is inserted for the first updated data member; when other data members are generated in the transaction When a change occurs, a new log record is inserted, and the previous member is set as the last changed data record; for insert and delete operations, multiple identifiers are used in the data address table to distinguish different versions of data; if the transaction is Submit or rollback, insert a commit or rollback log record, the former member is set to the previously updated member; record all the data members in the database that have changed and their specific data operations, and store them in the log file.
  • the method for recovering flash database data of the present invention has designed a new log record format, which saves the changed data members and all the data addresses of different versions in the same log record, which is convenient for log rollback or submission Transaction ID quickly finds effective data records and increases the efficiency of data recovery.
  • FIG. 1 is a schematic flowchart of the present invention.
  • the present invention provides a technical solution: a method for quickly recovering data from a flash memory database, including the following steps:
  • Step 1 Scan the log file in the database to confirm whether there are still valid transaction commit log records or transaction logs in the log file;
  • Step 2 According to the current status of the log file, respectively perform the following processing: If there is a valid transaction commit log record, it indicates that all changes related to the transaction have not been completely written into the data file, and the data file must be rewritten according to the log record , Check whether there is a valid rollback log record, if it exists, then find all log records according to the transaction ID, and perform a rollback operation, there is no valid transaction commit log record to enter the next step;
  • Step 3 If there is no valid transaction commit log record, and there is no valid rollback log, but there is still a valid log record, indicating that the transaction has not been completed, check whether there are some log records written to the data file, and part If it is not written, if it exists, a rollback operation is performed.
  • step three the rollback operation first finds out all log records about the transaction corresponding to the transaction ID from the log file according to the transaction ID, and then determines the type of log record operation in turn. According to different operation types, the following operations are completed: if it is an insert operation , The currently inserted data element is deleted; if it is a delete operation, the deleted data element is reinserted; if it is an update operation, the value of the data element is restored to the original state.
  • the log records in step 1 include a linked list and a data table.
  • the linked list sequentially stores the log records of different data operations generated by each transaction.
  • the data table contains a different version of each data member in the log record.
  • the linked list contains the log records Specify the address of the data table; the log records in the data table contain four fields: transaction ID, data member, former member, and data address table, where the transaction ID is the ID number of the transaction to which the current log record belongs; the data member is the one pointed to by the current data operation The name of the data member; the former member is the former member that has changed in the current transaction; the data address table is the address of all version data of the data member.
  • Each version data is connected in a chronological order with a linked list. When the transaction is submitted or rolled back, the The data address field is set to blank.
  • step two the data file is configured to store the data stored in the database.
  • the method of constructing the log file in step one is: when a new transaction starts and the first data change occurs, insert a log record for the first updated data member; when other data member changes occur in the transaction, insert A new log record with the previous member set as the last changed data record; for insert and delete operations, multiple identifiers are used in the data address table to distinguish different versions of data; if the transaction is committed or rolled back, Then insert a commit or rollback log record, the former member is set to the previously updated member; record all the data members in the database that have changed and their specific data operations, and store them in the log file.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本发明公开了一种闪存数据库快速进行数据恢复的方法,扫描数据库中的日志文件,若存在有效的事务提交日志记录,表明涉及该事务的所有更改尚未完全写入到数据文件中,需依据日志记录,完成数据文件的重写,若不存在有效的事务提交日志记录,也不存在有效的回滚日志,但存在仍然有效的日志记录,表明该事务尚未完成,检查是否存在部分日志记录已写入数据文件,而部分未写入的情况,如存在,则进行回滚操作,该发明的闪存数据库数据恢复的方法,设计了一种新的日志记录格式,将变更的数据成员及其所有不同版本的数据地址保存为在同一日志记录中,便于在日志回滚或提交时根据事务ID快速找到有效数据记录,增加数据恢复的效率。

Description

一种闪存数据库快速进行数据恢复的方法 技术领域
本发明涉及闪存数据恢复技术领域,具体为一种闪存数据库快速进行数据恢复的方法。
背景技术
闪存(Flash Memory)是一种长寿命的非易失性(在断电情况下仍能保持所存储的数据信息)的存储器,数据删除不是以单个的字节为单位而是以固定的区块为单位(注意:NORFlash为字节存储。),区块大小一般为256KB到20MB。闪存是电子可擦除只读存储器(EEPROM)的变种,闪存与EEPROM不同的是,EEPROM能在字节水平上进行删除和重写而不是整个芯片擦写,而闪存的大部分芯片需要块擦除。由于其断电时仍能保存数据,闪存通常被用来保存设置信息,如在电脑的BIOS(基本程序)、PDA(个人数字助理)、数码相机中保存资料等。
数据库,简而言之可视为电子化的文件柜——存储电子文件的处所,用户可以对文件中的数据运行新增、截取、更新、删除等操作。
所谓“数据库”是以一定方式储存在一起、能与多个用户共享、具有尽可能小的冗余度、与应用程序彼此独立的数据集合。
传统闪存数据库在数据恢复时,需要一步一步进行确认恢复,时间较长,效率较低,因此,亟待一种改进的技术来解决现有技术中所存在的这一问题。
发明内容
本发明的目的在于提供一种闪存数据库快速进行数据恢复的方法,以解决上述背景技术中提出的问题。
为实现上述目的,本发明提供如下技术方案:一种闪存数据库快速进行数据恢复的方法,包括以下步骤:
步骤一:扫描数据库中的日志文件,确认日志文件中是否有仍然有效的事务提交日志记录或事务日志;
步骤二:依据日志文件当前的状态分别进行如下处理:若存在有效的事务提交日志记录,表明涉及该事务的所有更改尚未完全写入到数据文件中,需依据日志记录,完成数据文件的重写,检查是否存在有效的回滚日志记录,若存在,则依据事务ID查找所有日志记录,并进行回滚操作,不存在有效的事务提交日志记录进入下一步;
步骤三:若不存在有效的事务提交日志记录,也不存在有效的回滚日志,但存在仍然有效的日志记录,表明该事务尚未完成,检查是否存在部分日志记录已写入数据文件,而部分未写入的情况,如存在,则进行回滚操作。
优选的,所述步骤三中回滚操作首先依据事务ID从日志文件中找出所有关于事务ID对应的该事务仍然有效的日志记录,然后依次判断日志记录操作类型,根据不同操作类型,完成如下操作:若是插入操作,则删除当前插入的数据元素;若是删除操作,则重新插入被删除的数据元素;若是更新操作,则将数据元素的值恢复到初始状态。
优选的,所述步骤一中日志记录包括链表和数据表,链表中顺序存储每一个事务产生的不同数据操作的日志记录,数据表中包含一个日志记录中每个数据成员的不同版本数据,链表的日志记录中包含指定数据表的地址;数据表中的日志记录包含事务ID、数据成员、前成员和数据地址表四 个字段,其中事务ID为当前日志记录所属事务的ID号;数据成员为当前数据操作指向的数据成员的名称;前成员为当前事务中产生变化的前成员;数据地址表为数据成员所有版本数据的地址,每个版本数据按时间顺序用链表进行连接,当事务提交或回滚后,该数据地址字段设置为空。
优选的,所述步骤二中数据文件被配置为存放着在数据库中存储的数据。
优选的,所述步骤一中日志文件构建的方法为:当一个新事务开启,并产生第一个数据变化时,为第一个更新的数据成员插入一条日志记录;当事务中产生其他数据成员变化时,则插入一条新的日志记录,将其前成员设为上一变化的数据记录;对于插入和删除操作,在数据地址表中使用多个标示符来区别不同版本的数据;如果事务被提交或回滚,则插入一条提交或回滚日志记录,前成员设置为之前更新的成员;记录数据库中所有产生变化的数据成员及其具体的数据操作,并统一存储在日志文件中。
与现有技术相比,本发明的有益效果是:
本发明的闪存数据库数据恢复的方法,设计了一种新的日志记录格式,将变更的数据成员及其所有不同版本的数据地址保存为在同一日志记录中,便于在日志回滚或提交时根据事务ID快速找到有效数据记录,增加数据恢复的效率。
附图说明
图1为本发明的流程示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例, 而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
请参阅图1,本发明提供一种技术方案:一种闪存数据库快速进行数据恢复的方法,包括以下步骤:
步骤一:扫描数据库中的日志文件,确认日志文件中是否有仍然有效的事务提交日志记录或事务日志;
步骤二:依据日志文件当前的状态分别进行如下处理:若存在有效的事务提交日志记录,表明涉及该事务的所有更改尚未完全写入到数据文件中,需依据日志记录,完成数据文件的重写,检查是否存在有效的回滚日志记录,若存在,则依据事务ID查找所有日志记录,并进行回滚操作,不存在有效的事务提交日志记录进入下一步;
步骤三:若不存在有效的事务提交日志记录,也不存在有效的回滚日志,但存在仍然有效的日志记录,表明该事务尚未完成,检查是否存在部分日志记录已写入数据文件,而部分未写入的情况,如存在,则进行回滚操作。
步骤三中回滚操作首先依据事务ID从日志文件中找出所有关于事务ID对应的该事务仍然有效的日志记录,然后依次判断日志记录操作类型,根据不同操作类型,完成如下操作:若是插入操作,则删除当前插入的数据元素;若是删除操作,则重新插入被删除的数据元素;若是更新操作,则将数据元素的值恢复到初始状态。
步骤一中日志记录包括链表和数据表,链表中顺序存储每一个事务产生的不同数据操作的日志记录,数据表中包含一个日志记录中每个数据成员的不同版本数据,链表的日志记录中包含指定数据表的地址;数据表中 的日志记录包含事务ID、数据成员、前成员和数据地址表四个字段,其中事务ID为当前日志记录所属事务的ID号;数据成员为当前数据操作指向的数据成员的名称;前成员为当前事务中产生变化的前成员;数据地址表为数据成员所有版本数据的地址,每个版本数据按时间顺序用链表进行连接,当事务提交或回滚后,该数据地址字段设置为空。
步骤二中数据文件被配置为存放着在数据库中存储的数据。
步骤一中日志文件构建的方法为:当一个新事务开启,并产生第一个数据变化时,为第一个更新的数据成员插入一条日志记录;当事务中产生其他数据成员变化时,则插入一条新的日志记录,将其前成员设为上一变化的数据记录;对于插入和删除操作,在数据地址表中使用多个标示符来区别不同版本的数据;如果事务被提交或回滚,则插入一条提交或回滚日志记录,前成员设置为之前更新的成员;记录数据库中所有产生变化的数据成员及其具体的数据操作,并统一存储在日志文件中。
尽管已经示出和描述了本发明的实施例,对于本领域的普通技术人员而言,可以理解在不脱离本发明的原理和精神的情况下可以对这些实施例进行多种变化、修改、替换和变型,本发明的范围由所附权利要求及其等同物限定。

Claims (4)

  1. 一种闪存数据库快速进行数据恢复的方法,其特征在于:包括以下步骤:
    步骤一:扫描数据库中的日志文件,确认日志文件中是否有仍然有效的事务提交日志记录或事务日志;
    步骤二:依据日志文件当前的状态分别进行如下处理:若存在有效的事务提交日志记录,表明涉及该事务的所有更改尚未完全写入到数据文件中,需依据日志记录,完成数据文件的重写,检查是否存在有效的回滚日志记录,若存在,则依据事务ID查找所有日志记录,并进行回滚操作,不存在有效的事务提交日志记录进入下一步;
    步骤三:若不存在有效的事务提交日志记录,也不存在有效的回滚日志,但存在仍然有效的日志记录,表明该事务尚未完成,检查是否存在部分日志记录已写入数据文件,而部分未写入的情况,如存在,则进行回滚操作。
  2. 根据权利要求1所述的一种闪存数据库快速进行数据恢复的方法,其特征在于:所述步骤三中回滚操作首先依据事务ID从日志文件中找出所有关于事务ID对应的该事务仍然有效的日志记录,然后依次判断日志记录操作类型,根据不同操作类型,完成如下操作:若是插入操作,则删除当前插入的数据元素;若是删除操作,则重新插入被删除的数据元素;若是更新操作,则将数据元素的值恢复到初始状态。
  3. 根据权利要求1所述的一种闪存数据库快速进行数据恢复的方法,其特征在于:所述步骤一中日志记录包括链表和数据表,链表中顺序存储每一个事务产生的不同数据操作的日志记录,数据表中包含一个日志记录 中每个数据成员的不同版本数据,链表的日志记录中包含指定数据表的地址;数据表中的日志记录包含事务ID、数据成员、前成员和数据地址表四个字段,其中事务ID为当前日志记录所属事务的ID号;数据成员为当前数据操作指向的数据成员的名称;前成员为当前事务中产生变化的前成员;数据地址表为数据成员所有版本数据的地址,每个版本数据按时间顺序用链表进行连接,当事务提交或回滚后,该数据地址字段设置为空。
  4. 根据权利要求1所述的一种闪存数据库快速进行数据恢复的方法,其特征在于:所述步骤二中数据文件被配置为存放着在数据库中存储的数据。
    根据权利要求1所述的一种闪存数据库快速进行数据恢复的方法,其特征在于:所述步骤一中日志文件构建的方法为:当一个新事务开启,并产生第一个数据变化时,为第一个更新的数据成员插入一条日志记录;当事务中产生其他数据成员变化时,则插入一条新的日志记录,将其前成员设为上一变化的数据记录;对于插入和删除操作,在数据地址表中使用多个标示符来区别不同版本的数据;如果事务被提交或回滚,则插入一条提交或回滚日志记录,前成员设置为之前更新的成员;记录数据库中所有产生变化的数据成员及其具体的数据操作,并统一存储在日志文件中。
PCT/CN2019/104085 2019-01-10 2019-09-03 一种闪存数据库快速进行数据恢复的方法 WO2020143240A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910021665.3A CN109684292A (zh) 2019-01-10 2019-01-10 一种闪存数据库快速进行数据恢复的方法
CN201910021665.3 2019-01-10

Publications (1)

Publication Number Publication Date
WO2020143240A1 true WO2020143240A1 (zh) 2020-07-16

Family

ID=66192857

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/104085 WO2020143240A1 (zh) 2019-01-10 2019-09-03 一种闪存数据库快速进行数据恢复的方法

Country Status (2)

Country Link
CN (1) CN109684292A (zh)
WO (1) WO2020143240A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684292A (zh) * 2019-01-10 2019-04-26 江苏华存电子科技有限公司 一种闪存数据库快速进行数据恢复的方法
CN110134340B (zh) * 2019-05-23 2020-03-06 苏州浪潮智能科技有限公司 一种元数据更新的方法、装置、设备以及存储介质
CN111176907B (zh) * 2020-01-06 2021-03-05 中科驭数(北京)科技有限公司 硬件数据库回滚方法、软件数据库回滚方法及装置
CN111694893B (zh) * 2020-04-23 2023-04-25 武汉达梦数据库股份有限公司 一种基于日志解析的部分回滚解析方法和数据同步系统
CN112612648B (zh) * 2020-12-29 2022-11-08 厦门市美亚柏科信息股份有限公司 一种SQL Server数据库恢复方法、终端设备及存储介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100281013A1 (en) * 2009-04-30 2010-11-04 Hewlett-Packard Development Company, L.P. Adaptive merging in database indexes
CN107220145A (zh) * 2017-05-19 2017-09-29 北京计算机技术及应用研究所 一种闪存数据库数据恢复的方法
CN109684292A (zh) * 2019-01-10 2019-04-26 江苏华存电子科技有限公司 一种闪存数据库快速进行数据恢复的方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100281013A1 (en) * 2009-04-30 2010-11-04 Hewlett-Packard Development Company, L.P. Adaptive merging in database indexes
CN107220145A (zh) * 2017-05-19 2017-09-29 北京计算机技术及应用研究所 一种闪存数据库数据恢复的方法
CN109684292A (zh) * 2019-01-10 2019-04-26 江苏华存电子科技有限公司 一种闪存数据库快速进行数据恢复的方法

Also Published As

Publication number Publication date
CN109684292A (zh) 2019-04-26

Similar Documents

Publication Publication Date Title
WO2020143240A1 (zh) 一种闪存数据库快速进行数据恢复的方法
US9183236B2 (en) Low level object version tracking using non-volatile memory write generations
WO2017190604A1 (zh) 数据库系统中事务恢复的方法与数据库管理系统
US7363540B2 (en) Transaction-safe FAT file system improvements
CN107220145B (zh) 一种闪存数据库数据恢复的方法
EP1503290B1 (en) Transaction consistent copy-on-write database
US7809777B2 (en) File system having deferred verification of data integrity
US7970803B2 (en) Optimized startup verification of file system integrity
US20070005874A1 (en) File system storing transaction records in flash-like media
US20060200500A1 (en) Method of efficiently recovering database
JP7395227B2 (ja) データバックアップ方法、装置、サーバ及びコンピュータプログラム
US20040193564A1 (en) Robust, self-maintaining file system
WO2017161795A1 (zh) 处理流水文件的方法及系统
US8108356B2 (en) Method for recovering data in a storage system
WO2023206968A1 (zh) 一种数据存储方法、系统及计算机可读存储介质
CN112988611A (zh) 非易失性存储器的数据写入方法、终端和可读存储介质
WO2018000191A1 (zh) 一种数据处理的方法和装置
Lee et al. RMSS: an efficient recovery management scheme on NAND flash memory based solid state disk
WO2010145967A1 (en) Memory device for managing the recovery of a non volatile memory
US20060004846A1 (en) Low-overhead relational database backup and restore operations
US10185653B2 (en) Integrated systems and methods for the transactional management of main memory and data storage
CN114880277B (zh) 块设备快照方法、系统和存储介质
CN116126591B (zh) 一种嵌入式系统的事务机制
CN112612648B (zh) 一种SQL Server数据库恢复方法、终端设备及存储介质
US11150940B2 (en) System and method for recording transaction associated with a page-oriented non-volatile memory

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19908793

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19908793

Country of ref document: EP

Kind code of ref document: A1