Catching Silent Corruption Across Clouds: Block Checks, Lost Write Protection and Automatic Block Repair with Data Guard
Most failures announce themselves: a disk fails, a node reboots, an instance crashes. Data corruption is different. A block can be damaged by a firmware bug, a faulty adapter or an operating system problem and sit unnoticed until a query reads it months later. Worse still is a lost write: the storage confirms a write that never reached the disk, so the block on disk is simply old, with a valid checksum and nothing to show it is wrong.
A physical standby is one of the best defences against both, because it holds an independent copy built from redo rather than from copied blocks. This post configures the checks that let the databases spot corruption and lost writes, validates the standby, and shows how Active Data Guard repairs a corrupt block on the primary without anyone touching it. The primary runs on Exadata Database Service in Oracle Database@Azure, the standby in OCI.
The Use Case
SALES_AZ is the production primary on Exadata Database Service in Oracle Database@Azure. SALES_OCI is its physical standby on Exadata Database Service in an OCI region, open read-only with apply for reporting. The parameters for block checking were never reviewed after the migration, and the audit team asks how the company would detect silent corruption, and how quickly it would be repaired.
Environment used in this runbook
Primary: SALES_AZ, Oracle Database 19c (19.24), two-node RAC on Exadata Database Service in Oracle Database@Azure
Standby: SALES_OCI, physical standby on Exadata Database Service in OCI, managed by the Data Guard broker
Standby mode: read only with apply (Active Data Guard)
Protection mode: Maximum Performance, asynchronous transport between the clouds
Licence: the block checking parameters and lost write detection are part of Oracle Database Enterprise Edition; automatic block media recovery from the standby requires the Active Data Guard option, an extra-cost licence on both databases
The Three Kinds of Checks
Block checksums catch physical damage. With DB_BLOCK_CHECKSUM, each block carries a checksum written by the database and verified when the block is read, so a block changed on its way to or from disk is detected.
Block checking catches logical damage. With DB_BLOCK_CHECKING, the database checks the internal structure of a block each time it changes, so a block that is logically inconsistent is caught before it is written.
Lost write protection catches stale blocks. With DB_LOST_WRITE_PROTECT, the primary records in its redo the version of each block it reads from disk, and the standby compares that version with its own copy during apply.
The standby is the reference. Because the standby builds its blocks from redo, a corrupt or stale block on the primary does not travel to it, and the standby can supply a good copy.
Step 1: Check the Current Settings on Both Databases
Look at the three parameters on the primary and on the standby. Run the same query on both.
SQL |
-- On SALES_AZ, then on SALES_OCI COLUMN name FORMAT A24 COLUMN value FORMAT A10
SELECT name, value FROM v$parameter WHERE name IN ('db_block_checksum', 'db_block_checking', 'db_lost_write_protect') ORDER BY name; |
Expected output |
NAME VALUE
------------------------ ----------
db_block_checking FALSE
db_block_checksum TYPICAL
db_lost_write_protect NONEWhat to expect: The defaults on both databases: checksums are calculated, but block checking is off and lost writes are not detected. This is the most common state after a migration, and it means the standby cannot detect a lost write on the primary.
Step 2: Enable Lost Write Protection on Both Sides
Lost write detection only works when the parameter is set on the primary and on every standby. Set it to TYPICAL, which covers read-write tablespaces.
SQL |
-- On SALES_AZ (primary) ALTER SYSTEM SET db_lost_write_protect = TYPICAL SCOPE = BOTH SID = '*';
-- On SALES_OCI (standby) ALTER SYSTEM SET db_lost_write_protect = TYPICAL SCOPE = BOTH SID = '*'; |
Expected output |
System altered.
System altered.What this does: From now on, the primary writes a small redo record each time it reads a block from disk into the buffer cache, with the version of the block it found. During apply, the standby compares that version with its own. If the primary read an older version than the standby holds, the primary lost a write, and the standby stops apply with ORA-00752. The cost is a little more redo on the primary, usually a few percent; measure it in Step 4.
Tip: Setting the parameter to NONE on either database disables detection for the whole configuration. Include it in the checks you run after every switchover rehearsal, so a rebuilt standby does not silently lose it.
Step 3: Enable Block Checking, Standby First
Block checking costs CPU, because each change to a block is followed by a check of the block. Start on the standby, where the cost does not affect users, and turn it on for the primary after measuring.
SQL |
-- On SALES_OCI (standby): check every changed block during redo apply ALTER SYSTEM SET db_block_checking = MEDIUM SCOPE = BOTH SID = '*';
-- On SALES_AZ (primary), after a test period ALTER SYSTEM SET db_block_checking = MEDIUM SCOPE = BOTH SID = '*'; |
Expected output |
System altered.
System altered.What this does: MEDIUM checks the structure of every changed block except index blocks; FULL also checks index blocks and costs more. On the standby, checking during apply finds logical corruption in the redo stream before it reaches the standby's datafiles. Leave DB_BLOCK_CHECKSUM at TYPICAL on both; FULL adds checks of blocks in memory and is mostly used during investigations.
Step 4: Measure the Cost on the Primary
Compare the redo generated and the CPU used per transaction before and after the change. Lost write protection shows up in redo, block checking in CPU.
SQL |
-- On SALES_AZ: hourly averages from AWR, the day before and the day after the change COLUMN hour FORMAT A13 COLUMN metric_name FORMAT A24
SELECT TO_CHAR(begin_time, 'YYYY-MM-DD HH24') AS hour, metric_name, ROUND(average, 2) AS avg_value FROM dba_hist_sysmetric_summary WHERE metric_name IN ('Redo Generated Per Sec', 'CPU Usage Per Txn') AND TO_CHAR(begin_time, 'HH24') = '11' AND begin_time >= TIMESTAMP '2026-11-23 00:00:00' AND instance_number = 1 ORDER BY begin_time, metric_name; |
Expected output |
HOUR METRIC_NAME AVG_VALUE
------------- ------------------------ ----------
2026-11-23 11 CPU Usage Per Txn .38
2026-11-23 11 Redo Generated Per Sec 19293798.4
2026-11-24 11 CPU Usage Per Txn .4
2026-11-24 11 Redo Generated Per Sec 20027310.7What to expect: The same business hour on the day before and the day after the change, at a similar workload. Redo, in bytes per second, grows by about 4 percent, and CPU per transaction, in centiseconds, by about 5 percent, an acceptable price for this workload. If CPU grows much more, keep block checking on the standby only and review the decision with the application owner.
Step 5: Validate the Standby
Run a full validation with logical checks on the standby. It reads every block, so it finds corruption that no query has touched yet, without any load on the primary.
RMAN |
# On SALES_OCI (standby), connected with rman target / RUN { ALLOCATE CHANNEL c1 DEVICE TYPE DISK; ALLOCATE CHANNEL c2 DEVICE TYPE DISK; ALLOCATE CHANNEL c3 DEVICE TYPE DISK; ALLOCATE CHANNEL c4 DEVICE TYPE DISK; VALIDATE CHECK LOGICAL DATABASE; } |
Expected output |
Starting validate at 24-NOV-26
channel c1: starting validation of datafile
channel c1: specifying datafile(s) for validation
input datafile file number=00012 name=+DATAC1/SALES_OCI/DATAFILE/sales_data.311.1171842297
channel c1: validation complete, elapsed time: 01:12:44
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
12 OK 0 18240 41943040 918273645
Finished validate at 24-NOV-26What to expect: Status OK and no blocks marked corrupt for each datafile. The full output lists every datafile; only one is shown here. Any block found corrupt is recorded in V$DATABASE_BLOCK_CORRUPTION, which the next step reads. Schedule this validation monthly, at a time when the standby's reporting load is low.
Step 6: Check the Corruption List on Both Databases
Query the corruption list on both databases after validations and after any error report. It shows the file and block of every corrupt block the database knows about.
SQL |
COLUMN corruption_type FORMAT A10
SELECT file#, block#, blocks, corruption_change#, corruption_type FROM v$database_block_corruption ORDER BY file#, block#; |
Expected output |
FILE# BLOCK# BLOCKS CORRUPTION_CHANGE# CORRUPTION
---------- ---------- ---------- ------------------ ----------
7 182044 1 0 CHECKSUMWhat to expect: No rows on a healthy database. The row shown here appeared on the primary after a query failed with ORA-01578 on one block of file 7: a checksum mismatch, meaning the block was damaged on disk. CORRUPTION_TYPE also distinguishes LOGICAL corruption, found by the logical checks, and NOLOGGING blocks, which are not corruption but blocks loaded without redo.
Step 7: Watch Automatic Block Media Recovery
With Active Data Guard, the primary repairs such a block on its own: when a session hits a corrupt block, the primary fetches a good copy from the standby and recovers it with redo, and the session continues. Check the alert log of the primary.
Shell |
# On a primary database server adrci exec="set home diag/rdbms/sales_az/SALES1; show alert -p \"message_text like '%block media recovery%'\" -term" |
Expected output |
2026-11-24 11:42:07.413000 +00:00
Automatic block media recovery requested for (file# 7, block# 182044)
2026-11-24 11:42:08.902000 +00:00
Automatic block media recovery successful for (file# 7, block# 182044)What to expect: The request and the successful repair about a second and a half later, including the round trip to the standby in OCI. The user's query got its result instead of an error, and V$DATABASE_BLOCK_CORRUPTION on the primary is empty again. Without Active Data Guard, the same block would need a manual repair from a backup.
Step 8: Repair Blocks Manually When Needed
If automatic repair is not available, or the corruption was found by a validation rather than by a query, repair the listed blocks with RMAN. On the primary, RMAN uses the standby or the backups to restore each block and applies redo to bring it up to date.
RMAN |
# On SALES_AZ, connected with rman target / catalog rcat@rcatdb RECOVER CORRUPTION LIST; |
Expected output |
Starting recover at 24-NOV-26
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 24-NOV-26What this does: It repairs every block in V$DATABASE_BLOCK_CORRUPTION in one command, without taking the datafile offline. Run the query from Step 6 again afterwards to confirm the list is empty, and keep the alert log entries with the incident record.
Step 9: Know What to Do About ORA-00752
A lost write is more serious than a corrupt block: the block on the primary is valid but out of date, and redo applied on top of it may already have produced wrong data there. The standby detects it and stops apply. Check the standby's apply status, then its alert log.
Shell |
# On a standby database server dgmgrl / "show database 'SALES_OCI'" |
Expected output |
Database - SALES_OCI
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 14 minutes 12 seconds (computed 1 second ago)
Average Apply Rate: 0 Byte/s
Real Time Query: OFF
Instance(s):
SALES1 (apply instance)
Database Error(s):
ORA-16766: Redo Apply is stopped
Database Status:
ERRORWhat to expect: Redo apply has stopped and the apply lag grows, while redo still arrives. The standby's alert log names the reason: ORA-00752: recovery detected a lost write of a data block, which means the primary lost a write. Oracle's guidance is to treat the standby as the correct copy: stop the primary and fail over to the standby. Do not copy blocks or datafiles from the primary to the standby to restart apply, because that would carry the lost write into the only good copy. Open a service request with Oracle Support at the same time, and rehearse this decision with the application owners before it is ever needed.
Summary
A standby in another cloud is also a corruption detector, provided the databases are told to check. Leave DB_BLOCK_CHECKSUM at TYPICAL, set DB_LOST_WRITE_PROTECT to TYPICAL on the primary and every standby, and enable DB_BLOCK_CHECKING on the standby first and on the primary after measuring the cost. Validate the standby every month with VALIDATE CHECK LOGICAL DATABASE and watch V$DATABASE_BLOCK_CORRUPTION on both sides. With Active Data Guard, corrupt blocks on the primary are repaired automatically from the standby; without it, use RECOVER CORRUPTION LIST. If the standby ever reports ORA-00752, the primary has lost a write, and the safe answer is a failover to the standby.
Comments