The short answer is: Yes! The longer answer is: Yes, but very busy systems or in certain situations, you might experience a few hiccups.
The obvious place to look for the answer would be in the documentation. Unfortunately, there is no Patching Guide similar to the Upgrade Guide. The information in this blog post is pieced together from many different sources.
A few facts about patching with Datapatch:
- The database must be open in read write mode.
- You can’t run Datapatch on a physical standby database – even if it’s open (Active Data Guard).
- A patch is not fully installed until you have executed Datapatch successfully.
First, let me state that it is fully supported to run Datapatch on a running database with users connected.
- Install a new Oracle Home and use OPatch to apply the desired patches.
- Shut down the database.
- Restart the database in the new, patched Oracle Home.
- Downtime is over! Users are allowed to connect to the database
- End of procedure. The patch is now fully applied.
Often users move step 3 to the end of the procedure. That’s of course also perfectly fine, but it does extend the downtime needed and often is not needed.
What About RAC and Data Guard
The above procedure is exactly what happens in a rolling patch apply on a RAC database. When you perform a rolling patch apply on a RAC database, there is no downtime at all. You use
opatchauto to patch a RAC database.
opatchauto restarts all instances of the database in the patched Oracle Home in a rolling manner. Finally, it executes
datapatch on the last node. Individual instances are down temporarily, but the database is always up.
It is a similar situation when you use the Standby First Patch Apply. First, you restart all standby databases in the patched Oracle Home. Then, you perform a switchover and restart the former primary database in the patched Oracle Home. Finally, you execute
datapatch to complete the patch installation. You must execute
datapatch on the primary database.
Either way, don’t use Datapatch until all databases or instances run on the new, patched Oracle Home.
Yes, but I did write initally that there might be hiccups.
Datapatch connects to the database like any other session to make changes inside the database. These changes could be:
- Creating new tables
- Altering existing tables
- Creating or altering views
- Recreating PL/SQL packages like
Imagine this scenario:
- Database is restarted in patched Oracle Home.
- A user connects and starts to use
- You execute
DBMS_STATSmust be recreated to fix a bug.
- Datapatch executes
CREATE OR REPLACE PACKAGE SYS.DBMS_STATS .....
- The Datapatch session will go into a wait.
- User is done with
- The Datapatch session will come out of wait and replace the package.
In this scenario, the patching procedure was prolonged due to the wait. But it was completed eventually.
From time to time, we are told that Datapatch hangs. Most likely, it is not a real hang, but just a wait on a lock. You can connect to the database and identify the blocker. You might even want to kill the blocking session to allow Datapatch to do its work.
What will happen in the above scenario if the user never releases the lock on
DBMS_STATS? After a while, the DDL statement executed by Datapatch will error out:
ORA-04021: timeout occurred while waiting to lock object
To resolve this problem, restart Datapatch and ensure that there are no blocking sessions.
Really Busy Databases
I recommend patching at off-peak hours to reduce the likelihood of hitting the above problems.
If possible, you can also limit the activity in the database while you perform the patching. If your application is using e.g.
DBMS_STATS and locking on that object is often a problem, you can hold off these sessions for a little while.
If nothing helps your situation, you can patch in restricted mode. But that means downtime:
SQL> startup restrict
SQL> alter system disable restricted session;
I don’t recommend starting in upgrade mode. To get out of upgrade mode a database restart is needed extending the downtime window.
Datapatch And Resources
How much resources does Datapatch need? Should I be worried about Datapatch depleting the system?
No, you should not. The changes that Datapatch needs to make are not resource-intensive. However, a consequence of the DDL statements might be object invalidation. But even here, you should not worry. Datapatch will automatically recompile any ORACLE_MAINTAINED object that was invalidated by the patch apply. But the recompilation happens serially, i.e., less resources needed.
Of course, if you system is running at 99% capacity, it might be a problem. On the other hand, if your system is at 99%, patching problems are probably the least of your worries.
What About OJVM
If you are using OJVM and you apply the OJVM bundle patch, things are a little different.
|Oracle Database 21c||Fully||No||No Datapatch downtime.|
|Oracle Database 19c + 18c||Partial||No||No Datapatch downtime, but java system is patched which requires ~10 second outage. Connected clients using java will receive ORA-29548.|
|Oracle Database 12.2 + 12.1||No||No||Datapatch must execute in upgrade mode.|
|Oracle Database 220.127.116.11||No||No||Similar to 12.2 and 12.1 except you don’t use Datapatch.|
- Before starting the patching procedure and downtime, I recommend you recompile invalid objects.
- Always execute Datapatch with the
-verboseflag. This will give you much better information about is going on.
$ $ORACLE_HOME/OPatch/datapatch -verbose
- Always use the latest OPatch.
- Always use out-of-place patching, even for RAC databases.
Go ahead and patch your database with Datapatch while users are connected.
- Datapatch User Guide (Doc ID 2680521.1)
- Troubleshooting Assistant:12c Datapatch Issues (Doc ID 2335899.2)
- Oracle Patch Assurance – Data Guard Standby-First Patch Apply (Doc ID 1265700.1)
- RAC Rolling Install Process for the "Oracle JavaVM Component Database PSU/RU" (OJVM PSU/RU) Patches (Doc ID 2217053.1)
- Grid Infrastructure Out of Place ( OOP ) Patching using opatchauto (Doc ID 2419319.1)