Information Technology Reference
In-Depth Information
2.3
Buffering and Fixing of Database Pages
When an instance of the database system is running, it is associated with a buffer
in main memory. The database buffer or buffer pool is an array BŒ1;2;:::;N of
page-sized buffer frames . If there are pages of varying size in the database, there
must be a buffer of its own for each different page size.
The number N of buffer frames is orders of magnitude smaller than the number
of pages in the database. Thus normally only a fraction of the set of pages in the
database can reside in the buffer at a time. It is possible to adjust the size of the
buffer, but it can seldom be more than a few thousand pages, whereas the database
may contain millions or even billions of pages.
Before reading or writing the contents of a page p in the database, the page must
be fetched from disk into some free buffer frame BŒi. A server-process thread that
accesses page p fixes ,or pins , p into the buffer for the duration of the page access.
If the page is not already in the buffer, the procedure call fix .p/ first fetches p from
disk into the buffer.
The buffer manager is not allowed to evict a fixed page from the buffer or to
move it to another buffer frame. Thus, the buffer-frame address passed to the server-
process thread that called fix stays valid for the duration of the fixing. After having
finished processing the page, the process must unfix ,or unpin , the page. A page can
be evicted from the buffer only when it is no longer fixed for any process.
Pages are evicted from the buffer only when the buffer is full and a buffer frame
needs to be assigned to a page p to be fetched from disk (by a fix .p/ call). Then
according to the least-recently-used ( LRU ) page-replacement policy, the page q is
evicted for which the longest time has passed since last being read or written; if that
page is a modified page, it must first be flushed onto disk.
A buffered page is a modified page if its contents differ from the disk version
of the page, that is, the page has been updated since it was last flushed onto disk.
Otherwise, if the contents of the buffer and disk versions of the page are the same,
thepageisan unmodified page .
For each buffered page, the buffer manager maintains a buffer control block in
the main memory, containing:
1. The page identifier of the page
2. The location of the page in the buffer (i.e., the address of the frame)
3. A fixcount that indicates how many process threads currently hold the page fixed
4. A modified bit that indicates whether or not the page has been updated since it
was last fetched from disk
5. P AGE -LSN : the log sequence number ( LSN ) of the log record for the last update on
the page (cf. Sect. 2.2 )
6. A pointer to a latch (semaphore) that controls concurrent accesses to the page
7. Links needed to maintain the LRU chain
Search WWH ::




Custom Search