Recovery File

0

Recover updates

If the page file is not properly unloaded then the data is recovered from recovery file. We figure out the page file shutdown status during its loading process by reading its metadata. The ‘Clean Shutdown’ property would be false if the shutdown was not clean. In case of an improper shutdown, the page writes are read from recovery file. First the recovery file header is read to know the next transaction ID, expected checksum and the no. of pages to recover. Next the data is read for each page into a buffer. The checksum is computed as we keep reading the data.
Recovery is aborted if any one of the following happens:
  1. Partial write to the recovery buffer. This will we will know as we read the data from the recovery file. Length of the data read must be equal to the page size.
  2. Recovery buffer was partially written to disk. The checksum is not valid. The computed checksum and the expected checksum must match.
Once the recovery file is successfully read into buffer and the checksum matched, the data in buffer is re-applied to the page file.

Recovery File Structure

Transaction ID is the next transaction ID counter.
Expected checksum is computed based on the data written to recovery buffer. During the recovery, the checksum is re-computed and compared with the ‘Expected checksum’. If it matches it means data is completely recovered else it means the recovery buffer was partially written to disk. Adler-32 algorithm is used to compute the checksum.
Page counter is the number of recovery pages that we have in the recovery buffer
Page Offset is the page ID which is followed by its data. This repeats for each page.

Recovery File
Recovery File

Home

Share.

Leave A Reply