ORA-01555错误浅析(3)
延迟块清除导致的1555错误
开始读取表。
SQL> var cc refcursor
SQL>
SQL> begin
2 open :cc for select * from t_multiver;
3 end;
4 /
SQL>
SQL> begin
2 open :cc for select * from t_multiver;
3 end;
4 /
这时一个事务更新了该数据块,但在提交前,我们手工将buffer cache中的数据做了flush,再做提交。这时的数据块上只记录了锁标志,没有事务标志和Commit SCN。
PL/SQL procedure successfully completed.
SQL>
SQL> update t_multiver set b=115 where a=1;
1 row updated.
SQL>
SQL> alter system flush buffer_cache;
System altered.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> update t_multiver set b=115 where a=1;
1 row updated.
SQL>
SQL> alter system flush buffer_cache;
System altered.
SQL>
SQL> commit;
Commit complete.
进行非常多的事务,将回滚段中的事务信息表中的数据全部覆盖:
SQL>
SQL> begin
2 -- overwrite rollback slot
3 for i in 1..40000 loop
4 update t_dual set dummy=1;
5 commit;
6 end loop;
7 end;
8 /
PL/SQL procedure successfully completed.
SQL> begin
2 -- overwrite rollback slot
3 for i in 1..40000 loop
4 update t_dual set dummy=1;
5 commit;
6 end loop;
7 end;
8 /
PL/SQL procedure successfully completed.
读取数据块前需要到回滚段的事务信息表中读取Itl中没有标记完全的事务的状态和Commit SCN,以判断是否需要进行一致性读。但是事务信息表中的数据都已经被覆盖,所以报1555错误:
SQL>
SQL> print :cc
ERROR:
ORA-01555: snapshot too old: rollback segment number 20 with name "_SYSSMU20$"
too small
no rows selected
SQL> print :cc
ERROR:
ORA-01555: snapshot too old: rollback segment number 20 with name "_SYSSMU20$"
too small
no rows selected
以上两个例子看起来是好像很类似,但是,他们的本质区别是:第一个实际上是在进行一致性读得时候发生的1555错误,而第二个例子是在判断是否需要进行一致性读得时候发生的1555错误。
0
相关文章