IP Library Granted Patent US 12,346,305
Granted Patent B2
US 12,346,305 · App. 17/994,229 · Granted Jul 1, 2025

Electronic device for recovering database and method of operating the same

Inventors: Hyeeun Jun (Suwon-si, KR); Kisung Lee (Suwon-si, KR); Yoonho Shin (Suwon-si, KR)
Assignee: Samsung Electronics Co., Ltd.
G06F16/2365G06F16/24552G06F2201/80
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,346,305
App. No.
17/994,229
Granted
Jul 1, 2025
Kind
B2
Abstract

An electronic device for recovering a database (DB) and a method of operating the electronic device are provided. The electronic device includes a non-volatile first memory configured to store a DB, a volatile second memory, and a processor operably connected to the first memory and the second memory. The processor may determine whether the DB is corrupted, may perform first integrity check of the DB after initializing a DB cache in which at least a portion of the DB is loaded to a user space of the second memory when it is determined that the DB is corrupted, may perform second integrity check of the DB after initializing an operating system (OS) cache in which at least a portion of the DB is loaded to a kernel space of the second memory when the first integrity check of the DB fails, and may perform a task on a DB file when the first integrity check or the second integrity check of the DB is successful.

Claims (87)

1. An electronic device, comprising:

first memory storing a database (DB), the first memory being non-volatile;

second memory storing at least a portion of the DB, the second memory being volatile;

third memory storing one or more computer programs; and

one or more processors operably connected to the first memory, the second memory, and the third memory,

wherein the one or more computer programs include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether the DB is corrupted,

in case that the DB is corrupted:

initialize a DB cache in a user space of the second memory, which includes to load a first portion of the at least a portion of the DB to the user space of the second memory,

perform a first consistency check of the first portion of the at least a portion of the DB after initializing the DB cache, and

perform a first integrity check of the first portion of the at least a portion of the DB on the user space of the second memory when the first consistency check is successful,

in case that the first consistency check or the first integrity check of the DB fails:

initialize an operating system (OS) cache in a kernel space of the second memory, which includes to load a second portion of the at least a portion of the DB to the kernel space of the second memory, and

perform a second integrity check of the DB on the kernel space of the second memory, and

perform a task on a DB file, when the first integrity check or the second integrity check of the DB is successful.

2. The electronic device of claim 1 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to initialize the DB cache by reloading the first portion of the at least a portion of the DB after clearing the DB cache in response to corruption of the DB being detected.

3. The electronic device of claim 1 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether metadata loaded to the DB cache is corrupted, when the second integrity check of the DB fails, and

perform metadata overriding on the DB cache based on backup data of the metadata, when it is determined that the metadata is corrupted.

4. The electronic device of claim 3 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether the backup data of the metadata is present, when it is determined that the metadata is corrupted,

perform a third integrity check of the backup data, when it is determined that the backup data is present,

load the backup data to the DB cache, when the third integrity check of the backup data is successful, and

recover the metadata through an in-place update based on the backup data.

5. The electronic device of claim 4 ,

wherein the in-place update is performed by rewriting metadata extracted from the backup data in a same position as a position of the corrupted metadata in a state in which an exclusive lock on the DB is acquired, and

wherein the exclusive lock is returned when the in-place update is completed.

6. The electronic device of claim 3 , wherein the backup data of the metadata is determined based on:

determining whether the metadata is updated, when a write transaction is performed on the DB,

generating the backup data of the metadata, when the metadata is updated, and

rolling back the backup data to a previous state, when the generating of the backup data fails.

7. The electronic device of claim 3 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

load template data of the metadata to the DB cache, when the backup data of the metadata is absent or when a third integrity check of the backup data fails, and

recover the metadata through an in-place update based on the template data.

8. The electronic device of claim 7 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether header data of the DB is corrupted, when the backup data of the metadata is absent or when the third integrity check of the backup data fails,

generate template data for the header data of the DB based on a state of the DB, when it is determined that the header data of the DB is corrupted,

determine whether header data of a page in the DB is corrupted, when it is determined that the header data of the DB is not corrupted, and

generate template data for the header data of the page based on a state of the page, when it is determined that the header data of the page is corrupted.

9. The electronic device of claim 7 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether the DB is opened normally, when recovering of the metadata based on the template data fails,

determine whether an index of the DB is corrupted, when it is determined that the DB is opened normally,

perform ReIndex on the DB, when it is determined that the index of the DB is corrupted,

determine whether a freelist or a table tree map for the DB is corrupted and/or whether an unused page is corrupted, when it is determined that the index of the DB is not corrupted; and

perform VACUUM on the DB, when it is determined that the freelist or the table tree map is corrupted or that the unused page is corrupted.

10. The electronic device of claim 9 , wherein the one or more computer programs further include computer-executable instructions that, when executed by the one or more processors individually or collectively, cause the electronic device to:

determine whether the DB is opened normally,

extract data from the DB based on a table page call module of a DB management system, when the table page call module is present, and

generate a new DB based on the extracted data.

11. A method of operating an electronic device, the method comprising:

determining whether a database (DB) stored in a first memory of the electronic device is corrupted, the first memory being non-volatile;

in case that the DB is corrupted:

initializing a DB cache in a user space of a second memory of the electronic device, wherein the second memory stores at least a portion of the DB when the DB was determined to be corrupted, and wherein the initializing of the DB cache includes loading a first portion of the at least a portion of the DB to the user space of the second memory;

performing a first consistency check of the first portion of the at least a portion of the DB after initializing the DB cache; and

performing a first integrity check of the first portion of the at least a portion of the DB on the user space of the second memory when the first consistency check is successful;

in case that the first consistency check or the first integrity check of the DB fails:

initializing an operating system (OS) cache in a kernel space of the second memory, wherein the initializing of the OS cache includes loading a second portion of the at least a portion of the DB to the kernel space of the second memory; and

performing a second integrity check of the DB on the kernel space of the second memory; and

performing a task on a DB file, when the first integrity check or the second integrity check of the DB is successful.

12. The method of claim 11 , wherein the performing of the first integrity check of the DB comprises initializing the DB cache by reloading the first portion of the at least a portion of the DB after clearing the DB cache in response to corruption of the DB being detected.

13. The method of claim 11 , further comprising:

determining whether metadata loaded to the DB cache is corrupted, when the second integrity check of the DB fails; and

performing metadata overriding on the DB cache based on backup data of the metadata, when it is determined that the metadata is corrupted.

14. The method of claim 13 , wherein the performing of the metadata overriding on the DB cache comprises:

determining whether the backup data of the metadata is present, when it is determined that the metadata is corrupted;

performing a third integrity check of the backup data, when it is determined that the backup data is present;

loading the backup data to the DB cache, when the third integrity check of the backup data is successful; and

recovering the metadata through an in-place update based on the backup data.

15. The method of claim 13 , wherein the backup data of the metadata is determined based on:

determining whether the metadata is updated when a write transaction is performed on the DB;

generating the backup data of the metadata, when the metadata is updated; and

rolling back the backup data to a previous state, when the generating of the backup data fails.

16. One or more non-transitory computer-readable storage media storing one or more computer programs including computer-executable instructions that, when executed by one or more processors of an electronic device individually or collectively, cause the electronic device to perform operations, the operations comprising to:

determine whether a database (DB) stored in first memory of the electronic device is corrupted, the first memory being non-volatile,

in case that the DB is corrupted:

initialize a DB cache in a user space of a second memory of the electronic device, wherein the second memory stores at least a portion of the DB when the DB was determined to be corrupted, and wherein to initialize the DB cache includes to load a first portion of the at least a portion of the DB to the user space of the second memory,

perform a first consistency check of the first portion of the at least a portion of the DB after initializing the DB cache, and

perform a first integrity check of the first portion of the at least a portion of the DB on the user space of the second memory when the first consistency check is successful,

in case that the first consistency check or the first integrity check of the DB fails:

