AutoUpgrade and the COMPATIBLE parameter

Several times I’ve got asked by customers if AutoUpgrade does change the COMPATIBLE parameter. So let me explain what happens to COMPATIBLE when you upgrade. And give you also some hints about AutoUpgrade and the COMPATIBLE parameter.

AutoUpgrade and the COMPATIBLE parameter

Photo by Ivana Cajina on Unsplash

Does AutoUpgrade change COMPATIBLE?

No. Clearly, AutoUpgrade does not change the COMPATIBLE parameter for several reasons. At first, we recommend to not change the COMPATIBLE parameter right after the upgrade if you can afford another downtime soon after. By keeping COMPATIBLE on the previous (before upgrade) value, you have the choice to revert back to the previous state. Either via flashing back to a Guaranteed Restore Point (GRP) right after the upgrade, or days after the upgrade with the database downgrade.

Furthermore, by default AutoUpgrade sets a GRP – and allows you to flashback to it. But having a GRP since Oracle Database 12.2.0.1 blocks the change of COMPATIBLE as long as the GRP is in place.

Actually these are enough reasons to have the AutoUpgrade not change COMPATIBLE. And still, we listen to your feedback and discussed whether AutoUpgrade may get a parameter to enforce compatibility after a successful upgrade. And with the change to the CDB-only architecture with Oracle 20c this may even play less of a role as there is no seamless simple fallback anyways anymore when you migrate to the CDB-architecture.

Can AutoUpgrade change COMPATIBLE?

Yes it can. Or actually you can convince it to do so. And here is how.

AutoUpgrade has these powerful options to execute a shell script before or after upgrade:
before_action and after_action.

I take screenshots from the Oracle Database 19c Upgrade Guide here:

AutoUpgrade and the COMPATIBLE parameter

AutoUpgrade and the COMPATIBLE parameter

This way I can pass a script to AutoUpgrade changing COMPATIBLE after the database upgrade.

But wait one second please. Didn’t I write above that you can’t change COMPATIBLE when a GRP is in place – which is the standard behavior of the tool? Yes, I did. And I will assume that you will change COMPATIBLE only in cases where you are either 100% certain that the upgrade will succeed and you won’t fall back to a GRP. Or in cases where you have another backup/restore strategy in place already, and don’t want to rely on a GRP.

Hence, I will use the parameter:

  • upg1.restoration=NO

in my command file to have no GRP created.

And even if you disagree with my statement above, there is still an option. You can advice AutoUpgrade to drop the GRP automatically once the upgrade has been completed successfully:

  • upg1.drop_grp_after_upgrade=YES

will drop the GRP.

A tiny example

With this config file I will upgrade my DB12 database in the Hands-On Lab:

global.autoupg_log_dir=/home/oracle/logs
upg1.dbname=DB12
upg1.start_time=NOW
upg1.source_home=/u01/app/oracle/product/12.2.0.1
upg1.target_home=/u01/app/oracle/product/19
upg1.sid=DB12
upg1.log_dir=/home/oracle/logs
upg1.upgrade_node=localhost
upg1.target_version=19
upg1.restoration=no
upg1.after_action=/home/oracle/scripts/change_compatible.sh

The key parameters are marked in RED.

If you’d like to use the GRP standard option, this would be the config file then instead:

global.autoupg_log_dir=/home/oracle/logs
upg1.dbname=DB12
upg1.start_time=NOW
upg1.source_home=/u01/app/oracle/product/12.2.0.1
upg1.target_home=/u01/app/oracle/product/19
upg1.sid=DB12
upg1.log_dir=/home/oracle/logs
upg1.upgrade_node=localhost
upg1.target_version=19
upg1.drop_grp_after_upgrade=YES
upg1.after_action=/home/oracle/scripts/change_compatible.sh

I’m executing a simple shell script after upgrade:

#!/bin/bash
. db19
sqlplus /nolog @/home/oracle/scripts/change_compatible.sql

Don’t forget to set:

chmod u+x /home/oracle/scripts/change_compatible.sh

And this shell script calls a SQL file:

connect / as sysdba
alter system set compatible='19.0.0' scope=spfile sid='*';
shutdown immediate
startup
exit

After the upgrade:

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Mar 17 23:12:57 2020
Version 19.6.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.6.0.0.0

SQL> show parameter compatible

NAME				     TYPE	 VALUE
------------------------------------ ----------- ------------------------------
compatible			     string	 19.0.0
noncdb_compatible		     boolean	 FALSE

Pretty nice – if you need and want this.

One important thing you should recognize:
You will find the logfile in <autoupg_log_dir>/<SID>/<jobnumber>/postupgrade – its name is action_stdout.log.

More Information and Links

–Mike

 

Share this: