一,建立测试环境

  01,一个oracle数据库环境

  02,具体数据库实验环境配置


SQL> create user test1 identified by kingle;

User created.

SQL> grant dba to test1;

Grant succeeded.

SQL> create tablespace ttt1 datafile '/u01/app/oracle/oradata/oracle01/test101.dbf' size 10M;

Tablespace created.

SQL> alter user test1 default tablespace ttt1;

User altered.


二,测试dump文件01

  01,建立表数据


SQL> conn test/kingle
Connected.
SQL> create table t1(id int,name varchar2(100));

Table created.

SQL> insert into t1 values(1,'AAAAA');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system checkpoint; --触发checkpoint操作,脏块写进磁盘

System altered.


  02,查看相关dump 信息


SQL> select  id,name,dbms_rowid.rowid_relative_fno(rowid)file#,dbms_rowid.rowid_block_number(rowid) block# from t1;

ID
----------
NAME
--------------------------------------------------------------------------------
FILE# BLOCK#
---------- ----------
1
AAAAA
7 132


SQL> col NAME format a20; --oracle 输出格式化
SQL> select id,name,dbms_rowid.rowid_relative_fno(rowid)file#,dbms_rowid.rowid_block_number(rowid) block# from t1;

ID NAME FILE# BLOCK#
---------- -------------------- ---------- ----------
1 AAAAA 7 132

SQL> alter system dump datafile 7 block 132; --dump 数据块

System altered.

SQL> select object_id from dba_objects where object_name='t1';

no rows selected

SQL> select p.spid from v$session s,v$process p where s.paddr=p.addr and s.sid in (select userenv('sid') from dual);

SPID
------------------------
3986


  03,查看dump文件


默认存放位置:
如果是DG的话可能位置sid会多一sid
找到TRACE 文件,打开。路径$ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace



[oracle@oracle01 trace]$ pwd
/u01/app/oracle/diag/rdbms/oracle01_oracle01/oracle01/trace
[oracle@oracle01 trace]$ ll -h |grep 9616
-rw-r----- 1 oracle oinstall 3.4K May 5 09:55 oracle01_ora_9616.trc
-rw-r----- 1 oracle oinstall 63 May 5 09:55 oracle01_ora_9616.trm



[oracle@oracle01 trace]$ cat oracle01_ora_9616.trc
Trace file /u01/app/oracle/diag/rdbms/oracle01_oracle01/oracle01/trace/oracle01_ora_9616.trc
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1
System name: Linux
Node name: oracle01
Release: 3.10.0-693.el7.x86_64
Version: #1 SMP Tue Aug 22 21:09:27 UTC 2017
Machine: x86_64
VM name: VMWare Version: 6
Instance name: oracle01
Redo thread mounted by this instance: 1
Oracle process number: 36
Unix process pid: 9616, image: oracle@oracle01 (TNS V1-V3)


*** 2019-05-05 09:55:08.835
*** SESSION ID:(26.8411) 2019-05-05 09:55:08.835
*** CLIENT ID:() 2019-05-05 09:55:08.835
*** SERVICE NAME:(SYS$USERS) 2019-05-05 09:55:08.835
*** MODULE NAME:(SQL*Plus) 2019-05-05 09:55:08.835
*** ACTION NAME:() 2019-05-05 09:55:08.835

Start dump data blocks tsn: 9 file#:7 minblk 132 maxblk 132
Block dump from cache:
Dump of buffer cache at level 4 for tsn=9 rdba=29360260
BH (0x82ff4948) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0x82ed6000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 32,28
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x7bfaaa98,0xf3ba92b0] lru: [0x82ff47c8,0x82ff4ca8]
ckptq: [NULL] fileq: [NULL] objq: [0x82ff4310,0x82ff4cd0] objaq: [0x82ff4590,0x82ff4ce0]
st: XCURRENT md: NULL fpin: 'ktspbwh2: ktspfmdb' tch: 3
flags: block_written_once redo_since_read
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [1]
Block dump from disk: --数据块头
buffer tsn: 9 rdba: 0x01c00084 (7/132)
scn: 0x0000.009b87a7 seq: 0x01 flg: 0x06 tail: 0x87a70601
--(0x01 (新建块)0x2(数据块延迟清洗推进scn和seq) 0X04(设置校验和) 0x08(临时块))
frmt: 0x02 chkval: 0xbc1e type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
#######################################
rba是相对数据块地址(用4个字节32位来表示,前10位为相对数据文件号,后22位为块号。
01400010=0000 0001 0100 0000 0000 0000 0001 0000(二进制)
我们看到前10位转换成十进制就是5,后22位转换成十进制就是16。),
scn:scn号总共占用6个字节,前2个字节表示SCN Wrap,后4个字节表示SCN 
Base,seq:scn序列号,tail:维护数据一致性验证块在开始到结束是同一个版本(由scn的低二字节+块类型+scn序列号)

frmt块的格式 chkval可选的检查值 如果db_block_checksum=true,type块类型
#######################################
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A633200
7EFD5A631200 0000A206 01C00084 009B87A7 06010000 [................]
7EFD5A631210 0000BC1E 00000001 00017A7C 009B8797 [........|z......]
7EFD5A631220 00000000 0032F802 01C00080 00060008 [......2.........]
7EFD5A631230 00000EFE 00C0093B 000505F5 00002001 [....;........ ..]
7EFD5A631240 009B87A7 00000000 00000000 00000000 [................]
7EFD5A631250 00000000 00000000 00000000 00000000 [................]
7EFD5A631260 00000000 00010100 0014FFFF 1F781F8C [..............x.]
7EFD5A631270 00001F78 1F8C0001 00000000 00000000 [x...............]
7EFD5A631280 00000000 00000000 00000000 00000000 [................]
Repeat 502 times
7EFD5A6331F0 0202012C 410502C1 41414141 87A70601 [,......AAAAA....]
Block header dump: 0x01c00084
Object id on Block? Y
seg/obj: 0x17a7c csc: 0x00.9b8797(块清除的时候的SCN) itc: 2 (ilt槽数) flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00080 ver: 0x01 opc: 0
inc: 0 exflg: 0

Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.006.00000efe 0x00c0093b.05f5.05 --U- 1 fsc 0x0000.009b87a7
0x02 0x0000.000.00000000 0x00000000.0000.00 ---- 0 fsc 0x0000.00000000

##########################################
csc:块最后清除时的scn ,itc事务槽数,type 1是data 2是index,xid事务id(undoseg.slot.wrap),
uba undo地址(undodba.seqno,recordno)

flag c=commit u=commit upper bound; t=active at csc lock被这个事务影响的行数,
scn/fsc scn=scn of commited tx fsc=free space credit

select xidusn,xidslot,xidsqn,ubafil,ubablk,ubasqn,ubarec from v$transaction; 可以查这个来对比

