SlideShare ist ein Scribd-Unternehmen logo
1 von 52
Enqueue Waits : Locks

             Kyle Hailey
http://perfvision.com/ftp/emea2010
         kylelf@gmail.com


                                     #.1
Locks Covered in this Section
 Part I : Intro
  Lock Name(type) and Mode
  Finding waiter and blocker
  Finding Object
 Part II : User
  TM – table modification
  TX – Transaction locks
  UL – user lock
 Part III : Internal
  CI – Cross Instance
  HW – High Water
  RO – Reusable Object
                     Copyright 2006 Kyle Hailey   #.2
Part I : Intro
 To Solve we need:

 1.Waiter
 2.Blocker
 3.Lock Type
       type
       mode
 1.Object blocking on

 Missing : blocking SQL
       Possibly with log miner


                       Copyright 2006 Kyle Hailey   #.3
Solving – Data Sources
   V$active_session_history

  or

   In “real time” can also use
        v$lock
        v$session   (v$session_wait)
        dba_blockers
        dba_waiters
        ?/rdbms/admin/utllockt.sql
        http://www.evdbt.com/enqwaits.sql


                        Copyright 2006 Kyle Hailey   #.4
v$active_session_history
   Fields in ASH for lock analysis and solution:
 Waiter                     SQL Waiting
    SESSION_ID
                                SQL_ID
    SESSION_SERIAL#
                             Blocker
    USER_ID
                                    BLOCKING_SESSION
 Object
                                    BLOCKING_SESSION_STATUS
    CURRENT_OBJ#
    CURRENT_FILE#                  BLOCKING_SESSION_SERIAL#

    CURRENT_BLOCK#          Lock Type and Mode
                                Event = Type (name)
                                P1    = Type | Mode


         Missing: SQL Blocking not reliably
           possible, Maybe by dumping REDO
                        Copyright 2006 Kyle Hailey         #.5
Lock Name and Mode
  Select parameter1 from v$event_name where name=‘enqueue’;

           Parameter1
           ----------
           Name|mode
  Select p1, p1raw from v$session where event like 'enq%';

            P1          P1RAW
            ---------- --------
            1415053318 54580006

         Name: 5458                                     Mode: 0006
Hex  Decimal          ASCII
54 =      84        =   “T”                    Lock = TX 6
58 =      88        =   “X”
                           Copyright 2006 Kyle Hailey                #.6
Type and Mode

  SELECT
   SELECT
      chr(bitand(p1,-16777216)/16777215)||
       chr(bitand(p1,-16777216)/16777215)||
          chr(bitand(p1, 16711680)/65535) Type,
           chr(bitand(p1, 16711680)/65535) Type,
            mod(p1,16) lmode
            mod(p1,16) lmode
  from v$session_wait
   from v$session_wait
  where event=‘enqueue’;
   where event=‘enqueue’;
  TY
  TY      LMODE
          LMODE
  -- ----------
  -- ----------
  TX
  TX          6
              6



                                                   #.7
Lock Names (types)
   9i
     One         Wait : “enqueue”
   10g
     208enqueue waits
     Specific to each type of enqueue

  enq:   HW   -   contention                              Configuration
  enq:   SQ   -   contention                              Configuration
  enq:   SS   -   contention                              Configuration
  enq:   ST   -   contention                              Configuration
  enq:   TM   -   contention                              Application
  enq:   TW   -   contention                              Administrative
  enq:   TX   -   allocate ITL entry                      Configuration
  enq:   TX   -   index contention                        Concurrency
  enq:   TX   -   row lock contention                     Application
  enq:   TX   –   contention                              Application
                             Copyright 2006 Kyle Hailey                    #.8
Lock Modes


    # Type         Name
    --- -------   ---------------------------
      1 Null      Null
      2 SS        Sub share
      3 SX        Sub exclusive
      4 S         Share
      5 SSX       Share/sub exclusive
      6 X         Exclusive

                      Copyright 2006 Kyle Hailey   #.9
P1 = name | mode
 P1 (parameter1) same for all locks
   select distinct parameter1 from v$event_name              PARAMETER1
   where name like 'enq:%'                                   name|mode

    select
         event,
          mod(p1,16) as "mode"
     from v$active_session_history
     where event like 'enq:%‘;

   EVENT                                              mode
   enq: TX - allocate ITL entry                         4
   enq: TX - row lock contention                        6
   enq: TX - row lock contention                        4

                         Copyright 2006 Kyle Hailey                      #.10
OEM 10g




                             if P1 = 1415053318
                             then mode = 6
                             Then it is a data block
                             row lock
          Copyright 2006 Kyle Hailey                   #.11
Querying ASH
 select
     substr(event,0,20)            lock_name,
     ash.session_id               waiter,
     mod(ash.p1,16)               lmode,
     ash.p2                      p2,
     ash.p3                      p3,
     o.object_name               object,
     o.object_type               otype,
     CURRENT_FILE#               filen,
     CURRENT_BLOCK#              blockn,
     ash.SQL_ID                  waiting_sql,
     BLOCKING_SESSION            blocker
     --,ash.xid
 from
       v$active_session_history ash,
       all_objects o
 where
        event like 'enq: %'
   and o.object_id (+)= ash.CURRENT_OBJ#
 /

                          Copyright 2006 Kyle Hailey   #.12
Part II : User Locks

  TX – Transaction Lock
    Mode 6: Modifying same row
    Mode 4: several reasons

  TM – Table Modification
    Mode   4: Unindexed Foreign Key
  UL – User Lock




                       Copyright 2006 Kyle Hailey   #.13
TX Lock
 Session B
                                             Undo
                             Wait for Tx     Segment
update toto set
update toto set              To commit       Header
name = ‘ADAMS’
name = ‘ADAMS’
where id = 1;
where id = 1;                                              Undo
                                                           Segment
     Table Toto
     Data Block
    Data Block
     Header
    Header
   Transaction 1
                                           Session a
                                          update toto set
                                          update toto set
                                          name = ‘SMITH’
                                          name = ‘SMITH’
        Row 1                             where id = 1;
                                          Delete from 1;
                                          where id = toto where id
                                           Delete from toto where id
             Copyright 2006 Kyle Hailey   = 2;
                                           = 2;
                                          Delete from toto where id
                                           Delete from toto where #.14
                                                                  id
Transaction Locks (TX)
TX = Transaction = Wait on UNDO
 Mode 6 (exclusive)
     modification of a row lock
 Mode 4 (share)
   Index  block spilt
   Unique Index Key enforcement
   Foreign key enforcement
   ITL space waits
   Bitmap chunk conflicts
   Alter tablespace … read only;
   Free Lists slot waits
   Possible with two phase commit

                   Copyright 2006 Kyle Hailey   #.15
Transaction Locks (TX)

Mode 4, new Events:

1. enq: TX - allocate ITL entry
       Wait on an ITL slot
1. enq: TX - index contention
       Index block split
1. enq: TX - row lock contention
   1.   Mode 6 – classic row lock
   2.   Mode 4 - pk violation, fk violation, bitmap chunk wait
2. enq: TX – contention
       Wait for a data file extension, Alter tbs read only


                            Copyright 2006 Kyle Hailey           #.16
enq: TX - row lock contention
 Mode 6, row in data block
 User 1                                  User 2
 SQL> delete from toto
       where id = 1;
                                         SQL> delete from toto
                                         where id =1;

                      Table
                     ID     Value
                       1     foo




                         Copyright 2006 Kyle Hailey              #.17
enq: TX - row lock contention




                               if P1 = 1415053318
                               then mode = 6
                               Then it is a data block
                               row lock



                Copyright 2006 Kyle Hailey               #.18
TX – Mode 4




                         if P1 = 1415053316
                         then mode = 4
                         Not same data but conflicts

              Copyright 2006 Kyle Hailey               #.19
enq: TX - row lock contention
Mode 4, happens for 3 reasons
1. Unique key contention
2. Foreign Key contention
3. Bitmap index contention
 (others?)




                   Copyright 2006 Kyle Hailey   #.20
1. enq: TX - row lock contention
 Mode 4 , unique index
