Sie sind auf Seite 1von 27

Redo Waits

Kyle Hailey
Kyle.hailey@hotmail.com
#.2

Redo

Locks

REDO Lib Buffer


Cache Cache

Network

I/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
SGA
Log Library Buffer
Buffer Cache Cache
Buffer Cache
Log Buffer
DBWR
LGWR
User1

User2

User3

REDO Log Files Data Files


Copyright 2006
Kyle Hailey
#.5

Log File Operations


 Redo is written to disk when
 User commits
 Log Buffer 1/3 full (_log_io_size)
 Log Buffer fills 1M
 Every 3 seconds
 DBWR 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
Log Buffer Space
#.7

SGA
Log Library Buffer
Buffer Cache Cache
Buffer Cache
Log Buffer

LGWR
User1
1. Log Buffer too small
User2
2. LGWR too slow
User3 • Disk problem
Insert
Update
REDO Log Files delete
Copyright 2006
Kyle Hailey
#.8
log file sync
 Wait for redo flush upon:
 Commit
 Rollback

 Arguments
 P1 = buffer# in log buffer that needs to be flushed
 P2 = not used
 P3 = not used
select parameter1, parameter2, parameter3
from v$event_name
where name=‘log file sync';
PARAMETER1 PARAMETER2 PARAMETER3
---------- ---------- ----------
buffer# Copyright 2006
Kyle Hailey
Log File Sync #.9

SGA
Log Library Buffer
Buffer Cache Cache

DBWR
LGWR
User1

User2

User3

Commit;
REDO Log Files Data Files
wait for LGWR
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

LGWR ARCH

Redo 1 Redo 2

Redo 3
Redo 4

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 steps DBWR makes a list of
A lot of activity: blocks that need to be
written out in order to over
write the Redo log file a
 Get next log file from control file
list of blocks that need to
 Get Redo Copy and Redo Allocation latch
be written out in order to
 Flush redo over write the Redo log
 Close File
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

Copyright 2006
Kyle Hailey
#.14
log file switch completion 1
Block xxxx
SGA Block xxxx
Sessions Log Library Buffer Block xxxx
Block xxxx
writing redo Buffer Cache Cache
Buffer Cache Block xxxx
wait while Block xxxx

switch happens Log Buffer Block xxxx


Block xxxx

DBWR
LGWR
User2
User1
User3

Commit;
1 2 3 Wait for
REDO Log Files LGWR Data Files
Wait : log file switch completion
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
log file switch (checkpoint incomplete)#.16: D
Sessions SGA Checkpoint 1 1
writing redo Log Library Buffer Block xxxx
wait while
Checkpoint 2
Block xxxx 2
Buffer Cache Cache
Buffer Cache Block xxxx
Block xxxx
switch happens BlockCheckpoint
Block xxxx xxxx 3
3
Log Buffer BlockBlock
Block xxxx xxxx xxxx
And checkpoint BlockBlock
Block xxxx xxxx xxxx
BlockBlock
Block xxxx xxxx xxxx
happen DBWRBlockBlock
Block xxxx xxxx xxxx
LGWR BlockBlock
xxxx xxxx
BlockBlock
xxxx xxxx
Block xxxx
User2 Block xxxx
User1
User3

Commit;
3 Wait for
REDO Log Files LGWR Data Files

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
SGA
Log Library Buffer
Buffer Cache Cache
Buffer Cache
Log Buffer
User
LGWR User 2
1 User
ARCH
3
Commit;
Wait for
3 LGWR
REDO Log Files Archive Dest

Copyright 2006
Kyle Hailey
#.19

switch logfile command


 Same as log file switch completion but the
command is executed by the dba
 Alter 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 Recovery
 Easy and accuracy
 Is overridden by FAST_START_IO_TARGET
 Is overridden by LOG_CHECKPOINT_INTERVAL

alter system set fast_start_mttr_target=17 scope=both;

SQL> select ESTIMATED_MTTR from V$INSTANCE_RECOVERY;


ESTIMATED_MTTR
--------------
21

Copyright 2006
Kyle Hailey
#.22
Recovery and Checkpoints
SGA
Log Library Buffer DBWR
Buffer Cache Cache

LGWR
Data Files

Current Position

Needed for Recovery


1 2 3
Incremental Checkpoint

REDO Log Files Copyright 2006


Kyle Hailey
#.23

DBWR dirty List and LGWR


Buffers

DBWR usually
just writes out
Current Position LGWR dirty blocks at
end of LRU
until checkpoint
Incremental Checkpoint
DBWR
Checkpoint a
Now, DBWR Block xxxx
keeps a Block xxxx
checkpoint list Block xxxx
Block xxxx
That it cleans a
Copyright 2006
Kyle Hailey
#.24

DBWR dirty List


MRU - Hot Buffer Headers LRU - Cold

Dirty List
Block xxxx
Block xxxx
Block xxxx
Block xxxx

DBWR
DBWR also has to track dirty
blocks at the cold end of the
LRU
Copyright 2006
Kyle Hailey
#.25
DBWR merges Dirty and
Checkpoint
MRU - Hot Buffer Headers LRU - Cold

Checkpoint a Dirty List


Block xxxx
Block xxxx
Block xxxx
Block xxxx
DBWR
Block xxxx Block xxxx
Block xxxx Block xxxx

There are 2 checkpoint lists Write List


One the DBWR can write to
disk While users can Block xxxx
concurrently update the other Block xxxx
Block xxxx
Block xxxx Data Files
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 sync
Commit less, put redo logs on faster disks
11 log buffer space
Increase log buffer no more than 32M, then tune LGWR
12 log file switch completion
Increase log file sizes
22 log file switch (checkpoint incomplete)
Add log files (or increase log file size)
30 switch logfile command
Avoid switching log files
32 log file switch (archiving needed) ***
Archive log running out of space
Copyright 2006
Kyle Hailey

Das könnte Ihnen auch gefallen