
System Architecture 2-65
Physical Log Buffer
The contents ofthephysical log buffermust alwaysbeflushed to diskbefore
anydatabuffers.Thisruleisrequiredforfastrecovery.(Refertopage 4-39for
a definition of fast recovery. Refer to page 2-74 for a description of physical
log buffer flushing when it is prompted by the need to flush the shared-
memory buffer pool. Refer to page 2-72 for a description of the checkpoint
procedure.)
Flushing a Full Buffer
Buffer flushing that results from the physical log buffer becoming full
proceeds as follows.
When a user process needs to write a page to the physical log buffer, it
acquires the latch associated with the physical log buffer and the latch
associated withthe physicallog ondisk. Ifanother userprocess is writing to
the buffer, theincoming userprocess must wait for the latches to be released.
After the incoming user process acquires the latches, before the write, the
user process first checks the physical log for fullness. If the log is more than
75 percent full, the user process sets a flag to request a checkpoint, performs
the write to the physical log buffer, and then releases the latch. The check-
point cannot begin until all shared-memory latches, including this one, are
released.
If the log is less than 75 percent full, the user process compares the incre-
mented pagecounter inthe physicallog buffer header to the buffercapacity.
If this one-page write does not fill the physical log buffer, the user process
reserves space in thelog buffer for the write and releases the latch. Any user
process waiting to write to the buffer is awakened. At this point, after the
latch is released,the userprocesswritesthe page tothe reserved space inthe
physical log buffer. This sequence of events eliminates the need to hold the
latch during the write and increases concurrency.
If this one-page write fills the physical log buffer, flushing is initiated as
follows.
Comentarios a estos manuales