Monday, 12 August 2013

fractured block


Oracle works with database blocks in 2, 4, 8, 16, or 32k pieces.  Say 8k is what you are using.

operating systems read and write files using their own chunk size.  say 512bytes (1/2 k) for 
example -- a common size.

So, you are copying a datafile -- you are using the OS to do that.  You are reading it in 512byte 
chunks.

You start reading block 55 in file 5 using "copy".  You got 1/2 of the way through it (meaning you 
read 4k of data).  You get pre-empted and along comes DBWR who decides to lay down a new version of 
that block on disk (checkpoint, flush dirty buffers).  DBWR was lucky enough to write all 8k.  Your 
copy picks back up and reads the next 4k of the block -- but -- it is 4k of the block at a totally 
different point in time. 

This is known as a fractured block -- happens easily on a system with many people reading and 
writing the same file at the same time. 

Now, you restore this copy -- we have a block that is half at time T0 and half at time T1 -- we 
cannot recover that block -- UNLESS we just happened to keep the full block image from the first 
change after starting the backup elsewhere -- which is what we did.  So, we are able to recover 
this block using that image.

Note that if you use RMAN, this isn't an issue.  RMAN is not affected by OS vs DB block sizes -- it 
knows how to read an Oracle datafile safely, with RMAN backups, you don't put a tablespace into 
backup mode, it is not necessary.

No comments: