[20150228]Delayed Block Cleanout 2.txt
[20150228]Delayed Block Cleanout 2.txt
--前几天我自己做了1次Delayed Block Cleanout的例子,我一直有一个疑问。
--链接如下:http://blog.itpub.net/267265/viewspace-1441526/
--如果我很久不查询这些块,scn会是多少呢?这个一直是我的疑问,重复测试:
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> alter system checkpoint ;
System altered.
SCOTT@test> select current_scn from v$database ;
CURRENT_SCN
------------
12004525127
SCOTT@test> commit ;
Commit complete.
SCOTT@test> select current_scn from v$database ;
CURRENT_SCN
------------
12004525132
--这样修改的数据块scn在 12004525127-12004525132之间。
SCOTT@test> select ora_rowscn,dept.* from dept where rownum=1;
ORA_ROWSCN DEPTNO DNAME LOC
------------ ------------ -------------- -------------
12004525130 10 ACCOUNTING NEW YORK
--可以发现结果是正确的。这个情况是对应的undo信息还存在,写入scn的信息是正确的。
3.重复上面的测试:
SCOTT@test> update dept set loc=UPPER(loc) ;
7 rows updated.
SCOTT@test> alter system flush BUFFER_CACHE ;
System altered.
SCOTT@test> alter system checkpoint ;
System altered.
SCOTT@test> select current_scn from v$database ;
CURRENT_SCN
------------
12004525447
SCOTT@test> commit ;
Commit complete.
SCOTT@test> select current_scn from v$database ;
CURRENT_SCN
------------
12004525468
--这样修改的数据块scn在 12004525447-12004525468之间。如果对应undo被覆盖会出现什么情况呢?
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 240 with name "_SYSSMU240_2447059684$" too small
no rows selected
--可以发现相关的undo信息被覆盖,为了保证一致性读取报错,出现ora-01555.
SCOTT@test> select ora_rowscn,dept.* from dept where rownum=1;
ORA_ROWSCN DEPTNO DNAME LOC
------------ ------------ -------------- -------------
12004775909 10 ACCOUNTING NEW YORK
-- 很明显scn=12004775909 不在12004525447-12004525468之间。
4.这个scn=12004775909来源那里呢?
SCOTT@test> alter system dump undo header "_SYSSMU240_2447059684$";
System altered.
SCOTT@test> @10to16 12004775909
10 to 16 HEX REVERSE16
-------------- -----------------------------------
00002cb8a57e5 0xe5578acb-02000000
********************************************************************************
Undo Segment: _SYSSMU240_2447059684$ (240)
********************************************************************************
Extent Control Header
-----------------------------------------------------------------
Extent Header:: spare1: 0 spare2: 0 #extents: 2 #blocks: 15
last map 0x00000000 #maps: 0 offset: 4080
Highwater:: 0x0280013c ext#: 1 blk#: 4 ext size: 8
#blocks in seg. hdr's freelists: 0
#blocks below: 0
mapblk 0x00000000 offset: 1
Unlocked
Map Header:: next 0x00000000 #extents: 2 obj#: 0 flag: 0x40000000
Extent Map
-----------------------------------------------------------------
0x02800131 length: 7
0x02800138 length: 8
Retention Table
-----------------------------------------------------------
Extent Number:0 Commit Time: 1425114056
Extent Number:1 Commit Time: 1425114056
TRN CTL:: seq: 0x0191 chd: 0x001c ctl: 0x0016 inc: 0x00000000 nfb: 0x0000
mgc: 0xb000 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)
uba: 0x0280013b.0191.03 scn: 0x0002.cb8a57e5
Version: 0x01
FREE BLOCK POOL::
uba: 0x00000000.0191.04 ext: 0x1 spc: 0x1dbe
uba: 0x00000000.0191.02 ext: 0x1 spc: 0x1f06
uba: 0x00000000.00a1.0b ext: 0x1 spc: 0x288
uba: 0x00000000.00a1.0b ext: 0x1 spc: 0x288
uba: 0x00000000.00a1.0b ext: 0x1 spc: 0x288
TRN TBL::
index state cflags wrap# uel scn dba parent-xid nub stmt_num cmt
------------------------------------------------------------------------------------------------
0x00 9 0x00 0x02b2 0x0001 0x0002.cb8a5959 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x01 9 0x00 0x02b2 0x0002 0x0002.cb8a598f 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x02 9 0x00 0x02b2 0x0005 0x0002.cb8a59d7 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x03 9 0x00 0x02b2 0x0007 0x0002.cb8a5a54 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x04 9 0x00 0x02b2 0x000a 0x0002.cb8a5b7d 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x05 9 0x00 0x02b2 0x0003 0x0002.cb8a5a1f 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x06 9 0x00 0x02b2 0x0008 0x0002.cb8a5ad3 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x07 9 0x00 0x02b2 0x0006 0x0002.cb8a5aa6 0x02800133 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x08 9 0x00 0x02b2 0x0009 0x0002.cb8a5b34 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x09 9 0x00 0x02b2 0x0004 0x0002.cb8a5b5a 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0a 9 0x00 0x02b2 0x000b 0x0002.cb8a5bad 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0b 9 0x00 0x02b2 0x000c 0x0002.cb8a5bd1 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0c 9 0x00 0x02b2 0x000d 0x0002.cb8a5c58 0x02800134 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0d 9 0x00 0x02b2 0x000f 0x0002.cb8a5d13 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0e 9 0x00 0x02b2 0x0010 0x0002.cb8a5de6 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x0f 9 0x00 0x02b2 0x000e 0x0002.cb8a5dbb 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x10 9 0x00 0x02b2 0x0013 0x0002.cb8a5e9d 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x11 9 0x00 0x02b2 0x0014 0x0002.cb8a5f6c 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x12 9 0x00 0x02b2 0x0015 0x0002.cb8a6048 0x02800136 0x0000.000.00000000 0x00000001 0x00000000 1425114023
0x13 9 0x00 0x02b2 0x0011 0x0002.cb8a5f04 0x02800135 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x14 9 0x00 0x02b2 0x0012 0x0002.cb8a5fee 0x02800136 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x15 9 0x00 0x02b2 0x0018 0x0002.cb8a6079 0x02800136 0x0000.000.00000000 0x00000001 0x00000000 1425114023
0x16 9 0x00 0x02b2 0xffff 0x0002.cb8a61dc 0x00000000 0x0000.000.00000000 0x00000000 0x00000000 1425114056
0x17 9 0x00 0x02b1 0x001d 0x0002.cb8a587b 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x18 9 0x00 0x02b2 0x001b 0x0002.cb8a6135 0x02800136 0x0000.000.00000000 0x00000001 0x00000000 1425114023
0x19 9 0x00 0x02b2 0x001a 0x0002.cb8a61d1 0x0280013b 0x0000.000.00000000 0x00000003 0x00000000 1425114055
0x1a 9 0x00 0x02b2 0x001f 0x0002.cb8a61d6 0x00000000 0x0000.000.00000000 0x00000000 0x00000000 1425114055
0x1b 9 0x00 0x02b2 0x0019 0x0002.cb8a61cf 0x0280013a 0x0000.000.00000000 0x00000001 0x00000000 1425114055
0x1c 9 0x00 0x02b1 0x001e 0x0002.cb8a581f 0x02800131 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x1d 9 0x00 0x02b1 0x0021 0x0002.cb8a58b8 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x1e 9 0x00 0x02b1 0x0017 0x0002.cb8a584b 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x1f 9 0x00 0x02b2 0x0016 0x0002.cb8a61d8 0x00000000 0x0000.000.00000000 0x00000000 0x00000000 1425114056
0x20 9 0x00 0x02b1 0x0000 0x0002.cb8a5942 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
0x21 9 0x00 0x02b1 0x0020 0x0002.cb8a58f2 0x02800132 0x0000.000.00000000 0x00000001 0x00000000 1425114022
EXT TRN CTL::
usn: 240
sp1:0x00000000 sp2:0x00000000 sp3:0x00000000 sp4:0x00000000
sp5:0x00000000 sp6:0x7f00000000 sp7:0x00000000 sp8:0x00000000
EXT TRN TBL::
index extflag extHash extSpare1 extSpare2
---------------------------------------------------
0x00 0x00000000 0x00000000 0x00000000 0x00000000
0x01 0x00000000 0x00000000 0x00000000 0x00000000
0x02 0x00000000 0x00000000 0x00000000 0x00000000
0x03 0x00000000 0x00000000 0x00000000 0x00000000
0x04 0x00000000 0x00000000 0x00000000 0x00000000
0x05 0x00000000 0x00000000 0x00000000 0x00000000
0x06 0x00000000 0x00000000 0x00000000 0x00000000
0x07 0x00000000 0x00000000 0x00000000 0x00000000
0x08 0x00000000 0x00000000 0x00000000 0x00000000
0x09 0x00000000 0x00000000 0x00000000 0x00000000
0x0a 0x00000000 0x00000000 0x00000000 0x00000000
0x0b 0x00000000 0x00000000 0x00000000 0x00000000
0x0c 0x00000000 0x00000000 0x00000000 0x00000000
0x0d 0x00000000 0x00000000 0x00000000 0x00000000
0x0e 0x00000000 0x00000000 0x00000000 0x00000000
0x0f 0x00000000 0x00000000 0x00000000 0x00000000
0x10 0x00000000 0x00000000 0x00000000 0x00000000
0x11 0x00000000 0x00000000 0x00000000 0x00000000
0x12 0x00000000 0x00000000 0x00000000 0x00000000
0x13 0x00000000 0x00000000 0x00000000 0x00000000
0x14 0x00000000 0x00000000 0x00000000 0x00000000
0x15 0x00000000 0x00000000 0x00000000 0x00000000
0x16 0x00000000 0x00000000 0x00000000 0x00000000
0x17 0x00000000 0x00000000 0x00000000 0x00000000
0x18 0x00000000 0x00000000 0x00000000 0x00000000
0x19 0x00000000 0x00000000 0x00000000 0x00000000
0x1a 0x00000000 0x00000000 0x00000000 0x00000000
0x1b 0x00000000 0x00000000 0x00000000 0x00000000
0x1c 0x00000000 0x00000000 0x00000000 0x00000000
0x1d 0x00000000 0x00000000 0x00000000 0x00000000
0x1e 0x00000000 0x00000000 0x00000000 0x00000000
0x1f 0x00000000 0x00000000 0x00000000 0x00000000
0x20 0x00000000 0x00000000 0x00000000 0x00000000
0x21 0x00000000 0x00000000 0x00000000 0x00000000
--可以发现如果覆盖,从TRN CTL里面取出Scn。
TRN CTL:: seq: 0x0191 chd: 0x001c ctl: 0x0016 inc: 0x00000000 nfb: 0x0000
mgc: 0xb000 xts: 0x0068 flg: 0x0001 opt: 2147483646 (0x7ffffffe)
uba: 0x0280013b.0191.03 scn: 0x0002.cb8a57e5
~~~~~~~~~~~~~~~~~~~~~~
SCOTT@test> select rowid from dept where rownum=1;
ROWID
------------------
AABBrlAAEAAAAWDAAB
SCOTT@test> @lookup_rowid AABBrlAAEAAAAWDAAB
OBJECT FILE BLOCK ROW DBA TEXT
---------- ---------- ---------- ---------- -------------------- ----------------------------------------
269029 4 1411 1 4,1411 alter system dump datafile 4 block 1411
SCOTT@test> alter system dump datafile 4 block 1411;
System altered.
Block header dump: 0x01000583
Object id on Block? Y
seg/obj: 0x41ae5 csc: 0x02.cb8a620f itc: 3 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1000580 ver: 0x01 opc: 0
inc: 0 exflg: 0
Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x00f3.006.00000371 0x0280016a.01eb.21 C--- 0 scn 0x0002.cb86844a
0x02 0x00f0.01d.00000259 0x0280013d.014d.04 C-U- 0 scn 0x0002.cb8a57e5
0x03 0x0068.001.00000317 0x028000b1.01e1.07 C-U- 0 scn 0x0002.cb80985e
bdba: 0x01000583
data_block_dump,data header at 0x2a97149a7c
[20150228]Delayed Block Cleanout 2.txt相关推荐
- [20170419]bbed探究数据块.txt
[20170419]bbed探究数据块.txt --//bbed 是一个瑞士军刀,也是了解oracle内部数据块结构的好工具.我自己开始使用基本是看别人的帖子,对oracle数据块的内部也不是很了解. ...
- Oracle Block浅析2:ITL(Interested Transaction List)
一.ITL(Interested Transaction List): ITL(Interested Transaction List)是Oracle数据块内部的一个组成部分,位于数据块头(block ...
- Oracle clean out.,Oracle(block clean out)的块清除
Oracle(block clean out)的块清除 Clean out有2种: fast commit cleanout,delayed block cleanout 1.如果一个事务(trans ...
- 直接路径读取对于延迟块清除的影响
在Oracle 11g版本中串行的全表扫描可能使用直接路径读取(direct path read)的方式取代之前版本中一直使用的DB FILE SCATTERED READ, 显然direct pat ...
- ORACLE 回滚段详解
ORACLE 回滚段 回滚段概述 回滚段用于存放数据修改之前的值(包括数据修改之前的位置和值).回滚段的头部包含正在使用的该回滚段事务的信息.一个事务只能使用一个回滚段来存放它的回滚信息,而一个 ...
- 在Oracle中如何让SELECT查询绕过UNDO
是否有想过如何在Oracle中实现脏读(dirty read),在Oracle官方文档或者Asktom的时候显然会提到Oracle是不实现脏读的, 总是有undo来提供数据块的前镜像(before i ...
- oracle快照太旧含义,全解ORA-1555快照太旧错误原理及解决方案
作者: |[转载时请以超链接形式标明文章和信息] 链接: 回滚机制的深入研究: 如果大家有兴趣深入了解一下回滚段的机制,那么请跟随我将前面的例子进一步深化. 1. 从DML更新事务开始: 重新来看这个 ...
- Know more about commit
COMMIT操作是RDBMS中事务结束的标志,在Oracle中与commit紧密相关的是SCN(System Change Number). 引入SCN的最根本目的在于: 为读一致性所用 为redol ...
- 《Oracle高性能自动化运维》一一3.3 Redo产生场景
3.3 Redo产生场景 我们知道,Oracle Redo是以条目(Redo Entries/Records)的形式记录数据库的所有更改操作(OP).更改操作主要包括: 数据库物理文件更改:主要指的是 ...
- ORA-01555 原因与解决
ORA-01555 原因与解决: 前面提到了ORA-01555错误,那么现在来看一下ORA-01555错误是怎样产生的.由于回滚段是循环使用的,当事务提交以后,该事务占用的回滚段事务会被标记为非活动, ...
最新文章
- Java项目:校园招聘平台系统(java+MySQL+Jdbc+Servlet+SpringMvc+Jsp)
- 学习笔记---取得枚举项的2种方法: Enum.GetValues()-Array.GetValue()和Enum.GetNames()-Enum.Parse()...
- Linux2.6内核 -- 编码风格(2)
- ASP.NET Core API 版本控制
- Another app is currently holding the yum lock; waiting for it to exit...
- Python老司机总结新手常见10大错误
- MTK 驱动(58)---MTK G-sensor
- Linux打开文件操作的注意事项
- 面试稳了!BATJ 等大厂 400+ 道面试题全汇总!
- iOS:Reachability网络监听
- 2018辛苦一年了,程序员这样跟大boss谈2019加薪,谈薪杯具变喜剧
- threejs的shader材质 颜色混合函数mix
- OAuth 2.0 授权认证详解
- 忒修斯之船,你还是原来的你吗?
- Sky Computing:利用空间异构分布式计算特性加速联邦学习
- Upload_上传_并传递额外参数
- 卡西欧科学计算机玩法,巨好玩:计算器CASIO(卡西欧)新玩法
- Android加密之全盘加密详解
- php+mysql一个简单的图书管理系统设计思路
- 易拉罐WiFi收集器
热门文章
- 调制方式演变(二)--DQPSK,4 /π​-DQPSK,FSK,MSK
- java中代码pu_一、线程Java代码实现1.继承Thread声明Thread的子类public class MyThread extends Thread { pu...
- python中提交post表单_python接口自动化二(发送post请求)
- python编程符号大全_2020 年最值得学习的 5 大 AI 编程语言
- nginx安装nginx-vts实现监控并打包镜像
- 语言模型总结(待完善)
- opengl es坐标变换理解1
- 划分数算法概述及习题
- 拥塞控制,图文并茂(挺丰富,借鉴较多大佬的思想)
- 锁php_php+redis实现分布式锁