Upgrade RMAN Catalog Fails with “RMAN-01005: Error while converting X lock to S lock”

The following errors occur while upgrading RMAN catalog from version 19.10 to version 19.16:

RMAN> upgrade catalog;

recovery catalog owner is RMAN
enter UPGRADE CATALOG command again to confirm catalog upgrade

RMAN> UPGRADE CATALOG;


recovery catalog upgraded to version 19.16.00.00.00
DBMS_RCVMAN package upgraded to version 19.16.00.00
DBMS_RCVCAT package upgraded to version 19.16.00.00.
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-01005: Error while converting X lock to S lock

INVESTIGATION

Check the RMAN debug trace file with following messages:

...
..
.
DBGSQL: RCVCAT> declare ret integer; str varchar2(120); begin str := 'begin :ret := '||dbms_catowner||'.get_lock_on_catalog(dbms_lock.S_MODE); end;'; EXECUTE IMMEDIATE str USING OUT ret; :retlock := ret; end;
DBGSQL: sqlcode = 6550
DBGSQL: B :retlock = NULL
DBGSQL: error: ORA-06550: line 1, column 50: (krmkosqlerr)
DBGSQL: PLS-00201: identifier 'DBMS_LOCK' must be declared (krmkosqlerr)
DBGSQL: ORA-06550: line 1, column 9: (krmkosqlerr)
DBGSQL: PL/SQL: Statement ignored (krmkosqlerr)
DBGSQL: ORA-06512: at line 1 (krmkosqlerr)
...
..
.

SOLUTION

Grant execute privilege to RMAN user, here we assume it is ‘rman’ user used in most environment.

SQL> grant execute on DBMS_LOCK to rman;

Grant succeeded.
RMAN>  UPGRADE CATALOG;

recovery catalog owner is RMAN
enter UPGRADE CATALOG command again to confirm catalog upgrade

RMAN>  UPGRADE CATALOG;

recovery catalog upgraded to version 19.16.00.00.00
DBMS_RCVMAN package upgraded to version 19.16.00.00
DBMS_RCVCAT package upgraded to version 19.16.00.00.