|
本帖最后由 Yong Huang 于 2016-9-30 14:55 编辑
Among the 5 cases you listed above, number 5 doesn't apply to you. Correct? 1 and 2 are both called distributed transaction (a remote query creates a transaction). But since you said "未使用分布式事务", 1 and 2 may not apply to you either. Did you have savepoint or call dbms_transaction?
I can add one more case where this problem is reproduced:
SQL> with x as (select /*+ materialize */ inst_id, sid, type, count(*) from gv$lock group by inst_id, sid, type) select * from x where type in ('TM','TX','DX') order by 1,2,3;
INST_ID SID TY COUNT(*)
---------- ---------- -- ----------
1 406 TM 1
1 406 TX 1
1 419 TM 3
1 419 TX 1
1 800 TX 1
SQL> with x as (select /*+ materialize */ sid, type, count(*) from v$lock group by sid, type) select * from x where type in ('TM','TX','DX') order by 1,2;
SID TY COUNT(*)
---------- -- ----------
406 TM 1
406 TX 1
419 TM 3
419 TX 1
800 TX 1
Sid 800 is my current session. During the execution of the SQL, it seems to hold a TX lock but not TM (nor DX) lock. The database is 11.2.0.3 single node. The materialize hint speeds up the query against gv$lock but not v$lock. If I remove this hint, the single TX lock (i.e. not accompanied with TM) disappears. I'm guessing that a TM lock on the global temporary table created on the fly may be briefly held during the execution and is not captured while the TX lock is, probably because it's held longer. We may be able to verify it with events such as 10704 (Print out information about what enqueues are being obtained). We know that a query against v$ views is not guaranteed read consistency.
But I doubt that's what you have in your database.
|
|