Running datapatch on 18c on a freshly created database fails
Symptoms,
Creating a database with a gold image of 18c patched with 18.16.0.0.211019 (33339024) Oct-2021 will create a CDB where you need to run datapatch.
When you run it fails complaining about a prereq failed
[oracle@devbox7 ~]$ export PATH=$ORACLE_HOME/OPatch:$PATH
[oracle@devbox7 ~]$ cd $ORACLE_HOME/OPatch
[oracle@devbox7 OPatch]$ ./datapatch -verbose
SQL Patching tool version 18.0.0.0.0 Production on Thu Jan 20 14:14:49 2022
Copyright (c) 2012, 2021, Oracle. All rights reserved.
Log file for this invocation: /databases/orabase/cfgtoollogs/sqlpatch/sqlpatch_4665_2022_01_20_14_14_49/sqlpatch_invocation.log
Connecting to database...OK
Gathering database info...done
Note: Datapatch will only apply or rollback SQL fixes for PDBs
that are in an open state, no patches will be applied to closed PDBs.
Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
(Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done
Current state of interim SQL patches:
Interim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):
Binary registry: Installed
PDB CDB$ROOT: Not installed
PDB PDB$SEED: Not installed
PDB PDBX: Not installed
Current state of release update SQL patches:
Binary registry:
18.16.0.0.0 Release_Update 2110130650: Installed
PDB CDB$ROOT:
No release update patches installed
PDB PDB$SEED:
No release update patches installed
PDB PDBX:
No release update patches installed
Adding patches to installation queue and performing prereq checks...done
Installation queue:
For the following PDBs: CDB$ROOT
No interim patches need to be rolled back
Patch 33339024 (Database Release Update : 18.16.0.0.211019 (33339024)):
Apply from 18.1.0.0.0 Feature Release to 18.16.0.0.0 Release_Update 2110130650
The following interim patches will be applied:
27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415))
For the following PDBs: PDB$SEED PDBX
No interim patches need to be rolled back
Patch 33339024 (Database Release Update : 18.16.0.0.211019 (33339024)):
Apply from 18.1.0.0.0 Feature Release to 18.16.0.0.0 Release_Update 2110130650
The following interim patches will be applied:
27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415))
Error: prereq checks failed!
patch 27923415:
Is not successfully installed in CDB$ROOT but is to be applied to PDBX.
This will cause a patch mismatch between PDBX and CDB$ROOT and prevent
the PDB from opening unrestricted. Please use the allow_pdb_mismatch option
if this is really intended.
patch 33339024:
Release update 18.16.0.0.0 Release_Update 2110130650 is being installed to PDBX but is not
installed in CDB$ROOT. This will cause a patch mismatch between this PDB and
CDB$ROOT and prevent the PDB from opening. Please use the allow_pdb_mismatch
option if this is really intended.
Prereq check failed, exiting without installing any patches.
Please refer to MOS Note 1609718.1 and/or the invocation log
/databases/orabase/cfgtoollogs/sqlpatch/sqlpatch_4665_2022_01_20_14_14_49/sqlpatch_invocation.log
for information on how to resolve the above errors.
SQL Patching tool complete on Thu Jan 20 14:15:19 2022
Notice this part
Error: prereq checks failed!
patch 27923415:
Is not successfully installed in CDB$ROOT but is to be applied to PDBX.
This will cause a patch mismatch between PDBX and CDB$ROOT and prevent
the PDB from opening unrestricted. Please use the allow_pdb_mismatch option
if this is really intended.
Workaround
[oracle@devbox7 OPatch]$ ./datapatch -verbose -allow_pdb_mismatch
then you get
[oracle@devbox7 OPatch]$ ./datapatch -verbose -allow_pdb_mismatch
SQL Patching tool version 18.0.0.0.0 Production on Thu Jan 20 14:17:39 2022
Copyright (c) 2012, 2021, Oracle. All rights reserved.
Log file for this invocation: /databases/orabase/cfgtoollogs/sqlpatch/sqlpatch_5395_2022_01_20_14_17_39/sqlpatch_invocation.log
Connecting to database...OK
Gathering database info...done
Note: Datapatch will only apply or rollback SQL fixes for PDBs
that are in an open state, no patches will be applied to closed PDBs.
Please refer to Note: Datapatch: Database 12c Post Patch SQL Automation
(Doc ID 1585822.1)
Bootstrapping registry and package to current versions...done
Determining current state...done
Current state of interim SQL patches:
Interim patch 27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415)):
Binary registry: Installed
PDB CDB$ROOT: Not installed
PDB PDB$SEED: Not installed
PDB PDBX: Not installed
Current state of release update SQL patches:
Binary registry:
18.16.0.0.0 Release_Update 2110130650: Installed
PDB CDB$ROOT:
No release update patches installed
PDB PDB$SEED:
No release update patches installed
PDB PDBX:
No release update patches installed
Adding patches to installation queue and performing prereq checks...done
Installation queue:
For the following PDBs: CDB$ROOT
No interim patches need to be rolled back
Patch 33339024 (Database Release Update : 18.16.0.0.211019 (33339024)):
Apply from 18.1.0.0.0 Feature Release to 18.16.0.0.0 Release_Update 2110130650
The following interim patches will be applied:
27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415))
For the following PDBs: PDB$SEED PDBX
No interim patches need to be rolled back
Patch 33339024 (Database Release Update : 18.16.0.0.211019 (33339024)):
Apply from 18.1.0.0.0 Feature Release to 18.16.0.0.0 Release_Update 2110130650
The following interim patches will be applied:
27923415 (OJVM RELEASE UPDATE: 18.3.0.0.180717 (27923415))
Installing patches...
Patch installation complete. Total patches installed: 6
Validating logfiles...done
Patch 33339024 apply (pdb CDB$ROOT): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/33339024/24463226/33339024_apply_CDB18X_CDBROOT_2022Jan20_14_18_18.log (no errors)
Patch 27923415 apply (pdb CDB$ROOT): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/27923415/22239273/27923415_apply_CDB18X_CDBROOT_2022Jan20_14_18_16.log (no errors)
Patch 33339024 apply (pdb PDB$SEED): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/33339024/24463226/33339024_apply_CDB18X_PDBSEED_2022Jan20_14_21_19.log (no errors)
Patch 27923415 apply (pdb PDB$SEED): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/27923415/22239273/27923415_apply_CDB18X_PDBSEED_2022Jan20_14_21_14.log (no errors)
Patch 33339024 apply (pdb PDBX): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/33339024/24463226/33339024_apply_CDB18X_PDBX_2022Jan20_14_21_30.log (no errors)
Patch 27923415 apply (pdb PDBX): SUCCESS
logfile: /databases/orabase/cfgtoollogs/sqlpatch/27923415/22239273/27923415_apply_CDB18X_PDBX_2022Jan20_14_21_14.log (no errors)
SQL Patching tool complete on Thu Jan 20 14:24:34 2022