Flag:事务标志位。这个标志位就记录了这个事务的操作状态,各个标志的含义分别是:
C = transaction has been committed and locks cleaned out --事物已经提交,锁已经被清除
B = this undo record contains the undo for this ITL entry
U = transaction committed (maybe long ago); SCN is an upper bound --事物已经提交,但是锁还没有清除
T = transaction was still active at block cleanout SCN --块清除的SCN被记录时,该事务仍然是活动的,块
上如果有已经提交的事务,那么在clean ount的时候,块会被进行清除,但是这个块里面的事务不会被清除。
Lck:表示这个事务所影响的行数。我们看到01号事物槽Lck为0,因为该事物槽中的事物Flag为C,证明该事物
已经提交,锁也被清楚掉了,该事物槽可以被重用了。02号事物槽Lck为1,是因为我对第一行做了一个更新,
并且没有提交,Flag为----说明该事物是活动的。
Scn/Fsc:Commit SCN或者快速提交(Fast Commit Fsc)的SCN。
每条记录中的行级锁对应Itl条目lb,对应于Itl列表中的序号,即那个事务在该记录上产生的锁。
对于Oracle来说,对于一个事务,可以是快速提交、也可以是延迟提交,目的都是为了提高提交的速度。提交以后,
oracle需要对ITL事务槽、每一行的锁定标记进行清除。如果是快速提交,那么在提交的时候,会将事务表和每一个数据块的ITL槽进行清除。
但是锁定标记可能没有清除,等下次用到的时候再进行清除。如果是延迟提交,那么在提交的时候,只是将事务表进行清除,
并没有对ITL事务槽进行清除,每一行的锁定标记也没有清除。因此C和U的情况特别多。块清除的过程并不包括每个行的锁定标记的清除,
主要指的是ITL的清除。 
注意:
1、事务槽中首先记录的是Xid和Uba,只有在提交以后,当对这个数据块进行cleanout的时候,才会更新Flag和Scn。
因此Oracle总是以事务表中对这个数据块的Scn以及Flag为准。 
2、一个事务开始以后,在一个数据块上得到一个事务槽,那么在这个事务提交以前,这个事务槽会一直占用,
直到这个事务提交释放这个事务槽。 
3、只有在已经提交以后,这个itl事务槽中的scn才会有数值。
4、事务是否已经提交、事务对应的SCN,这些信息都是以回滚段事务表中的为主,事务槽中的不准确
5、事务槽中的事务id和uba地址是准确的
6、事务槽1中的事务id和回滚段中的事务id肯定不是一样的,不同回滚段中的事务id也一定不一样。
##########################################
bdba: 0x01c00084
data_block_dump,data header at 0x7efd5a631264
===============
tsiz: 0x1f98
hsiz: 0x14
pbl: 0x7efd5a631264
76543210
flag=--------
ntab=1
nrow=1
frre=-1
fsbo=0x14
fseo=0x1f8c
avsp=0x1f78
tosp=0x1f78
0xe:pti[0] nrow=1 offs=0
0x12:pri[0] offs=0x1f8c
block_row_dump:
tab 0, row 0, @0x1f8c
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 41 41 41 41 41
end_of_block_dump
End dump data blocks tsn: 9 file#: 7 minblk 132 maxblk 132
########################################
bdba: 0x01c00084-- 数据块的地址:16进制转成2进制取前10位二进制为文件号0000 0001 1100 .....  0000000110=7号文件,
后面剩于的部分表示块号,0X84转成10进制为132号块
tsiz:数据区总大小 hsiz数据头大小 pbl指向持有该块的buffer指针 bdba数据块的相对地址 flag n=pctfree hit;
f=不放到空闲列表上,k=可刷新簇键 ntab表行数 nrow行数量,frre第一个索引的条目,如果是-1说明需要创建索引,
fsbo开始偏移的自由空间,fseo结束便宜的自由空间。avsp块中可用空间。tosp 当tx提交后总的可用空间 nrow第一个表行数。

lb锁字节 cc在这个行片中的列数,fb flag byte,t1行大小,col column数据。
hsiz: 0x14   --Data header size 数据头大小即20个字节
pbl: 0x7efd5a631264 76543210 --Pointer to buffer holding the block
76543210
flag=--------  N=pcrfree hit(clusters);F=do not put on free list;K=flushable cluster keys
ntab=1     --叫表数:表示这个块的数据在一个表(如果是聚簇表就有可能是2或2以上)
nrow=1     --叫行数:表示这个表有一行数据
frre=-1      -- The first free row entry in the row directory=you have to add one
fsbo=0x14   -- Free space begin offset  叫起始空间:可以存放数据空间的起始位置(即定义了数据层中空闲空间的起始offset)
fseo=0x1f8c  -- Free space end offset  叫结束空间:可以存放数据空间的结束位置(即定义了数据层中空闲空间的结束offset)
avsp=0x1f78  --Available space for new entries  叫空闲空间:定义了数据层中空闲空间的字节数
tosp=0x1f78  --Total space   叫最终空闲空间:定义了ITL中事务提交后,数据层中空闲空间的字节数
0xe:pti[0]      nrow=1  offs=0  --Table directory,整个表的开始,共一行数据 ,定义了该表在行索引中使用的插槽数
0x12:pri[0]     offs=0x1f8c      --Row index,叫行索引,定义了该块中包含的所有行数据的位置
tab 0, row 0, @0x1f8c      --第一个表第一行的位置 ,定义了该表在行索引中的起始插槽号
tl: 12 fb: --H-FL-- lb: 0x1  cc: 2  --行头,tl: 12行长度12个字节,
fb: (Flag byte)--H-FL指H(Head piece of row)F(First data piece) L(Last data piece)
lb: 0x1 --Lock byte和上面的ITL的lck相对应,表示这行是否被lock了
cc: 2 --表示有两列,即这个表有两个字段
col  0: [ 2]  c1 02 --第一行的第一个字段长度和值
col  1: [ 5]  41 41 41 41 41 --第一行的第二个字段长度和值
数据块的最后四字节tail: 0xa3eb0601=scn BASE+flg+seq
########################################


