ora-1628,undo unable extend.的问题排查脚本

查询分配太多小的extent的undo段。如果一个大查询分配到 太多小的extent的undo段的时候。就容易出现该错误
IF: ORA-1628 Reported During Long Running Transactions (文档 ID 1951032.1)
ORA-01628 errors i.e max # extents (32765) reached for rollback segment <SEGMENT_NAME>
1.确定小的事务分配的undo段
SELECT b.usn,
tablespace_name,segment_name,
bytes "Extent_Size",
count(extent_id) "Extent_Count",
bytes * count(extent_id) "Extent_Bytes"
FROM dba_undo_extents a ,v$rollname b
WHERE status = 'ACTIVE'
and a.SEGMENT_NAME=b.name
group by b.usn,tablespace_name,segment_name, bytes
order by count(extent_id) desc;

2.确定会话事务(需要两个节点各自执行v$rollname,显示单节点的)
select a.inst_id,a.sid, a.serial#,b.XIDUSN,a.SQL_ID, a.username, b.used_urec, b.used_ublk*8/1024/1024 G
from gv$session a, gv$transaction b
where a.saddr=b.ses_addr
and a.inst_id=b.inst_id
and xidusn=2672
order by used_ublk desc

3.怎样评估undo表空间大小

统计undoblks的1s钟最大数量*undo_retention*1.5
select inst_id,max(undoblks)/600*10800*8/1024/1024*1.5 from gv$undostat t group by t.INST_ID;

4.监控undo表空间是否足够

select inst_id,t.BEGIN_TIME,t.END_TIME,t.UNXPBLKREUCNT,t.UNXPSTEALCNT,t.UNXPBLKRELCNT,t.EXPSTEALCNT,t.EXPBLKRELCNT from gv$undostat t where t.UNXPBLKREUCNT>0 order by begin_time desc,inst_id ;
UNXPBLKREUCNT:未过期块重用
UNXPSTEALCNT:未过期块偷窃次数
UNXPBLKRELCNT:未过期块偷窃成功的块数

 5.查找大事务相关的session

select a.inst_id,a.sid, a.serial#,a.SQL_ID, a.username, b.used_urec, b.used_ublk*8/1024/1024 G
from gv$session a, gv$transaction b
where a.saddr=b.ses_addr
and a.inst_id=b.inst_id
order by used_ublk desc

原文地址:https://www.cnblogs.com/erwadba/p/9532538.html