Bug 39294341

Datapatch fails with ORA-00054: Failed to acquire a lock (Type: "TM", Name: "DML", Description: "Synchronizes accesses to an object") because it is currently held by another session. The resource being locked can be identified by 7756 (“Table”) and 0 (“operation”).

This occurs because another session has acquired a lock on the table SYS.WRI$_ADV_DIRECTIVE_INSTANCES. Datapatch performs DDL operations on this table and is therefore unable to acquire the required lock while the other session is holding it.

Workaround:

Check for any sessions holding a lock on table SYS.WRI$_ADV_DIRECTIVE_INSTANCES using the following query and wait for those sessions to complete:

 SELECT lo.inst_id,
        s.sid,
        s.serial#,
        s.username,
        s.status,
        s.machine,
        s.program,
        s.module,
        s.action,
        s.sql_id,
        lo.locked_mode
 FROM   gv$locked_object lo
        JOIN dba_objects o
          ON o.object_id = lo.object_id
        JOIN gv$session s
          ON s.inst_id = lo.inst_id
         AND s.sid     = lo.session_id
 WHERE  o.owner       = 'SYS'
 AND    o.object_name = 'WRI$_ADV_DIRECTIVE_INSTANCES'
 AND    o.object_type = 'TABLE'
 ORDER BY lo.inst_id, s.sid;

Once all the locks are released, rerun datapatch.