三,测试dump文件02

  01,建立表数据


create table t2(id int,name varchar2(10))segment creation
SQL> create table t2(id int,name varchar2(10))segment creation immediate;

Table created. immediate;
SQL> select extent_id,file_id,block_id from dba_extents where segment_name='T2';

EXTENT_ID FILE_ID BLOCK_ID
---------- ---------- ----------
0 7 136

SQL> alter system dump datafile 7 block 136;

System altered.


  02,查看dump文件,

  发现新增的数据,再文件 的最后


Start dump data blocks tsn: 9 file#:7 minblk 136 maxblk 136

*** 2019-05-05 10:37:30.903
Block dump from cache:
Dump of buffer cache at level 4 for tsn=9 rdba=29360264
BH (0x83f93b08) file#: 7 rdba: 0x01c00088 (7/136) class: 8 ba: 0x834e6000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 44,28
dbwrid: 0 obj: 96895 objn: 96895 tsn: 9 afn: 7 hint: f
hash: [0x7cf9e2b8,0xf35ca2b0] lru: [0x83f93e68,0x83f93988]
obj-flags: object_ckpt_list
ckptq: [0x83f93898,0x83f93d78] fileq: [0xf2147838,0x83f93d88] objq: [0x83f93e90,0xe73b4ae0] objaq: [0x83f93ea0,0xe73b4ac0]
st: XCURRENT md: NULL fpin: 'kcbwh6: kcbnew' tch: 1
flags: buffer_dirty redo_since_read
LRBA: [0x7db.206.0] LSCN: [0x0.9ba0f2] HSCN: [0x0.9ba0f2] HSUB: [6]
Block dump from disk:
buffer tsn: 9 rdba: 0x00000088 (0/136)
scn: 0x0000.00000000 seq: 0x01 flg: 0x05 tail: 0x00000001
frmt: 0x02 chkval: 0xa788 type: 0x00=unknown
Hex dump of corrupt header 4 = CORRUPT
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A631214
7EFD5A631200 0000A200 00000088 00000000 05010000 [................]
7EFD5A631210 0000A788 [....]
Hex dump of block: st=4, typ_found=0
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A633200
7EFD5A631200 0000A200 00000088 00000000 05010000 [................]
7EFD5A631210 0000A788 00000000 00000000 00000000 [................]
7EFD5A631220 00000000 00000000 00000000 00000000 [................]
Repeat 508 times
7EFD5A6331F0 00000000 00000000 00000000 00000001 [................]
End dump data blocks tsn: 9 file#: 7 minblk 136 maxblk 136


 发现改变了flg-->0X05是0X01和0X04的集合,0X01表示新建的块,0X04表示设置校验。chkval: 0xa88就是校验和。

四,测试dump文件03

  01,建立测试数据



SQL>  insert into t1 values(2,'BBBBB');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system flush buffer_cache;

System altered.
SQL> select name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from t1 where id=2;

NAME DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)
-------------------- ------------------------------------
DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
BBBBB 7
132


SQL> alter system dump datafile 7 block 132;

System altered.


  02,查看dump数据


