What is a deadlock and how does one fix deadlock errors?
orafaq
A deadlock occurs when two or more users are waiting for data locked by each other. When this happens, these users are stuck (deadly embraced) and cannot continue processing.
Oracle automatically detects deadlocks and resolves them by rolling back one of the statements involved in the deadlock, thus releasing one set of data locked by that statement. The session that is rolled back will observe Oracle error: : deadlock detected while waiting for resource. Oracle will also write out a trace file with detailed information to the database's UDUMP directory.
Multi-table deadlocks can be avoided by locking tables in same order (in all applications), thus preventing a deadlock condition. For example, session1 lock table: emp then dept; session2: emp then dept. If this is not possible, your application should check for ORA-60 errors and restart the rolled back transactions.
Here is an example of how to simulate a deadlock error:
Session 1 lock table EMP:
SQL> UPDATE emp SET sal=sal+100; 14 rows updated.
Session 2 lock table DEPT:
SQL> UPDATE dept SET loc = 'Japan'; 4 rows updated.
Session 1 now update DEPT. The session will hang waiting for a lock (not a deadlock yet!):
SQL> UPDATE dept SET loc = 'Japan';
Session 2 now update EMP, causing the deadlock:
SQL> UPDATE emp SET sal=sal+100;
Oracle will detect the deadlock and roll back one of these statements:
SQL> UPDATE emp SET sal=sal+100; UPDATE emp SET sal=sal+100 * ERROR at line 1: ORA-00060: deadlock detected while waiting for resource
Other more obscure deadlock situations one needs to be aware of:
- If you get ORA-60 errors on UPDATE and DELETE statements, where two processes wait for 'S' mode locks on each other's 'TX' enqueues, you are experiencing ITL shortage deadlocks". This cannot happen with INSERT statements, as Oracle doesn't wait on ITL (Interested Transaction List) slots for inserts, it will simply try to insert the row into the next available block.
To fix this, recreate the segment with higher INITTRANS and/or PCTFREE values. This will allow more space in the data blocks for Oracle to allocate more transaction entries (24 bytes at a time) when required.
Note: "ITL waits" can be monitored per segments by querying the sys.v_$segment_statistics view.
- High transaction activity on tables with bitmap indexes. Bitmap indexes are only appropriate in read only/ read mostly environments. You can try to use a very high INITTRANS value for the bitmap index, however, it would be best to disable the index before heavy transactional activity, and to rebuild it when done.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-1003534/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- How does one rename a database?Database
- mysql deadlockMySql
- deadlock exceptionException
- Deadlock Overview and DiscussionView
- 死鎖_DeadLock_示例
- GLOBAL ENQUEUE SERVICES DEADLOCK DETECTEDENQ
- Global Enqueue Services Deadlock detected.ENQ
- 【DEADLOCK】Oracle“死鎖”模擬Oracle
- oracle deadlock with TM lock in SX/SSX modeOracle
- deadlock引起資料庫掛死資料庫
- [Java]一個DeadLock(死鎖)的例子Java
- how to fix bug in daily workAI
- What does "xargs grep" do?
- oracle deadlock死鎖trace file分析之一Oracle
- oracle deadlock 之(一)--鎖機制介紹Oracle
- Canvas errors & CORS All In OneCanvasErrorCORS
- React 18 errors All In OneReactError
- Oracle Global Enqueue Services Deadlock detected錯誤詳解OracleENQ
- mysql innodb_deadlock_detect檢測和處理MySql
- ORA-000060 Deadlock detected 問題解決
- ORA-00060: Deadlock detected(場景模擬)
- nvm command errors All In OneError
- How does a HashMap work in JAVAHashMapJava
- How to recover from USB pipe errorsError
- PostgreSQL 原始碼解讀(224)- Locks(The Deadlock Detection Algorithm)SQL原始碼Go
- 涉及到一個deadlock event monitor的問題
- Troubleshooting "Global Enqueue Services Deadlock detected" (Doc ID 1443482.1)ENQ
- 【ORA-00060】 deadlock detected while waiting for resourceWhileAI
- oracle lock轉換及oracle deadlock死鎖系列一Oracle
- oracle deadlock死鎖trace file分析之一增補Oracle
- ORA-00600 "deadlock detected while waiting for resource"WhileAI
- 設計模式 what? why? how?設計模式
- How to Diagnose and Resolve UNABLE TO EXTEND ErrorsError
- Bunder: What does :require => nil in Gemfile mean?UI
- Web效能優化:What? Why? How?Web優化
- 關於 SAP HANA 資料庫的死鎖問題(deadlock)資料庫
- 【死鎖】ORA-00060: deadlock detected while waiting for resourceWhileAI
- 測試庫死鎖診斷DEADLOCK DETECTED ( ORA-00060 )