1 问题现象:V$TRANSACTION为ACTIVE,V$SESSION为INACTIVE
如下查询。
select 'alter system kill session ' || '''' || sid || ',' || serial# || '''' ||
' immediate;',
T1.XIDUSN,
T1.XIDSLOT,
T1.XIDSQN,
t1.status,
T1.START_DATE,
T2.LOGON_TIME,
T2.CLIENT_INFO,
T2.MACHINE,
t2.status,t2.event
From v$transaction t1, v$session t2
where t1.addr = t2.taddr
and t2.status = 'INACTIVE'
--and start_date < trunc(sysdate, 'dd')
ORDER BY T1.START_DATE, T2.LOGON_TIME ASC
1 对于v$TRANSACTION 事务为ACTIVE,并且v$SESSION 为 INACTIVE状态测试。
1 简单事务
insert into t1 select * from t1;--不提交,
在另一会话查询v$transaction和v$session,发现transaction为active,session为 INACTIVE;
2 复杂事务
模拟一个处理比较多的事务
[oracle@gzrac01 ~]$ vi in.sql
insert into t1 select * from t1; --执行完成未提交。
insert into t1 select * from t1; --执行完成未提交。
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1; --一直在执行,
分析发现,在V$TRANSACTION中存在active并且v$session也为ACTIVE的会话。
然后我将表空间对应的数据文件缩小,等待这个事务报错。
15044608 rows created.
30089216 rows created.
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 8192 in tablespace SYSTEM
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 8192 in tablespace SYSTEM
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 8192 in tablespace SYSTEM
insert into t1 select * from t1
*
ERROR at line 1:
ORA-01653: unable to extend table SYS.T1 by 8192 in tablespace SYSTEM
sql>
sql>
整个事务中途报错退出,session不退出,但是在V$TRANSACTION中存在active并且v$session也为INACTIVE的会话。
总结,
无论对于简单事务,事务不提交或者回滚,transaction为ACTIVE,session 为 INACTIVE.
对于多个DML组成的复杂事务,前面的不提交,后面的一直在运行,则transaction为active,session为 active。
如果运行报错,且未出现显示或隐式的提交或者回滚,且会话不退出,transaction为ACTIVE,session为 INACTIVE,EVENT 为 sql net message from client。