﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>FranklinFaces.com - Oracle &amp; SQL Server Database Forums for all IT Professionals / Oracle Forum / ORA - Oracle Database Error Codes - Search via specific error codes. / ORA-00000 Through ORA-09989   / Getting ora error ORA-00054: resource busy when gathering stats. / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>FranklinFaces.com - Oracle &amp; SQL Server Database Forums for all IT Professionals</description><link>http://www.franklinfaces.com/</link><webMaster>no-reply@FranklinFaces.com</webMaster><lastBuildDate>Tue, 07 Sep 2010 10:16:29 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>&lt;H3 class="post-title entry-title"&gt;ORA-00054: resource busy and acquire with NOWAIT specified &lt;/H3&gt;&lt;DIV class=post-header-line-1&gt;&lt;/DIV&gt;&lt;DIV class="post-body entry-content"&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;U&gt;Problem Description&lt;/U&gt;&lt;/SPAN&gt;&lt;BR&gt;In my production database Oracle 10.2g while I was adding column to one of my transaction table it fails with ORA-54 error as below.&lt;BR&gt;&lt;BR&gt;SQL&amp;gt; alter table student add b number;&lt;BR&gt;alter table student add b number&lt;BR&gt;*&lt;BR&gt;ERROR at line 1:&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;U&gt;Description of the Problem&lt;/U&gt;&lt;/SPAN&gt;&lt;BR&gt;Let's try to produce the problem in our development environment. I have opened two session that connected to database under a schema. In one session, I have created a table and inserted data into it.&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; create table a (a number);&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;Table created.&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; insert into a values(1);&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;1 row created.&lt;BR&gt;&lt;BR&gt;I did not yet committed data in session 1. Now in another session whenever I try to any ddl like (alter table, drop table) ORA-00054 will produce.&lt;BR&gt;&lt;BR&gt;In another session,&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; alter table a add b number;&lt;/SPAN&gt;&lt;BR&gt;alter table a add b number&lt;BR&gt;*&lt;BR&gt;ERROR at line 1:&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;BR&gt;SQL&amp;gt; drop table a;&lt;/SPAN&gt;&lt;BR&gt;drop table a&lt;BR&gt;*&lt;BR&gt;ERROR at line 1:&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;BR&gt;SQL&amp;gt; lock table a in exclusive mode nowait;&lt;/SPAN&gt;&lt;BR&gt;lock table a in exclusive mode nowait&lt;BR&gt;*&lt;BR&gt;ERROR at line 1:&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;U&gt;Cause of the Problem&lt;/U&gt;&lt;/SPAN&gt;&lt;BR&gt;Whenever you try to do any structural changes on a table oracle try to lock the table exclusively with NOWAIT option(this is in 10.2g while in 11g you can change the wait timeout). If oracle fails to lock the table exclusively then ORA-00054 will occur.&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;&lt;U&gt;Solution of the Problem&lt;/U&gt;&lt;/SPAN&gt;&lt;BR&gt;In 10.2g you are limited to several choices to solve the problem. To avoid it,&lt;BR&gt;&lt;BR&gt;-Re run the DDL at a later time when the database become idle.&lt;BR&gt;or,&lt;BR&gt;&lt;BR&gt;-Kill the sessions that are preventing the exclusive lock.&lt;BR&gt;or,&lt;BR&gt;&lt;BR&gt;-Prevent end user to connect to the database and then run the DDL.&lt;BR&gt;&lt;BR&gt;You have different views to see locking information about the table.&lt;BR&gt;&lt;B&gt;1)DBA_BLOCKERS:&lt;/B&gt; Displays a session if it is not waiting for a locked object but is holding a lock on an object for which another session is waiting. In our scenario this view will not help.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;2)DBA_DDL_LOCKS:&lt;/B&gt; It lists all DDL locks held in the database and all outstanding requests for a DDL lock.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;3)DBA_DML_LOCKS:&lt;/B&gt; It lists all DML locks held in the database and all outstanding requests for a DML lock.&lt;BR&gt;If you query from it in the mode_held field you will see 'row exclusive lock'.&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; select mode_held from dba_dml_locks where owner='MAXIMSG';&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;MODE_HELD&lt;BR&gt;-------------&lt;BR&gt;Row-X (SX)&lt;BR&gt;&lt;BR&gt;&lt;B&gt;4)DBA_LOCK:&lt;/B&gt; It lists all locks or latches held in the database, and all outstanding requests for a lock or latch.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;5)DBA_LOCK_INTERNAL:&lt;/B&gt; It displays a row for each lock or latch that is being held, and one row for each outstanding request for a lock or latch.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;6)DBA_LOCKS&lt;/B&gt; is a synonym for DBA_LOCK.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;7)DBA_WAITERS:&lt;/B&gt; Shows all the sessions that are waiting for a lock.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;8)V$LOCK:&lt;/B&gt; It lists the locks currently held by the Oracle Database and outstanding requests for a lock or latch.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;9)V$LOCK_ACTIVITY:&lt;/B&gt; This view is deprecated.&lt;BR&gt;&lt;BR&gt;&lt;B&gt;10)V$LOCKED_OBJECT:&lt;/B&gt; This view lists all locks acquired by every transaction on the system.&lt;BR&gt;&lt;BR&gt;In order to see locked object query,&lt;BR&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; set linesize 130&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; set pages 100&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; col username       format a20&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; col sess_id        format a10&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; col object format a25&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; col mode_held      format a10&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;SQL&amp;gt; select     oracle_username || ' (' || s.osuser || ')' username,  &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;s.sid || ',' || s.serial# sess_id,  &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;owner || '.' || object_name object,  &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;object_type,  &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;decode( l.block,       0, 'Not Blocking',       1, 'Blocking',       2, 'Global') status,  &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;decode(v.locked_mode, 0, 'None', 1, 'Null',  2, 'Row-S (SS)',  3, 'Row-X (SX)',  4, 'Share',  5, 'S/Row-X (SSX)',   6, 'Exclusive', TO_CHAR(lmode)) mode_held&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;from       v$locked_object v,  dba_objects d,  v$lock l,  v$session s&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;where      v.object_id = d.object_id&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;and        v.object_id = l.id1&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;and        v.session_id = s.sid&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;order by oracle_username,  session_id&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;/&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt; &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;USERNAME             SESS_ID    OBJECT                    OBJECT_TYPE         STATUS       MODE_HELD&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;-------------------- ---------- ------------------------- ------------------- ------------ ----------&lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt;MAXIMSG (A)          142,232    MAXIMSG.A                 TABLE               Not Blocking Row-X (SX)OMS (DBA2\ershad)    143,280   &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt; OMS.T                     TABLE               Not Blocking Row-X (SX)OMS (DBA2\ershad)    143,280    OMS.T1                   &lt;/PRE&gt;&lt;PRE style="FONT-SIZE: 12px; COLOR: black"&gt; TABLE               Not Blocking Row-X (SX)&lt;/PRE&gt;&lt;BR&gt;Here we see there is 3 types of locking. In our case the object is A. And we see the sid=142 and serial#=232 is preventing us from locking the table in exclusive mode. So to achieve our task we can kill the session as below.&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; alter system kill session '142, 232';&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;System altered.&lt;BR&gt;&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; alter table a add b number;&lt;/SPAN&gt;&lt;BR&gt;&lt;BR&gt;Table altered.&lt;BR&gt;&lt;BR&gt;Now in the first session whenever you try to access error will be generated saying that session has been killed. In the first session.&lt;BR&gt;&lt;SPAN style="FONT-WEIGHT: bold"&gt;SQL&amp;gt; commit;&lt;/SPAN&gt;&lt;BR&gt;commit&lt;BR&gt;*&lt;BR&gt;ERROR at line 1:&lt;BR&gt;ORA-00028: your session has been killed&lt;/DIV&gt;</description><pubDate>Thu, 17 Jun 2010 14:15:18 GMT</pubDate><dc:creator>Admin</dc:creator></item><item><title>RE: Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>&lt;TABLE cellPadding=5 width="100%" align=center border=0&gt;&lt;TBODY&gt;&lt;TR vAlign=top&gt;&lt;TD noWrap&gt;&lt;H2 style="FONT-SIZE: 18px; MARGIN-BOTTOM: 0px"&gt;ORA-00054:&lt;/H2&gt;&lt;/TD&gt;&lt;TD style="FONT-SIZE: 16px"&gt;resource busy and acquire with NOWAIT specified&lt;/TD&gt;&lt;/TR&gt;&lt;TR vAlign=top&gt;&lt;TD style="FONT-SIZE: 18px"&gt;&lt;B&gt;Cause:&lt;/B&gt;&lt;/TD&gt;&lt;TD style="FONT-SIZE: 16px; LINE-HEIGHT: 1.5"&gt;Resource interested is busy.&lt;BR&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR vAlign=top&gt;&lt;TD style="FONT-SIZE: 18px"&gt;&lt;B&gt;Action:&lt;/B&gt;&lt;/TD&gt;&lt;TD style="FONT-SIZE: 16px; LINE-HEIGHT: 1.5"&gt;Retry if necessary.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description><pubDate>Thu, 17 Jun 2010 14:13:27 GMT</pubDate><dc:creator>Admin</dc:creator></item><item><title>RE: Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>Your very welcome. &lt;/P&gt;&lt;P&gt;Will continue to post..  .. &lt;/P&gt;&lt;P&gt;Stacy</description><pubDate>Fri, 16 Jan 2009 01:18:28 GMT</pubDate><dc:creator>stacyliang83</dc:creator></item><item><title>RE: Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>Thank you!!  This  certainly help.&lt;br&gt;&lt;br&gt;Appreciate it.</description><pubDate>Fri, 16 Jan 2009 00:35:57 GMT</pubDate><dc:creator>Admin</dc:creator></item><item><title>RE: Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>Hi,&lt;BR&gt;&lt;BR&gt;Since this isn't a Scheduler ora error but a problem with the gather_stats job being executed, you might get better understand if you take a look at any locks or dead locks you have in your system. &lt;BR&gt;&lt;BR&gt;You maybe running this at the same time another process is running. &lt;BR&gt;&lt;BR&gt;You can try to kill of the process if you see a dead lock or have it run at a different time so you won't get the message.&lt;BR&gt;&lt;BR&gt;Here are some useful queries to run to see what's running in the db.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;column oracle_username format a15&lt;BR&gt;column os_user_name format a15&lt;BR&gt;column object_name format a37&lt;BR&gt;column object_type format a37&lt;BR&gt;&lt;BR&gt;select a.session_id,a.oracle_username, a.os_user_name, b.owner "OBJECT OWNER", b.object_name,b.object_type,a.locked_mode from &lt;BR&gt;(select object_id, SESSION_ID, ORACLE_USERNAME, OS_USER_NAME, LOCKED_MODE from v$locked_object) a, &lt;BR&gt;(select object_id, owner, object_name,object_type from dba_objects) b&lt;BR&gt;where a.object_id=b.object_id;&lt;BR&gt;&lt;BR&gt;SELECT LPAD(' ',DECODE(l.xidusn,0,3,0)) || l.oracle_username "User Name",&lt;BR&gt;o.owner, o.object_name, o.object_type&lt;BR&gt;FROM v$locked_object l, dba_objects o&lt;BR&gt;WHERE l.object_id = o.object_id&lt;BR&gt;ORDER BY o.object_id, 1 desc;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;SELECT a.sid,a.serial#, a.username,c.os_user_name,a.terminal,&lt;BR&gt;b.object_id,substr(b.object_name,1,40) object_name&lt;BR&gt;from v$session a, dba_objects b, v$locked_object c&lt;BR&gt;where a.sid = c.session_id&lt;BR&gt;and b.object_id = c.object_id;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;You can run this to find out the currently running query:&lt;BR&gt;&lt;BR&gt;set pagesize 24&lt;BR&gt;set newpage 1&lt;BR&gt;set linesize 125&lt;BR&gt;&lt;BR&gt;column sql_text format a100&lt;BR&gt;column user_name format a12&lt;BR&gt;&lt;BR&gt;select &lt;BR&gt;u.sid, &lt;BR&gt;substr(u.username,1,12) user_name, &lt;BR&gt;s.sql_text&lt;BR&gt;from &lt;BR&gt;v$sql s, &lt;BR&gt;v$session u&lt;BR&gt;where &lt;BR&gt;s.hash_value = u.sql_hash_value&lt;BR&gt;and &lt;BR&gt;sql_text not like '%from v$sql s, v$session u%'&lt;BR&gt;order by &lt;BR&gt;u.sid;&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;This all depends on what version of oracle you are running.&lt;BR&gt;&lt;BR&gt;&lt;BR&gt;Hope this helps.&lt;BR&gt;&lt;BR&gt;Stacy</description><pubDate>Thu, 15 Jan 2009 01:26:57 GMT</pubDate><dc:creator>stacyliang83</dc:creator></item><item><title>Getting ora error ORA-00054: resource busy when gathering stats.</title><link>http://www.franklinfaces.com/Topic36-54-1.aspx</link><description>Anyone have an idea of what to do about this?&lt;BR&gt;&lt;BR&gt;I have GATHER_STATS_JOB running daily on our production box. Majority of the runs it gives the following error in the alert log (but no error is seen in the job history log):&lt;BR&gt;&lt;BR&gt;GATHER_STATS_JOB encountered errors. Check the trace file.&lt;BR&gt;ORA-00054: resource busy&lt;BR&gt;&lt;BR&gt;The trace file holds the following:&lt;BR&gt;&lt;BR&gt;ORACLE V10.2.0.3.0 - Production vsnsta=0&lt;BR&gt;vsnsql=14 vsnxtr=3&lt;BR&gt;Oracle Database 10g Release 10.2.0.3.0 - Production&lt;BR&gt;Windows NT Version V5.2 Service Pack 1&lt;BR&gt;CPU : 2 - type 586, 2 Physical Cores&lt;BR&gt;Process Affinity : 0x00000000&lt;BR&gt;Memory (Avail/Total): Ph:732M/2046M, Ph+PgF:2481M/3947M, VA:942M/2047M&lt;BR&gt;Redo thread mounted by this instance: 1&lt;BR&gt;Oracle process number: 15&lt;BR&gt;Windows thread id: 8712, image: ORACLE.EXE (J001)&lt;BR&gt;*** 2007-12-08 06:01:26.781&lt;BR&gt;*** ACTION NAME:(GATHER_STATS_JOB) 2007-12-08 06:01:26.781&lt;BR&gt;*** MODULE NAME:(DBMS_SCHEDULER) 2007-12-08 06:01:26.781&lt;BR&gt;*** SERVICE NAME:(SYS$USERS) 2007-12-08 06:01:26.781&lt;BR&gt;*** SESSION ID:(135.52155) 2007-12-08 06:01:26.781&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;*** 2007-12-08 06:01:26.781&lt;BR&gt;GATHER_STATS_JOB: GATHER_TABLE_STATS('"SYS"','"WRI$_ADV_OBJECTS"','""', ...)&lt;BR&gt;ORA-00054: resource busy and acquire with NOWAIT specified&lt;BR&gt;&lt;BR&gt;</description><pubDate>Thu, 15 Jan 2009 01:21:39 GMT</pubDate><dc:creator>Admin</dc:creator></item></channel></rss>