*** 2019-05-05 10:49:04.309
Start dump data blocks tsn: 9 file#:7 minblk 132 maxblk 132
Block dump from cache:
Dump of buffer cache at level 4 for tsn=9 rdba=29360260
BH (0xbdfcc838) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xbdaba000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xc2fb85f8,0xf3ba92b0] lru: [0xbdfccb98,0xbdfcc6b8]
ckptq: [NULL] fileq: [NULL] objq: [0xbdfccbc0,0xbdfcc6e0] objaq: [0xbdfccbd0,0xbdfcc6f0]
st: XCURRENT md: NULL fpin: 'kdswh01: kdstgr' tch: 2
flags: only_sequential_access
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [65535]
BH (0xc2fb8540) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xc28a8000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x82ff4a00,0xbdfcc8f0] lru: [0xa1f95800,0xbefd9c00]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh11: kdst_fetch' tch: 0 lfb: 33
flags:
BH (0x82ff4948) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0x82ed6000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x7bfaaa98,0xc2fb85f8] lru: [0xc2fc1870,0x82fdba78]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'ktspbwh2: ktspfmdb' tch: 0 lfb: 33
flags:
Block dump from disk:
buffer tsn: 9 rdba: 0x01c00084 (7/132)
scn: 0x0000.009ba4b4 seq: 0x01 flg: 0x06 tail: 0xa4b40601
frmt: 0x02 chkval: 0x6f8e type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A633200
7EFD5A631200 0000A206 01C00084 009BA4B4 06010000 [................]
7EFD5A631210 00006F8E 00000001 00017A7C 009B8797 [.o......|z......]
7EFD5A631220 00000000 0032F802 01C00080 00060008 [......2.........]
7EFD5A631230 00000EFE 00C0093B 000505F5 00002001 [....;........ ..]
7EFD5A631240 009B87A7 00170006 00000FDC 00C002CB [................]
7EFD5A631250 000C0410 00002001 009BA4B4 00000000 [..... ..........]
7EFD5A631260 00000000 00020100 0016FFFF 1F6A1F80 [..............j.]
7EFD5A631270 00001F6A 1F8C0002 00001F80 00000000 [j...............]
7EFD5A631280 00000000 00000000 00000000 00000000 [................]
Repeat 501 times
7EFD5A6331E0 00000000 0202022C 420503C1 42424242 [....,......BBBBB]
7EFD5A6331F0 0202012C 410502C1 41414141 A4B40601 [,......AAAAA....]
Block header dump: 0x01c00084
Object id on Block? Y
seg/obj: 0x17a7c csc: 0x00.9b8797 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00080 ver: 0x01 opc: 0
inc: 0 exflg: 0

Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.006.00000efe 0x00c0093b.05f5.05 --U- 1 fsc 0x0000.009b87a7
0x02 0x0006.017.00000fdc 0x00c002cb.0410.0c --U- 1 fsc 0x0000.009ba4b4
bdba: 0x01c00084
data_block_dump,data header at 0x7efd5a631264
===============
tsiz: 0x1f98
hsiz: 0x16
pbl: 0x7efd5a631264
76543210
flag=--------
ntab=1
nrow=2
frre=-1
fsbo=0x16
fseo=0x1f80
avsp=0x1f6a
tosp=0x1f6a
0xe:pti[0] nrow=2 offs=0
0x12:pri[0] offs=0x1f8c
0x14:pri[1] offs=0x1f80
block_row_dump:
tab 0, row 0, @0x1f8c
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2 -- lb 0x1对应ITL的1号槽
col 0: [ 2] c1 02
col 1: [ 5] 41 41 41 41 41
tab 0, row 1, @0x1f80
tl: 12 fb: --H-FL-- lb: 0x2 cc: 2 -- lb 0x2对应ITL的1号槽
col 0: [ 2] c1 03
col 1: [ 5] 42 42 42 42 42
end_of_block_dump
End dump data blocks tsn: 9 file#: 7 minblk 132 maxblk 132
事务槽都是U,表示快速提交了,但是没有清除行锁。


  03,再进行插入数据


SQL> insert into t1 values (3,'DDDDD');

1 row created.

SQL> commit;

Commit complete.

SQL> alter system flush buffer_cache;

System altered.

SQL> select name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from t1 where id=3;

NAME DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)
-------------------- ------------------------------------
DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
DDDDD 7
132


SQL> alter system dump datafile 7 block 132;

System altered.


  查看dump文件