initialize an operating system (OS) cache in a kernel space of the second memory, wherein to initialize the OS cache includes to load a second portion of the at least a portion of the DB to the kernel space of the second memory, and

perform a second integrity check of the DB on the kernel space of the second memory, and

perform a task on a DB file, when the first integrity check or the second integrity check of the DB is successful.

17. The method of claim 15 ,

wherein the determining of whether the metadata is updated comprises determining whether a specific portion of the metadata is updated, and

wherein the specific portion comprises at least one of a DB header or a DB schema.

18. The method of claim 17 , further comprising:

indicating a DB write transaction commitment, in case that the specific portion of the metadata is updated and the generating of the backup data succeeds.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 25, 2022
From: JUN, HYEEUN; LEE, KISUNG; SHIN, YOONHO
To: SAMSUNG ELECTRONICS CO., LTD.
Reel/Frame 061878/0507 →
Priority Claims (2)
KR 10-2021-0156549 · Nov 15, 2021 · national
KR 10-2021-0168020 · Nov 30, 2021 · national
Continuity (2)
Continuation PCTKR2022015546 · Oct 14, 2022
Related Publication 20230153291A1 · May 18, 2023
References Cited (31)
US 8364648B1 · Sim-Tang · 2013 [cited by examiner]
US 8484616B1 · McCann · 2013 [cited by examiner]
US 10013439B2 · Gruenheid · 2018 [cited by examiner]
US 12093726B2 · Li · 2024 [cited by examiner]
US 20050015456A1 · Martinson, Jr. · 2005 [cited by examiner]
US 20050246453A1 · Erlingsson · 2005 [cited by examiner]
US 20070061266A1 · Moore · 2007 [cited by examiner]
US 20170351584A1 · Griffith · 2017 [cited by examiner]
US 20180172468A1 · Sagall · 2018 [cited by examiner]
US 20180173744A1 · Barbas · 2018 [cited by examiner]
US 20180359090A1 · Grover · 2018 [cited by examiner]
US 20190236168A1 · Vaswani · 2019 [cited by examiner]
US 20190379621A1 · Ichikawa · 2019 [cited by examiner]
US 20200073832A1 · Chaiken et al. · 2020 [cited by applicant]
US 20210149795A1 · Kapusta · 2021 [cited by examiner]
US 20220197796A1 · Rumanek · 2022 [cited by examiner]
JP 2007272493A · 2007 [cited by applicant]
JP 2013222467A · 2013 [cited by applicant]
KR 1020070058281A · 2007 [cited by applicant]
KR 1020080058834A · 2008 [cited by applicant]
KR 1020100126069A · 2010 [cited by applicant]
KR 101484882B1 · 2015 [cited by applicant]
KR 101575246A · 2015 [cited by applicant]
KR 1020170133778A · 2017 [cited by applicant]
KR 1020190021773A · 2019 [cited by applicant]
KR 1020200101217A · 2020 [cited by applicant]
Kaczmarek et al., “Operating system security by integrity checking and recovery using writeprotected storage,” IET Information Security, vol. 8, Issue 2, pp. 122-131, Mar. 1, 2014. [cited by applicant]
International Search Report dated Jan. 19, 2023, issued in International Application No. PCT/KR2022/015546. [cited by applicant]
Anonymous; Oracle Database Concepts; Data Integrity; 10g Release 2 (10.2); XP055277132; http://wayback.archive.org/web/20111120011731/http://docs.oracle.com/cd/B19306_01/server.102/b14220/data _ int.htm. [cited by applicant]
Nervag; The Vagabond Approach to Logging and Recovery in Transaction-Time Temporal Object Database Systems; IEEE Transactions on Knowledge and Data Engineering; vol. 16. No. 4; Apr. 2004; XP011108190; Apr. 1, 2004; Alam… [cited by applicant]
Extended European Search Report dated Sep. 18, 2024; European Appln. No. 22893042.6-1203 / 4345624 PCT/KR2022015546. [cited by applicant]