User 1                                         User 2
create table p(n number);
create unique index p_i on p(n);
insert into p values(2);
                                               insert into p values(2);

                   PK     Table

                    ID    ID Value
                   2?     2?



                          Copyright 2006 Kyle Hailey                      #.21
2. enq: TX - row lock contention
 Mode 4, foreign key
  User 1                                   User 2
  create table parent (
      id number primary key);
   create table child (
      id number references parent,
      name varchar2(20));
   insert into parent values (2);
                                           insert into child values (2,88);
      PK      Parent                             Child
       ID     ID Value                             ID Name
      2?      2?                                 2


                           Copyright 2006 Kyle Hailey                     #.22
3. enq: TX - row lock contention


    Mode 4
    Bitmaps are compressed
    Changes to the same bitmap cause locks
   Value Start          End   Bitmap
         Rowid          Rowid
   1                          01010000111000011100001100
         000.000.0000   000.000.000




   2                                       01010000111000011100001100
         000.000.0000   000.000.000




                                      Copyright 2006 Kyle Hailey    #.23
3. enq: TX - row lock contention
           Session 1
 create table t1 ((
  create table t1                           Different rows but
         n1
          n1     number(4),
                 number(4),                 same key value
         n2
          n2     number(4));
                 number(4));
 insert into t1
  insert into t1
    select 1, rownum
     select 1, rownum
    from all_objects
     from all_objects
    where rownum <= 400;
     where rownum <= 400;
 commit;
  commit;
 create bitmap index i1 on t1(n1);
  create bitmap index i1 on t1(n1);
 update t1 set n1 = 2
  update t1 set n1 = 2
 where n2 = 12;
  where n2 = 12;                                Session 2
                                   update t1 set n1 = 2
                                    update t1 set n1 = 2
                                   where n2 = 13;
                                    where n2 = 13;
                         Copyright 2006 Kyle Hailey              #.24
3. enq: TX - row lock contention
    Bitmaps are compressed
    Changes to the same bitmap chunk cause
     locks
   Value Start End   Bitmap
         Rowid Rowid
   1                 01010000111000011100001100
          200.0    204.7
   1                            01010000111000011100001100
          205.0    210.3
   2                            01010000111000011100001100
          200.0    205.6


       block      row
                           Copyright 2006 Kyle Hailey    #.25
3. enq: TX - row lock contention

  Value Start End   Bitmap
        Rowid Rowid
  1                 01010000111000011100001100
          200.0   204.7
  2                           01010000111000011100001100
          205.0   210.3
  3                           01010000111000011100001100
          200.0   205.6


                     Session 1                    Session 2
      Update id=12                                     Update id=13
      set value 2                                      set value 2
                          Copyright 2006 Kyle Hailey                  #.26
Summary: TX 4 from ASH
uniq index
ST    EVENT                    SID LM      P2   P3 OBJ   OTYPE FN BLOCKN SQL_ID             BSID
----- ----------------------   --- --- ------ ---- ----- ----- --- ------ --
10:39 enq: TX - row lock c     141   4 655406 6672 -1            0      0 bjvx94vnxtxgv      158
10:39 enq: TX - row lock c     141   4 655406 6672 -1            0      0 bjvx94vnxtxgv      158
10:39 enq: TX - row lock c     141   4 655406 6672 -1            0      0 bjvx94vnxtxgv      158
10:39 enq: TX - row lock c     141   4 655406 6672 -1            0      0 bjvx94vnxtxgv      158

FK (10.2.0.3)
ST    EVENT                    SID LM      P2   P3 OBJ     OTYPE FN BLOCKN SQL_ID           BSID
----- ----------------------   --- --- ------ ---- -----   ----- --- ------ --
10:41 enq: TX - row lock c     144   4 179681 7074 CHILD   TABLE   1 60954 ahm7c9rupbz9r     1
10:41 enq: TX - row lock c     144   4 179681 7074 CHILD   TABLE   1 60954 ahm7c9rupbz9r     1
10:41 enq: TX - row lock c     144   4 179681 7074 CHILD   TABLE   1 60954 ahm7c9rupbz9r     1

bitmap
ST     EVENT                   SID LM      P2   P3 OBJ     OTYPE FN BLOCKN SQL_ID           BSID
----- ----------------------   --- --- ------ ---- -----   ----- --- ------ --
10:41 enq: TX - row lock c     143   4 966081 4598 I1      INDEX   0      0 azav296xxqcjx    144
10:41 enq: TX - row lock c     143   4 966081 4598 I1      INDEX   0      0 azav296xxqcjx    144
10:41 enq: TX - row lock c     143   4 966081 4598 I1      INDEX   0      0 azav296xxqcjx    144
10:41 enq: TX - row lock c     143   4 966081 4598 I1      INDEX   0      0 azav296xxqcjx    144




                                         Copyright 2006 Kyle Hailey                                #.27
enq: TX - allocate ITL entry



                                  Transaction 1 Info
       Data Block
      Data Block                  Transaction 2 Info
       Header
      Header
      ITL



      Data



                    Copyright 2006 Kyle Hailey         #.28
enq: TX - allocate ITL entry




       Data Block
      Data Block
       Header
      Header
     Transaction 1                       Transaction 3
     Transaction 2
         Row 3
         Row 2
      Data
        Row 1


                     Copyright 2006 Kyle Hailey          #.29
enq: TX - allocate ITL entry
 create table itl (
  create table itl (
       id number,
        id number,
       data varchar2(20)
        data varchar2(20)
  ))
  pctfree 0
   pctfree 0
  initrans 1
   initrans 1
  ;;
 insert into itl select rownum,'a' from all_objects
  insert into itl select rownum,'a' from all_objects
                   where rownum < 2000;
                    where rownum < 2000;
 commit;
  commit;
  session 1: update itl set data=data where id=1;
   session 1: update itl set data=data where id=1;
  session 2: update itl set data=data where id=2;
   session 2: update itl set data=data where id=2;
  session 3: update itl set data=data where id=3;
   session 3: update itl set data=data where id=3;
  session 4: update itl set data=data where id=4;
   session 4: update itl set data=data where id=4;
  session 5: update itl set data=data where id=5;
   session 5: update itl set data=data where id=5;
                    Copyright 2006 Kyle Hailey       #.30
enq: TX - contention

 1. Altering tablespace read only with open transaction
     Example
      Session 1 – start transaction, don’t commit
      Session 2 – alter tablespace read only

 1. Data File Extension – waiter waiting for another session to extend
    file
 2. Index Block Split – waiter waiting for another session to split the
    block




                                   Copyright 2006 Kyle Hailey             #.31
TX Further Investigation

select  event, sql_id,
         CURRENT_OBJ# || ' ' || name obj
        ,CURRENT_FILE# file#
        ,CURRENT_BLOCK# block#
from v$active_session_history ash,
     obj$ o
where
     event like 'enq: TX%'
  and o.obj# (+)= ash.current_obj#
order by sample_time

EVENT                                       SQL_ID              OBJ           FILE# BLOCK#
enq:   TX   -   row   lock   contention     ahm7c9rupbz9r       53363   FOO   1   123586
enq:   TX   -   row   lock   contention     bjvx94vnxtxgv       53363   FOO   1   123586
enq:   TX   -   row   lock   contention     ahm7c9rupbz9r       53363   FOO   1   123586
enq:   TX   -   row   lock   contention     bjvx94vnxtxgv       53363   FOO   1   123586
enq:   TX   -   row   lock   contention     ahm7c9rupbz9r       53363   FOO   1   123586
                                   Copyright 2006 Kyle Hailey                              #.32
TX Further Investigation

Who is the blocker:



         V$active_session_history :
            BLOCKING_SESSION
            BLOCKING_SESSION_STATUS
            BLOCKING_SESSION_SERIAL#




     No Guarentee of finding blocker SQL

                      Copyright 2006 Kyle Hailey   #.33
enq: TM - contention


   TX locks have a corresponding TM lock
   TM locks the structure from change

     Parameter1   = object id
LOCK
LOCK    Parmeter1
         Parmeter1     Parmeter2(ID1) Parameter3(ID2)
                        Parmeter2(ID1) Parameter3(ID2)
------- ---------
------- ---------      -------------
                        -------------  ---------------
                                        ---------------
