Re: Why BgWriterDelay is fixed? - Mailing list pgsql-general
From | Xiong He |
---|---|
Subject | Re: Why BgWriterDelay is fixed? |
Date | |
Msg-id | tencent_4FE00EF0246CCCFE1C8C58E3@qq.com Whole thread Raw |
In response to | Why BgWriterDelay is fixed? (高健 <luckyjackgao@gmail.com>) |
List | pgsql-general |
You can check the code in guc.c, search "bgwriter_delay", &BgWriterDelay<br />In the global user configuration, itcan change the value of BgWriterDelay.<br />Since the BgWriterDelay declared in bgwriter.h as extern. It can be changedin the global namespace.<br /><br /><div><div style="color:#909090;font-family:Arial Narrow;font-size:12px">------------------</div><divstyle="font-size:14px;font-family:Verdana;color:#000;"><div><div style="font-family:'lucida Grande', Verdana; font-size: 12px; line-height: 18px; ">Thanks&Regards,</div><div style="font-family:'lucida Grande', Verdana; font-size: 12px; line-height: 18px; ">Xiong He<br /><br /></div></div></div></div><div> </div><div><div><br/></div><div><br /></div><div style="font-size: 12px;font-family: ArialNarrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From:</b> "高健"<luckyjackgao@gmail.com>;</div><div><b>Date: </b> Mon,Oct 29, 2012 03:17 PM</div><div><b>To: </b> "pgsql-general"<pgsql-general@postgresql.org>; <wbr /></div><div></div><div><b>Subject:</b> [GENERAL] Why BgWriterDelay is fixed?</div></div><div><br /></div>In src/backend/postmaster/bgwriter.c, I can find the following source code(PostgreSQL9.2):<div><br /></div><div><div><br/></div><div>/*</div><div> * GUC parameters</div><div> */</div><div>int<span class="Apple-tab-span"style="white-space:pre"> </span>BgWriterDelay = 200;</div></div><div><br /></div><div>...</div><div><div><spanclass="Apple-tab-span" style="white-space:pre"> </span>rc = WaitLatch(&MyProc->procLatch,</div><div><spanclass="Apple-tab-span" style="white-space:pre"> </span> WL_LATCH_SET| WL_TIMEOUT | WL_POSTMASTER_DEATH,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> BgWriterDelay /* ms */ );</div></div><div>...</div><div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if(rc == WL_TIMEOUT && can_hibernate && prev_hibernate)</div><div><span class="Apple-tab-span" style="white-space:pre"></span>{</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>/* Ask for notificationat next buffer allocation */</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>StrategyNotifyBgWriter(&MyProc->procLatch);</div><div><spanclass="Apple-tab-span" style="white-space:pre"></span>/* Sleep ... */</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>rc= WaitLatch(&MyProc->procLatch,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> BgWriterDelay * HIBERNATE_FACTOR);</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>/* Resetthe notification request in case we timed out */</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>StrategyNotifyBgWriter(NULL);</div><div><spanclass="Apple-tab-span" style="white-space:pre"> </span>}</div></div><div><br/></div><div>But I also found the following in postgresql.conf:</div><div><div>#bgwriter_delay= 200ms # 10-10000ms between rounds</div></div><div>It isnow comment .</div><div>But according to the fixed code of BgWriterDelay = 200, even when I update bgwriter_delay in postgresql.confto a different value(eg 300ms), </div><div>how can it ovewrite the fixed 200ms in bgwriter.c ?</div><div><br/></div><div>I also want to know, if it is not a bug, then what is the reason?</div></div>
pgsql-general by date: