Misunderstanding of Oracle Parallel 2 -- actually locking the entire table, oracle2 --

Source: Internet
Author: User

Misunderstanding of Oracle Parallel 2 -- actually locking the entire table, oracle2 --

I have written a misunderstanding about Oracle parallelism before. 1. In fact, you didn't use parallelism. I always thought that Oracle would only lock the data to be modified. But in parallel, this is the case, parallel update locks the entire table. The following experiment:

Session1:

SQL> select sid from v $ mystat where rownum = 1;
SID
----------
11
SQL> select sid from v $ mystat where rownum = 1;
SQL> create table test as select * from dba_objects;
SQL> alter session force parallel dml;
SQL> update/* + parallel (t, 4) */test t set object_name = 'ggg 'where object_type = 'table ';

Session2:
SQL> select sid from v $ mystat where rownum = 1;
SID
----------
8
SQL> update test t set object_name = 'ggg 'where object_type = 'index '; -- Hang

Session3:
SQL> select sid, type, id1, id2, lmode, request, ctime, block from v $ lock where sid in (8, 11) order by sid;
Sid type ID1 ID2 LMODE REQUEST CTIME BLOCK
--------------------------------------------------------------------------
8 TM 80189 0 0 3 61 0
8 AE 100 0 4 0 1871 0
11 TO 65927 1 3 0 1305 0
11 TX 196620 5212 6 0 64 0
11 PS 1 2 4 0 64 0
11 PS 1 3 4 0 64 0
11 TM 80189 0 6 0 64 1
11 PS 1 0 4 0 64 0
11 AE 100 0 4 0 2836 0
11 PS 1 1 4 0 64 0

SQL> select object_id, locked_mode from v $ locked_object where session_id in (8, 11 );
OBJECT_ID LOCKED_MODE
---------------------
80189 6
80189 0

SQL> select sid, event from v $ session_wait where wait_class <> 'idle' and sid in (8, 11 );
SID EVENT
-----------------------------------------------------------------------------------

8 enq: TM-contention


V $ LOCK View Structure

TYPE

Differentiate the lock protection object types (table 4)
TM-DML enqueue
TX-Transaction enqueue
UL-User supplied
-We mainly focus on the TX and TM locks.
-UL locks are defined by users and are rarely defined.
-All others are system locks, which will be released soon without attention

ID1
ID2

The value meanings of ID1 and ID2 vary according to the value of type.
For tmlock
ID1 indicates that the object_id of the locked table can be associated with the dba_objects view to obtain specific table information. The ID2 value is 0.
For TX? Lock
ID1 uses a decimal value to indicate the rollback segment number occupied by the firm and the slot number in the transaction slot, in the form of a group:
0 xRRRRSSSS, RRRR = RBS/undo number, SSSS = SLOT NUMBER
ID2 represents the number of times that wrap in decimal format, that is, the number of times that the transaction slot is reused.

LMODE

0-none
1-null (NULL)
2-row-S (SS)
3-row-X (SX)
4-share (S)
5-S/Row-X (SSX)
6-exclusive (X)

REQUEST

Same as LMODE. If it is greater than 0, the current session is blocked. Other sessions occupy the modified lock mode.

BLOCK

Whether to block other session lock applications 1: Blocking 0: not blocking

Related Article

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.