ORA-20016
Tried to do a datapatch (SQL apply) against a database, but it failed with ORA-20016: Unable to get the lock.
C:\Users\Administrator>datapatch -verbose
...
Error: prereq checks failed!
verify_queryable_inventory returned ORA-20016: Unable to get the lock : get_pending_activity : 1
Prereq check failed, exiting without installing any patches.
...
We suspected that the database is stuck at somewhere. So we decide to restart the database service.
Solution
To restart a database service, open services.msc directly, right click on the service, then choose "Restart".
For RAC databases in Linux, you should restart the database on all nodes.
[oracle@primary01 ~]$ srvctl stop database -d orclcdb
[oracle@primary01 ~]$ srvctl start database -d orclcdb
Then try to datapatch again.
C:\Users\Administrator>datapatch -verbose
...
We're good.