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

Reply via email to