Why SyncOneBuffer does not called frequently?

From: 高健 <luckyjackgao(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Why SyncOneBuffer does not called frequently?
Date: 2012-10-31 08:53:07
Message-ID: CAL454F2Om3VY_5gvn4_VWfQ+4niKhqu7CpW6OJEFi+z_JwY8qg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all:

I am trying to understand when the bgwriter is written.

I thought that the bgwriter.c's calling turn is:

BackgroundWriterMain ->BgBufferSync-> SyncOneBuffer

And In my postgresql.conf , the bgwriter_delay=200ms.

I did the following:

postgres=# select * from testtab;
id | val
----+-------
1 | 12345
(1 row)

postgres=# update testtab set val='54321' where id=1;
UPDATE 1
postgres=# select * from testtab;
id | val
----+-------
1 | 54321
(1 row)

postgres=#

Now I can say the buffer is dirty ,right?

I wait for a few minutes, I can found bgwriter's BackgroundWriterMain
called BgBufferSync many times.

But I can't find BgBufferSync really call SyncOneBuffer to put the dirty
data todisk.

Untill I close the postgres process, I can find the SyncOneBuffer is called
for many times.

My question is:
Why even there are dirty buffer(s), the SyncOneBuffer is still not called?
Is it violating the background writer's purpose?

Or the flushing to disk will be done untill the amount of block/buffer is
satisfied? If so , what is it?

Thanks in advance for any help

Responses

Browse pgsql-general by date

  From Date Subject
Next Message telenieko 2012-10-31 09:22:36 Re: Average Balance "life"
Previous Message Tom Lane 2012-10-30 23:09:59 Re: How to setup chained CA?