Average Active Sessions (AAS) The Golden Metric ? Kyle Hailey .
Redo Waits Kyle Hailey [email protected]. #.2 Copyright 2006 Kyle Hailey Redo REDO Lib Cache...
-
Upload
beverley-bishop -
Category
Documents
-
view
225 -
download
0
Transcript of Redo Waits Kyle Hailey [email protected]. #.2 Copyright 2006 Kyle Hailey Redo REDO Lib Cache...
Copyright 2006 Kyle Hailey
#.2
Redo
REDOREDO Lib Lib CacheCache
Buffer Buffer CacheCache
LocksLocks
NetworkNetwork
I/OI/O
Copyright 2006 Kyle Hailey
#.3
In This Section:
1. Log Buffer Space
2. Log File Sync
3. Log File Switch Completion
4. Log File Switch (checkpoint incomplete)
5. Log File Switch (private strand flush incomplete)
6. Log File Switch (archiving needed)
7. Switch Log File Command
Copyright 2006 Kyle Hailey
#.4
Log File Waits
REDO Log FilesREDO Log Files Data FilesData Files
DBWRDBWRLGWRLGWR
User2User2
User1User1
User3User3
Log BufferLog Buffer
Buffer CacheBuffer CacheLog Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
Copyright 2006 Kyle Hailey
#.5
Log File Operations
Redo is written to disk whenUser commitsLog Buffer 1/3 full (_log_io_size)Log Buffer fills 1MEvery 3 secondsDBWR asks LGWR to flush redo
Sessions Commiting wait for LGWR
Copyright 2006 Kyle Hailey
#.6
log buffer space
Wait for space in the redo log buffer in SGA Solution
1. Increase log_buffer parameter in init.ora Above 3M log_buffer little affect, if still a problem then
backup is at disk level
2. Improve disk IO for redo Faster disk Raw file Direct IO Dedicated disk
p1, p2, p3 – no values
Copyright 2006 Kyle Hailey
#.7Log Buffer Space
REDO Log FilesREDO Log Files
Log BufferLog Buffer
LGWRLGWR
Buffer CacheBuffer Cache
User2User2
User1User1
User3User3
Insert Insert UpdateUpdatedeletedelete
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
1.1. Log Buffer too smallLog Buffer too small
2.2. LGWR too slowLGWR too slow
• Disk problemDisk problem
Copyright 2006 Kyle Hailey
#.8
log file sync Wait for redo flush upon:
CommitRollback
ArgumentsP1 = buffer# in log buffer that needs to be flushedP2 = not usedP3 = not used
select parameter1, parameter2, parameter3 select parameter1, parameter2, parameter3 from v$event_namefrom v$event_namewhere name=‘log file sync';where name=‘log file sync';
PARAMETER1 PARAMETER2 PARAMETER3PARAMETER1 PARAMETER2 PARAMETER3
---------- ---------- -------------------- ---------- ----------
buffer#buffer#
Copyright 2006 Kyle Hailey
#.9Log File Sync
REDO Log FilesREDO Log Files Data FilesData Files
DBWRDBWRLGWRLGWR
User2User2
User1User1
User3User3
Commit;Commit;
wait for LGWRwait for LGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
Copyright 2006 Kyle Hailey
#.10
Log File Sync: Solutions Commit less
Often possible in PL/SQL loops that commit every loop Commit every 50 or 100 instead
Put redo on dedicated disk Use Raw Device or Direct IO More Radical
Consider Ram Disks Can stripe if redo writes are comparable to stripe size
Striping shouldn’t heard Striping can help
Ex: imp – can have large redo writes – can improve by 10-30%
Alternate disks for redo and archiving of redo Possibly 10gR2
ALTER SYSTEM SET COMMIT_WRITE = BATCH, NOWAIT Commit could be lost if machine crash Or IO error
Copyright 2006 Kyle Hailey
#.11
Separating LGWR and ARCH
Redo 1Redo 1
Redo 3Redo 3
Redo 2Redo 2
Redo 4Redo 4
LGWRLGWR ARCHARCH
Copyright 2006 Kyle Hailey
#.12
Log file switch completion
No p1,p2,p3 Wait for lgwr to switch log files when
generating redo Solution:
Increase redo log file size Reduce frequency of switches
Copyright 2006 Kyle Hailey
#.13
Log File Switch completion
Log File Switch stepsA lot of activity:
Get next log file from control file Get Redo Copy and Redo Allocation latch Flush redo Close File Update Controlfile
Set new file to Current Set old file to Active If in Archivelog mode add file to archive list Open all members of new logfile group Write the SCN to the headers Enable redo log generation
DBWR makes a list of DBWR makes a list of blocks that need to be blocks that need to be written out in order to over written out in order to over write the Redo log file a write the Redo log file a list of blocks that need to list of blocks that need to be written out in order to be written out in order to over write the Redo log over write the Redo log
filefile
Copyright 2006 Kyle Hailey
#.14
log file switch completion
REDO Log FilesREDO Log Files Data FilesData Files
Log BufferLog Buffer
DBWRDBWRLGWRLGWR
Buffer CacheBuffer Cache
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Wait : log file switch completion
User2User2User1User1
User3User3
User2User2User1User1
User3User3
Commit;Commit;
Wait for Wait for LGWRLGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
11 22 33
11
Sessions Sessions writing redo writing redo wait while wait while switch happensswitch happens
Copyright 2006 Kyle Hailey
#.15
log file switch (checkpoint incomplete)
No p1,p2,p3 args Wait for checkpoint to complete because all
log files are full Solutions
Add more log files Increase size of log files
Copyright 2006 Kyle Hailey
#.16log file switch (checkpoint incomplete) : Diag
REDO Log FilesREDO Log Files Data FilesData Files
Log BufferLog Buffer
LGWRLGWR
Buffer CacheBuffer Cache
User2User2User1User1
User3User3
Commit;Commit;
Wait for Wait for LGWRLGWR
Checkpoint 1Checkpoint 1
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Checkpoint 2Checkpoint 2
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Checkpoint 3Checkpoint 3
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
11
22
33
33
Sessions Sessions writing redo writing redo wait while wait while switch happensswitch happens
And checkpoint And checkpoint happenhappen
Copyright 2006 Kyle Hailey
#.17
log file switch (archiving needed)
No p1,p2,p3 Database “hangs” for transactions
archive log stop;
-- make room in log_archive_dest
archive log start;
Copyright 2006 Kyle Hailey
#.18
log file switch (archiving needed) :
Diag
REDO Log FilesREDO Log Files Archive DestArchive Dest
ARCHARCH
LGWRLGWRUserUser
22UserUser11 UserUser
33
Commit;Commit;
Wait for Wait for LGWRLGWR
Log BufferLog Buffer
Buffer CacheBuffer Cache
Log BufferLog Buffer
Buffer CacheBuffer CacheLog Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
33
Copyright 2006 Kyle Hailey
#.19
switch logfile command
Same as log file switch completion but the command is executed by the dbaAlter system switch logfile;
Copyright 2006 Kyle Hailey
#.20
Concerns – Recovery Time
What happens to recovery time if I change my redo log file sizes
Larger Redo Log size can increase recovery time but
There are init.ora parameters to limit this
Standby DB: ARCHIVE_LAG_TARGET Seconds, limits lag between primary and standby Increases log file switches
Copyright 2006 Kyle Hailey
#.21
Incremental Checkpoints (9iR2+) FAST_START_MTTR_TARGET
Seconds to RecoveryEasy and accuracy Is overridden by FAST_START_IO_TARGET Is overridden by LOG_CHECKPOINT_INTERVAL
SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;
ESTIMATED_MTTR-------------- 21
SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;
ESTIMATED_MTTR-------------- 21
alter system set fast_start_mttr_target=17 scope=both;alter system set fast_start_mttr_target=17 scope=both;
Copyright 2006 Kyle Hailey
#.22
Recovery and Checkpoints
REDO Log FilesREDO Log Files
Data FilesData Files
DBWRDBWR
LGWRLGWR
Log Log BufferBuffer
Buffer Buffer CacheCache
SGASGALibrary Library CacheCache
Incremental CheckpointIncremental Checkpoint
Current PositionCurrent Position
Needed for RecoveryNeeded for Recovery11 22 33
Copyright 2006 Kyle Hailey
#.23
DBWR dirty List and LGWRBuffers
Checkpoint aCheckpoint a
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
LGWRLGWR
DBWRDBWR
Current PositionCurrent Position
Incremental CheckpointIncremental CheckpointDBWRDBWR
DBWR usually DBWR usually just writes out just writes out dirty blocks at dirty blocks at end of LRU end of LRU until checkpointuntil checkpoint
Now, DBWR Now, DBWR keeps a keeps a checkpoint listcheckpoint list
That it cleans aThat it cleans a
Copyright 2006 Kyle Hailey
#.24
DBWR dirty List
MRU - HotMRU - Hot LRU - ColdLRU - ColdBuffer Headers
Dirty ListDirty List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWRDBWR also has to track dirty DBWR also has to track dirty blocks at the cold end of the blocks at the cold end of the LRULRU
Copyright 2006 Kyle Hailey
#.25
DBWR merges Dirty and Checkpoint
MRU - HotMRU - Hot LRU - ColdLRU - ColdBuffer Headers
Dirty ListDirty List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
DBWRDBWRCheckpoint aCheckpoint a
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx
Write ListWrite List
Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxx Block xxxxBlock xxxx Data FilesData Files
There are 2 checkpoint listsThere are 2 checkpoint listsOne the DBWR can write toOne the DBWR can write to disk While users can disk While users can concurrently update the otherconcurrently update the other
Copyright 2006 Kyle Hailey
#.26
log file switch (private strand flush incomplete)
New wait 10g Like a “log file switch Completion”
Copyright 2006 Kyle Hailey
#.27
Redo Wait Solutions
2 log file syncCommit less, put redo logs on faster disks
11 log buffer spaceIncrease log buffer no more than 32M, then tune LGWR
12 log file switch completionIncrease log file sizes
22 log file switch (checkpoint incomplete)Add log files (or increase log file size)
30 switch logfile commandAvoid switching log files
32 log file switch (archiving needed) ***Archive log running out of space