Oracle常見錯誤——ORA-00054

如何解決ORA-00054資源正忙,要求指定NOWAIT?

 查閱錯誤代碼指南後有如下提示:
ORA-00054 resource busy and acquire with NOWAIT specified
Cause: The NOWAIT keyword forced a return to the command prompt because a resource was unavailable for a LOCK TABLE or SELECT FOR UPDATE command.

Action: Try the command after a few minutes or enter the command without the NOWAIT keyword.

 

一、相關知識簡介

  1. V$LOCKED_OBJECT中的列說明:
    XIDUSN:回滾段號
    XIDSLOT:槽號
    XIDSQN:序列號
    OBJECT_ID:被鎖對象ID
    SESSION_ID:持有鎖的sessionID
    ORACLE_USERNAME:持有鎖的Oracle 用戶名
    OS_USER_NAME:持有鎖的操作系統 用戶名
    PROCESS:操作系統進程號
    LOCKED_MODE:鎖模式
  2. dba_objects的列說明(網上找的,懶得翻譯了^_^)
    OWNER
          Username of the owner of the object
       OBJECT_NAME
          Name of the object
       SUBOBJECT_NAME
          Name of the sub-object (for example,partititon)
       OBJECT_ID
          Object number of the object
       DATA_OBJECT_ID
          Object number of the segment which contains the object
       OBJECT_TYPE
          Type of the object
       CREATED
          Timestamp for the creation of the object
       LAST_DDL_TIME
          Timestamp for the last DDL change (including GRANT and REVOKE) to the object
       TIMESTAMP
          Timestamp for the specification of the object
       STATUS
          Status of the object
       TEMPORARY
          Can the current session only see data that it place in this object itself?
       GENERATED
          Was the name of this object system generated?
       SECONDARY
          Is this a secondary object created as part of icreate for domain indexes?
  3. v$session的說明
    V$SESSION是基礎信息視圖,用於找尋用戶SID或SADDR
    常用列:
    SID:SESSION標識
    SERIAL#:如果某個SID又被其它的session使用的話則此數值自增加(當一個SESSION結束,另一個SESSION開始並使用了同一個SID)。
    AUDSID:審查session ID唯一性,確認它通常也用於當尋找並行查詢模式
    USERNAME:當前session在oracle中的用戶名。
    STATUS:這列用來判斷session狀態是:
       Achtive:正執行SQL語句(waiting for/using a resource)
       Inactive:等待操作(即等待需要執行的SQL語句)
       Killed:被標註爲刪除
  4. v$process視圖
    v$process視圖包含當前系統Oracle
    運行的所有進程信息。常被用於將Oracle或服務進程的操作系統進程ID與數據庫session之間建立聯繫。
    常用列:
    ADDR:進程對象地址
    PID:oracle進程ID
    SPID:操作系統進程ID

二、錯誤處理方法
    1.通過上句查找出已被鎖定的數據庫表及相關的sid、serial#及spid:

     select object_name as 對象名稱,s.sid,s.serial#,p.spid as 系統進程號
     from v$locked_object l , dba_objects o , v$session s , v$process p
     where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;

     2.在數據庫中滅掉相關session

     alter system kill session 'sid,serial#';--sid及serial#爲第一步查出來的數據

     若是執行時提示“ora-00031錯誤”,可以多執行幾次,估計和數據量的多少有關,具體爲什麼我暫時也不知道了^_^。

     3.從系統中滅掉與該session對應的進程

     kill -9 spid; --spid爲第一步中查出來的系統進程號

經過以上操作之後重新對之前鎖定的對象進行操作應該就可以了

發佈了18 篇原創文章 · 獲贊 0 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章