Do you need STARTUP UPGRADE for OJVM?

Actually I carry around this topic with me since the October 2019 workshop in Dubai. We’ve had one of these OJVM Patching discussions I’d like to escape usually. Anyhow, during this session, it dawned me that the STARTUP UPGRADE requirement in the OJVM readme may be not correct anymore. So the question will be: Do you need STARTUP UPGRADE for OJVM?

Do you need STARTUP UPGRADE for OJVM?

Photo by Nik Shuliahin on Unsplash

A little bit of history

You will find a good amount of blog posts about OJVM here. OJVM stands for Oracle Java Virtual Machine. It is a very powerful thing and allows you to execute java code within the database much quicker than from outside. I have attended sessions by ACE Directors who showed impressive flame graphs about the performance differences. But as powerful OJVM is, not everybody uses it. And the power aspect leads to a lot of security issues in the past years.

Hence, I think it is not the worst idea to deinstall it when you can ensure that nobody is using it.

Since Oracle Database 18.4.0 OJVM is does really allow RAC rolling patching. Before, it is a conditional rolling install. Please refer to MOS Note: 2217053.1 – RAC Rolling Install Process for the “Oracle JavaVM Component Database PSU/RU” (OJVM PSU/RU) Patches if you seek for further details on this complex topic.

This important note contains also sections covering “Is OJVM installed?” and “Is OJVM used?“.

And just on the side, while OJVM is RAC Rolling, it is still not Data Guard Standby First Installable.

Do you need STARTUP UPGRADE for OJVM?

But the question which bothered me is: Do you need STARTUP UPGRADE for OJVM?

Let’s have a quick look at the 19.6.0 OJVM January 2020 readme. Under 1.4.1 it has this section explaining that STARTUP UPGRADE is required – with one exception, I will explain in a second:

Do you need STARTUP UPGRADE for OJVM?

But what I didn’t understand: Why should a STARTUP UPGRADE be required when datapatch requires all databases and PDBs in OPEN mode? Especially since all the patch bundles, RUs, BPs and PSUs per se are rolling installable.

Well, we’ve had an internal discussion. And as a result, the “Footnote 1” got added to the note, saying:

Following the link gets you to:

Aha! When you follow the approach in MOS Note: 2217053.1 then there’s no need for STARTUP UPGRADE anymore.

Then let us check what MOS Note: 2217053.1 has to say about this topic:

  • If a database has any current or past exposure to an OJVM PSU patchset that was installed via “startup upgrade”, it will insist that all future OJVM PSU patchset actions also use “startup upgrade”. To workaround this expectation of “startup upgrade” originating from a previous OJVM PSU patchset  installed via “startup upgrade”, the new datapatch parameter of “-skip_upgrade_check” should be used, as shown in the following example:### Replacing the Java system classes while database is up 
    ### Do not use -force flag for datapatch
    cd $ORACLE_HOME/OPatch
    ./datapatch -verbose -skip_upgrade_check

Now we come closer to it. To me this reads: If you used STARTUP UPGRADE before, then use the flag now to avoid the need for STARTUP UPGRADE. Hence, in a RAC environment – and those are the environments where you can avoid downtime patching OJVM in a rolling fashion, since at least 18.4.0 you can do the entire process fully rolling. Including of course the datapatch run.

And this was the crucial topic we discussed in Dubai in October 2019. What does it help to apply the binaries rolling when I will have downtime to run datapatch? I hope this is clarified now. Even though I would have wished a way more obvious edit to the OJVM patches readme.

How about in non-RAC environments?

First of all, in a non-RAC environment you will encounter downtime anyway. You will at best case switch homes from the current one to the patched one. Hence, you will need to take your database down and start it up again. A little bit extra downtime for another STARTUP UPGRADE sequence won’t hurt too much. But actually I try to avoid such phases whenever possible.

Then, the crucial question is:
Do you need STARTUP UPGRADE in a non-RAC environment?

The OJVM patch readme says: Yes. The steps haven’t been removed. But datapatch patches the database while it is up and running without the need for STARTUP UPGRADE. What should be different from a situation in a 4-node RAC cluster when applying changes with datapatch from a non-RAC database?

I don’t see it – and I’d like to try out such things. So I installed the patch into my environment, and configured OJVM into my 19c CDB.

To configure OJVM into my existing CDB, I could have used the guidance of MOS Note: 2262919.1 – Repairing/Reinstalling JVM To A Multitenant Database (CDB and all PDBs) which by the way explains at first how to remove OJVM from a CDB database.

But instead I used the DBCA:

Do you need STARTUP UPGRADE for OJVM?

See the summary:

Quick check after I configured it:

    CON_ID COMP_ID  STATUS	 VERSION
---------- -------- ------------ ----------
	 1 CATALOG  VALID	 19.0.0.0.0
	 1 CATJAVA  VALID	 19.0.0.0.0
	 1 CATPROC  VALID	 19.0.0.0.0
	 1 JAVAVM   VALID	 19.0.0.0.0
	 1 OLS	    VALID	 19.0.0.0.0
	 1 OWM	    VALID	 19.0.0.0.0
	 1 RAC	    OPTION OFF	 19.0.0.0.0
	 1 XDB	    VALID	 19.0.0.0.0
	 1 XML	    VALID	 19.0.0.0.0
	 2 CATALOG  VALID	 19.0.0.0.0
	 2 CATJAVA  VALID	 19.0.0.0.0
	 2 CATPROC  VALID	 19.0.0.0.0
	 2 JAVAVM   VALID	 19.0.0.0.0
	 2 OLS	    VALID	 19.0.0.0.0
	 2 OWM	    VALID	 19.0.0.0.0
	 2 RAC	    OPTION OFF	 19.0.0.0.0
	 2 XDB	    VALID	 19.0.0.0.0
	 2 XML	    VALID	 19.0.0.0.0

Looks ok.

Applying the 19.6.0 OJVM without STARTUP UPGRADE

First step is to verify that my opatch version is good enough to apply the OJVM Jan 2020 RU to my existing 19.6.0 home. The readme requires only the “10” version. As I have the “17” version installed, all should be fine.

Next step, after I downloaded and unzipped the patch 30484981, is the conflict check.

$ $ORACLE_HOME/OPatch/opatch prereq CheckConflictAgainstOHWithDetail -ph ./
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2020, Oracle Corporation.  All rights reserved.

PREREQ session

Oracle Home       : /u01/app/oracle/product/19
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19/oraInst.loc
OPatch version    : 12.2.0.1.17
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2020-01-21_22-55-00PM_1.log

Invoking prereq "checkconflictagainstohwithdetail"

Prereq "checkConflictAgainstOHWithDetail" passed.

OPatch succeeded.

Ok, I’m safe.

Let’s apply the patch to my home.

$ $ORACLE_HOME/OPatch/opatch apply
Oracle Interim Patch Installer version 12.2.0.1.17
Copyright (c) 2020, Oracle Corporation.  All rights reserved.


Oracle Home       : /u01/app/oracle/product/19
Central Inventory : /u01/app/oraInventory
   from           : /u01/app/oracle/product/19/oraInst.loc
OPatch version    : 12.2.0.1.17
OUI version       : 12.2.0.7.0
Log file location : /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2020-01-21_23-15-41PM_1.log

Verifying environment and performing prerequisite checks...
OPatch continues with these patches:   30484981  

Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.

Please shutdown Oracle instances running out of this ORACLE_HOME on the local system.
(Oracle Home = '/u01/app/oracle/product/19')


Is the local system ready for patching? [y|n]
y
User Responded with: Y
Backing up files...
Applying interim patch '30484981' to OH '/u01/app/oracle/product/19'

Patching component oracle.javavm.server, 19.0.0.0.0...

Patching component oracle.javavm.server.core, 19.0.0.0.0...

Patching component oracle.rdbms.dbscripts, 19.0.0.0.0...

Patching component oracle.rdbms, 19.0.0.0.0...
Patch 30484981 successfully applied.
Log file location: /u01/app/oracle/product/19/cfgtoollogs/opatch/opatch2020-01-21_23-15-41PM_1.log

OPatch succeeded.

But why should I start my database now with STARTUP UPGRADE?

Test 1 – No STARTUP UPGRADE and no datapatch flag

In my first test, I pretend to have no idea and do exactly the same I do for my databases. This means, I don’t use the datapatch flag mentioned in MOS Note: 2217053.1 to skip the upgrade check. I started my database in regular mode (no STARTUP UPGRADE) and ran datapatch:

$ $ORACLE_HOME/OPatch/datapatch -verbose
SQL Patching tool version 19.6.0.0.0 Production on Tue Jan 21 23:21:41 2020
Copyright (c) 2012, 2019, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_8154_2020_01_21_23_21_41/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 30484981 (OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981)):
  Binary registry: Installed
  PDB CDB$ROOT: Not installed
  PDB PDB$SEED: Not installed