*** 2019-05-05 11:07:00.450
Block dump from cache:
Dump of buffer cache at level 4 for tsn=9 rdba=29360260
BH (0xb1f77950) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xb1204000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xbdfcc8f0,0xf3ba92b0] lru: [0xb1f77cb0,0xb1f77908]
ckptq: [NULL] fileq: [NULL] objq: [0xb1f77cd8,0xb1f77930] objaq: [0xb1f77ce8,0xb1f77940]
st: XCURRENT md: NULL fpin: 'kdswh11: kdst_fetch' tch: 1
flags: only_sequential_access
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [65535]
BH (0xbdfcc838) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xbdaba000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xc2fb85f8,0xb1f77a08] lru: [0xbdfcc580,0xbef82138]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh01: kdstgr' tch: 0 lfb: 33
flags:
BH (0xc2fb8540) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xc28a8000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x82ff4a00,0xbdfcc8f0] lru: [0xa1f95800,0xbefd9c00]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh11: kdst_fetch' tch: 0 lfb: 33
flags:
BH (0x82ff4948) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0x82ed6000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x7bfaaa98,0xc2fb85f8] lru: [0xc2fc1870,0x82fdba78]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'ktspbwh2: ktspfmdb' tch: 0 lfb: 33
flags:
Block dump from disk:
buffer tsn: 9 rdba: 0x01c00084 (7/132)
scn: 0x0000.009baf43 seq: 0x01 flg: 0x06 tail: 0xaf430601
frmt: 0x02 chkval: 0x9899 type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A633200
7EFD5A631200 0000A206 01C00084 009BAF43 06010000 [........C.......]
7EFD5A631210 00009899 00000001 00017A7C 009BAF3E [........|z..>...]
7EFD5A631220 00000000 0032F802 01C00080 00110008 [......2.........]
7EFD5A631230 00000F03 00C000F7 001F05F6 00002001 [............. ..]
7EFD5A631240 009BAF43 00170006 00000FDC 00C002CB [C...............]
7EFD5A631250 000C0410 00008000 009BA4B4 00000000 [................]
7EFD5A631260 00000000 00030100 0018FFFF 1F5C1F74 [............t.\.]
7EFD5A631270 00001F5C 1F8C0003 1F741F80 00000000 [\.........t.....]
7EFD5A631280 00000000 00000000 00000000 00000000 [................]
Repeat 500 times
7EFD5A6331D0 00000000 00000000 0202012C 440504C1 [........,......D]
7EFD5A6331E0 44444444 0202002C 420503C1 42424242 [DDDD,......BBBBB]
7EFD5A6331F0 0202002C 410502C1 41414141 AF430601 [,......AAAAA..C.]
Block header dump: 0x01c00084
Object id on Block? Y
seg/obj: 0x17a7c csc: 0x00.9baf3e itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00080 ver: 0x01 opc: 0
inc: 0 exflg: 0

Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.011.00000f03 0x00c000f7.05f6.1f --U- 1 fsc 0x0000.009baf43
0x02 0x0006.017.00000fdc 0x00c002cb.0410.0c C--- 0 scn 0x0000.009ba4b4
bdba: 0x01c00084
data_block_dump,data header at 0x7efd5a631264
===============
tsiz: 0x1f98
hsiz: 0x18
pbl: 0x7efd5a631264
76543210
flag=--------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0x1f74
avsp=0x1f5c
tosp=0x1f5c
0xe:pti[0] nrow=3 offs=0
0x12:pri[0] offs=0x1f8c
0x14:pri[1] offs=0x1f80
0x16:pri[2] offs=0x1f74
block_row_dump:
tab 0, row 0, @0x1f8c
tl: 12 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 41 41 41 41 41
tab 0, row 1, @0x1f80
tl: 12 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 03
col 1: [ 5] 42 42 42 42 42
tab 0, row 2, @0x1f74
tl: 12 fb: --H-FL-- lb: 0x1 cc: 2
col 0: [ 2] c1 04
col 1: [ 5] 44 44 44 44 44
end_of_block_dump
End dump data blocks tsn: 9 file#: 7 minblk 132 maxblk 132
一个清除了行锁。当事务槽上的提交标志都是快速提交(U),
再有事务进来,其他ITL插槽的快速提交U变成正常提交C,并且清除行锁。
同时CSC csc: 0x00.9baf3e也推进了。Csc是数据本块中最小的COMMIT SCN。


五,测试dump文件04

  01,更新数据


SQL> update t1 set name='EEEEE' where id=3;

1 row updated.