enq: TM name|mode
enq: TM name|mode      object #
                        object #       table/partition
                                        table/partition




                       Copyright 2006 Kyle Hailey         #.34
enq: TM - contention

Exclusive Row Level Lock

User 1                                   User 2
create table parent (
    id number primary key);
 create table child (
    id number references parent,
    name varchar2(20));
 insert into parent values (1);
 insert into parent values (2);
 commit;
                                         insert into child values (1,2);
delete from parent where id=2;

                         Copyright 2006 Kyle Hailey                        #.35
enq: TM - contention

    PK     Parent                                  Child
     ID    ID   Value                              ID Name
     1     1                                       1
     X
     2      X
            2




   Session 1     Insert into Child ID=1

    Session 2       Delete from Parent where ID=2 :
  Enqueue TM 4
  Session 2 doesn’t know the value Session 1 inserted
  Session 2 only knows there is an outstanding change
                      Copyright 2006 Kyle Hailey             #.36
enq: TM – contention Solution

      PK    Parent                                  Child
                                      Index
       ID   ID    Value                  ID         ID Name
      1                                   1
      2




                 Foreign Key

      Session 1: Insert into Child ID=1
      Session 2: Delete from Parent ID=2
            OK – can verify quickly in the child index
                       Copyright 2006 Kyle Hailey             #.37
TM Further Investigation
 select
      event,
      sql_id,
      mod(p1,16) as "mode",
      p2|| ' ' || o.name obj
  from v$active_session_history ash,
     obj$ o
  where
      event like 'enq: TM%'
    and o.obj# (+)= ash.p2
  order by sample_time;
EVENT                                   SQL_ID            mode OBJ
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD
enq:   TM   -   contention              8zw36yw3fq4yy       4   53372   CHILD

                             Copyright 2006 Kyle Hailey                         #.38
UL Locks
 User-defined Locks
   dbms_lock




    Wait Event                          Parameter2      Parameter3
    enq: UL - contention                 id              0



    dbms_lock.allocate_unique(v_lockname, v_lockhandle);
    dbms_lock.request(v_lockhandle, p_ltype);
    dbms_lock.release(v_lockhandle);



                           Copyright 2006 Kyle Hailey                #.39
Internal Locks


 CI – Cross Instance
 HW – High Water
 KO – fast object checkpoint
 RO – Reuse Object
 SQ – Sequence Lock
 ST – Space Transaction




                    Copyright 2006 Kyle Hailey   #.40
enq: CI - contention
 Cross Instance
 not OPS lock.
 invoke actions in background processes
     checkpoints
     log switches
     instance is shut down




                       Copyright 2006 Kyle Hailey   #.41
CI – Cross Instance


 Id1 Meaning (parameter2)
  Id1 Meaning (parameter2)                                Id2 Meaning (parameter3)
                                                           Id2 Meaning (parameter3)
 00Flush buffers for reuse as new class
    Flush buffers for reuse as new class                  11Pass in Parameters
                                                             Pass in Parameters
 11LGWR checkpointing and Hot Backup
    LGWR checkpointing and Hot Backup                     22Invoke the call in background process
                                                             Invoke the call in background process
 22DBWR synchronization of SGA with control file
    DBWR synchronization of SGA with control file         33Foreground has not returned yet
                                                             Foreground has not returned yet
 33Log file add/drop/rename notification                  44Used to allocate the CI call
                                                             Used to allocate the CI call
    Log file add/drop/rename notification
 44Write buffer for CR read                               55Used to queue up interested clients
                                                             Used to queue up interested clients
    Write buffer for CR read
 55Test Call
    Test Call
 66Invalidate KCK cache in all instances
    Invalidate KCK cache in all instances
 77Alter rollback segment optimal
    Alter rollback segment optimal
 88Signal Query Servers/coordinator
    Signal Query Servers/coordinator
 99Create Remote Parallel Query Server
    Create Remote Parallel Query Server
 10 Set Global Partitions
  10 Set Global Partitions
 11 Stop Disk Writes
  11 Stop Disk Writes
 12 Drop Sort Segments
  12 Drop Sort Segments
 13 Release unused space from Sort Segments
  13 Release unused space from Sort Segments
 14 Instance Recovery for Parallel operation Group
  14 Instance Recovery for Parallel operation Group
 15 Validate parallel slave Lock Value
  15 Validate parallel slave Lock Value
 16 Check Transaction State Objects
  16 Check Transaction State Objects

                                     Copyright 2006 Kyle Hailey                                #.42
CI Locks
select
      substr(sql_text,0,20) sql_text,
      p2,p3,
      CURRENT_OBJ# || ' ' || name obj
     ,CURRENT_FILE# file#
     ,CURRENT_BLOCK# block#
 from v$active_session_history ash,
        obj$ o,
     v$sqltext sql
 where
        event like 'enq: CI%'
   and o.obj# (+)= ash.current_obj#
   and sql.sql_id (+)= ash.sql_id
 order by sample_time;

            SQL_TEXT                   P2          P3 OBJ           FILE#   BLOCK#

            INSERT INTO TOTO1 VA        1           5 54225 TOTO1      6    682721


                            Copyright 2006 Kyle Hailey                           #.43
CI Locks

    SQL_TEXT
     SQL_TEXT                                     P2 P3
                                                   P2 P3
    ---------------------------------------- --- --
     ---------------------------------------- --- --
    alter table XXXXX drop partition YYYYY
     alter table XXXXX drop partition YYYYY        1 5
                                                    1 5
    P2 = 1 ""LGWR checkpointing and Hot Backup ""
     P2 = 1 LGWR checkpointing and Hot Backup

    P3 = 5. "Used to queue up interested clients""
     P3 = 5. "Used to queue up interested clients


      If p2=1 and p3=5, then contention on blocks being
       checkpointed, try raising fast_start_mttr_target


alter system set fast_start_mttr_target=600 scope=both;

                             Copyright 2006 Kyle Hailey    #.44
enq: HW - contention

Wait Event                   Parameter2              Parameter3
enq: HW - contention         table space #           block

  Session 1                 Header
                                                    Table
   Session 2
                             Data
   Session 3



     High Water Mark
                             Empty

                       Copyright 2006 Kyle Hailey                 #.45
HW

 Use Freelists
      Cause a jump in High Water Mark by freelists *
       _bump_highwater_mark_count
 Hidden Parameter
    _bump_highwater_mark_count
    alter session set "_bump_highwater_mark_count"=100;
          Not supported
 ASSM
          Automatic segment space management




                           Copyright 2006 Kyle Hailey      #.46
HW Further Investigation

 select
       event,
       sql_id,
       CURRENT_OBJ# || ' ' || name obj
      ,CURRENT_FILE# file#
      ,CURRENT_BLOCK# block#
  from v$active_session_history ash,
         obj$ o
  where
         event like 'enq: HW%'
    and o.obj# (+)= ash.current_obj#
  order by sample_time;

EVENT                  SQL_ID                    OBJ   FILE# BLOCK#
enq: HW - contention 49ch3jfkncnsp 53410 T1_I1           13   29734


                         Copyright 2006 Kyle Hailey              #.47
enq: KO - fast object checkpoint
 Used when checking the cache for blocks from a
  table for PQO direct read




                    Copyright 2006 Kyle Hailey     #.48
enq: RO - fast object reuse
   Drop or Truncate a table
     Wait   for DBWR to clean cache
   Solution
     Tune DBWR using smaller MTTR
     Use GTT
     Truncate/drop less often




                                       #.49
Other Resources




       @?/rdbms/admin/utllockt
       WAITING_SESSION LOCK_TYPE     MODE_REQUESTED MODE_HELD LOCK_ID1   LOCK_ID2
       --------------- ----------- -------------- --------- --------- --------
       144            None
         139          Transaction Share             Exclusive 131113     7507


                       Copyright 2006 Kyle Hailey                               #.50
Blocking Sessions




               Copyright 2006 Kyle Hailey   #.51
Summary : Internal Locks
    CI – Cross Instance
    HW – High Water
         Look at object and SQL
         use ASSM, freelists, pre-allocate extents
    KO – fast object checkpoint
         PQO
    RO – reusable object
         Reduce cache, tune DBWR, use GTT
    SQ – Sequence Lock
         logon/logoff problem
    ST - Space Transaction
         only one per database
         used for space allocations uet, fet
         Find object
         use LMT


                                   Copyright 2006 Kyle Hailey   #.52