Current state of release update SQL patches:
  Binary registry:
    19.6.0.0.0 Release_Update 191217155004: Installed
  PDB CDB$ROOT:
    Applied 19.6.0.0.0 Release_Update 191217155004 successfully on 21-JAN-20 09.23.28.157993 PM
  PDB PDB$SEED:
    Applied 19.6.0.0.0 Release_Update 191217155004 successfully on 21-JAN-20 09.23.29.338333 PM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT PDB$SEED
    No interim patches need to be rolled back
    No release update patches need to be installed
    The following interim patches will be applied:
      30484981 (OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981))

Installing patches...
Patch installation complete.  Total patches installed: 2

Validating logfiles...done
Patch 30484981 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30484981/23248235/30484981_apply_CDB2_CDBROOT_2020Jan21_23_22_56.log (no errors)
Patch 30484981 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30484981/23248235/30484981_apply_CDB2_PDBSEED_2020Jan21_23_23_37.log (no errors)
SQL Patching tool complete on Tue Jan 21 23:23:51 2020

To my big surprise, the patch applied flawless. Without thinking a second about STARTUP UPGRADE. This may happen because I never applied any OJVM patches in STARTUP UPGRADE mode before, and hence, the -skip_upgrade_check flag was not needed. I won’t complain about this behavior.

Test 2 – No STARTUP UPGRADE and the datapatch flag

Still, I’d like to check whether using the flag “-skip_upgrade_check” works and leads to the same result.

$ $ORACLE_HOME/OPatch/datapatch -verbose -skip_upgrade_check
SQL Patching tool version 19.6.0.0.0 Production on Tue Jan 21 23:31:43 2020
Copyright (c) 2012, 2019, Oracle.  All rights reserved.

Log file for this invocation: /u01/app/oracle/cfgtoollogs/sqlpatch/sqlpatch_8288_2020_01_21_23_31_43/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 30484981 (OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981)):
  Binary registry: Installed
  PDB CDB$ROOT: Not installed
  PDB PDB$SEED: Not installed

Current state of release update SQL patches:
  Binary registry:
    19.6.0.0.0 Release_Update 191217155004: Installed
  PDB CDB$ROOT:
    Applied 19.6.0.0.0 Release_Update 191217155004 successfully on 21-JAN-20 09.23.28.157993 PM
  PDB PDB$SEED:
    Applied 19.6.0.0.0 Release_Update 191217155004 successfully on 21-JAN-20 09.23.29.338333 PM

Adding patches to installation queue and performing prereq checks...done
Installation queue:
  For the following PDBs: CDB$ROOT PDB$SEED
    No interim patches need to be rolled back
    No release update patches need to be installed
    The following interim patches will be applied:
      30484981 (OJVM RELEASE UPDATE: 19.6.0.0.200114 (30484981))

Installing patches...
Patch installation complete.  Total patches installed: 2

Validating logfiles...done
Patch 30484981 apply (pdb CDB$ROOT): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30484981/23248235/30484981_apply_CDB2_CDBROOT_2020Jan21_23_32_44.log (no errors)
Patch 30484981 apply (pdb PDB$SEED): SUCCESS
  logfile: /u01/app/oracle/cfgtoollogs/sqlpatch/30484981/23248235/30484981_apply_CDB2_PDBSEED_2020Jan21_23_33_23.log (no errors)
SQL Patching tool complete on Tue Jan 21 23:33:38 2020

My personal summary

As I explained above, we discussed this internally. But I can’t update readmes by myself. And I don’t want to pretend that I’m right. But to me it looks as if the STARTUP UPGRADE requirement in the OJVM patches’ readme is wrong.

In a RAC environment, MOS Note: 2217053.1 explains clearly how to patch with datapatch without the need for STARTUP UPGRADE. The readme should be much clearer here instead of hiding the important piece under a footnote and another click. Especially under the consideration that this is really impacting – and not needing a STARTUP UPGRADE in a RAC environment is a big relief.

Even though you could argue that it doesn’t make a big difference in a non-RAC system where you can’t apply the OJVM or any other patch binaries rolling anyway, whether you use STARTUP UPGRADE or not, I can see that especially in an environment with many PDBs it may take a bit until datapatch is finished. As STARTUP UPGRADE means downtime, I’d rather like to avoid it. And so far, with everything I tested and everything I know, I don’t see any reason to apply the changes with datapatch while my database is in UPGRADE mode.

But again, the non-RAC test is my personal view on this topic, not an official Oracle standpoint according to the OJVM readmes. I’d just like to share my experience and ideas with you.

Further Information and Links

–Mike

Share this: