Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

8

积分

0

好友

0

主题
1#
发表于 2012-2-17 11:28:00 | 查看: 8607| 回复: 14
斑竹大大,麻烦了

trace.TXT

160.02 KB, 下载次数: 2665

2#
发表于 2012-2-17 11:32:19
不知道你想要说明什么情况

回复 只看该作者 道具 举报

3#
发表于 2012-2-17 11:35:03
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_27373.trc.
Wed Feb 15 19:00:56 2012
Thread 1 advanced to log sequence 8650 (LGWR switch)
  Current log# 1 seq# 8650 mem# 0: /opt/orasrv/oradata/queuecen/redo01.log
Wed Feb 15 20:57:11 2012
Thread 1 advanced to log sequence 8651 (LGWR switch)
  Current log# 2 seq# 8651 mem# 0: /opt/orasrv/oradata/queuecen/redo02.log
Wed Feb 15 22:25:12 2012
Thread 1 advanced to log sequence 8652 (LGWR switch)
  Current log# 3 seq# 8652 mem# 0: /opt/orasrv/oradata/queuecen/redo03.log
Wed Feb 15 23:29:07 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_30799.trc.
Wed Feb 15 23:29:57 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_30799.trc.
Thu Feb 16 00:08:42 2012
Thread 1 advanced to log sequence 8653 (LGWR switch)
  Current log# 6 seq# 8653 mem# 0: /opt/orasrv/oradata/queuecen/redo06.log
Thu Feb 16 08:52:36 2012
Thread 1 advanced to log sequence 8654 (LGWR switch)
  Current log# 4 seq# 8654 mem# 0: /opt/orasrv/oradata/queuecen/redo04.log
Thu Feb 16 09:21:56 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_6910.trc.
Thu Feb 16 10:08:26 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_7407.trc.
Thu Feb 16 12:58:12 2012
Thread 1 advanced to log sequence 8655 (LGWR switch)
  Current log# 5 seq# 8655 mem# 0: /opt/orasrv/oradata/queuecen/redo05.log
Thu Feb 16 14:24:18 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_9985.trc.
Thu Feb 16 16:42:56 2012
Thread 1 advanced to log sequence 8656 (LGWR switch)
  Current log# 1 seq# 8656 mem# 0: /opt/orasrv/oradata/queuecen/redo01.log
Thu Feb 16 19:09:23 2012
Thread 1 advanced to log sequence 8657 (LGWR switch)
  Current log# 2 seq# 8657 mem# 0: /opt/orasrv/oradata/queuecen/redo02.log
Thu Feb 16 19:56:21 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_12746.trc.
Thu Feb 16 22:01:09 2012
Thread 1 advanced to log sequence 8658 (LGWR switch)
  Current log# 3 seq# 8658 mem# 0: /opt/orasrv/oradata/queuecen/redo03.log
Fri Feb 17 01:10:10 2012
Thread 1 advanced to log sequence 8659 (LGWR switch)
  Current log# 6 seq# 8659 mem# 0: /opt/orasrv/oradata/queuecen/redo06.log
Fri Feb 17 10:43:50 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_21608.trc.
Fri Feb 17 10:45:08 2012
ORA-00060: Deadlock detected. More info in file /opt/orasrv/admin/queuecenter/udump/queuecenter_ora_21650.trc.

回复 只看该作者 道具 举报

4#
发表于 2012-2-17 11:35:26
那个trace文件是里面的一个

回复 只看该作者 道具 举报

5#
发表于 2012-2-17 11:36:52
想知道为什么会产生死锁?

回复 只看该作者 道具 举报

6#
发表于 2012-2-17 13:07:40
ODM data:
  1. DEADLOCK DETECTED ( ORA-00060 )
  2. [Transaction Deadlock]
  3. The following deadlock is not an ORACLE error. It is a
  4. deadlock due to user error in the design of an application
  5. or from issuing incorrect ad-hoc SQL. The following
  6. information may aid in determining the deadlock:
  7. Deadlock graph:
  8.                        ---------Blocker(s)--------  ---------Waiter(s)---------
  9. Resource Name          process session holds waits  process session holds waits
  10. TX-001c0004-00001dae        49    1028     X             33     223           S
  11. TX-0038000f-00000fb7        33     223     X             49    1028           S
  12. session 1028: DID 0001-0031-00007C46    session 223: DID 0001-0021-000027FC
  13. session 223: DID 0001-0021-000027FC     session 1028: DID 0001-0031-00007C46
  14. Rows waited on:
  15. Session 223: obj - rowid = 0000CA54 - AAAX+BAAAAAAAAAAAA
  16.   (dictionary objn - 51796, file - 0, block - 0, slot - 0)
  17. Session 1028: obj - rowid = 0000CA55 - AAAX+EAAAAAAAAAAAA
  18.   (dictionary objn - 51797, file - 0, block - 0, slot - 0)
  19. Information on the OTHER waiting sessions:
  20. Session 223:
  21.   pid=33 serial=30760 audsid=1695734 user: 58/SN_QUEUE
  22.   O/S info: user: , term: , ospid: 1234, machine: TJ-BGP-251
  23.             program:
  24.   Current SQL Statement:
  25.   INSERT INTO SN_QUEUE.QUE_TASK (N_ID,N_TASK_ID,N_SUBIDC_ID,N_GAREA_ID,N_PRETASK_ID,N_AMOUNT,S_STATE,D_CREATE,
  26. D_MODIFY) VALUES (:B5 ,:B4 ,:B3 ,NVL(:B2 ,0),0,0,'0',:B1 ,:B1 )
  27. End of information on OTHER waiting sessions.
  28. Current SQL statement for this session:
  29. INSERT INTO SN_QUEUE.QUE_TASK (N_ID,N_TASK_ID,N_SUBIDC_ID,N_GAREA_ID,N_PRETASK_ID,N_AMOUNT,S_STATE,D_CREATE,D_
  30. MODIFY) VALUES (:B5 ,:B4 ,:B3 ,NVL(:B2 ,0),0,0,'0',:B1 ,:B1 )
  31. ----- PL/SQL Call Stack -----
  32.   object      line  object
  33.   handle    number  name
  34. 0xdb63e9b0        41  package body SN_QUEUE.QUEUETASKMANAGER
  35. 0xc34176a0         1  anonymous block
复制代码
session 1028  X block  =>  session 223   X block  => session 1028

形成dead lock


Rows waited on:
Session 223: obj - rowid = 0000CA54 - AAAX+BAAAAAAAAAAAA
  (dictionary objn - 51796, file - 0, block - 0, slot - 0)                                   => session 223 wait for NO ROW 不存在的row
Session 1028: obj - rowid = 0000CA55 - AAAX+EAAAAAAAAAAAA
  (dictionary objn - 51797, file - 0, block - 0, slot - 0)                                   => session 1028 wait for NO ROW 不存在的row

objn - 51796   objn - 51797  猜测  对象51797   是 51796   的索引


session 223 正在运行:
  INSERT INTO SN_QUEUE.QUE_TASK (N_ID,N_TASK_ID,N_SUBIDC_ID,N_GAREA_ID,N_PRETASK_ID,N_AMOUNT,S_STATE,D_CREATE,
D_MODIFY) VALUES (:B5 ,:B4 ,:B3 ,NVL(:B2 ,0),0,0,'0',:B1 ,:B1 )


session 1028:

INSERT INTO SN_QUEUE.QUE_TASK (N_ID,N_TASK_ID,N_SUBIDC_ID,N_GAREA_ID,N_PRETASK_ID,N_AMOUNT,S_STATE,D_CREATE,D_
MODIFY) VALUES (:B5 ,:B4 ,:B3 ,NVL(:B2 ,0),0,0,'0',:B1 ,:B1 )


同样的代码

查询整个trace 文件发现没有其他 DML(除了以上的INSERT)语句。

回复 只看该作者 道具 举报

7#
发表于 2012-2-17 13:08:36
action plan:

确认objn - 51796   objn - 51797这2个对象, 把这2个对象的DDL 定义 贴出来

回复 只看该作者 道具 举报

8#
发表于 2012-2-17 13:27:42
SYS@queuecenter AS SYSDBA>desc SN_QUEUE.QUE_TASK;
Name                                                                                Null?    Type
----------------------------------------------------------------------------------- -------- --------------------------------------------------------
N_ID                                                                                NOT NULL NUMBER(38)
N_TASK_ID                                                                           NOT NULL NUMBER(38)
N_SUBIDC_ID                                                                         NOT NULL NUMBER(38)
N_GAREA_ID                                                                                   NUMBER(38)
N_PRETASK_ID                                                                                 NUMBER(38)
D_CREATE                                                                                     DATE
N_AMOUNT                                                                                     NUMBER(38)
D_MODIFY                                                                                     DATE
S_STATE                                                                             NOT NULL VARCHAR2(1)


  CREATE TABLE "SN_QUEUE"."QUE_TASK"
   (    "N_ID" NUMBER(*,0) NOT NULL ENABLE,
        "N_TASK_ID" NUMBER(*,0) NOT NULL ENABLE,
        "N_SUBIDC_ID" NUMBER(*,0) NOT NULL ENABLE,
        "N_GAREA_ID" NUMBER(*,0),
        "N_PRETASK_ID" NUMBER(*,0),
        "D_CREATE" DATE,
        "N_AMOUNT" NUMBER(*,0),
        "D_MODIFY" DATE,
        "S_STATE" VARCHAR2(1) NOT NULL ENABLE,
         CONSTRAINT "PK_QUE_TASK" PRIMARY KEY ("N_ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TS_QUEUE"  ENABLE
   ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TS_QUEUE"


TABLE_NAME                     COLUMN_NAME                       INDEX_NAME
------------------------------ --------------------------------- ------------------------------
QUE_TASK                       S_STATE                           IDX_QUE_TASK_X1
QUE_TASK                       N_SUBIDC_ID                       IDX_QUE_TASK_X2

回复 只看该作者 道具 举报

9#
发表于 2012-2-17 13:28:51
OBJECT_NAME                       OBJECT_TYPE          OBJECT_ID
--------------------------------- ------------------- ----------
IDX_QUE_TASK_X1                   INDEX                    51796
IDX_QUE_TASK_X2                   INDEX                    51797

回复 只看该作者 道具 举报

10#
发表于 2012-2-17 13:55:36
把这2个索引的  DDL定义贴出来 , 请 不要把 action plan 打折扣

回复 只看该作者 道具 举报

11#
发表于 2012-2-17 13:57:51
SYS@queuecenter AS SYSDBA>select dbms_metadata.get_ddl('INDEX','IDX_QUE_TASK_X1','SN_QUEUE') FROM DUAL;

DBMS_METADATA.GET_DDL('INDEX','IDX_QUE_TASK_X1','SN_QUEUE')
--------------------------------------------------------------------------------

  CREATE BITMAP INDEX "SN_QUEUE"."IDX_QUE_TASK_X1" ON "SN_QUEUE"."QUE_TASK" ("S_
STATE")
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TS_QUEUE"



Elapsed: 00:00:00.16
SYS@queuecenter AS SYSDBA>select dbms_metadata.get_ddl('INDEX','IDX_QUE_TASK_X2','SN_QUEUE') FROM DUAL;

DBMS_METADATA.GET_DDL('INDEX','IDX_QUE_TASK_X2','SN_QUEUE')
--------------------------------------------------------------------------------

  CREATE BITMAP INDEX "SN_QUEUE"."IDX_QUE_TASK_X2" ON "SN_QUEUE"."QUE_TASK" ("N_
SUBIDC_ID")
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
  TABLESPACE "TS_QUEUE"

回复 只看该作者 道具 举报

12#
发表于 2012-2-17 14:01:52
oracle不是说 死锁会自动处理的嘛

回复 只看该作者 道具 举报

13#
发表于 2012-2-17 14:05:10
ODM Data

Bitmap Indexes and Deadlocks: Deadlocks on Insert Statements [ID 171795.1]
:
  1. PURPOSE
  2. -------

  3. The purpose of this article is to explain the occurrence of deadlocks
  4. when the only DML activity is insert statements against a table with
  5. a bitmap index.  This applies from version 8 to 11.

  6. SCOPE & APPLICATION
  7. -------------------

  8. Database administrators and Application developers involved in
  9. application design.


  10. BITMAP INDEXES: THE HIDDEN DEADLOCK THREAT
  11. ------------------------------------------


  12. The limitations of bitmap indexes as this:

  13. Extract of documentation:

  14. "DML and DDL statements, such as UPDATE, DELETE, DROP TABLE, affect bitmap
  15. indexes the same way they do traditional indexes: the consistency model is
  16. the same. A compressed bitmap for a key value is made up of one or more bitmap
  17. segments, each of which is at most half a block in size (but may be smaller).
  18. The locking granularity is one such bitmap segment. This may affect performance
  19. in environments where many transactions make simultaneous updates. If numerous
  20. DML operations have caused increased index size and decreasing performance for
  21. queries, then you can use the ALTER INDEX ... REBUILD statement to compact the
  22. index and restore efficient performance.

  23. A B*-tree index entry contains a single rowid. Therefore, when the index entry
  24. is locked, a single row is locked. With bitmap indexes, an entry can potentially
  25. contain a range of rowids. When a bitmap index entry is locked, the entire range
  26. of rowids is locked. The number of rowids in this range affects concurrency.
  27. As the number of rowids increases in a bitmap segment, concurrency decreases.

  28. Locking issues affect DML operations, and may affect heavy OLTP environments.
  29. Locking issues do not, however, affect query performance. As with other types
  30. of indexes, updating bitmap indexes is a costly operation. Nonetheless, for
  31. bulk inserts and updates where many rows are inserted or many updates are made
  32. in a single statement, performance with bitmap indexes can be better than with
  33. regular B*-tree indexes."

  34.                          **************

  35. What is not mentioned is the fact that the same architectural feature that
  36. locks a range of rowid's also means that its possible to get a deadlock within
  37. the bitmap when updating rows in the underlying table. This deadlock is not in
  38. the table itself, as one might suspect, but rather in the bitmap index blocks.
  39. This kind of deadlock is easily diagnosable by the deadlock trace file, which
  40. has an entry that looks like the example below:

  41. The following deadlock is not an ORACLE error. It is a
  42. deadlock due to user error in the design of an application
  43. or from issuing incorrect ad-hoc SQL. The following
  44. information may aid in determining the deadlock:

  45. Deadlock graph:
  46.                        ---------Blocker(s)--------  ---------Waiter(s)---------
  47. Resource Name          process session holds waits  process session holds waits
  48. TX-00080027-0000d2a1        12      37     X             15      35           S
  49. TX-000a0016-0000d6d2        15      35     X             12      37           S
  50. session 37: DID 0001-000C-00000002        session 35: DID 0001-000F-00000002
  51. session 35: DID 0001-000F-00000002        session 37: DID 0001-000C-00000002
  52. Rows waited on:
  53. Session 35: no row
  54. Session 37: no row

  55. The piece of information that leads us to a bitmap deadlock is the "no row"
  56. value in the session information.  If we had encountered a deadlock in the
  57. underlying table, the Session line would give us row information so that we
  58. could track down the exact point of failure. Without a row, it would seem that
  59. we are at a dead end. Even more mysterious is when we get this deadlock on
  60. inserts, where we are inserting only new rows and therefore it would seem
  61. impossible to get a deadlock. No one should be requesting a row that someone
  62. else holds locked.

  63. There are no solutions to this kind of problems, except not using bitmap indexes
  64. when having an application where you can't control when the DML are issued against
  65. the tables with bitmap indexes. Bitmaps are normally intended for datawarehouse
  66. applications that are loading data via batches and that users are only querying.

  67. The following testcase can be used to see the results of this type of problem.
  68. We will create a table called CAR_TYPE, which holds information about cars,
  69. including the car's color. We will build a bitmap index on the COLOR column.
  70. After doing so, we will populate the table with data. After the initial insert,
  71. we will open two sessions of the same user, and run simultaneous inserts into
  72. the CAR_TYPE table.

  73. TESTCASE:

  74. =====================================
  75. =====================================

  76. create table car_type (
  77. make        varchar2(20),
  78. model        varchar2(20),
  79. color        varchar2(20),
  80. VIN        number(15) primary key,
  81. year        number(4));

  82. create bitmap index car_type_bm_idx on car_type(color);

  83. create sequence car_type_seq
  84. start with 35001
  85. increment by 1
  86. nocache
  87. nocycle;

  88. declare
  89. v_CarMake varchar2(20) := 'Audi';
  90. v_CarModel varchar(20) := 'Quattro';
  91. v_CarColor varchar(20) := 'Gold';
  92. v_CarVin binary_integer :=1;
  93. begin
  94. loop
  95. insert into car_type (make,model,color,VIN,year)
  96. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  97. v_CarVin := v_CarVin + 1;
  98. exit when v_CarVin > 5000;
  99. end loop;
  100. end;
  101. /
  102. commit;

  103. declare
  104. v_CarMake varchar2(20) := 'Toyota';
  105. v_CarModel varchar(20) := 'Camry';
  106. v_CarColor varchar(20) := 'Red';
  107. v_CarVin binary_integer :=5001;
  108. begin
  109. loop
  110. insert into car_type (make,model,color,VIN,year)
  111. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  112. v_CarVin := v_CarVin + 1;
  113. exit when v_CarVin > 10000;
  114. end loop;
  115. end;
  116. /
  117. commit;

  118. declare
  119. v_CarMake varchar2(20) := 'Audi';
  120. v_CarModel varchar(20) := 'Quattro';
  121. v_CarColor varchar(20) := 'Blue';
  122. v_CarVin binary_integer :=10001;
  123. begin
  124. loop
  125. insert into car_type (make,model,color,VIN,year)
  126. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  127. v_CarVin := v_CarVin + 1;
  128. exit when v_CarVin > 15000;
  129. end loop;
  130. end;
  131. /
  132. commit;

  133. declare
  134. v_CarMake varchar2(20) := 'Toyota';
  135. v_CarModel varchar(20) := 'Camry';
  136. v_CarColor varchar(20) := 'Silver';
  137. v_CarVin binary_integer :=15001;
  138. begin
  139. loop
  140. insert into car_type (make,model,color,VIN,year)
  141. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  142. v_CarVin := v_CarVin + 1;
  143. exit when v_CarVin > 20000;
  144. end loop;
  145. end;
  146. /
  147. commit;

  148. declare
  149. v_CarMake varchar2(20) := 'Audi';
  150. v_CarModel varchar(20) := 'Quattro';
  151. v_CarColor varchar(20) := 'Green';
  152. v_CarVin binary_integer :=20001;
  153. begin
  154. loop
  155. insert into car_type (make,model,color,VIN,year)
  156. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  157. v_CarVin := v_CarVin + 1;
  158. exit when v_CarVin > 25000;
  159. end loop;
  160. end;
  161. /
  162. commit;

  163. declare
  164. v_CarMake varchar2(20) := 'Audi';
  165. v_CarModel varchar(20) := 'Quattro';
  166. v_CarColor varchar(20) := 'Black';
  167. v_CarVin binary_integer :=25001;
  168. begin
  169. loop
  170. insert into car_type (make,model,color,VIN,year)
  171. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  172. v_CarVin := v_CarVin + 1;
  173. exit when v_CarVin > 30000;
  174. end loop;
  175. end;
  176. /
  177. commit;

  178. declare
  179. v_CarMake varchar2(20) := 'Toyota';
  180. v_CarModel varchar(20) := 'Camry';
  181. v_CarColor varchar(20) := 'White';
  182. v_CarVin binary_integer :=30001;
  183. begin
  184. loop
  185. insert into car_type (make,model,color,VIN,year)
  186. values (v_CarMake, v_CarModel, v_CarColor, v_CarVin, '2002');
  187. v_CarVin := v_CarVin + 1;
  188. exit when v_CarVin > 35000;
  189. end loop;
  190. end;
  191. /
  192. commit;

  193. ===============================
  194. ===============================

  195. After this initial creation, cut the following script into a .sql file, and
  196. then execute it simultaneously from two sessions:

  197. ===============================
  198. ===============================

  199. insert into car_type values (
  200. 'Toyota','Camry','White',car_type_seq.nextval,'2002');  

  201. insert into car_type values (
  202. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  203. insert into car_type values (
  204. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  205. insert into car_type values (
  206. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');
  207. commit;

  208. insert into car_type values (
  209. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  210. insert into car_type values (
  211. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  212. insert into car_type values (
  213. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  214. insert into car_type values (
  215. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  216. insert into car_type values (
  217. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  218. insert into car_type values (
  219. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  220. insert into car_type values (
  221. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  222. insert into car_type values (
  223. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  224. insert into car_type values (
  225. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  226. insert into car_type values (
  227. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  228. insert into car_type values (
  229. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  230. insert into car_type values (
  231. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  232. insert into car_type values (
  233. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  234. insert into car_type values (
  235. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');
  236. commit;

  237. insert into car_type values (
  238. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  239. insert into car_type values (
  240. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  241. insert into car_type values (
  242. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  243. insert into car_type values (
  244. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  245. insert into car_type values (
  246. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  247. insert into car_type values (
  248. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  249. insert into car_type values (
  250. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  251. insert into car_type values (
  252. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  253. insert into car_type values (
  254. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  255. insert into car_type values (
  256. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  257. insert into car_type values (
  258. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  259. insert into car_type values (
  260. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  261. insert into car_type values (
  262. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  263. insert into car_type values (
  264. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  265. insert into car_type values (
  266. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  267. insert into car_type values (
  268. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  269. insert into car_type values (
  270. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  271. insert into car_type values (
  272. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  273. insert into car_type values (
  274. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  275. insert into car_type values (
  276. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  277. insert into car_type values (
  278. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  279. insert into car_type values (
  280. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  281. insert into car_type values (
  282. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');
  283. commit;

  284. insert into car_type values (
  285. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  286. insert into car_type values (
  287. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  288. insert into car_type values (
  289. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  290. insert into car_type values (
  291. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  292. insert into car_type values (
  293. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  294. insert into car_type values (
  295. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  296. insert into car_type values (
  297. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  298. insert into car_type values (
  299. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  300. insert into car_type values (
  301. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  302. insert into car_type values (
  303. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  304. insert into car_type values (
  305. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  306. insert into car_type values (
  307. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  308. insert into car_type values (
  309. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  310. insert into car_type values (
  311. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  312. insert into car_type values (
  313. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  314. insert into car_type values (
  315. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  316. insert into car_type values (
  317. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  318. insert into car_type values (
  319. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  320. insert into car_type values (
  321. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  322. insert into car_type values (
  323. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  324. insert into car_type values (
  325. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  326. insert into car_type values (
  327. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  328. insert into car_type values (
  329. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  330. insert into car_type values (
  331. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  332. insert into car_type values (
  333. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  334. insert into car_type values (
  335. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');
  336. commit;
  337. insert into car_type values (
  338. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  339. insert into car_type values (
  340. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  341. insert into car_type values (
  342. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');


  343. insert into car_type values (
  344. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  345. insert into car_type values (
  346. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  347. insert into car_type values (
  348. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  349. insert into car_type values (
  350. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  351. insert into car_type values (
  352. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  353. insert into car_type values (
  354. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  355. insert into car_type values (
  356. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');


  357. insert into car_type values (
  358. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  359. insert into car_type values (
  360. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  361. insert into car_type values (
  362. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  363. insert into car_type values (
  364. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  365. insert into car_type values (
  366. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  367. insert into car_type values (
  368. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  369. insert into car_type values (
  370. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  371. insert into car_type values (
  372. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  373. insert into car_type values (
  374. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  375. insert into car_type values (
  376. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  377. insert into car_type values (
  378. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  379. insert into car_type values (
  380. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');
  381. commit;
  382. insert into car_type values (
  383. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  384. insert into car_type values (
  385. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');

  386. insert into car_type values (
  387. 'Toyota','Camry','White',car_type_seq.nextval,'2002');

  388. insert into car_type values (
  389. 'Toyota','Camry','Red',car_type_seq.nextval,'2002');

  390. insert into car_type values (
  391. 'Toyota','Camry','Silver',car_type_seq.nextval,'2002');

  392. insert into car_type values (
  393. 'Audi','Quatro','Black',car_type_seq.nextval,'2002');

  394. insert into car_type values (
  395. 'Audi','Quatro','Gold',car_type_seq.nextval,'2002');

  396. insert into car_type values (
  397. 'Audi','Quatro','Blue',car_type_seq.nextval,'2002');

  398. insert into car_type values (
  399. 'Audi','Quatro','Green',car_type_seq.nextval,'2002');
  400. commit;

  401. ========================================
  402. ========================================

  403. The result will be occasional deadlock errors:

  404. insert into car_type values (
  405. *
  406. ERROR at line 1:
  407. ORA-00060: deadlock detected while waiting for resource

  408. The trace file will show the tell-tale 'No Row' message:

  409. Rows waited on:
  410. Session 11: no row
  411. Session 10: no row
复制代码

回复 只看该作者 道具 举报

14#
发表于 2012-2-17 14:10:14
刘总威武!nice job!

回复 只看该作者 道具 举报

15#
发表于 2012-2-17 14:13:12
问题已经很清晰了, 由BITMAP INDEX 引起的 INSERT TX LOCK

类似的问题重现:
  1. SQL> select  * from v$version;

  2. BANNER
  3. -----------------------------------------------------------------------
  4. Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
  5. PL/SQL Release 11.2.0.1.0 - Production
  6. CORE    11.2.0.1.0      Production
  7. TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
  8. NLSRTL Version 11.2.0.1.0 - Production




  9. 重现该问题


  10. SQL> create bitmap index bit_mac1 on maclean(t1);

  11. 索引已创建。

  12. SQL> create bitmap index bit_mac2 on maclean(t2);

  13. 索引已创建。


  14. session 1

  15. SQL> insert into maclean values(1,1);

  16. 已创建 1 行。

  17. SQL> insert into maclean values(2,2);
  18. insert into maclean values(2,2)
  19.             *
  20. 第 1 行出现错误:
  21. ORA-00060: 等待资源时检测到死锁
  22. ORA-00060: 等待资源时检测到死锁

  23. session 2 :

  24. SQL> insert into maclean values(2,2);

  25. 已创建 1 行。

  26. SQL> insert into maclean values(1,1);
  27. insert into maclean values(1,1)








  28. DEADLOCK DETECTED ( ORA-00060 )

  29. [Transaction Deadlock]

  30. The following deadlock is not an ORACLE error. It is a
  31. deadlock due to user error in the design of an application
  32. or from issuing incorrect ad-hoc SQL. The following
  33. information may aid in determining the deadlock:

  34. Deadlock graph:
  35.                        ---------Blocker(s)--------  ---------Waiter(s)---------
  36. Resource Name          process session holds waits  process session holds waits
  37. TX-00030015-000000be        20       6     X             21      67           S
  38. TX-0004001c-000000c4        21      67     X             20       6           S

  39. session 6: DID 0001-0014-0000000E        session 67: DID 0001-0015-00000007
  40. session 67: DID 0001-0015-00000007        session 6: DID 0001-0014-0000000E

  41. Rows waited on:
  42.   Session 6: no row
  43.   Session 67: no row

  44. ----- Information for the OTHER waiting sessions -----
  45. Session 67:
  46.   sid: 67 ser: 15 audsid: 4294967295 user: 0/SYS flags: 0x41
  47.   pid: 21 O/S info: user: SYSTEM, term: MACLEANLIU-PC, ospid: 3572
  48.     image: ORACLE.EXE (SHAD)
  49.   client details:
  50.     O/S info: user: MacleanLiu-PC\Maclean.Liu, term: MACLEANLIU-PC, ospid: 3052:1720
  51.     machine: WORKGROUP\MACLEANLIU-PC program: sqlplus.exe
  52.     application name: sqlplus.exe, hash value=254292535
  53.   current SQL:
  54.   insert into maclean values(1,1)

  55. ----- End of information for the OTHER waiting sessions -----

  56. Information for THIS session:

  57. ----- Current SQL Statement for this session (sql_id=g4arrzgb4q5cr) -----
  58. insert into maclean values(2,2)
复制代码

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-11-15 01:51 , Processed in 0.058760 second(s), 25 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569