Re: Why SyncOneBuffer does not called frequently?

From: Xiong He <iihero(at)qq(dot)com>
To: 高健 <luckyjackgao(at)gmail(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Why SyncOneBuffer does not called frequently?
Date: 2012-10-31 23:40:22
Message-ID: tencent_0211B79461CB9BE629605520@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

HI,

I just debug the code, find that the following stack will call the SyncOneBuffer.

> postgres.exe!SyncOneBuffer(int buf_id=2, char skip_recently_used=0) Line 1640 C
postgres.exe!BufferSync(int flags=64) Line 1284 + 0xb bytes C
postgres.exe!CheckPointBuffers(int flags=64) Line 1801 + 0x9 bytes C
postgres.exe!CheckPointGuts(XLogRecPtr checkPointRedo={...}, int flags=64) Line 8129 + 0x9 bytes C
postgres.exe!CreateCheckPoint(int flags=64) Line 7977 + 0x11 bytes C
postgres.exe!CheckpointerMain() Line 505 + 0x9 bytes C
postgres.exe!AuxiliaryProcessMain(int argc=2, char * * argv=0x002f6fb8) Line 429 C
postgres.exe!SubPostmasterMain(int argc=4, char * * argv=0x002f6fb0) Line 4136 + 0x13 bytes C
postgres.exe!main(int argc=4, char * * argv=0x002f6fb0) Line 176 + 0xd bytes C
postgres.exe!__tmainCRTStartup() Line 582 + 0x19 bytes C
postgres.exe!mainCRTStartup() Line 399 C

This is the check point background process.

------------------
Thanks&Regards,
Xiong He

------------------ Original ------------------
From: "高健"<luckyjackgao(at)gmail(dot)com>;
Date: Wed, Oct 31, 2012 04:53 PM
To: "pgsql-general"<pgsql-general(at)postgresql(dot)org>;

Subject: [GENERAL] Why SyncOneBuffer does not called frequently?

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

Browse pgsql-general by date

  From Date Subject
Next Message Edson Richter 2012-10-31 23:56:05 Re: dropdb breaks replication?
Previous Message Joshua D. Drake 2012-10-31 23:32:54 Re: role does not exist