Thread: flush buffer cache

This question is answered. Helpful answers available: 5. Correct answers available: 1.


Permlink Replies: 26 - Pages: 2 [ Previous | 1 2 ] - Last Post: Jul 12, 2009 10:19 PM Last Post By: Don Lewis
Zapotocny

Posts: 21
Registered: 06/13/09
Re: flush buffer cache
Posted: Jun 13, 2009 11:12 PM   in response to: Aman.... in response to: Aman....
 
Click to report abuse...   Click to reply to this thread Reply
Hi Aman and Sb

I think I misunderstand the concept:

ALTER SYSTEM FLUSH BUFFER CACHE;

This statement do not delete the data inside the buffer cache, it writes everything to inside to cache to disk. (like checkpoint)
Is that correct?

Girish Sharma

Posts: 983
Registered: 07/30/07
Re: flush buffer cache
Posted: Jun 13, 2009 11:26 PM   in response to: sb92075 in response to: sb92075
 
Click to report abuse...   Click to reply to this thread Reply
I too found the same link for the topic in this thread; but i am not finding the documentation link which says that checkpoint will occur in the following events. Can you please post the link from official documentation of 9i and/or 10g?

Regards
Girish Sharma
Aman....

Posts: 8,910
Registered: 05/20/01
Re: flush buffer cache
Posted: Jun 13, 2009 11:44 PM   in response to: Zapotocny in response to: Zapotocny
 
Click to report abuse...   Click to reply to this thread Reply
Zapotocny wrote:
Hi Aman and Sb

I think I misunderstand the concept:

ALTER SYSTEM FLUSH BUFFER CACHE;

This statement do not delete the data inside the buffer cache, it writes everything to inside to cache to disk. (like checkpoint)
Is that correct?

Nope. You must remember tthat checkppointing is an event which further causes ddbwr to write. Iit itself doesnt write and neither does ckpt does any io by iself. at flsh command, indeed cache is made empty and data is writeen to disk.

HTH
Aman.....
Zapotocny

Posts: 21
Registered: 06/13/09
Re: flush buffer cache
Posted: Jun 14, 2009 12:01 AM   in response to: Aman.... in response to: Aman....
 
Click to report abuse...   Click to reply to this thread Reply
so as a result;

after;
ALTER SYSTEM FLUSH BUFFER CACHE;

data is written to disk and cache is made empty.

Is it right? I was thinking previously that, all the data in cache is deleted and not writen to datafiles

Aman....

Posts: 8,910
Registered: 05/20/01
Re: flush buffer cache
Posted: Jun 14, 2009 12:55 AM   in response to: Zapotocny in response to: Zapotocny
 
Click to report abuse...   Click to reply to this thread Reply
yup its correct!

Aman....

PS- If you are clear with question, mark the helpful an correct replies and close the thread.

Aman....
Zapotocny

Posts: 21
Registered: 06/13/09
Re: flush buffer cache
Posted: Jun 14, 2009 1:49 AM   in response to: Zapotocny in response to: Zapotocny
 
Click to report abuse...   Click to reply to this thread Reply
..
Jonathan Lewis

Posts: 1,794
Registered: 01/23/07
Re: flush buffer cache
Posted: Jun 14, 2009 2:15 AM   in response to: Zapotocny in response to: Zapotocny
 
Click to report abuse...   Click to reply to this thread Reply
Zapotocny wrote:
so as a result;

after;
ALTER SYSTEM FLUSH BUFFER CACHE;

data is written to disk and cache is made empty.


The purpose of "alter system flush buffer cache" is to make all the buffers in the buffer cache free. However a buffer cannot become free if it is "pinned" (i.e. actualy in use) or if it is "dirty" (i.e. needs to be written to disc). There's nothing that Oracle can do about the pinned buffers, but it can write the content of the dirty buffers to disk before freeing them. Your description here is a good enough approximation.

Side not regarding checkpoints: there was a link to a list of checkpoint reasons earlier on, but things keep changing in Oracle and the manuals (and commentary) don't always keep up. In 10.2 there are lots more checkpoints than shown in the previous list. (I've published a list, which I think was complete, of checkpoint names on my blog a couple of years ago).

If you're interested in seeing the effect of the call, you could run this query (as SYS) before and after:

select 
	status, count(*) 
from 
	v$bh 
group by 
	status
;

Responding to another detail mentioned above relating to that list of checkpoints - again things change. A log file switch used to result in an immediate thread checkpoint, but in 10.2 Oracle got even lazier about clearing the dirty blocks, and will only start a thread checkpoint if the switch takes it into the "last available" redo log. Otherwise it just hopes that the incremental checkpointing activity will allow the "first" log file to become free again in time for the next switch.

Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk

"For every expert there is an equal and opposite expert."
Arthur C. Clarke

Zapotocny

Posts: 21
Registered: 06/13/09
Re: flush buffer cache
Posted: Jun 14, 2009 2:28 AM   in response to: Jonathan Lewis in response to: Jonathan Lewis
 
Click to report abuse...   Click to reply to this thread Reply
Thanks Jonathan
I appreciate that.
You have been really helpfull.

If I want to write dirty blocks to datafiles, I can issue either "alter system checkpoint" or "alter system flush buffer_cache"

Is that right?
Jonathan Lewis

Posts: 1,794
Registered: 01/23/07
Re: flush buffer cache
Posted: Jun 14, 2009 2:57 AM   in response to: Zapotocny in response to: Zapotocny
 
Click to report abuse...   Click to reply to this thread Reply
Zapotocny wrote:
Thanks Jonathan
I appreciate that.
You have been really helpfull.

If I want to write dirty blocks to datafiles, I can issue either "alter system checkpoint" or "alter system flush buffer_cache"

Is that right?


That is correct - the impact and side effects are quite different though.
It's possible that the rate at which the database writer writes may be different (there is a "priority" concept that might be set differently for the two commands); and when you flush the cache you (or other sessions) may have to re-read the data that they had been using if they still need it, so the flush could be followed by an enormous I/O load as these reads take place.

Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk

New Scientist: "Would you prefer a cautious expert or a confident ignoramus"
http://www.newscientist.com/article/mg20227115.500-humans-prefer-cockiness-to-expertise.html

Don Lewis

Posts: 192
Registered: 06/11/09
Re: flush buffer cache
Posted: Jun 14, 2009 3:09 AM   in response to: Jonathan Lewis in response to: Jonathan Lewis
 
Click to report abuse...   Click to reply to this thread Reply
I have seen 2-node RAC systems (I imagine it could be a lot worse with >2 nodes) grind to a halt, finally leading to CRS node reboot, followed by a slooooow recovery, following cache flushing, probably owing to just this cause.

Regards - Don Lewis
Jonathan Lewis

Posts: 1,794
Registered: 01/23/07
Re: flush buffer cache
Posted: Jun 14, 2009 4:31 AM   in response to: Don Lewis in response to: Don Lewis
 
Click to report abuse...   Click to reply to this thread Reply
Don Lewis wrote:
I have seen 2-node RAC systems (I imagine it could be a lot worse with >2 nodes) grind to a halt, finally leading to CRS node reboot, followed by a slooooow recovery, following cache flushing, probably owing to just this cause.

There are four or five effects that could come together to cause this:

    a) The flush could cause an I/O overload on the disc subsystem

    b) As current blocks are written from this note, interconnect traffic has to go to other nodes to tell them to flush their PI buffers.

    c) As buffers are freed, the global cache resources and locks have to be updated and released, leading to increased CPU and interconnect traffic. You will have local shadows for every buffer freed and remote resources for typically (n-1)/nths (viz. half in the case of two nodes) of the buffers.

    d) As the cache clears, other processes on your node (and on the nodes which have released their PIs) are likely to want re-read at least some of the blocks from disc - so the I/O subsystem picks up another load, and the interconnect gets another load as global resources and locks are negotiated and re-acquired.

    e) If you're unlucky, the sudden demand for reads on a specific object from a specific node may result in a "DRM freeze" and object-remastering takes place.

Any of the above might be sufficient to cause enough of a delay to result in node eviction if the volume of dirty data and rate of data change are relatively high.

All in all, if anything is going to give you an easy way to crash out a node, flushing the buffer cache on a busy system is a good candidate for the job.

I think it's probably more likely to happen if you're running slightly older versions of Oracle at the smaller end of the Linux range.

Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk

"For every expert there is an equal and opposite expert."
Arthur C. Clarke

Don Lewis

Posts: 192
Registered: 06/11/09
Re: flush buffer cache
Posted: Jun 14, 2009 2:57 PM   in response to: Jonathan Lewis in response to: Jonathan Lewis
 
Click to report abuse...   Click to reply to this thread Reply
CRS is as bug-ridden and likely to fail at inopportune times as ever, if my recent experiences are anything to go by. That's 11g CRS, with virtually the latest patches applied, on a high-end IBM AIX system.

Regards - Don Lewis
http://little-shop-of-oras.blogspot.com
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums