Oracle Internals Notes

Log Buffer Usage

The Oracle log buffer is internally divided into blocks. Each active block in the log buffer maps to a block in the current online log file. The size of the log file and log buffer blocks is a platform specific constant, and is not related to the database block size. The log buffer blocks are reused cyclically until a log buffer block maps to the last block in the log file.

For example the instance illustrated in the following figure has 100 log blocks in its log buffer. After a log switch, an SGA variable (b) is set to indicate that the base disk block for the log buffer is block 2. Another SGA variable (i) is used for the index into the log buffer for redo generation. This is shown as pointing to log buffer block 30 shortly after the log switch. A little later, after several log writes have occurred, the base disk block for the log buffer is disk block 82. This maps to log buffer block 81. Redo generation continues and wraps from log buffer block 100 to log buffer block 1. At the moment illustrated the index into the log buffer for redo generation is block 5. This maps to disk block 106. The log buffer is used cyclically in this way until i maps to the last block in the log file.

How blocks in the log buffer map to block in the log files

The variables b and i are both protected by the redo allocation latch. Thus the redo allocation latch is needed not only to allocate space in the log buffer for redo generation, but also to free space in the log buffer after each redo write.

According to bug 182447, the variables shown here as b and i are actually called kcrfsfbb and kcrfsfi internally. They appear to reside in the kcrfsg structure.


© Ixora Pty Ltd.   All rights reserved.
28-Mar-2002
Search   Questions   Feedback   Up   Home