Tuesday, August 20, 2019

RMAN Unable to delete obsolete control file copy

I have a snapshot control file and cannot delete it using RMAN as it is part of recovery catalog. Bringing me in a loop, RMAN 'delete obsolete' command is also failing due to this causing archive log files to fill up the disk space. Regarding the reason for the problem. Perhaps it may also be file system permissions (file/directory/mount point).
PROBLEM: while deleting obsolete backup files, following warning is thrown
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Control File Copy     307    30-MAY-2019      /u01/oracle/11.2.0.4/dbhome_1/dbs/snapshotcf_mydb.f

RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212:   Object Type   Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Datafile Copy   /u01/oracle/11.2.0.4/dbhome_1/dbs/snapshotcf_mydb.f

SOLUTION: You can run a RMAN crosscheck to expire any records that have no physical counterpart. Then run a delete expired. It is the snapshot control file which is a temporary file and should not be a part of the recovery catalog.
To delete a snapshot control file you must first change the snapshot control file location, then delete the file at the older location, as follows:
RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/backup/dump/snapshotcf_mydb.f'';
RMAN> DELETE COPY OF CONTROLFILE;
RMAN> DELETE FORCE NOPROMPT OBSOLETE DEVICE TYPE DISK;
or
RMAN> CROSSCHECK COPY OF CONTROLFILE;
You can crosscheck all the copies with:
RMAN> crosscheck copy;
Then the delete obsolete worked successfully.
RMAN> delete noprompt obsolete;