SQL> alter system flush buffer_cache;

System altered.

SQL> select name,dbms_rowid.rowid_relative_fno(rowid),dbms_rowid.rowid_block_number(rowid) from t1 where id=3;

NAME DBMS_ROWID.ROWID_RELATIVE_FNO(ROWID)
-------------------- ------------------------------------
DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
------------------------------------
EEEEE 7
132


SQL> alter system dump datafile 7 block 132;

System altered.


  02,查看文件


*** 2019-05-05 11:10:24.592
Start dump data blocks tsn: 9 file#:7 minblk 132 maxblk 132
Block dump from cache:
Dump of buffer cache at level 4 for tsn=9 rdba=29360260
BH (0xa9fdb718) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xa9c42000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xb0fd8230,0xf3ba92b0] lru: [0xa9fdb940,0xa9fdb6d0]
ckptq: [NULL] fileq: [NULL] objq: [0xa9fdb968,0xa9fdb6f8] objaq: [0xa9fdb978,0xa9fdb708]
st: XCURRENT md: NULL fpin: 'kdswh11: kdst_fetch' tch: 1
flags: only_sequential_access
LRBA: [0x0.0.0] LSCN: [0x0.0] HSCN: [0xffff.ffffffff] HSUB: [65535]
BH (0xb0fd8178) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xb0bea000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xb1f77a08,0xa9fdb7d0] lru: [0xb8fd4440,0xbefb6410]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh11: kdst_fetch' tch: 0 lfb: 33
flags:
BH (0xb1f77950) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xb1204000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xbdfcc8f0,0xb0fd8230] lru: [0xb0fd63f0,0xb8fd6b40]
lru-flags: moved_to_tail on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh11: kdst_fetch' tch: 0 lfb: 33
flags:
BH (0xbdfcc838) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xbdaba000
set: 5 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0xc2fb85f8,0xb1f77a08] lru: [0xbdfcc580,0xbef82138]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh01: kdstgr' tch: 0 lfb: 33
flags:
BH (0xc2fb8540) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0xc28a8000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x82ff4a00,0xbdfcc8f0] lru: [0xa1f95800,0xbefd9c00]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'kdswh11: kdst_fetch' tch: 0 lfb: 33
flags:
BH (0x82ff4948) file#: 7 rdba: 0x01c00084 (7/132) class: 1 ba: 0x82ed6000
set: 6 pool: 3 bsz: 8192 bsi: 0 sflg: 1 pwc: 0,15
dbwrid: 0 obj: 96892 objn: 96892 tsn: 9 afn: 7 hint: f
hash: [0x7bfaaa98,0xc2fb85f8] lru: [0xc2fc1870,0x82fdba78]
lru-flags: on_auxiliary_list
ckptq: [NULL] fileq: [NULL] objq: [NULL] objaq: [NULL]
st: FREE md: NULL fpin: 'ktspbwh2: ktspfmdb' tch: 0 lfb: 33
flags:
Block dump from disk:
buffer tsn: 9 rdba: 0x01c00084 (7/132)
scn: 0x0000.009bb102 seq: 0x01 flg: 0x04 tail: 0xb1020601
frmt: 0x02 chkval: 0x096c type: 0x06=trans data
Hex dump of block: st=0, typ_found=1
Dump of memory from 0x00007EFD5A631200 to 0x00007EFD5A633200
7EFD5A631200 0000A206 01C00084 009BB102 04010000 [................]
7EFD5A631210 0000096C 00000001 00017A7C 009BB102 [l.......|z......]
7EFD5A631220 00000000 0032F802 01C00080 00110008 [......2.........]
7EFD5A631230 00000F03 00C000F7 001F05F6 00008000 [................]
7EFD5A631240 009BAF43 00140001 00000B38 00C00D0B [C.......8.......]
7EFD5A631250 001304C9 00000001 00000000 00000000 [................]
7EFD5A631260 00000000 00030100 0018FFFF 1F5C1F74 [............t.\.]
7EFD5A631270 00001F5C 1F8C0003 1F741F80 00000000 [\.........t.....]
7EFD5A631280 00000000 00000000 00000000 00000000 [................]
Repeat 500 times
7EFD5A6331D0 00000000 00000000 0202022C 450504C1 [........,......E]
7EFD5A6331E0 45454545 0202002C 420503C1 42424242 [EEEE,......BBBBB]
7EFD5A6331F0 0202002C 410502C1 41414141 B1020601 [,......AAAAA....]
Block header dump: 0x01c00084
Object id on Block? Y
seg/obj: 0x17a7c csc: 0x00.9bb102 itc: 2 flg: E typ: 1 - DATA
brn: 0 bdba: 0x1c00080 ver: 0x01 opc: 0
inc: 0 exflg: 0

