[20150225]Delayed Block Cleanout.txt
--主要原因是buffer太小或者修改的信息太大,大于buffer 的10%,出现一些块在dml时已经不在buffer。这样在提交时剩下的block不触
--摸,仅仅修改undo段的提交标志,表示事务已经结束。
--这样仅仅在下次select或者操作相应的数据块是在修改itl槽以及块内的信息,清除lb标识。
--昨天看了Apress.Oracle.Database.Transactions.and.Locking.Revealed.1484207610.pdf。
--参考文档,改进一下做一个测试:
1.建立测试环境:
SCOTT@test> @ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.3.0 Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
CREATE UNDO TABLESPACE UNDOTBS2 DATAFILE
'/u01/app/oracle11g/oradata/test/undotbs02.dbf' SIZE 4M AUTOEXTEND OFF
ONLINE
RETENTION NOGUARANTEE
BLOCKSIZE 8K
FLASHBACK ON;
create table small ( x int, y char(500) );
insert into small select rownum, 'x' from all_users;
commit;
exec dbms_stats.gather_table_stats( user, 'SMALL' );
--建立sql脚本test2.sql:
set verify off
begin
for i in 1 .. 5000
loop
update small set y = i where x= &1;
commit;
end loop;
end;
/
exit
--建立shell脚本如下test2.sh:
sqlplus -s scott/btbtms @test2 1 &
sqlplus -s scott/btbtms @test2 2 &
sqlplus -s scott/btbtms @test2 3 &
sqlplus -s scott/btbtms @test2 4 &
sqlplus -s scott/btbtms @test2 5 &
sqlplus -s scott/btbtms @test2 6 &
sqlplus -s scott/btbtms @test2 7 &
sqlplus -s scott/btbtms @test2 8 &
sqlplus -s scott/btbtms @test2 9 &
2.开始测试:
alter system set undo_tablespace = UNDOTBS2;
SCOTT@test> update dept set loc=UPPER(loc) ;
7 rows updated.
SCOTT@test> alter system flush BUFFER_CACHE ;
System altered.
--我已经转储了数据缓冲。
SCOTT@test> commit ;
Commit complete.
--这样提交不写
SCOTT@test> variable x refcursor ;
SCOTT@test> exec open :x for select * from dept ;
PL/SQL procedure successfully completed.
$ ./test2.sh
--等待结束.我保险执行了2次。
SCOTT@test> set serveroutput on format wrapped
SCOTT@test> print x
ERROR:
ORA-01555: snapshot too old: rollback segment number 239 with name "_SYSSMU239_1274966276$" too small
--可以发现出现了ORA-01555错误。
SCOTT@test> column spare1 noprint
SCOTT@test> column spare2 noprint
SCOTT@test> column spare3 noprint
SCOTT@test> column spare4 noprint
SCOTT@test> column spare5 noprint
SCOTT@test> column spare6 noprint
SCOTT@test> select * from sys.undo$ where name='_SYSSMU239_1274966276$';
US# NAME USER# FILE# BLOCK# SCNBAS SCNWRP XACTSQN UNDOSQN INST# STATUS$ TS# UGRP# KEEP OPTIMAL FLAGS
---------- ------------------------------ ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
239 _SYSSMU239_1274966276$ 1 10 288 0 0 0 0 0 3 5