2-74 IBM Informix OnLine Database Server Administrator’s Guide

How OnLine Synchronizes Buffer Flushing

How OnLine Synchronizes Buffer Flushing
Bufferflushing occurs within the context of OnLine activity. When OnLine is
firstinitiated, all buffers are empty.As processing occurs, data pages are read
from disk into the buffers and user processes begin to modify these pages.
(Referto page 2-73for an explanation of the “before-images first” rule, which
isthe reason that synchronization is necessary.In addition, page 2-73lists the
four events thatprompt buffer-pool flushing and cross-references to further
backgroundinformation.)
Before a page in shared memory is modified for the first time, a copy of the
page“before-image” is written to the physical log buffer. Subsequent modifi-
cations to that page in shared memory do not result in additional “before-
images”being written to the physical log; only the first modification does so.
After each modification, a record of the change is written to the logical log
buffer if the database was created with logging or if the change affected the
database schema.
MLRUqueues begin to fill with modified pages. Each modified page includes
a timestamp that describes the time at which the page was modified.
Eventually the number of modified buffers in theMLRU queues reaches
LRU_MAX_DIRTY and page cleaning begins.
The pages in the physical log buffer are always flushed to disk prior to
flushing the pages that are contained in the modified buffers in the shared-
memory buffer pool. (Refer topage 2-73.)
When page cleaning is initiated from the shared-memory buffer pool, the
daemonprocess performing the page cleaning must coordinate the flushing
so that the physical log buffer is flushed first.
Howis this done? The answer is timestamp comparison. (Refer to page 2-44for
a definition of a timestamp.)
Shared memory contains a structure that stores a timestamp each time the
physical log buffer is flushed. If atbpgcl or tbinit daemon needs to flush a
page in a shared-memory buffer, the daemon process compares the
timestampin the modified buffer with the timestamp that indicates the point
when the physical log buffer was last flushed.