How Oracle uses built-in scripting to check for jams

Source: Internet
Author: User

When diagnosing a problem with a lock, check with the holder, the person who is blocked. Often is very troublesome, if you do not accumulate the script, rely on Manual Check to check a lot of tables, such as V$lock,v$process p, v$session s, V$latchholder and so on. Now there's an easy way to use Oracle's built-in scripts to generate two views dba_waiters and dba_blockers to check for jams. Execute the built-in script to execute in sys, as follows:

C:documents and Settingsguogang>sqlplus/as sysdba;

Sql*plus:release 10.2.0.1.0-production on Friday January 24 08:26:42 2014
Copyright (c) 1982, +, Oracle. All rights reserved.
Connect to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0-production
With the partitioning, OLAP and Data Mining options
Sql> @?/rdbms/admin/catblock.sql
The view has been created.

The synonym has been created.

.........................

Experiment:

Simulate DML lock

Session1:

SELECT * from test for update;

Session2:

SELECT * from test for update;

Session3:

Sql> select * from Dba_waiters;

Waiting_session holding_session lock_type Mode_held mode_requested lock_id1
--------------- --------------- ------------------------- ---------------------- ----------------------- ----------- --------- --------------- ---------
Transaction Exclusive Exclusive 131099 2550

Sql> select * from Dba_blockers;

Holding_session
---------------
150

It is clear to see that the holder of the lock is session 150, and the waiting person is 142.

Simulate DDL locks

Session1:

SELECT * FROM obj$ for update

Session2:

CREATE INDEX ind_t_id on test (object_id);

Session3:

Sql> select * from Dba_waiters;

Waiting_session holding_session lock_type Mode_held mode_requested lock_id1
--------------- --------------- -------------------------- ---------------------------------------- --------------- ------------------------- ---------- ----------
145 Transaction Exclusive Exclusive 1310729 1391

Sql> select * from Dba_blockers;

Holding_session
---------------
145

It is clear to see that the holder of the lock is session 145, and the waiting person is 150.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.