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-11-01 00:05:09
Message-ID: tencent_7D1FF17D6BD3013B0BC67173@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

This perhaps proves that the bgwriter&nbsp; doesn't need to call the SyncOneBuffer again on the same buffer.<br><br><div><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><div style="font-size:14px;font-family:Verdana;color:#000;"><div><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px; ">Thanks&amp;Regards,</div><div>Xiong He</div></div></div></div><div><includetail><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------&nbsp;Original&nbsp;------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b>&nbsp;"Xiong He"&lt;iihero(at)qq(dot)com&gt;;</div><div><b>Date: </b>&nbsp;Thu, Nov 1, 2012 07:40 AM</div><div><b>To: </b>&nbsp;"高健"&lt;luckyjackgao(at)gmail(dot)com&gt;; "pgsql-general"&lt;pgsql-general(at)postgresql(dot)org&gt;; <wbr></div><div></div><div><b>Subject: </b>&nbsp;Re: [GENERAL] Why SyncOneBuffer does not called frequently?</div></div><div><br></div>HI, <br><br>I just debug the code, find that the following stack will call the SyncOneBuffer.<br><br>&gt;&nbsp; &nbsp; postgres.exe!SyncOneBuffer(int buf_id=2, char skip_recently_used=0)&nbsp; Line 1640&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!BufferSync(int flags=64)&nbsp; Line 1284 + 0xb bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!CheckPointBuffers(int flags=64)&nbsp; Line 1801 + 0x9 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!CheckPointGuts(XLogRecPtr checkPointRedo={...}, int flags=64)&nbsp; Line 8129 + 0x9 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!CreateCheckPoint(int flags=64)&nbsp; Line 7977 + 0x11 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!CheckpointerMain()&nbsp; Line 505 + 0x9 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!AuxiliaryProcessMain(int argc=2, char * * argv=0x002f6fb8)&nbsp; Line 429&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!SubPostmasterMain(int argc=4, char * * argv=0x002f6fb0)&nbsp; Line 4136 + 0x13 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!main(int argc=4, char * * argv=0x002f6fb0)&nbsp; Line 176 + 0xd bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!__tmainCRTStartup()&nbsp; Line 582 + 0x19 bytes&nbsp; &nbsp; C<br>&nbsp;&nbsp; &nbsp; postgres.exe!mainCRTStartup()&nbsp; Line 399&nbsp; &nbsp; C<br><br>This is the check point background process.<br><br><br><br><div><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><div style="font-size:14px;font-family:Verdana;color:#000;"><div><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px; ">Thanks&amp;Regards,</div><div style="font-family: 'lucida Grande', Verdana; font-size: 12px; line-height: 18px; ">Xiong He<br><br></div></div></div></div><div>&nbsp;</div><div><div><br></div><div><br></div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b>&nbsp;"高健"&lt;luckyjackgao(at)gmail(dot)com&gt;;</div><div><b>Date: </b>&nbsp;Wed, Oct 31, 2012 04:53 PM</div><div><b>To: </b>&nbsp;"pgsql-general"&lt;pgsql-general(at)postgresql(dot)org&gt;; <wbr></div><div></div><div><b>Subject: </b>&nbsp;[GENERAL] Why SyncOneBuffer does not called frequently?</div></div><div><br></div><div>Hi all:</div><div><br></div><div>I am trying to understand when the bgwriter is written.</div><div><br></div><div>I thought that the &nbsp;bgwriter.c's calling turn is:</div><div><br></div><div>BackgroundWriterMain -&gt;BgBufferSync-&gt; SyncOneBuffer</div>
<div><br></div><div>And In my postgresql.conf , the bgwriter_delay=200ms.</div><div><br></div><div>I did the following:</div><div><br></div><div>postgres=# select * from testtab;</div><div>&nbsp;id | &nbsp;val &nbsp;</div><div>----+-------</div>
<div>&nbsp; 1 | 12345</div><div>(1 row)</div><div><br></div><div>postgres=# update testtab set val='54321' where id=1;</div><div>UPDATE 1</div><div>postgres=# select * from testtab;</div><div>&nbsp;id | &nbsp;val &nbsp;</div><div>----+-------</div>
<div>&nbsp; 1 | 54321</div><div>(1 row)</div><div><br></div><div>postgres=# </div><div><br></div><div>Now I can say the buffer is dirty ,right?</div><div><br></div><div>I wait for a few minutes, I can found bgwriter's BackgroundWriterMain called BgBufferSync many times.</div>
<div><br></div><div>But I can't find BgBufferSync really call SyncOneBuffer to put the dirty data todisk.</div><div><br></div><div>Untill I close the postgres process, I can find the SyncOneBuffer is called for many times.</div>
<div><br></div><div>My question is: </div><div>Why even there are dirty buffer(s), the SyncOneBuffer is still not called? &nbsp;</div><div>Is it violating the background writer's purpose? </div><div><br></div><div>Or the flushing to disk will be done untill &nbsp;the amount of block/buffer is satisfied? If so , what is it?</div>
<div><br></div><div>Thanks in advance for any help</div></div></includetail></div>

Attachment Content-Type Size
unknown_filename text/html 5.0 KB

Browse pgsql-general by date

  From Date Subject
Next Message Xiong He 2012-11-01 00:24:47 Re: Why PGDLLIMPORT is needed
Previous Message Edson Richter 2012-10-31 23:56:05 Re: dropdb breaks replication?