| Lesson 7 | Recovery issues related to read-only tablespaces |
| Objective | Explain how control-file history and tablespace state changes affect read-only tablespace recovery in Oracle AI Database 26ai. |
Read-only tablespaces can reduce backup and recovery work because their data remains unchanged between writable periods. However, successful recovery depends on more than the tablespace's current status. You must also consider the history of the restored files and the information available in the control file.
The previous lesson examined recovery across read-only and read-write periods. This lesson explains the additional issues that arise when a control file is restored from backup or recreated, particularly when healthy read-only datafiles reside on physically read-only or slow storage.
The examples assume a primary database in ARCHIVELOG mode, usable backups, all changes required for the recovery endpoint, working storage, and any necessary encryption keys. EMP_HISTORY and APPPDB are illustrative tablespace and PDB names. The inspection commands support recovery planning; they are not a complete disaster-recovery script.
A tablespace is a logical storage unit backed by datafiles. Its files contain segments for objects such as tables and indexes. An online read-only tablespace allows queries while preventing ordinary modifications to its data. An offline tablespace is unavailable for normal access. These are different conditions.
A backup taken after the transition to READ ONLY completed can provide a restore-only recovery path when the tablespace has remained read-only and the applicable control-file conditions are satisfied. By contrast, a backup taken during an earlier writable period may need recovery. An older read-only backup also needs recovery if the tablespace subsequently became writable.
Consequently, it is incorrect to say that redo can never be applied to a read-only tablespace's restored files. Recovery depends on the changes needed to bring those files to the required state. The absence of ordinary data changes during one read-only interval does not erase earlier or later recovery requirements.
The control file records database structure, datafile information, redo information, and recovery metadata. A current control file and an older backup can describe different points in the database's history. Recreating a control file introduces another situation because its initial file inventory comes from the reconstruction statement.
| Situation | Recovery consideration |
|---|---|
| Usable current control file | Prefer current metadata when it is available and appropriate. Determine file recovery requirements from the backup and subsequent state history. |
| Restored backup control file | Historical metadata may describe a tablespace as read-write even though its surviving files are now read-only. Follow backup-control-file recovery requirements. |
| Recreated control file | Follow the reconstruction procedure, including special handling of omitted read-only files and any resulting missing-file entries. |
In a multitenant database, the control files serve the CDB. A PDB does not have a separate control file that you recreate independently. Perform database-level control-file work from the CDB root with the required administrative privileges, and identify the owning container before handling a tablespace or datafile.
For an authorized SQL*Plus session connected to the root while the database is mounted or open, begin with:
SELECT name, controlfile_type, open_mode, log_mode
FROM v$database;
SELECT con_id, file#, name, status
FROM v$datafile
ORDER BY con_id, file#;
Compare the results with the recovery plan and known file inventory. A recorded filename does not prove that the operating system or ASM can access the file. Investigate storage errors before replacing or renaming anything.
Oracle documents a particular problem involving read-only tablespaces on physically read-only or slow media. If the backup control file records the tablespace as read-write, media recovery may attempt to write to its files. Such writes can fail on unwritable media or add substantial work when the storage is slow.
Logical read-only status and physical write protection are separate concepts. A tablespace marked READ ONLY can reside on ordinary writable disks. The special issue is the combination of historical control-file information, file state, and storage characteristics.
Use a usable current control file when possible. If a backup control file is required and the read-only tablespace has not suffered media failure, Oracle describes two alternatives:
These are alternatives, not instructions to perform both actions in sequence. Matching the tablespace state is only one selection criterion. The control file must also fit the database identity, structural history, available files, and recovery endpoint.
For example, suppose EMP_HISTORY became read-only after the available control-file backup was taken. Its datafiles survive intact on slow storage, but other database files require recovery. That is a reason to evaluate the documented healthy-file alternatives. If EMP_HISTORY's own datafiles are missing or damaged, excluding them does not solve their recovery problem.
There is therefore no universal rule to take all read-only tablespaces offline before every recovery. When files are deliberately left offline, record their identities and the conditions for restoring access. Otherwise, the database may open while required application data remains unavailable.
These conditions come from section 37.2.4, Recovering Read-Only Tablespaces with a Backup Control File, in the Oracle AI Database 26ai Backup and Recovery User's Guide.
In a user-managed SQL*Plus procedure, the following illustrates recovery using an already restored and mounted backup control file:
RECOVER DATABASE USING BACKUP CONTROLFILE;
This command does not restore the control file or datafiles. Required restores, file handling, and recovery prerequisites must already have been addressed. It is SQL*Plus syntax, not an RMAN command.
RMAN uses its own control-file restoration and recovery commands. After recovery with a restored backup control file, the primary database must be opened with RESETLOGS, even when recovery applied all required redo. This differs from ordinary complete recovery using the current control file. See Oracle's RMAN RECOVER reference.
RESETLOGS creates a new database incarnation. It does not reset database SCNs to 1, and it does not automatically make every earlier backup unusable. Future recovery still depends on sufficient backup, redo, and incarnation metadata.
Before choosing recreation, check for usable current multiplexed copies and suitable binary backups or autobackups. A mismatch in one backup does not establish that recreation is necessary. A recovery catalog can supply valuable metadata, but the instance still needs a control file to mount the database.
While the database has a usable control file and is mounted or open, an authorized SQL*Plus session can generate reconstruction SQL:
ALTER DATABASE BACKUP CONTROLFILE TO TRACE;
This is preparation for a possible future failure. It writes a trace containing SQL that can be reviewed and adapted. It does not execute CREATE CONTROLFILE, and it cannot obtain the lost structure from an unavailable control file after the fact.
Retain binary control-file backups as well. A trace script describes reconstruction SQL, whereas a binary backup preserves control-file contents, including recovery repository information that is not reproduced fully by the trace.
Actual recreation requires a reviewed CREATE CONTROLFILE statement with the instance started but the database not mounted. Successful creation mounts the database. The statement and follow-up procedure must account for the real database structure, available redo, and correct opening option. See the CREATE CONTROLFILE reference.
Recreation does not always imply the same opening procedure as restoration of a backup control file. Whether the reconstruction uses RESETLOGS or NORESETLOGS depends on the applicable recovery path. Do not select either option solely because some tablespaces are read-only.
Section 37.3.2 of the Oracle recovery guide describes special handling of read-only files during control-file recreation. Omit those read-only files from the CREATE CONTROLFILE statement so recovery can skip them. This procedure assumes their recovery requirements have been evaluated; files restored from an earlier writable period can still need recovery.
When Oracle reconciles the control-file inventory with the data dictionary, a file present in the dictionary but omitted from the reconstruction statement can receive a name such as MISSING00005. This is a placeholder in metadata. It does not by itself mean the physical file was deleted.
At the documented stage after the database opens, associate each applicable read-only placeholder with its verified file using ALTER DATABASE RENAME FILE. Before doing so, establish:
A metadata rename changes the recorded filename. It does not copy data, repair corruption, or apply redo. Replacing a placeholder with the path of an unrelated file is not recovery. Similarly, bringing a tablespace online cannot compensate for missing changes in a restored file.
If a file is absent or damaged, use the appropriate restore and recovery procedure. If it was intentionally left offline, verify that its recovery and state requirements have been met before restoring access. The special read-only reconstruction procedure should not be generalized to every file whose name begins with MISSING.
Changing a tablespace from read-only to read-write removes the restore-only shortcut for an older read-only backup. It does not automatically invalidate that backup. The backup may remain usable if the required recovery changes and metadata are available.
Consider a historical tablespace backed up on Monday after it became read-only. On Wednesday, it is made read-write for corrections, then made read-only again. A failure on Friday cannot be resolved simply by restoring Monday's unchanged-looking backup and ignoring Wednesday. Those corrections and state transitions are part of the recovery history.
A backup taken after Wednesday's final read-only transition provides a more recent starting point. If no later writable period occurred, that backup may avoid redo application for the static interval. The older backup can still be useful, but recovery must account for the intervening changes.
Take a backup after a READ ONLY transition completes. When returning a tablespace to READ WRITE, review and refresh the backup plan to reduce dependency on a long chain of changes. Record state transitions and preserve appropriate control-file backups alongside the datafile backups.
One old copy is not a permanent recovery strategy. Protect backups against media loss, retain necessary encryption keys, and verify that the backup remains accessible. Backup optimization can reduce repeated work under its configured rules, but it does not remove the need for retention planning and restore testing.
RMAN supports RESTORE DATABASE SKIP READONLY to exclude read-only files from a restore operation. That exclusion neither repairs missing files nor guarantees they will be available when applications resume. A staged restoration needs an explicit plan for the excluded files.
Do not add the same clause to RECOVER DATABASE: SKIP READONLY is a RESTORE option, not an equivalent RECOVER option. Consult the RESTORE reference when deciding what to restore. Keep that decision separate from the recovery requirements of each file.
After recovery, review the recovery output and alert log for unresolved errors. From an authorized CDB-root session at the appropriate mounted or open stage, inspect affected file headers:
SELECT con_id, file#, status, recover, fuzzy, error, name
FROM v$datafile_header
ORDER BY con_id, file#;
Use the results with the known file inventory and completed recovery procedure. Header information alone is not a complete corruption check. Also, V$RECOVER_FILE is unreliable when the control file was restored or recreated, so an empty result is not proof that recovery succeeded.
Once the owning PDB is open, connect to that PDB and check the expected tablespace state. For the example tablespace:
SELECT tablespace_name, status
FROM dba_tablespaces
WHERE tablespace_name = 'EMP_HISTORY';
This query describes current status, not every past transition. Verify that the expected CDB and PDBs are open, required files are accessible, and application queries can read the recovered data. Resolve unexpected offline files before declaring the application available.
Finally, update the recovery record with the control file used, restored files, completed recovery, and any incarnation change. Refresh backups as required by the recovery plan and ensure another administrator can identify the files and metadata needed for the next incident.
The next lesson concludes this module.