Itl Xid Uba Flag Lck Scn/Fsc
0x01 0x0008.011.00000f03 0x00c000f7.05f6.1f C--- 0 scn 0x0000.009baf43
0x02 0x0001.014.00000b38 0x00c00d0b.04c9.13 ---- 1 fsc 0x0000.00000000
bdba: 0x01c00084
data_block_dump,data header at 0x7efd5a631264
===============
tsiz: 0x1f98
hsiz: 0x18
pbl: 0x7efd5a631264
76543210
flag=--------
ntab=1
nrow=3
frre=-1
fsbo=0x18
fseo=0x1f74
avsp=0x1f5c
tosp=0x1f5c
0xe:pti[0] nrow=3 offs=0
0x12:pri[0] offs=0x1f8c
0x14:pri[1] offs=0x1f80
0x16:pri[2] offs=0x1f74
block_row_dump:
tab 0, row 0, @0x1f8c
tl: 12 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 02
col 1: [ 5] 41 41 41 41 41
tab 0, row 1, @0x1f80
tl: 12 fb: --H-FL-- lb: 0x0 cc: 2
col 0: [ 2] c1 03
col 1: [ 5] 42 42 42 42 42
tab 0, row 2, @0x1f74
tl: 12 fb: --H-FL-- lb: 0x2 cc: 2
col 0: [ 2] c1 04
col 1: [ 5] 45 45 45 45 45
end_of_block_dump
End dump data blocks tsn: 9 file#: 7 minblk 132 maxblk 132
对象号:seg/obj: 0x17a7c  装欢成十进制为: 96892


  03,数据对应


SQL> select object_id,data_object_id from dba_objects where object_name='T1' and  owner='TEST1';

OBJECT_ID DATA_OBJECT_ID
---------- --------------
96892 96892 --一致对应



Xid是由XIDUSN(Undo segmentnumber)、XIDSLOT(Slot number)+XIDSQN(Sequence number)三部分组成的。


查看事务:


SQL> set linesize 200
SQL> select xid,xidusn,xidslot,xidsqn,ubafil,ubablk,ubasqn,ubarec,status from v$transaction;

XID XIDUSN XIDSLOT XIDSQN UBAFIL UBABLK UBASQN UBAREC STATUS
---------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------------
01001400380B0000 1 20 2872 3 3339 1225 19 ACTIVE

SQL>

其中:

   XIDUSN=1    (1号回滚段)

   XIDSLOT=20  (在1号回滚段的事务表的第20行)

   XIDSQN=2872 (事务表第20行被覆盖了2872次)



与之对应 0x0001.014.00000b38 这个转换成十进制和上面一样的结果
0x00c00d0b.04c9.13 ==>
1100 0000 0000 1101  0000 1011
前两位为11 ==> 3
后面22为 ==> 3339
04c9 ==> 1225
13 ==> 19
和查询出来的UBAFIL     UBABLK    UBASQN    UBAREC STATUS 一模一样


查看当前SID:


SQL>  select sid from v$mystat where rownum=1;

SID
----------
26


查看锁:


SQL> select * from v$lock where sid=26;

ADDR KADDR SID TY ID1 ID2 LMODE REQUEST CTIME BLOCK
---------------- ---------------- ---------- -- ---------- ---------- ---------- ---------- ---------- ----------
00000000F5D41D40 00000000F5D41D98 26 AE 100 0 4 0 5158 0
00007EFD5A596338 00007EFD5A596398 26 TM 96892 0 3 0 567 0
00000000F1265A10 00000000F1265A88 26 TX 65556 2872 6 0 567 0


发现有一个TM锁的块就是那个我们的块