本文地址:https://www.askmaclean.com/archives/fast-path-redo-algorithms.html
LGWR写redo的伪代码
while(1)
{
/* The RBA can be stored into rba_pga; The pic keeps meta-data
corresponding to each write. */
Read RBA corresponding to end of last write issued and store into rba_pga;
for (each strand)
{
/* Start address for the write and is a pointer within the
strand buffer up to which the last write went to disk.
The LGWR then does a dirty read of the pointer within the
strand buffer where the latest redo block is being allocated.
The range of redo from the start address to the dirty read is
referred to as the "potential range" because it will most
likely make it to disk. The final range within each strand that
together forms a consistent set of redo will be determined by
the "extend" range step under the redo alloc latch (RAL). */
Pick potential range within strand that will go into the next
write issued to the logfile;
kcrfa[strand#].potential_end = ptr to latest redo;
}
/* Bumping the SCN after picking the range in the above step makes it
unnecessary to contract the range in the "extend" step below.
Range expansion is easy because strand meta-data points to the
start of a LWN. */
Bump SCN and store into scn_pga;
for (each strand)
{
/* Get redo alloc latch for strand */
Get RAL[strand#];
kcrfa[strand#].rba = rba_pga;
kcrfa[strand#].scn = scn_pga;
/* This uses kcrfa[strand#].potential_end as an optimized starting
point to traverse the forward redo block allocation links including all blocks of redo with SCN less than scn_pga. */
Extend strand write range to include all redo with SCN less than
scn_pga;
/* Free redo alloc latch for strand */
Free RAL[strand#];
}
Issue write to logfile;
}