At this point the process may need to post LGWR to signal that it should begin to flush the log buffer. This applies if the allocation raised the number of used blocks in the log buffer above the background write threshold, or if a commit marker has been copied into the redo stream and needs to be synced. However, to ensure that LGWR is not posted needlessly, the process takes the redo writing latch to check whether LGWR is already active or has already been posted. The redo writing latch is then released, and if appropriate the LGWR process is posted.
The redo allocation latch is needed again by processes waking up from log file sync waits,
to check whether the log buffer block containing the redo of interest has yet been written to disk.
If not, that process must continue to wait.
The SGA variable that shows whether a particular log buffer block has yet been written to disk
is the index into the log file representing the base disk block for the log buffer.
This variable is of course protected by the redo allocation latch, and so the redo allocation latch must be taken to check it.
Similarly, DBWn needs the redo allocation latch to check whether the high RBA of a set blocks that it intends to write has yet been synced.
如果分配的空间使用超过了_log_io_size参数的设置,或者重做流中包含了提交标记符,此时进程可能需要唤醒lgwr并通知刷新日志缓冲。为了确 保lgwr不会不必要的被唤醒,进程将采用redo writing latch检查lgwr是否active或者已经被唤醒。然后释放redo writing latch。
LGWR使用redo latches的机制
获得redo latches不仅仅与重做产生和log file
sync有关,同时它们也被lgwr用来写重做到日志文件上。当lgwr被唤醒的时候,其首先得到redo writing
latch更新sga变量指示其active状态,以避免其他进程不必要的唤醒lgwr。如果没有被唤醒,lgwr将获得redo
allocation latch确定是否有重做可写。如果没有,在启动rdbms ipc message前,将重新得到redo writing
latch指示其不再active。
如果有任何重做可写,lgwr将会为redo copy
latches预计latch恢复区域以确定重做缓冲中是否有任何不完整的拷贝需要写。如果有,lgwr将在LGWR wait for redo
copy上沉睡,并且在需要的copy latches被释放后被唤醒。
LGWR用来得到redo writing latch,redo allocation latch和redo copy latches花费的时间的和累计在redo writer latching time统计中。
在每次写完成后,LGWR必须再次得到redo allocation latch更新饱含日志缓冲基磁盘块的sga变量。使用这种机制高效的释放日志缓冲块,并可以重用。
redo latches的调整
通常仅在redo allocation latch上的等待模式未命中率很高或者redo copy latch上的非等待模式很高时,才考虑调整redo latch。
Redo Allocation
在每个实例中只有一个redo allocation,并且不能并行使用。通常也没有办法减少latch保持的延迟。DBA能做的通常只是减少LATCH上的负载。最重要的是确保LGWR不能过分活跃,并且DBWn不能过渡频率的检查点最近的改变。
在应用程序级别,主要频繁的commit,避免SELECT FOR UPDATE和before行触发器,以及最小化redo的产生。
Redo Copy
在Oracle 8.1下,LGWR自身是不会在redo copy
latch上沉睡的,在这些latch上的沉睡指示并行性的程度超过了latch支持的并行度。在这种情况下, redo copy
latch可以使用 _log_simultaneous_copies参数增加,但是不能超过32的限制。
总的来说,除非产生的重做最小化了并且redo allocation已经调整过了,否则不应该调整redo copy latch。同时也应该检查latch持有者的CPU短缺问题。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/7928987/viewspace-364438/ ,如需转载,请注明出处,否则将追究法律责任。