← Back to Recovery methods

Database Page Corruption and Transaction Recovery

A damaged database can fail at different levels: pages that cannot be read, pages or trees that are structurally inconsistent, or a set of files that does not add up to one transactional state. Telling these apart decides whether the answer is a restore from backup, the engine’s own crash recovery, a repair that may lose data, or a documented partial extraction. SQL Server and InnoDB appear here as labelled examples, not as one universal engine.

In short
  • Readable pages, consistent structures, a consistent transaction state and valid business data are four separate checks.
  • A report naming specific pages localises the evidence; it does not measure how far damage spreads or promise page restore.
  • Logs bring pages to a consistent state; whether recent commits survive depends on settings and storage, and logs are not an unlimited history.
  • Engine startup, crash recovery and repair can all write; experiments belong on separate working copies.
  • When restore is not possible, salvage is an explicitly partial result to validate, not a choice between repair and total loss.
Diagram of database pages and the transaction log converging on a consistent recovery point.
A generic picture of pages and log converging on one consistent point. Engines differ in how they reach it, and the point is only reachable when the needed pages, logs and backups exist together.

Four levels of a database check

Relational engines store persistent data in fixed-size pages that hold rows, index entries and allocation information. Recovery has to answer several separate questions:

  • Physical readability. Can every page of every file be read from storage?
  • Structural consistency. Is each page valid, does it belong to the object it claims, and do allocation maps, trees and index relationships agree?
  • Transaction state. Do data and log files describe one state that existed, with unfinished transactions rolled back?
  • Business validity. Are the records the owner needs present and plausible?

A database can pass some of these and fail others. A file that copies without read errors can still be structurally damaged, and a structurally clean database can be missing committed work.

What a localised error report does and does not say

SQL Server’s DBCC CHECKDB checks allocation, structural and logical consistency, and its report can name a specific object, file and page. That is evidence about where the engine found a problem. It is not an estimate of how widespread the damage is: several reported pages may share a cause in storage or memory, and other damage may not have been read yet. Nor is it a guarantee that the named page can be restored on its own. Microsoft’s Restore Pages article excludes the log, allocation pages and boot pages, and says that when more than a few pages in a file need restoring, restoring the whole file is generally more efficient. The details are in SQL Server Corruption, Page Restore and DBCC.

Varying check results do not isolate a cause

Microsoft’s troubleshooting article lists file-system corruption, hardware, drivers, corrupted pages in memory or storage cache and SQL Server itself as possible causes, and says that errors appearing on one run and disappearing on the next may point to disk-cache or other I/O-path issues. That is a reason to investigate, not a diagnosis. Results that differ between a live database, different copies, different check options or different available resources do not show which layer is at fault.

A useful comparison holds variables fixed: the same unchanged copy, the same engine version and settings, with the error log and storage logs kept alongside. I/O path, cache and memory problems remain hypotheses to test. Repeated checks against a failing source mainly add load to it.

What logs can and cannot reconstruct

Engines write log records so that changes can be redone or undone after a crash. The MySQL 8.4 glossary describes a checkpoint as a record of the latest changes that have been written to the data files; until redo is applied, a data page can legitimately be older than the committed state. That gap is normal operation, not damage.

Three roles should not be blurred. Redo brings pages forward to the last logged change. Undo, or the equivalent rollback information, removes the effects of transactions that never finished. A history of log backups or binary logs, where it exists, is what allows a restored backup to be rolled forward to a chosen point in time. None of these is an unlimited copy of the data: log space is reused once it is no longer needed, and history that was never backed up cannot be replayed.

Write-ahead logging also does not guarantee that every acknowledged commit is on disk regardless of configuration. Whether a recent commit survives depends on commit and flush settings and on whether the storage honours flushes; see InnoDB Tablespaces, Redo Logs and Crash Recovery for the MySQL case.

Preserving a consistent set of files

Data files, logs, configuration, encryption keys or certificates, existing backups and the engine’s error logs belong together. Starting the engine, native crash recovery, backup preparation and repair can all change files, so the original set is preserved before any of them runs. Repeated attempts happen on separate working copies, each with a matching engine version and the keys it needs.