Weitere ähnliche Inhalte

Was ist angesagt?

Oracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 samplingOracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 sampling
Kyle Hailey
 
Fatkulin presentation
Fatkulin presentationFatkulin presentation
Fatkulin presentation
Enkitec
 
Oracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and EnqueuesOracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and Enqueues
Hemant K Chitale
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
Kyle Hailey
 
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
maclean liu
 
了解Oracle rac brain split resolution
了解Oracle rac brain split resolution了解Oracle rac brain split resolution
了解Oracle rac brain split resolution
maclean liu
 
你所不知道的Oracle后台进程Smon功能
你所不知道的Oracle后台进程Smon功能你所不知道的Oracle后台进程Smon功能
你所不知道的Oracle后台进程Smon功能
maclean liu
 

Was ist angesagt? (20)

Oracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 samplingOracle 10g Performance: chapter 00 sampling
Oracle 10g Performance: chapter 00 sampling
 
Oracle goldengate 11g schema replication from standby database
Oracle goldengate 11g schema replication from standby databaseOracle goldengate 11g schema replication from standby database
Oracle goldengate 11g schema replication from standby database
 
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade DowntimeSCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
 
Fatkulin presentation
Fatkulin presentationFatkulin presentation
Fatkulin presentation
 
Automating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQLAutomating Disaster Recovery PostgreSQL
Automating Disaster Recovery PostgreSQL
 
Oracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and EnqueuesOracle Diagnostics : Latches and Enqueues
Oracle Diagnostics : Latches and Enqueues
 
OpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developersOpenWorld Sep14 12c for_developers
OpenWorld Sep14 12c for_developers
 
Survey of Percona Toolkit
Survey of Percona ToolkitSurvey of Percona Toolkit
Survey of Percona Toolkit
 
Managing MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona ToolkitManaging MariaDB Server operations with Percona Toolkit
Managing MariaDB Server operations with Percona Toolkit
 
还原Oracle中真实的cache recovery
还原Oracle中真实的cache recovery还原Oracle中真实的cache recovery
还原Oracle中真实的cache recovery
 
OakTable World Sep14 clonedb
OakTable World Sep14 clonedb OakTable World Sep14 clonedb
OakTable World Sep14 clonedb
 
Oracle Golden Gate
Oracle Golden GateOracle Golden Gate
Oracle Golden Gate
 
Direct SGA access without SQL
Direct SGA access without SQLDirect SGA access without SQL
Direct SGA access without SQL
 
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Develo...
 
How to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with GaleraHow to Avoid Pitfalls in Schema Upgrade with Galera
How to Avoid Pitfalls in Schema Upgrade with Galera
 
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
【Maclean liu技术分享】拨开oracle cbo优化器迷雾,探究histogram直方图之秘 0321
 
Riyaj real world performance issues rac focus
Riyaj real world performance issues rac focusRiyaj real world performance issues rac focus
Riyaj real world performance issues rac focus
 
了解Oracle rac brain split resolution
了解Oracle rac brain split resolution了解Oracle rac brain split resolution
了解Oracle rac brain split resolution
 
Performance Schema for MySQL Troubleshooting
Performance Schema for MySQL TroubleshootingPerformance Schema for MySQL Troubleshooting
Performance Schema for MySQL Troubleshooting
 
你所不知道的Oracle后台进程Smon功能
你所不知道的Oracle后台进程Smon功能你所不知道的Oracle后台进程Smon功能
你所不知道的Oracle后台进程Smon功能
 

Ähnlich wie Oracle 10g Performance: chapter 09 enqueues

Finding root blocker in oracle database
Finding root blocker in oracle databaseFinding root blocker in oracle database
Finding root blocker in oracle database
Mohsen B
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
Jeen Lee
 
Kyle Hailey Oracle Performance IO Waits
Kyle Hailey  Oracle Performance IO WaitsKyle Hailey  Oracle Performance IO Waits
Kyle Hailey Oracle Performance IO Waits
cookie1969
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
Lars Albertsson
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
Karam Abuataya
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
Kyle Hailey
 

Ähnlich wie Oracle 10g Performance: chapter 09 enqueues (20)

Finding root blocker in oracle database
Finding root blocker in oracle databaseFinding root blocker in oracle database
Finding root blocker in oracle database
 
Hadoop World 2011: Leveraging Hadoop for Legacy Systems - Mathias Herberts, C...
Hadoop World 2011: Leveraging Hadoop for Legacy Systems - Mathias Herberts, C...Hadoop World 2011: Leveraging Hadoop for Legacy Systems - Mathias Herberts, C...
Hadoop World 2011: Leveraging Hadoop for Legacy Systems - Mathias Herberts, C...
 
Leveraging Hadoop for Legacy Systems
Leveraging Hadoop for Legacy SystemsLeveraging Hadoop for Legacy Systems
Leveraging Hadoop for Legacy Systems
 
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2Cassandra Community Webinar  - Introduction To Apache Cassandra 1.2
Cassandra Community Webinar - Introduction To Apache Cassandra 1.2
 
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
Cassandra Community Webinar | Introduction to Apache Cassandra 1.2
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
 
Kyle Hailey Oracle Performance IO Waits
Kyle Hailey  Oracle Performance IO WaitsKyle Hailey  Oracle Performance IO Waits
Kyle Hailey Oracle Performance IO Waits
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
11thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp0111thingsabout11g 12659705398222 Phpapp01
11thingsabout11g 12659705398222 Phpapp01
 
Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)Kickin' Ass with Cache-Fu (without notes)
Kickin' Ass with Cache-Fu (without notes)
 
Unix executable buffer overflow
Unix executable buffer overflowUnix executable buffer overflow
Unix executable buffer overflow
 
Oracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmastersOracle Open World Thursday 230 ashmasters
Oracle Open World Thursday 230 ashmasters
 
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020Troubleshooting Tips and Tricks for Database 19c   ILOUG Feb 2020
Troubleshooting Tips and Tricks for Database 19c ILOUG Feb 2020
 
Clojure ♥ cassandra
Clojure ♥ cassandra Clojure ♥ cassandra
Clojure ♥ cassandra
 
ash-1-130820122404-phpapp01.pdf
ash-1-130820122404-phpapp01.pdfash-1-130820122404-phpapp01.pdf
ash-1-130820122404-phpapp01.pdf
 
SQL Server Blocking Analysis
SQL Server Blocking AnalysisSQL Server Blocking Analysis
SQL Server Blocking Analysis
 
Turbo-Geth Optimizing Ethereum Clients
Turbo-Geth Optimizing Ethereum ClientsTurbo-Geth Optimizing Ethereum Clients
Turbo-Geth Optimizing Ethereum Clients
 
MySQL under the siege
MySQL under the siegeMySQL under the siege
MySQL under the siege
 
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
Troubleshooting Tips and Tricks for Database 19c - Sangam 2019
 
Cassandra - lesson learned
Cassandra  - lesson learnedCassandra  - lesson learned
Cassandra - lesson learned
 

Mehr von Kyle Hailey

Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Kyle Hailey
 

Mehr von Kyle Hailey (20)

Hooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume LelargeHooks in postgresql by Guillaume Lelarge
Hooks in postgresql by Guillaume Lelarge
 
Performance insights twitch
Performance insights twitchPerformance insights twitch
Performance insights twitch
 
History of database monitoring
History of database monitoringHistory of database monitoring
History of database monitoring
 
Successfully convince people with data visualization
Successfully convince people with data visualizationSuccessfully convince people with data visualization
Successfully convince people with data visualization
 
Virtual Data : Eliminating the data constraint in Application Development
Virtual Data :  Eliminating the data constraint in Application DevelopmentVirtual Data :  Eliminating the data constraint in Application Development
Virtual Data : Eliminating the data constraint in Application Development
 
DBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application DevelopmentDBTA Data Summit : Eliminating the data constraint in Application Development
DBTA Data Summit : Eliminating the data constraint in Application Development
 
Accelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual DataAccelerate Develoment with VIrtual Data
Accelerate Develoment with VIrtual Data
 
Delphix and Pure Storage partner
Delphix and Pure Storage partnerDelphix and Pure Storage partner
Delphix and Pure Storage partner
 
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
Mark Farnam  : Minimizing the Concurrency Footprint of TransactionsMark Farnam  : Minimizing the Concurrency Footprint of Transactions
Mark Farnam : Minimizing the Concurrency Footprint of Transactions
 
Dan Norris: Exadata security
Dan Norris: Exadata securityDan Norris: Exadata security
Dan Norris: Exadata security
 
Martin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle GuysMartin Klier : Volkswagen for Oracle Guys
Martin Klier : Volkswagen for Oracle Guys
 
What is DevOps
What is DevOpsWhat is DevOps
What is DevOps
 
Data as a Service
Data as a Service Data as a Service
Data as a Service
 
Data Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloningData Virtualization: Revolutionizing data cloning
Data Virtualization: Revolutionizing data cloning
 
BGOUG "Agile Data: revolutionizing database cloning'
BGOUG  "Agile Data: revolutionizing database cloning'BGOUG  "Agile Data: revolutionizing database cloning'
BGOUG "Agile Data: revolutionizing database cloning'
 
Denver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualizationDenver devops : enabling DevOps with data virtualization
Denver devops : enabling DevOps with data virtualization
 
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
Oracle Open World 2014: Lies, Damned Lies, and I/O Statistics [ CON3671]
 
Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix Jonathan Lewis explains Delphix
Jonathan Lewis explains Delphix
 
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuseOaktable World 2014 Toon Koppelaars: database constraints polite excuse
Oaktable World 2014 Toon Koppelaars: database constraints polite excuse
 
Profiling the logwriter and database writer
Profiling the logwriter and database writerProfiling the logwriter and database writer
Profiling the logwriter and database writer
 

Kürzlich hochgeladen

Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Kürzlich hochgeladen (20)

SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 

