Oracle Internals Notes

Cache Header and Tail

All datafile blocks are written and read by the cache layer of the Oracle kernel (KCB) generally through the database buffer cache. The cache layer reads and maintains a 20-byte header and 4-byte tail on each data block, called the cache header and tail. The cache header is called the common block header in V$TYPE_SIZE and elsewhere. Controlfile blocks also have a cache header and tail, although not all the fields are used.

This is what the cache header and tail look like in a datablock dump.

buffer tsn: 0 rdba: 0x004000f8 (1/248)
scn: 0x0000.0001ab63 seq: 0x01 flg: 0x00 tail: 0xab630601
frmt: 0x02 chkval: 0x0000 type: 0x06=trans data
The header is comprised of the following fields.
database
block address
4 bytes The tablespace relative database block address (RDBA). This is constructed from the tablespace relative file number, and the block number of the data block within that file.
SCN 6 bytes The SCN at which the block was last changed. The low-order 4 bytes are called the SCN base, and the high-order 2 bytes are called the SCN wrap.
sequence 1 byte A sequence number incremented for each change to a block at the same SCN. A new SCN is allocated if the sequence number wraps.
flag 1 byte (I don't know.)
format 1 byte The format of the cache header was changed for Oracle8. Under Oracle8, the value is always 2. Previously, it was 1.
checksum 2 bytes An optional checksum of the block contents. When a block is written, the checksum is either cleared or set depending on the setting of the db_block_checksum parameter. When a block is read, the checksum is verified if present.
block type 1 byte The most common block types are:
1 = undo segment header block
2 = undo data block
5 = data segment header block
6 = data block
unused 4 bytes Unused space, possibly for backward or forward compatibility.
The physical order of the header fields is: block type, format, unused (2 bytes), RDBA, SCN, sequence, flag, checksum, unused (2 bytes).

The tail is comprised of the low-order two bytes of the SCN base followed by the block type and the sequence number. The consistency of the header and tail is checked whenever a block is read. This detects most block corruptions, in particular split blocks from hot backups.


© Ixora Pty Ltd.   All rights reserved.
05-Apr-2002
Search   Questions   Feedback   Up   Home