Monitoring and Detecting Lock Contention pdf

19 195 0
Monitoring and Detecting Lock Contention pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

17 Copyright © Oracle Corporation, 2002. All rights reserved. Monitoring and Detecting Lock Contention 17-2 Copyright © Oracle Corporation, 2002. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Define levels of locking • Identify causes of contention • Prevent locking problems • Use Oracle utilities to detect lock contention • Resolve contention in an emergency • Resolve deadlock conditions 17-3 Copyright © Oracle Corporation, 2002. All rights reserved. Locking Mechanism • Automatic management • High level of data concurrency – Row-level locks for DML transactions – No locks required for queries • Multi-version consistency • Exclusive and Share lock modes • Locks held until commit or rollback operations are performed 17-4 Copyright © Oracle Corporation, 2002. All rights reserved. Data Concurrency Transaction 1 SQL> SELECT salary 2 FROM employees 3 WHERE id = 10; SALARY 1000 SQL> UPDATE employees 2 SET salary=salary*1.1 3 WHERE id= 24878; 1 row updated. SQL> UPDATE employees 2 SET salary=salary+1200; 13120 rows updated. SQL> UPDATE employees 2 SET salary=salary*1.1 3 WHERE id= 24877; 1 row updated. Transaction 2 17-6 Copyright © Oracle Corporation, 2002. All rights reserved. Two Types of Locks • DML or data locks: – Table-level locks – Row-level locks • DDL or dictionary locks (TM) (TX) 17-8 Copyright © Oracle Corporation, 2002. All rights reserved. DML Locks A DML transaction gets at least two locks: • A shared table lock • An exclusive row lock 17-9 Copyright © Oracle Corporation, 2002. All rights reserved. Enqueue Mechanism The enqueue mechanism keeps track of: • Users waiting for locks • The requested lock mode • The order in which users requested the lock 17-10 Copyright © Oracle Corporation, 2002. All rights reserved. Table Lock Modes These table lock modes are automatically assigned by the Oracle server: • Row Exclusive (RX): INSERT, UPDATE, DELETE • Row Share (RS): SELECT FOR UPDATE 17-12 Copyright © Oracle Corporation, 2002. All rights reserved. Manually Locking a Table Manually acquired in LOCK TABLE statement: • Share (S) – No DML operations allowed – Implicitly used for referential integrity SQL> LOCK TABLE hr.employees IN share MODE; 17-13 Copyright © Oracle Corporation, 2002. All rights reserved. Manually Locking a Table • Share Row Exclusive (SRX) – No DML operations or Share mode allowed – Implicitly used for referential integrity – No index is required on the foreign key column in the child table • Exclusive (X) – No DML or DDL operations allowed by other sessions – No manual locks allowed by other sessions – Queries are allowed [...]...DML Locks in Blocks Block Header TX slot 1 TX slot 2 1 Row 6 Lock bytes 2 17-14 Row 1 Copyright © Oracle Corporation, 2002 All rights reserved DDL Locks • Exclusive DDL locks are required for: – DROP TABLE statements – ALTER TABLE statements – (The lock is released when the DDL statement completes.) • Shared DDL locks are required for: – CREATE PROCEDURE statements – AUDIT statements – (The lock. .. Breakable parse locks are used for invalidating statements in the shared SQL area Copyright © Oracle Corporation, 2002 All rights reserved Possible Causes of Lock Contention • • • • 17-17 Unnecessarily high locking levels Long-running transactions Uncommitted changes Other products imposing higher-level locks Copyright © Oracle Corporation, 2002 All rights reserved Diagnostic Tools for Monitoring Locking... Deadlocks Server process ORA-00060: Deadlock detected while waiting for resource SID_ora_PID.trc UNIX Trace file in USER_DUMP_DEST directory 17-25 Copyright © Oracle Corporation, 2002 All rights reserved Summary In this lesson, you should have learned to do the following: • Define levels of locking • Identify causes of contention • Prevent locking problems • Use Oracle utilities to detect lock contention. .. employees SET salary = salary x 1.1; UPDATE employees SET salary = salary x 1.1 WHERE empno = 1000; v $lock v$locked_object dba_waiters dba_blockers 17-18 UPDATE employees SET salary = salary x 1.1 WHERE empno = 2000; Copyright © Oracle Corporation, 2002 All rights reserved Guidelines for Resolving Contention Transaction 1 UPDATE employees SET salary = salary x 1.1 WHERE empno = 1000; Transaction 2... 2002 All rights reserved Performance Manager: Locks 17-22 Copyright © Oracle Corporation, 2002 All rights reserved Deadlocks Transaction Transaction 1 2 UPDATE employees SET salary = salary x 1.1 WHERE empno = = 1000; UPDATE employees SET salary = salary x 1.1 WHERE empno = 2000; 9:15 UPDATE employees SET manager = 1342 WHERE empno = 1000; ORA-00060: Deadlock detected while waiting for resource 17-23... should have learned to do the following: • Define levels of locking • Identify causes of contention • Prevent locking problems • Use Oracle utilities to detect lock contention • Resolve contention in an emergency • Resolve deadlock conditions 17-26 Copyright © Oracle Corporation, 2002 All rights reserved . following: • Define levels of locking • Identify causes of contention • Prevent locking problems • Use Oracle utilities to detect lock contention • Resolve contention in. following: • Define levels of locking • Identify causes of contention • Prevent locking problems • Use Oracle utilities to detect lock contention • Resolve contention in

Ngày đăng: 15/03/2014, 17:20

Từ khóa liên quan

Mục lục

  • Monitoring and Detecting Lock Contention

  • Objectives

  • Locking Mechanism

  • Data Concurrency

  • Two Types of Locks

  • DML Locks

  • Enqueue Mechanism

  • Table Lock Modes

  • Manually Locking a Table

  • Slide 13

  • DML Locks in Blocks

  • DDL Locks

  • Possible Causes of Lock Contention

  • Diagnostic Tools for Monitoring Locking Activity

  • Guidelines for Resolving Contention

  • Performance Manager: Locks

  • Deadlocks

  • Slide 25

  • Summary

Tài liệu cùng người dùng

Tài liệu liên quan