Oracle 10g Performance: chapter 09 enqueues

  • 1. Enqueue Waits : Locks Kyle Hailey http://perfvision.com/ftp/emea2010 kylelf@gmail.com #.1
  • 2. Locks Covered in this Section Part I : Intro  Lock Name(type) and Mode  Finding waiter and blocker  Finding Object Part II : User  TM – table modification  TX – Transaction locks  UL – user lock Part III : Internal  CI – Cross Instance  HW – High Water  RO – Reusable Object Copyright 2006 Kyle Hailey #.2
  • 3. Part I : Intro To Solve we need: 1.Waiter 2.Blocker 3.Lock Type  type  mode 1.Object blocking on Missing : blocking SQL  Possibly with log miner Copyright 2006 Kyle Hailey #.3
  • 4. Solving – Data Sources  V$active_session_history or  In “real time” can also use  v$lock  v$session (v$session_wait)  dba_blockers  dba_waiters  ?/rdbms/admin/utllockt.sql  http://www.evdbt.com/enqwaits.sql Copyright 2006 Kyle Hailey #.4
  • 5. v$active_session_history Fields in ASH for lock analysis and solution:  Waiter SQL Waiting  SESSION_ID SQL_ID  SESSION_SERIAL# Blocker  USER_ID  BLOCKING_SESSION  Object  BLOCKING_SESSION_STATUS  CURRENT_OBJ#  CURRENT_FILE#  BLOCKING_SESSION_SERIAL#  CURRENT_BLOCK# Lock Type and Mode Event = Type (name) P1 = Type | Mode Missing: SQL Blocking not reliably possible, Maybe by dumping REDO Copyright 2006 Kyle Hailey #.5
  • 6. Lock Name and Mode Select parameter1 from v$event_name where name=‘enqueue’; Parameter1 ---------- Name|mode Select p1, p1raw from v$session where event like 'enq%'; P1 P1RAW ---------- -------- 1415053318 54580006 Name: 5458 Mode: 0006 Hex Decimal ASCII 54 = 84 = “T” Lock = TX 6 58 = 88 = “X” Copyright 2006 Kyle Hailey #.6
  • 7. Type and Mode SELECT SELECT chr(bitand(p1,-16777216)/16777215)|| chr(bitand(p1,-16777216)/16777215)|| chr(bitand(p1, 16711680)/65535) Type, chr(bitand(p1, 16711680)/65535) Type, mod(p1,16) lmode mod(p1,16) lmode from v$session_wait from v$session_wait where event=‘enqueue’; where event=‘enqueue’; TY TY LMODE LMODE -- ---------- -- ---------- TX TX 6 6 #.7
  • 8. Lock Names (types)  9i  One Wait : “enqueue”  10g  208enqueue waits  Specific to each type of enqueue enq: HW - contention Configuration enq: SQ - contention Configuration enq: SS - contention Configuration enq: ST - contention Configuration enq: TM - contention Application enq: TW - contention Administrative enq: TX - allocate ITL entry Configuration enq: TX - index contention Concurrency enq: TX - row lock contention Application enq: TX – contention Application Copyright 2006 Kyle Hailey #.8
  • 9. Lock Modes # Type Name --- ------- --------------------------- 1 Null Null 2 SS Sub share 3 SX Sub exclusive 4 S Share 5 SSX Share/sub exclusive 6 X Exclusive Copyright 2006 Kyle Hailey #.9
  • 10. P1 = name | mode  P1 (parameter1) same for all locks select distinct parameter1 from v$event_name PARAMETER1 where name like 'enq:%' name|mode select event, mod(p1,16) as "mode" from v$active_session_history where event like 'enq:%‘; EVENT mode enq: TX - allocate ITL entry 4 enq: TX - row lock contention 6 enq: TX - row lock contention 4 Copyright 2006 Kyle Hailey #.10
  • 11. OEM 10g if P1 = 1415053318 then mode = 6 Then it is a data block row lock Copyright 2006 Kyle Hailey #.11
  • 12. Querying ASH select substr(event,0,20) lock_name, ash.session_id waiter, mod(ash.p1,16) lmode, ash.p2 p2, ash.p3 p3, o.object_name object, o.object_type otype, CURRENT_FILE# filen, CURRENT_BLOCK# blockn, ash.SQL_ID waiting_sql, BLOCKING_SESSION blocker --,ash.xid from v$active_session_history ash, all_objects o where event like 'enq: %' and o.object_id (+)= ash.CURRENT_OBJ# / Copyright 2006 Kyle Hailey #.12
  • 13. Part II : User Locks  TX – Transaction Lock  Mode 6: Modifying same row  Mode 4: several reasons  TM – Table Modification  Mode 4: Unindexed Foreign Key  UL – User Lock Copyright 2006 Kyle Hailey #.13
  • 14. TX Lock Session B Undo Wait for Tx Segment update toto set update toto set To commit Header name = ‘ADAMS’ name = ‘ADAMS’ where id = 1; where id = 1; Undo Segment Table Toto Data Block Data Block Header Header Transaction 1 Session a update toto set update toto set name = ‘SMITH’ name = ‘SMITH’ Row 1 where id = 1; Delete from 1; where id = toto where id Delete from toto where id Copyright 2006 Kyle Hailey = 2; = 2; Delete from toto where id Delete from toto where #.14 id
  • 15. Transaction Locks (TX) TX = Transaction = Wait on UNDO  Mode 6 (exclusive)  modification of a row lock  Mode 4 (share)  Index block spilt  Unique Index Key enforcement  Foreign key enforcement  ITL space waits  Bitmap chunk conflicts  Alter tablespace … read only;  Free Lists slot waits  Possible with two phase commit Copyright 2006 Kyle Hailey #.15
  • 16. Transaction Locks (TX) Mode 4, new Events: 1. enq: TX - allocate ITL entry  Wait on an ITL slot 1. enq: TX - index contention  Index block split 1. enq: TX - row lock contention 1. Mode 6 – classic row lock 2. Mode 4 - pk violation, fk violation, bitmap chunk wait 2. enq: TX – contention  Wait for a data file extension, Alter tbs read only Copyright 2006 Kyle Hailey #.16
  • 17. enq: TX - row lock contention Mode 6, row in data block User 1 User 2 SQL> delete from toto where id = 1; SQL> delete from toto where id =1; Table ID Value 1 foo Copyright 2006 Kyle Hailey #.17
  • 18. enq: TX - row lock contention if P1 = 1415053318 then mode = 6 Then it is a data block row lock Copyright 2006 Kyle Hailey #.18
  • 19. TX – Mode 4 if P1 = 1415053316 then mode = 4 Not same data but conflicts Copyright 2006 Kyle Hailey #.19
  • 20. enq: TX - row lock contention Mode 4, happens for 3 reasons 1. Unique key contention 2. Foreign Key contention 3. Bitmap index contention (others?) Copyright 2006 Kyle Hailey #.20
  • 21. 1. enq: TX - row lock contention Mode 4 , unique index User 1 User 2 create table p(n number); create unique index p_i on p(n); insert into p values(2); insert into p values(2); PK Table ID ID Value 2? 2? Copyright 2006 Kyle Hailey #.21
  • 22. 2. enq: TX - row lock contention Mode 4, foreign key User 1 User 2 create table parent ( id number primary key); create table child ( id number references parent, name varchar2(20)); insert into parent values (2); insert into child values (2,88); PK Parent Child ID ID Value ID Name 2? 2? 2 Copyright 2006 Kyle Hailey #.22
  • 23. 3. enq: TX - row lock contention  Mode 4  Bitmaps are compressed  Changes to the same bitmap cause locks Value Start End Bitmap Rowid Rowid 1 01010000111000011100001100 000.000.0000 000.000.000 2 01010000111000011100001100 000.000.0000 000.000.000 Copyright 2006 Kyle Hailey #.23
  • 24. 3. enq: TX - row lock contention Session 1 create table t1 (( create table t1 Different rows but n1 n1 number(4), number(4), same key value n2 n2 number(4)); number(4)); insert into t1 insert into t1 select 1, rownum select 1, rownum from all_objects from all_objects where rownum <= 400; where rownum <= 400; commit; commit; create bitmap index i1 on t1(n1); create bitmap index i1 on t1(n1); update t1 set n1 = 2 update t1 set n1 = 2 where n2 = 12; where n2 = 12; Session 2 update t1 set n1 = 2 update t1 set n1 = 2 where n2 = 13; where n2 = 13; Copyright 2006 Kyle Hailey #.24
  • 25. 3. enq: TX - row lock contention  Bitmaps are compressed  Changes to the same bitmap chunk cause locks Value Start End Bitmap Rowid Rowid 1 01010000111000011100001100 200.0 204.7 1 01010000111000011100001100 205.0 210.3 2 01010000111000011100001100 200.0 205.6 block row Copyright 2006 Kyle Hailey #.25
  • 26. 3. enq: TX - row lock contention Value Start End Bitmap Rowid Rowid 1 01010000111000011100001100 200.0 204.7 2 01010000111000011100001100 205.0 210.3 3 01010000111000011100001100 200.0 205.6 Session 1 Session 2 Update id=12 Update id=13 set value 2 set value 2 Copyright 2006 Kyle Hailey #.26
  • 27. Summary: TX 4 from ASH uniq index ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID ----- ---------------------- --- --- ------ ---- ----- ----- --- ------ -- 10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158 10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158 10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158 10:39 enq: TX - row lock c 141 4 655406 6672 -1 0 0 bjvx94vnxtxgv 158 FK (10.2.0.3) ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID ----- ---------------------- --- --- ------ ---- ----- ----- --- ------ -- 10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1 10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1 10:41 enq: TX - row lock c 144 4 179681 7074 CHILD TABLE 1 60954 ahm7c9rupbz9r 1 bitmap ST EVENT SID LM P2 P3 OBJ OTYPE FN BLOCKN SQL_ID BSID ----- ---------------------- --- --- ------ ---- ----- ----- --- ------ -- 10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144 10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144 10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144 10:41 enq: TX - row lock c 143 4 966081 4598 I1 INDEX 0 0 azav296xxqcjx 144 Copyright 2006 Kyle Hailey #.27
  • 28. enq: TX - allocate ITL entry Transaction 1 Info Data Block Data Block Transaction 2 Info Header Header ITL Data Copyright 2006 Kyle Hailey #.28
  • 29. enq: TX - allocate ITL entry Data Block Data Block Header Header Transaction 1 Transaction 3 Transaction 2 Row 3 Row 2 Data Row 1 Copyright 2006 Kyle Hailey #.29
  • 30. enq: TX - allocate ITL entry create table itl ( create table itl ( id number, id number, data varchar2(20) data varchar2(20) )) pctfree 0 pctfree 0 initrans 1 initrans 1 ;; insert into itl select rownum,'a' from all_objects insert into itl select rownum,'a' from all_objects where rownum < 2000; where rownum < 2000; commit; commit; session 1: update itl set data=data where id=1; session 1: update itl set data=data where id=1; session 2: update itl set data=data where id=2; session 2: update itl set data=data where id=2; session 3: update itl set data=data where id=3; session 3: update itl set data=data where id=3; session 4: update itl set data=data where id=4; session 4: update itl set data=data where id=4; session 5: update itl set data=data where id=5; session 5: update itl set data=data where id=5; Copyright 2006 Kyle Hailey #.30
  • 31. enq: TX - contention 1. Altering tablespace read only with open transaction Example  Session 1 – start transaction, don’t commit  Session 2 – alter tablespace read only 1. Data File Extension – waiter waiting for another session to extend file 2. Index Block Split – waiter waiting for another session to split the block Copyright 2006 Kyle Hailey #.31
  • 32. TX Further Investigation select event, sql_id, CURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file# ,CURRENT_BLOCK# block# from v$active_session_history ash, obj$ o where event like 'enq: TX%' and o.obj# (+)= ash.current_obj# order by sample_time EVENT SQL_ID OBJ FILE# BLOCK# enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586 enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586 enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586 enq: TX - row lock contention bjvx94vnxtxgv 53363 FOO 1 123586 enq: TX - row lock contention ahm7c9rupbz9r 53363 FOO 1 123586 Copyright 2006 Kyle Hailey #.32
  • 33. TX Further Investigation Who is the blocker: V$active_session_history : BLOCKING_SESSION BLOCKING_SESSION_STATUS BLOCKING_SESSION_SERIAL# No Guarentee of finding blocker SQL Copyright 2006 Kyle Hailey #.33
  • 34. enq: TM - contention  TX locks have a corresponding TM lock  TM locks the structure from change  Parameter1 = object id LOCK LOCK Parmeter1 Parmeter1 Parmeter2(ID1) Parameter3(ID2) Parmeter2(ID1) Parameter3(ID2) ------- --------- ------- --------- ------------- ------------- --------------- --------------- enq: TM name|mode enq: TM name|mode object # object # table/partition table/partition Copyright 2006 Kyle Hailey #.34
  • 35. enq: TM - contention Exclusive Row Level Lock User 1 User 2 create table parent ( id number primary key); create table child ( id number references parent, name varchar2(20)); insert into parent values (1); insert into parent values (2); commit; insert into child values (1,2); delete from parent where id=2; Copyright 2006 Kyle Hailey #.35
  • 36. enq: TM - contention PK Parent Child ID ID Value ID Name 1 1 1 X 2 X 2 Session 1 Insert into Child ID=1 Session 2 Delete from Parent where ID=2 : Enqueue TM 4 Session 2 doesn’t know the value Session 1 inserted Session 2 only knows there is an outstanding change Copyright 2006 Kyle Hailey #.36
  • 37. enq: TM – contention Solution PK Parent Child Index ID ID Value ID ID Name 1 1 2 Foreign Key Session 1: Insert into Child ID=1 Session 2: Delete from Parent ID=2 OK – can verify quickly in the child index Copyright 2006 Kyle Hailey #.37
  • 38. TM Further Investigation select event, sql_id, mod(p1,16) as "mode", p2|| ' ' || o.name obj from v$active_session_history ash, obj$ o where event like 'enq: TM%' and o.obj# (+)= ash.p2 order by sample_time; EVENT SQL_ID mode OBJ enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD enq: TM - contention 8zw36yw3fq4yy 4 53372 CHILD Copyright 2006 Kyle Hailey #.38
  • 39. UL Locks  User-defined Locks  dbms_lock Wait Event Parameter2 Parameter3 enq: UL - contention id 0 dbms_lock.allocate_unique(v_lockname, v_lockhandle); dbms_lock.request(v_lockhandle, p_ltype); dbms_lock.release(v_lockhandle); Copyright 2006 Kyle Hailey #.39
  • 40. Internal Locks  CI – Cross Instance  HW – High Water  KO – fast object checkpoint  RO – Reuse Object  SQ – Sequence Lock  ST – Space Transaction Copyright 2006 Kyle Hailey #.40
  • 41. enq: CI - contention  Cross Instance  not OPS lock.  invoke actions in background processes  checkpoints  log switches  instance is shut down Copyright 2006 Kyle Hailey #.41
  • 42. CI – Cross Instance Id1 Meaning (parameter2) Id1 Meaning (parameter2) Id2 Meaning (parameter3) Id2 Meaning (parameter3) 00Flush buffers for reuse as new class Flush buffers for reuse as new class 11Pass in Parameters Pass in Parameters 11LGWR checkpointing and Hot Backup LGWR checkpointing and Hot Backup 22Invoke the call in background process Invoke the call in background process 22DBWR synchronization of SGA with control file DBWR synchronization of SGA with control file 33Foreground has not returned yet Foreground has not returned yet 33Log file add/drop/rename notification 44Used to allocate the CI call Used to allocate the CI call Log file add/drop/rename notification 44Write buffer for CR read 55Used to queue up interested clients Used to queue up interested clients Write buffer for CR read 55Test Call Test Call 66Invalidate KCK cache in all instances Invalidate KCK cache in all instances 77Alter rollback segment optimal Alter rollback segment optimal 88Signal Query Servers/coordinator Signal Query Servers/coordinator 99Create Remote Parallel Query Server Create Remote Parallel Query Server 10 Set Global Partitions 10 Set Global Partitions 11 Stop Disk Writes 11 Stop Disk Writes 12 Drop Sort Segments 12 Drop Sort Segments 13 Release unused space from Sort Segments 13 Release unused space from Sort Segments 14 Instance Recovery for Parallel operation Group 14 Instance Recovery for Parallel operation Group 15 Validate parallel slave Lock Value 15 Validate parallel slave Lock Value 16 Check Transaction State Objects 16 Check Transaction State Objects Copyright 2006 Kyle Hailey #.42
  • 43. CI Locks select substr(sql_text,0,20) sql_text, p2,p3, CURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file# ,CURRENT_BLOCK# block# from v$active_session_history ash, obj$ o, v$sqltext sql where event like 'enq: CI%' and o.obj# (+)= ash.current_obj# and sql.sql_id (+)= ash.sql_id order by sample_time; SQL_TEXT P2 P3 OBJ FILE# BLOCK# INSERT INTO TOTO1 VA 1 5 54225 TOTO1 6 682721 Copyright 2006 Kyle Hailey #.43
  • 44. CI Locks SQL_TEXT SQL_TEXT P2 P3 P2 P3 ---------------------------------------- --- -- ---------------------------------------- --- -- alter table XXXXX drop partition YYYYY alter table XXXXX drop partition YYYYY 1 5 1 5 P2 = 1 ""LGWR checkpointing and Hot Backup "" P2 = 1 LGWR checkpointing and Hot Backup P3 = 5. "Used to queue up interested clients"" P3 = 5. "Used to queue up interested clients If p2=1 and p3=5, then contention on blocks being checkpointed, try raising fast_start_mttr_target alter system set fast_start_mttr_target=600 scope=both; Copyright 2006 Kyle Hailey #.44
  • 45. enq: HW - contention Wait Event Parameter2 Parameter3 enq: HW - contention table space # block Session 1 Header Table Session 2 Data Session 3 High Water Mark Empty Copyright 2006 Kyle Hailey #.45
  • 46. HW  Use Freelists  Cause a jump in High Water Mark by freelists * _bump_highwater_mark_count  Hidden Parameter  _bump_highwater_mark_count  alter session set "_bump_highwater_mark_count"=100;  Not supported  ASSM  Automatic segment space management Copyright 2006 Kyle Hailey #.46
  • 47. HW Further Investigation select event, sql_id, CURRENT_OBJ# || ' ' || name obj ,CURRENT_FILE# file# ,CURRENT_BLOCK# block# from v$active_session_history ash, obj$ o where event like 'enq: HW%' and o.obj# (+)= ash.current_obj# order by sample_time; EVENT SQL_ID OBJ FILE# BLOCK# enq: HW - contention 49ch3jfkncnsp 53410 T1_I1 13 29734 Copyright 2006 Kyle Hailey #.47
  • 48. enq: KO - fast object checkpoint  Used when checking the cache for blocks from a table for PQO direct read Copyright 2006 Kyle Hailey #.48
  • 49. enq: RO - fast object reuse  Drop or Truncate a table  Wait for DBWR to clean cache  Solution  Tune DBWR using smaller MTTR  Use GTT  Truncate/drop less often #.49
  • 50. Other Resources @?/rdbms/admin/utllockt WAITING_SESSION LOCK_TYPE MODE_REQUESTED MODE_HELD LOCK_ID1 LOCK_ID2 --------------- ----------- -------------- --------- --------- -------- 144 None 139 Transaction Share Exclusive 131113 7507 Copyright 2006 Kyle Hailey #.50
  • 51. Blocking Sessions Copyright 2006 Kyle Hailey #.51
  • 52. Summary : Internal Locks  CI – Cross Instance  HW – High Water  Look at object and SQL  use ASSM, freelists, pre-allocate extents  KO – fast object checkpoint  PQO  RO – reusable object  Reduce cache, tune DBWR, use GTT  SQ – Sequence Lock  logon/logoff problem  ST - Space Transaction  only one per database  used for space allocations uet, fet  Find object  use LMT Copyright 2006 Kyle Hailey #.52

