Method for restoring a database after I/O error employing write-ahead logging protocols
First Claim
1. In a computerized database system including a storage medium for storing data files, index files, and a recovery log having a plurality of files, and a CPU for I/O to said storage medium, a method executed by said system for recovering a database after an I/O error, comprising the steps of:
- (a) writing log records during normal forward processing to said recovery log on said storage medium;
(b) traversing across said recovery log on said storage medium during RESTART routine processing after said I/O error for detecting committed and uncommitted transactions, said RESTART routine including a REDO sub-routine for redoing committed transactions recorded in said recovery log;
(c) detecting said written log records in said recovery log which are incomplete or failed;
(d) executing a recovery routine;
(e) executing an UNDO routine for undoing said detected uncommitted transactions;
(f) renaming said files on said storage medium having said I/O error;
(g) storing in a first file on said storage medium indicators of said renamed files that identify said renamed files as error files;
(h) accessing said first file for said indicators;
(i) preventing a subsequent RESTART routine from accessing said identified I/O error files in response to said accessing said first file;
(j) continuing said RESTART routine in response to said accessing said first file while preventing operations on said identified I/O error files during said continued RESTART routine;
(k) generating a request for access to one of said data files on said storage medium having a corresponding index file;
(l) accessing said one of said data files on said medium to determine whether said corresponding index file has been renamed thereby indicating said corresponding index file is an error index file;
(m) rebuilding said index file in response to said determination of said error index file.
1 Assignment
0 Petitions
Accused Products
Abstract
Method for reducing data loss during I/O errors and power failure during non-atomic writes to media in a transaction management system using write-ahead logging protocol. A recovery log is written during forward processing. On system restart processing, the log is traversed and a REDO executed. Recovery is effected from detected incomplete log writes or log write failures and uncommitted transactions are undone. A technique is provided in which files having I/O errors are identified, whereby subsequent restart operations are prevented from accessing these files. In one embodiment index files with such error are renamed, serving to indicate that corresponding original files contain errors, and the error index files are automatically rebuilt whereby I/O error on the files causes no data loss. The index file rebuild does not invalidate access plans related to the failed index.
166 Citations
9 Claims
-
1. In a computerized database system including a storage medium for storing data files, index files, and a recovery log having a plurality of files, and a CPU for I/O to said storage medium, a method executed by said system for recovering a database after an I/O error, comprising the steps of:
-
(a) writing log records during normal forward processing to said recovery log on said storage medium; (b) traversing across said recovery log on said storage medium during RESTART routine processing after said I/O error for detecting committed and uncommitted transactions, said RESTART routine including a REDO sub-routine for redoing committed transactions recorded in said recovery log; (c) detecting said written log records in said recovery log which are incomplete or failed; (d) executing a recovery routine; (e) executing an UNDO routine for undoing said detected uncommitted transactions; (f) renaming said files on said storage medium having said I/O error; (g) storing in a first file on said storage medium indicators of said renamed files that identify said renamed files as error files; (h) accessing said first file for said indicators; (i) preventing a subsequent RESTART routine from accessing said identified I/O error files in response to said accessing said first file; (j) continuing said RESTART routine in response to said accessing said first file while preventing operations on said identified I/O error files during said continued RESTART routine; (k) generating a request for access to one of said data files on said storage medium having a corresponding index file; (l) accessing said one of said data files on said medium to determine whether said corresponding index file has been renamed thereby indicating said corresponding index file is an error index file; (m) rebuilding said index file in response to said determination of said error index file. - View Dependent Claims (2, 3, 4, 5, 6, 7, 8)
-
-
9. In a computerized database system, a method of generating a recovery log for use in a relational database system having a data file and an index file, comprising the steps of:
-
initializing a plurality of log pages; generating a plurality of log records; writing to media a full log page of said records in one of said initialized log pages having a page number n; writing to said media in response to said system sub-pages of said records in next ones of said initialized log pages having respective alternative and consecutive page locations numbers n+1 and n+2; detecting an I/O error in at least one of said written full pages or sub-pages; and preventing additional said writes to said media in response to said detected I/O error, wherein said I/O error is a detected log write failure or an incomplete log write on said index file.
-
Specification