How the set was captured matters. A file-by-file copy of a live, writing database is not necessarily even crash-consistent: data and log files copied at different moments may describe a state that never existed. A coordinated storage snapshot that covers all data and log volumes together can be crash-consistent, but that is still not the same as an application-consistent backup made with the engine’s cooperation. See Live Systems, Snapshots and Consistent Recovery Copies.

Illustration: readable files, no proven state

Observed

Data files and the log were copied at different times. Every file reads without errors, and repeated hashes match.

Interpretation

Stable hashes prove the copies have not changed since they were made. They say nothing about whether the files ever formed one consistent database state.

Next step

Establish when each file was captured, look for a backup or coordinated snapshot, and treat any startup of this set as an experiment on a working copy.

Limit

A conceptual example. The set might still recover cleanly; the point is that readability and hashes do not show it.

Base rows and derived indexes

A secondary or nonclustered index is derived from base data, the heap or clustered index, and can be rebuilt from it. That is conditional: it works only when the base rows and the schema the index depends on are confirmed intact and consistent. Index damage is therefore not automatically the less serious kind. A damaged unique index can hide duplicate rows, dependent objects and queries may rely on it, and the database may be unavailable until it is dealt with. A rebuild also writes and reads the base data through the storage underneath. Damage to base rows, system tables or dictionary metadata has no equivalent source to rebuild from.

Restore, crash recovery, repair and salvage

Scroll horizontally to see the full table →

Four paths, what each depends on and what the result represents.
PathDepends onResult
Restore from backupReadable backups and, for a recent point, continuous log history; keys for encrypted backupsA new copy at a known recovery point; the damaged database stays as evidence
Native crash recoveryData and log files that belong to the same state, on a working copyA consistent state up to what was logged and persisted; writes the files it runs on
Engine repairNo usable restore, and accepted lossA structurally consistent database that may have discarded rows or pages
Salvage or extractionReadable pages or a database that opens in a limited modePartial records exported to a new destination, with gaps listed

Restoring from history and repairing the damaged copy are different operations. Page restore in SQL Server, where its prerequisites hold, restores selected pages from backup and rolls them forward using log records. This is recovery from recorded history rather than manual reconstruction of damaged page contents. Restore writes to its target, so preserve the original file set and use a separate working or restore destination. Other engines have their own recovery capabilities and prerequisites; SQL Server’s procedure must not be assumed to apply to them. Microsoft calls restoring from a known good backup the best solution for permanent consistency errors, and warns that repairing with data loss can leave a database logically inconsistent. A message that repair succeeded means the structure is consistent again, not that every record survived.

When no restore is possible, salvage is a legitimate outcome, but a partial one. InnoDB’s forced-recovery mode, for example, exists to dump tables from a copy in an emergency, and some of its levels change what the extracted rows represent. Pages or rows salvaged from different moments are not combined into one data set without checking them against each other.

Accepting the result

A database that opens, or a dump that finishes, is an intermediate result. Accept it by:

  • a structural check of the result, on a copy where possible;
  • required tables and row counts against known references;
  • constraints, keys and dependencies between objects, which repair does not necessarily maintain;
  • business totals, balances or sequence numbers reconciled with independent records;
  • the accepted recovery point and the known gaps written down, including any rows removed by repair and any forced or limited mode used.

General methods are in How to Validate Recovered Data; how metadata from different moments can disagree is in Storage Metadata Generations and Consistency.

Practical rule

Preserve the complete file set before any engine start, prefer restore from history where it exists, run repair and extraction only on copies, and accept the result by data checks rather than by the server starting.

Technical references: Microsoft Learn: Restore Pages (SQL Server) — excluded pages, whole-file restore for many pages · Microsoft Learn: Troubleshoot database consistency errors — possible causes, intermittent errors, restore before repair · MySQL 8.4 Glossary — checkpoint and flushing · MySQL 8.4, Forcing InnoDB Recovery — emergency extraction from a copy. Pages checked October 2026; SQL Server behaviour depends on version and edition, MySQL references are for 8.4, and other engines differ.

Related: SQL Server Corruption, Page Restore and DBCC · InnoDB Tablespaces, Redo Logs and Crash Recovery · Database Corruption (SQL Server, MySQL, and Similar) · Storage Metadata Generations and Consistency · Live Systems, Snapshots and Consistent Recovery Copies · Repair vs. Recovery · How to Validate Recovered Data