Hinweis der Redaktion

  1. Lock seems easy Compared to latches, buffer busy waits etc
  2. bitand(p1, 65536) &quot;Mode&quot;
  3. TX if P1 = 1415053316 then mode = 4 if P1 = 1415053318 then mode = 6
  4. col event for a22 col block_type for a18 col objn for a18 col otype for a10 col fn for 99 col sid for 9999 col bsid for 9999 col lm for 99 col p3 for 99999 col blockn for 99999 select to_char(sample_time,&apos;HH:MI&apos;) st, substr(event,0,20) event, ash.session_id sid, mod(ash.p1,16) lm, ash.p2, ash.p3, nvl(o.object_name,ash.current_obj#) objn, substr(o.object_type,0,10) otype, CURRENT_FILE# fn, CURRENT_BLOCK# blockn, ash.SQL_ID, BLOCKING_SESSION bsid --,ash.xid from v$active_session_history ash, all_objects o where event like &apos;enq: TX %&apos; and o.object_id (+)= ash.CURRENT_OBJ# and sample_time &gt; sysdate - &amp;1/(60*24) Order by sample_time /
  5. create table p(n number); create unique index p_i on p(n); insert into p values(3);
  6. Subject: Bitmap Indexes and Deadlocks: Deadlocks on Insert Statements Doc ID: Note:171795.1 Type: TROUBLESHOOTING Last Revision Date: 18-MAY-2004 Status: PUBLISHED PURPOSE ------- The purpose of this article is to explain the occurrence of deadlocks when the only DML activity is insert statements against a table with a bitmap index SCOPE &amp; APPLICATION ------------------- Database administrators and Application developers involved in application design. BITMAP INDEXES: THE HIDDEN DEADLOCK THREAT ------------------------------------------ The &quot;Oracle8i Designing and Tuning for Performance&quot; guide explains the limitations of bitmap indexes as this: Extract of documentation: &quot;DML and DDL statements, such as UPDATE, DELETE, DROP TABLE, affect bitmap indexes the same way they do traditional indexes: the consistency model is the same. A compressed bitmap for a key value is made up of one or more bitmap segments, each of which is at most half a block in size (but may be smaller). The locking granularity is one such bitmap segment. This may affect performance in environments where many transactions make simultaneous updates. If numerous DML operations have caused increased index size and decreasing performance for queries, then you can use the ALTER INDEX ... REBUILD statement to compact the index and restore efficient performance. A B*-tree index entry contains a single rowid. Therefore, when the index entry is locked, a single row is locked. With bitmap indexes, an entry can potentially contain a range of rowids. When a bitmap index entry is locked, the entire range of rowids is locked. The number of rowids in this range affects concurrency. As the number of rowids increases in a bitmap segment, concurrency decreases. Locking issues affect DML operations, and may affect heavy OLTP environments. Locking issues do not, however, affect query performance. As with other types of indexes, updating bitmap indexes is a costly operation. Nonetheless, for bulk inserts and updates where many rows are inserted or many updates are made in a single statement, performance with bitmap indexes can be better than with regular B*-tree indexes.&quot; ************** What is not mentioned is the fact that the same architectural feature that locks a range of rowid&apos;s also means that its possible to get a deadlock within the bitmap when updating rows in the underlying table. This deadlock is not in the table itself, as one might suspect, but rather in the bitmap index blocks. This kind of deadlock is easily diagnosable by the deadlock trace file, which has an entry that looks like the example below: The following deadlock is not an ORACLE error. It is a deadlock due to user error in the design of an application or from issuing incorrect ad-hoc SQL. The following information may aid in determining the deadlock: Deadlock graph: ---------Blocker(s)-------- ---------Waiter(s)--------- Resource Name process session holds waits process session holds waits TX-00080027-0000d2a1 12 37 X 15 35 S TX-000a0016-0000d6d2 15 35 X 12 37 S session 37: DID 0001-000C-00000002 session 35: DID 0001-000F-00000002 session 35: DID 0001-000F-00000002 session 37: DID 0001-000C-00000002 Rows waited on: Session 35: no row Session 37: no row The piece of information that leads us to a bitmap deadlock is the &quot;no row&quot; value in the session information. If we had encountered a deadlock in the underlying table, the Session line would give us row information so that we could track down the exact point of failure. Without a row, it would seem that we are at a dead end. Even more mysterious is when we get this deadlock on inserts, where we are inserting only new rows and therefore it would seem impossible to get a deadlock. No one should be requesting a row that someone else holds locked. There are no solutions to this kind of problems, except not using bitmap indexes when having an application where you can&apos;t control when the DML are issued against the tables with bitmap indexes. Bitmaps are normally intended for datawarehouse applications that are loading data via batches and that users are only querying. The following testcase can be used to see the results of this type of problem. We will create a table called CAR_TYPE, which holds information about cars, including the car&apos;s color. We will build a bitmap index on the COLOR column. After doing so, we will populate the table with data. After the initial insert, we will open two sessions of the same user, and run simultaneous inserts into the CAR_TYPE table. TESTCASE: ===================================== ===================================== create table car_type ( make varchar2(20), model varchar2(20), color varchar2(20), VIN number(15) primary key, year number(4)); create bitmap index car_type_bm_idx on car_type(color); create sequence car_type_seq start with 35001 increment by 1 nocache nocycle; declare v_CarMake varchar2(20) := &apos;Audi&apos;; v_CarModel varchar(20) := &apos;Quattro&apos;; v_CarColor varchar(20) := &apos;Gold&apos;; v_CarVin binary_integer :=1; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 5000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Toyota&apos;; v_CarModel varchar(20) := &apos;Camry&apos;; v_CarColor varchar(20) := &apos;Red&apos;; v_CarVin binary_integer :=5001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 10000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Audi&apos;; v_CarModel varchar(20) := &apos;Quattro&apos;; v_CarColor varchar(20) := &apos;Blue&apos;; v_CarVin binary_integer :=10001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 15000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Toyota&apos;; v_CarModel varchar(20) := &apos;Camry&apos;; v_CarColor varchar(20) := &apos;Silver&apos;; v_CarVin binary_integer :=15001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 20000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Audi&apos;; v_CarModel varchar(20) := &apos;Quattro&apos;; v_CarColor varchar(20) := &apos;Green&apos;; v_CarVin binary_integer :=20001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 25000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Audi&apos;; v_CarModel varchar(20) := &apos;Quattro&apos;; v_CarColor varchar(20) := &apos;Black&apos;; v_CarVin binary_integer :=25001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 30000; end loop; end; / commit; declare v_CarMake varchar2(20) := &apos;Toyota&apos;; v_CarModel varchar(20) := &apos;Camry&apos;; v_CarColor varchar(20) := &apos;White&apos;; v_CarVin binary_integer :=30001; begin loop insert into car_type (make,model,color,VIN,year) values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, &apos;2002&apos;); v_CarVin := v_CarVin + 1; exit when v_CarVin &gt; 35000; end loop; end; / commit; =============================== =============================== After this initial creation, cut the following script into a .sql file, and then execute it simultaneously from two sessions: =============================== =============================== insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;White&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Red&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Toyota&apos;,&apos;Camry&apos;,&apos;Silver&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Black&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Gold&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Blue&apos;,car_type_seq.nextval,&apos;2002&apos;); insert into car_type values ( &apos;Audi&apos;,&apos;Quatro&apos;,&apos;Green&apos;,car_type_seq.nextval,&apos;2002&apos;); commit; ======================================== ======================================== The result will be occasional deadlock errors: insert into car_type values ( * ERROR at line 1: ORA-00060: deadlock detected while waiting for resource The trace file will show the tell-tale &apos;No Row&apos; message: Rows waited on: Session 11: no row Session 10: no row RELATED DOCUMENTS ----------------- Oracle8i Designing and Tuning for Performance Release 2 (8.1.6) Part Number A76992-01 .
  7. select to_char(sample_time,&apos;HH:MI&apos;) st, substr(event,0,20) event, ash.session_id sid, mod(ash.p1,16) lm, ash.p2, ash.p3, nvl(o.object_name,ash.current_obj#) objn, substr(o.object_type,0,10) otype, CURRENT_FILE# fn, CURRENT_BLOCK# blockn, ash.SQL_ID, BLOCKING_SESSION bsid from v$active_session_history ash, all_objects o where event like &apos;enq: TX - %&apos; and o.object_id (+)= ash.CURRENT_OBJ# --and sample_time &gt; sysdate - 40/(60*24) Order by sample_time /
  8. Used to invoke specific actions in background processes on a specific instance or all instances. Examples include checkpoint, log switch, shutting down, identifying or re-identifying datafiles, etc. All in all, there are a small number (10’s) of predefined cross-instance call types. Not an Oracle Parallel Server lock. The name of this lock is misleading because it doesn&apos;t deal with distributed transactions. Rather, the CI lock is used to invoke specific actions in background processes on a specific instance or all instances. Examples would include checkpoints, log switches, or when the instance is shut down.
  9. col event for a20 col obj for a12 col p2 for 9999 col p3 for 999999 col file# for 99999 col block# for 999999 select substr(sql_text,0,20) sql_text, --event, --sql_id, --p1, p2,p3, CURRENT_OBJ# || &apos; &apos; || name obj ,CURRENT_FILE# file# ,CURRENT_BLOCK# block# from v$active_session_history ash, obj$ o, v$sqltext sql where event like &apos;enq: CI%&apos; and o.obj# (+)= ash.current_obj# and sql.sql_id (+)= ash.sql_id order by sample_time;
  10. col event for a20 col obj for a12 col p2 for 9999 col p3 for 999999 col file# for 99999 col block# for 999999 select substr(sql_text,0,20) sql_text, --event, --sql_id, --p1, p2,p3, CURRENT_OBJ# || &apos; &apos; || name obj ,CURRENT_FILE# file# ,CURRENT_BLOCK# block# from v$active_session_history ash, obj$ o, v$sqltext sql where event like &apos;enq: CI%&apos; and o.obj# (+)= ash.current_obj# and sql.sql_id (+)= ash.sql_id order by sample_time;
  11. enq: HW - contention 4 16777715
  12. column parameter format a30 column value format a10 select a.ksppinm parameter, c.ksppstvl value from x$ksppi a, x$ksppcv b, x$ksppsv c where a.indx = b.indx and a.indx = c.indx and substr(ksppinm,1,11)=&apos;_bump_highw&apos; order by a.ksppinm;