This article was published by
This article provides the Database Administrator a better understanding of checkpoint processing and a description of four key initialization parameters used for checkpoint tuning:
It also explains how to interpret and handle checkpoint errors ....
o Checkpoint not Complete
o Cannot Allocate New Log
.... reported in the ALERT
What is a Checkpoint ?
A Checkpoint is a database event which synchronizes the modifies data blocks in memory with the datafiles on disk. It offers Oracle the means for ensuring the consistency of data modified by transactions. The mechanism of writing modified blocks on disk in Oracle is not synchronized with the commit of the corresponding transactions.
A checkpoint has two purposes: (1) to establish data consistency, and (2) enable faster database recovery. How is recovery faster? Because all database changes up to the checkpoint have been recorded in the datafiles, making it unnecessary to apply redo log entries prior to the checkpoint. The checkpoint must ensure that all the modified buffers in the cache are really written to the corresponding datafiles to avoid the loss of data which may occur with a crash (instance or disk failure).
Oracle writes the dirty buffers to disk only on certain conditions:
o A shadow process must scan more than one-quarter of DB_BLOCK_BUFFER
o Every three seconds
o When a checkpoint is produced
A checkpoint is realized on five types of events:
o At each switch of the redo log files
o When the delay for LOG_CHECKPOINT_TIMEOUT is reached.
o When the size in bytes corresponding to:
o Directly by the ALTER SYSTEM SWITCH LOGFILE command.
o Directly with the ALTER SYSTEM CHECKPOINT command
During a checkpoint the following occurs:
o The database writer (DBWR) writes all modified database blocks in the buffer cache back to datafiles
o Log writer (LGWR) updates both the controlfile and the datafiles to indicate when the last checkpoint occurred (SCN).
The checkpoint process
The CHECKPOINT_PROCESS init.ora parameter determines whether or not the optional CKPT background process will be started to perform LGWRs tasks during checkpoint operations of updating the datafile headers. LGWR is then free to perform its' primary function flushing the redo log buffer to the online redo logs.
The CKPT process can improve performance significantly and decrease the amount of time users have to wait for a checkpoint operation to complete.The overhead associated with starting another background process is not significant when compared to the performance benefit to be gained by enabling CKPT, therefore, Oracle recommends always enabling the checkpoint process (CKPT).
Please note that this parameter is obsolete starting with Oracle8 and now the CKPT process is always started as part of the background processes.
Checkpoints and Performance
Checkpoints present a tuning dilemma for the Database Administrator. Frequent checkpoints will enable faster recovery, but can cause performance degradation. How then should the DBA address this?
Depending on the number of datafiles in a database, a checkpoint can be a highly resource intensive operation, since all datafile headers are frozen during the checkpoint. There is a performance trade-off regarding frequency of checkpoints. More frequent checkpoints enable faster database recovery after a crash. This is why some customer sites which have a very low tolerance for unscheduled system downtime will often choose this option. However, the performance degradation of frequent checkpoints may not justify this philosophy in many cases. Let's assume the database is up and running 95% of the time, and unavailable 5% of the time from infrequent instance crashes or hardware failures requiring database recovery. For most customer sites, it makes more sense to tune for the 95% case rather than the rare 5% downtime.
Redo logs and Checkpoint
A checkpoint occurs at every log switch. If a previous checkpoint is already in progress, the checkpoint forced by the log switch will override the current checkpoint.
This necessitates well-sized redo logs to avoid unnecessary checkpoints as a result of frequent log switches. The alert log is a valuable tool for monitoring the rate that log switches occur, and subsequently, checkpoints occur. Oracle recommends sizing the online redo logs such that switches occur no more than once per hour. The following is an example of quick log switches from the alert log:
Fri May 16 17:15:43 1997
If redo logs switch every 3 minutes, you will see performance degradation. This indicates the redo logs are not sized large enough to efficiently handle the transaction load.
Instance parameters related with the checkpoint process
The LOG_CHECKPOINT_INTERVAL init.ora parameter controls how often a checkpoint operation will be performed based upon the number of operating system blocks that have been written to the redo log.If this value is larger than the size of the redo log, then the checkpoint will only occur when Oracle performs a log switch from one group to another, which is preferred.
NOTE for Oracle 8.1
Starting with Oracle 8.1, LOG_CHECKPOINT_INTERVAL will be interpreted to mean that the incremental checkpoint should not lag the tail of the log by more than LOG_CHECKPOINT_INTERVAL number of redo blocks.
On most Unix systems the operating system block size is 512 bytes. This means that setting LOG_CHECKPOINT_INTERVAL to a value of 10,000 (the default setting), causes a checkpoint to occur after 5,120,000 (5M) bytes are written to the redo log. If the size of your redo log is 20M, you are taking 4
LOG_CHECKPOINT_INTERVAL influences when a checkpoint occurs, which means careful attention should be given to the setting of this parameter, keeping it updated as the size of the redo log files is changed. The checkpoint frequency is one of the factors which impacts the time required for the database to recover from an unexpected failure. Longer intervals between checkpoints mean that if the system crashes, more time will be needed for the database to recover. Shorter checkpoint intervals mean that the database will recover more quickly, at the expense of increased resource utilization during the checkpoint operation. This parameter also impacts the time required to complete a database recovery operation during the roll forward phase of recovery. The actual recovery time is dependent upon this time, and other factors, such as the type of failure (instance or system crash, media failure, etc.), and the number of archived redo logs which need to be applied.
The LOG_CHECKPOINT_TIMEOUT init.ora parameter controls how often a checkpoint will be performed based on the number of seconds that have passed since the last checkpoint.
NOTE for Oracle 8.1
LOG_CHECKPOINT_TIMEOUT will be interpreted to mean that the incremental checkpoint should be at the log position where the tail of the log was LOG_CHECKPOINT_TIMEOUT seconds ago.
Checkpoint frequency impacts the time required for the database to recover from an unexpected failure. Longer intervals between checkpoints mean that more time will be required during database recovery.
Oracle recommends using LOG_CHECKPOINT_INTERVAL to control the checkpoint interval rather than LOG_CHECKPOINT_TIMEOUT, which will initiate a checkpoint every "n" seconds, regardless of the transaction frequency.This can cause unnecessary checkpoints in cases where transaction volumes vary.Unnecessary checkpoints must be avoided whenever possible for optimal performance.
It is a misconception that setting LOG_CHECKPOINT_TIMEOUT to a given value will initiate a log switch at that interval, enabling a recovery window used for a stand-by database configuration. Log switches cause a checkpoint, but a checkpoint does not cause a log switch.The only way to cause a log switch is manually with ALTER SYSTEM SWITCH LOGFILE or resizing the redo logs to cause more frequent switches.This is controlled by operating system blocks, not a timed interval.
The LOG_CHECKPOINTS_TO_ALERT init.ora parameter, when set to a value of TRUE, allows you to log checkpoint start and stop times in the alert log.This is very helpful in determining if checkpoints are occurring at the optimal frequency and gives a chronological view of checkpoints and other database activities occurring in the background.
Understanding Checkpoint Error messages
Sometimes, you can see in your alert.log file, the following corresponding
Thread 1 advanced to log sequence 248
This message indicates that Oracle wants to reuse a redo log file, but the corresponding checkpoint associated is not terminated. In this case, Oracle must wait until the checkpoint is completely realized. This situation may be encountered particularly when the transactional activity is important.
This situation may also be checked by tracing two statistics in the BSTAT/ESTAT report.txt file. The two statistics are:
o Background checkpoint started.
o Background checkpoint completed.
These two statistics must not be different more than once. If this is not true, your database hangs on checkpoints. LGWR is unable to continue writing the next transactions until the checkpoints complete.
Three reasons may explain this difference:
o A frequency of checkpoints which is too high
o A checkpoints are starting but not completing
o A DBWR which writes too slowly.
The number of checkpoints completed and started as indicated by these statistics should be weighed against the duration of the bstat/estat report.Keep in mind the goal of only one log switch per hour, which ideally should equate to one checkpoint per hour as well.
The way to resolve incomplete checkpoints is through tuning checkpoints and logs:
o Give the checkpoint process more time to cycle through the logs
Add more redo log groups
o Reduce the frequency of checkpoints
o Set LOG_CHECKPOINT_TIMEOUT = 0
This disables the checkpointing based on time interval
Oracle Release Information
The CKPT process is optional in lower versions of Oracle7, but is mandatory in Oracle8.
In versions 7.0 - 7.3.2, the CKPT is an optional background process which is enabled by setting CHECKPOINT_PROCESS=TRUE in init.ora.
In versions 7.3.3 and 7.3.4, the CKPT process will be started automatically regardless of the CHECKPOINT_PROCESS setting if either of the following conditions exist:
o a large value for DB_FILES (50 or higher)
o a large value for DB_BLOCK_BUFFERS (10,000 or higher)
In version 8.0.3 and higher, the CKPT process is always enabled. Attempting to set CHECKPOINT_PROCESS in the init.ora will give the following error:
LM-101 "unknown parameter name checkpoint_process"
8i Parameters that influence Checkpoints
In Oracle8i, there are a couple of things that cause checkpointing to occur. They are:
o FAST_START_IO_TARGET init.ora parameter
o LOG_CHECKPOINT_TIMEOUT init.ora parameter
o LOG_CHECKPOINT_INTERVAL init.ora parameter
o Size of the smallest log
Oracle continually calculates where the checkpoint position must be in order to satisfy these things, and writes dirty buffers in order of age to advance the checkpoint position such that all of these targets are met. When it advances the checkpoint, it does not advance it to the end of the log. Rather, it advances it far enough to satisfy all of the targets corresponding to the items above.
Oracle continually calculates the number of IO operations that would be required to perform roll-forward should the database fail. If this number is greater than FAST_START_IO_TARGET, Oracle writes dirty buffers and advances the checkpoint to satisfy this target. FAST_START_IO_TARGET is only useable on 8i Entreprise Edition.
Assume this is set to 60. Oracle continually calculates the address of the redo record that was written 60 seconds ago. In order to satisfy this parameter, the checkpoint position must advance at least as far as this redo record. Should the checkpoint position point to a redo record older than this target position (written over 60 seconds ago), Oracle writes dirty buffers and advances the checkpoint until it points at a redo record written less than 60 seconds ago. Should the checkpoint position point to a redo record newer than this target position (written less than 60 seconds ago), Oracle does nothing to satisfy this target for it is already satisfied.
Assume this is set to 1000. Oracle continually calculates the address of the redo record that was written 1000 records (OS blocks) ago. In order to satisfy this parameter, the checkpoint position must advance at least as far as this redo record. Should the checkpoint position point to a redo record written earlier than this target position (written over 1000 records before the record at the end of the log), Oracle writes dirty buffers and advances the checkpoint until it points at a redo record written less than 1000 records ago. Should the checkpoint position point to a redo record newer than this target position (written less than 1000 records ago), Oracle does nothing to satisfy this target for it is already satisfied.
Size of smallest REDO LOG
Oracle forces LOG_CHECKPOINT_INTERVAL to be no greater than 90% of the size of the smallest log file. This guarantees that when Oracle tries to do a log switch because it has filled a redo log file, the checkpoint position will have advanced into this current log. Should you only have two logs (the worst case), Oracle does not have to stall while the checkpoint advances out of the soon to be reused log.
So, when Oracle does a checkpoint due to a log switch, it does not really have to do anything. The checkpoint position is already advanced out of the soon to be reused log. The log switch checkpoint does not actually do anything right away. It is a "zero priority" checkpoint: it does not cause any writes to happen on its own, but is marked as complete only when checkpointing for other reasons causes the checkpoint position to advance beyond the rba that marked the end of the log when the checkpoint was initiated.
Assume you have two logs, A and B. When B fills, Oracle initiates a zero priority checkpoint to advance the checkpoint position to the end of log B. However, because the checkpoint position is no more than 90% of the size of the smallest log behind the end of the log, the checkpoint position is roughly 10% of the way into log B when this checkpoint is initiated. There is no reason to do any writes, as log A can be reused immediately. So Oracle does nothing and lets the checkpoint position continue to advance based upon other factors. When the other factors cause the checkpoint position to advance beyond the end of log B, the zero priority checkpoint previously initiated is declared complete and you see the checkpoint complete message.
If you manually switch log files, the checkpoint position may not have advanced out of the log to be reused. In this case, Oracle initiates a real checkpoint and advances the checkpoint position up to the rba that marked the end of the log when the checkpoint was initiated.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/26706/viewspace-64596/，如需转载，请注明出处，否则将追究法律责任。