解決ORA-00054: resource busy and acquire with NOWAIT specified需要注意

來源:互聯網
上載者:User

    昨天建索引碰到ORA-00054: resource busy and acquire with NOWAIT specified的問題,花費了很多時間解決。這個報錯其實很簡單,我碰到的這種情況就是使用者對這張表的事務沒有提交,導致不能對這種表進行DDL操作(建索引是有DDL操作的)。當然花費的時間主要是在一個坑上,值得注意的是資料庫是RAC的,當我kill掉事務還沒提交的session時,看不到堵塞了,但建索引還是報這個錯,原因是要多RAC的多個節點都要kill才行。下面我們來做個小實驗,只是單點的處理,RAC的處理只不過是要連不通的資料庫:

session1:(製造堵塞,事務不提交)

SQL> create table tt as select * from dba_objects;
表已建立。
SQL> update tt set object_id = object_id + 1;
已更新49838行。

session2:(建索引報錯)
SQL> create index ind_tt_object_id on tt(object_id);
create index ind_tt_object_id on tt(object_id)     *
第 1 行出現錯誤:
ORA-00054: resource busy and acquire with NOWAIT specified

session3:(查出是哪個會話有問題,kill,如果是RAC則需要連多個資料庫kill)

SQL> select t2.username, t2.sid, t2.serial#, t2.logon_time
      from v$locked_object t1, v$session t2
     where t1.session_id = t2.sid
     order by t2.logon_time;
USERNAME                              SID    SERIAL# LOGON_TIME
------------------------------ ---------- ---------- --------------
TEST                                  149      20845 14-4月 -14

SQL> alter system kill session '149,20845';
系統已更改。

session2:(再建索引,就成功了)
SQL> create index ind_tt_object_id on tt(object_id);
索引已建立。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.