criticalI/O

SQL Server Error 824 - Causes & Fixes

Complete SQL Server Error 824 troubleshooting guide. Diagnose page corruption, run integrity checks, restore corrupted pages, and prevent data corruption recurrence.

Quick Answer

SQL Server Error 824 indicates page corruption detected after successful disk read/write operations. The storage subsystem reports success but SQL Server's logical consistency checks fail on the page contents. This critical error requires immediate investigation as it signals potential data corruption from hardware failures, storage issues, or memory problems.

Root Cause Analysis

Error 824 occurs when SQL Server's buffer pool manager successfully reads a page from disk (no I/O error reported by Windows), but the page fails logical consistency validation. The buffer pool performs checksum verification and logical structure validation after each page read. When these checks fail, the checkpoint process, lazy writer, or read-ahead mechanism triggers Error 824.

The error manifests during several internal operations: buffer pool page validation after disk reads, checkpoint writes when dirty pages fail consistency checks, or lazy writer operations when pages contain invalid data structures. SQL Server 2016 introduced enhanced page verification that catches corruption earlier in the I/O pipeline. Later versions continue to rely on page checksums and the suspect_pages catalog as the primary mechanism for tracking logical consistency failures.

Memory pressure exacerbates this error when the buffer pool manager frequently flushes and reloads pages, increasing corruption detection frequency. The lock manager may escalate page-level locks to table locks when encountering corrupted pages, causing application timeouts. Version store cleanup in tempdb can trigger Error 824 when snapshot isolation transactions access corrupted version pages.

SQL Server 2022's Accelerated Database Recovery feature changes Error 824 behavior by isolating corruption to specific persistent version store pages rather than affecting primary data pages. This version also improved CHECKDB integration with Azure Backup corruption detection.

AutoDBA checks Page corruption detection, integrity check scheduling, and storage subsystem monitoring across your entire SQL Server instance in 60 seconds. Download the free diagnostic script and see what else needs attention.

Diagnostic Queries

-- Check for recent Error 824 occurrences in error log
EXEC xp_readerrorlog 0, 1, N'824', N'database', NULL, NULL, N'DESC';

Reveals Error 824 instances with timestamps, affected databases, and page details.

-- Examine suspect pages catalog for corruption tracking
SELECT database_id, file_id, page_id, event_type, error_count, last_update_date
FROM msdb.dbo.suspect_pages 
WHERE event_type IN (1, 2, 3)
ORDER BY last_update_date DESC;

Shows pages SQL Server has marked as potentially corrupt with error classifications.

-- Query Page Life Expectancy and buffer pool pressure indicators
SELECT 
    cntr_value AS page_life_expectancy_seconds,
    cntr_value/60 AS page_life_expectancy_minutes
FROM sys.dm_os_performance_counters 
WHERE counter_name = 'Page life expectancy'
AND object_name LIKE '%Buffer Manager%';

Low PLE values indicate memory pressure that increases corruption detection frequency.

-- Check for hardware correlation with wait statistics
SELECT 
    wait_type, 
    waiting_tasks_count,
    wait_time_ms,
    signal_wait_time_ms,
    wait_time_ms - signal_wait_time_ms AS resource_wait_time_ms
FROM sys.dm_os_wait_stats 
WHERE wait_type IN ('PAGEIOLATCH_SH', 'PAGEIOLATCH_EX', 'WRITELOG', 'IO_COMPLETION')
ORDER BY wait_time_ms DESC;

Correlates I/O wait patterns with potential hardware issues causing corruption.

-- Analyze error log for storage subsystem patterns
EXEC xp_readerrorlog 0, 1, N'I/O requests taking longer', NULL, NULL, NULL, N'DESC';

Identifies storage performance issues that often precede corruption events.

Fix Scripts

Immediate Database Integrity Check

-- Run comprehensive integrity check on affected database
-- WARNING: This can be resource-intensive on large databases
USE [YourDatabaseName];
GO
DBCC CHECKDB WITH NO_INFOMSGS, ALL_ERRORMSGS;
-- If corruption found, run: DBCC CHECKDB WITH REPAIR_ALLOW_DATA_LOSS
-- Only after full backup and in single-user mode

Performs complete logical and physical consistency verification. Test repair options in development first as data loss may occur.

Enable Page Verification and Checksums

-- Enable page checksums for corruption detection (requires offline operation)
ALTER DATABASE [YourDatabaseName] 
SET PAGE_VERIFY CHECKSUM WITH NO_WAIT;
GO

-- For online operation, use:
-- ALTER DATABASE [YourDatabaseName] SET PAGE_VERIFY CHECKSUM;
-- Then rebuild all indexes to apply checksums to existing pages

Implements checksum verification on all database pages. Existing pages need index rebuilds to apply checksums retroactively.

Restore Corrupted Pages from Backup

-- Restore specific corrupted pages (Enterprise Edition only)
-- Replace file_id and page_id with values from suspect_pages catalog
RESTORE DATABASE [YourDatabaseName] 
PAGE = '1:12345' -- Format: file_id:page_id
FROM DISK = 'C:\YourBackup.bak'
WITH NORECOVERY;
GO
-- Apply subsequent log backups
RESTORE LOG [YourDatabaseName] FROM DISK = 'C:\YourLogBackup.trn';

Restores individual corrupted pages without full database restore. Requires recent full backup and continuous log backup chain.

Configure Automatic Page Repair for Mirroring/AG

-- Enable automatic page repair in AlwaysOn Availability Groups
-- This runs automatically but verify configuration
SELECT 
    database_id,
    automatic_page_repair_count,
    automatic_page_repair_error_count
FROM sys.dm_hadr_database_replica_states
WHERE is_local = 1;

Monitors automatic page repair functionality in high availability configurations. No manual intervention required when properly configured.

AutoDBA generates fix scripts like these automatically, with impact estimates and rollback SQL included.

Prevention

Configure robust backup strategies with frequent transaction log backups to minimize data loss from page-level restores. Enable page checksums on all production databases and implement CHECKDB automation with appropriate scheduling based on database size and maintenance windows.

Monitor storage subsystem health using Windows Performance Monitor counters for disk queue length, average disk response time, and disk transfers per second. Values exceeding manufacturer specifications indicate hardware issues preceding corruption. Configure SQL Server alerts for Error 824 using Database Mail to ensure immediate notification.

Implement memory configuration best practices including max server memory settings leaving adequate RAM for the operating system. Enable lock pages in memory privilege for SQL Server service account to prevent memory pressure. Configure instant file initialization to reduce I/O overhead during database growth operations.

Deploy storage solutions with enterprise-grade RAID configurations, battery-backed write caches, and regular firmware updates. Avoid consumer-grade storage devices in production environments. Implement SAN replication or storage-level snapshots as additional corruption protection layers.

Use SQL Server 2019+ Intelligent Query Processing features to improve query resilience and enable Query Store to track plan regressions that may accompany corruption-related performance degradation. Note that Query Store itself does not detect page corruption; rely on CHECKDB, page checksums, and the suspect_pages catalog for corruption detection.

Need hands-on help?

Dealing with persistent sql server error 824 issues across your environment? Samix Technology provides hands-on SQL Server performance consulting with 15+ years of production DBA experience.

Related Pages