Advertisement
ExaGridDba

Demonstrate Jonathan Lewis's RI deadlock.

May 10th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. Demonstrate Jonathan Lewis's RI deadlock.
  2.  
  3. https://jonathanlewis.wordpress.com/2016/05/09/ri-locks/
  4.  
  5. ----- Session 1 -----
  6. [oracle@stormking cdb12102 deadlock]$ sqlplus /nolog
  7.  
  8. SQL*Plus: Release 12.1.0.2.0 Production on Tue May 10 23:21:04 2016
  9.  
  10. Copyright (c) 1982, 2014, Oracle. All rights reserved.
  11.  
  12. SQL> @ conn.u.sql
  13. Connected.
  14. SQL> set echo on
  15. SQL> @ sidprompt.sql
  16. SQL> column sid_ new_value sid_ format a5
  17. SQL> select sys_context('userenv','sid' ) sid_ from dual;
  18.  
  19. SID_
  20. -----
  21. 81
  22.  
  23. SQL> set sqlprompt '&&sid_> '
  24. 81>
  25. 81> @ create.tables.sql
  26. 81>
  27. 81> create table parent (
  28. 2 id number(8,0),
  29. 3 constraint par_pk primary key(id)
  30. 4 );
  31.  
  32. Table created.
  33.  
  34. 81>
  35. 81> create table child (
  36. 2 id_p number(8,0) not null references parent,
  37. 3 id_c number(8,0) not null,
  38. 4 constraint child_pk primary key(id_p, id_c)
  39. 5 )
  40. 6 ;
  41.  
  42. Table created.
  43.  
  44. 81>
  45. 81> @ insert.parent.1.sql
  46. 81> -- (1) session 1
  47. 81> insert into parent values(1);
  48.  
  49. 1 row created.
  50.  
  51. ----- Session 2 -----
  52. [oracle@stormking cdb12102 deadlock]$ sqlplus /nolog
  53.  
  54. SQL*Plus: Release 12.1.0.2.0 Production on Tue May 10 23:22:29 2016
  55.  
  56. Copyright (c) 1982, 2014, Oracle. All rights reserved.
  57.  
  58. SQL> @ conn.u.sql
  59. Connected.
  60. SQL> set echo on
  61. SQL> @ sidprompt.sql
  62. SQL> column sid_ new_value sid_ format a5
  63. SQL> select sys_context('userenv','sid' ) sid_ from dual;
  64.  
  65. SID_
  66. -----
  67. 34
  68.  
  69. SQL> set sqlprompt '&&sid_> '
  70. 34>
  71. 34> @ insert.parent.2.sql
  72. 34> -- (2) session 2
  73. 34> insert into parent values(2);
  74.  
  75. 1 row created.
  76.  
  77.  
  78.  
  79. ----- Session 1 -----
  80. 81> @ insert.child.2.2.sql
  81. 81> -- (3) session 1
  82. 81> insert into child values(2,2);
  83.  
  84. ----- Session 2 -----
  85.  
  86. 34> @ insert.child.1.1.sql
  87. 34> -- (4)session 2
  88. 34> insert into child values(1,1);
  89.  
  90.  
  91. ----- Session 1 -----
  92. insert into child values(2,2)
  93. *
  94. ERROR at line 1:
  95. ORA-00060: deadlock detected while waiting for resource
  96.  
  97.  
  98. Trace file /u01/app/oracle/diag/rdbms/cdb12102/cdb12102/trace/cdb12102_ora_478.trc
  99. Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
  100. With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
  101. and Real Application Testing options
  102. ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1
  103. System name: Linux
  104. Node name: stormking
  105. Release: 2.6.39-400.17.1.el6uek.x86_64
  106. Version: #1 SMP Fri Feb 22 18:16:18 PST 2013
  107. Machine: x86_64
  108. Instance name: cdb12102
  109. Redo thread mounted by this instance: 1
  110. Oracle process number: 24
  111. Unix process pid: 478, image: oracle@stormking
  112.  
  113.  
  114. *** 2016-05-10 23:24:23.568
  115. *** SESSION ID:(81.58350) 2016-05-10 23:24:23.568
  116. *** CLIENT ID:() 2016-05-10 23:24:23.568
  117. *** SERVICE NAME:(pdbm) 2016-05-10 23:24:23.568
  118. *** MODULE NAME:(SQL*Plus) 2016-05-10 23:24:23.568
  119. *** CLIENT DRIVER:(SQL*PLUS) 2016-05-10 23:24:23.568
  120. *** ACTION NAME:() 2016-05-10 23:24:23.568
  121. *** CONTAINER ID:(4) 2016-05-10 23:24:23.568
  122.  
  123.  
  124.  
  125. *** 2016-05-10 23:24:23.568
  126.  
  127. *** 2016-05-10 23:24:23.611
  128. DEADLOCK DETECTED ( ORA-00060 )
  129. See Note 60.1 at My Oracle Support for Troubleshooting ORA-60 Errors
  130. [Transaction Deadlock]
  131.  
  132. The following deadlock is not an ORACLE error. It is a
  133. deadlock due to user error in the design of an application
  134. or from issuing incorrect ad-hoc SQL. The following
  135. information may aid in determining the deadlock:
  136.  
  137. Deadlock graph:
  138. ---------Blocker(s)-------- ---------Waiter(s)---------
  139. Resource Name process session holds waits process session holds waits
  140. TX-00070000-0000569D-00000000-00000000 24 81 X 29 34 S
  141. TX-00050006-00005882-00000000-00000000 29 34 X 24 81 S
  142.  
  143. session 81: DID 0001-0018-0000D951 session 34: DID 0001-001D-000077DF
  144. session 34: DID 0001-001D-000077DF session 81: DID 0001-0018-0000D951
  145.  
  146. Rows waited on:
  147. Session 81: no row
  148. Session 34: no row
  149.  
  150. ----- Information for the OTHER waiting sessions -----
  151. Session 34:
  152. sid: 34 ser: 19294 audsid: 14014101 user: 104/U
  153. pdb: 4/PDBM
  154. flags: (0x41) USR/- flags_idl: (0x1) BSY/-/-/-/-/-
  155. flags2: (0x40009) -/-/INC
  156. pid: 29 O/S info: user: grid, term: UNKNOWN, ospid: 495
  157. image: oracle@stormking
  158. client details:
  159. O/S info: user: oracle, term: pts/3, ospid: 493
  160. machine: stormking program: sqlplus@stormking (TNS V1-V3)
  161. application name: SQL*Plus, hash value=3669949024
  162. current SQL:
  163. insert into child values(1,1)
  164.  
  165. ----- End of information for the OTHER waiting sessions -----
  166.  
  167. Information for THIS session:
  168.  
  169. ----- Current SQL Statement for this session (sql_id=1vk0n5d4z5rya) -----
  170. insert into child values(2,2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement