Re: Hi- How frequently Postgres Poll for trigger file

Lists: pgsql-hackers
From: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-01 11:27:05
Message-ID: AANLkTimDKES0egBJxCpt99tSOpwz95Nh_QDu+FFTOZS_@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi All,
I am new to postgres.
I want to know how frequently postgres search for trigger file to switch
over.
Can this switch over time be reduced?
Plz let me know where postgres poll for trigger file. I could find it out in
"backend/access/trans/xlog.c" ? am i right?

--
Thanks & Regards,

Aaliya Zarrin
(+91)-9160665888


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-01 12:23:32
Message-ID: 4CF63E44.1050704@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01.12.2010 13:27, aaliya zarrin wrote:
> I want to know how frequently postgres search for trigger file to switch
> over.

In 9.0, every 100ms while streaming replication is active and connected.
5 seconds otherwise. In current git master branch, it's always 5 s.

> Can this switch over time be reduced?

Not without hacking the sources and compiling.

Although, on many platforms, Linux included I believe, sending a signal
to the startup process should wake it up from the sleep and make it
check the trigger file immediately. "pg_ctl reload" for example should
do it. So if ýou send a signal to the startup process immediately after
creating the trigger file, it should take notice sooner.

> Plz let me know where postgres poll for trigger file. I could find it out in
> "backend/access/trans/xlog.c" ? am i right?

Yes. search for callers of CheckForStandbyTrigger() function.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-01 15:16:00
Message-ID: 4CF666B0.40909@timbira.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Heikki Linnakangas escreveu:
> On 01.12.2010 13:27, aaliya zarrin wrote:
>> I want to know how frequently postgres search for trigger file to switch
>> over.
>
> In 9.0, every 100ms while streaming replication is active and connected.
> 5 seconds otherwise. In current git master branch, it's always 5 s.
>
>> Can this switch over time be reduced?
>
> Not without hacking the sources and compiling.
>
> Although, on many platforms, Linux included I believe, sending a signal
> to the startup process should wake it up from the sleep and make it
> check the trigger file immediately. "pg_ctl reload" for example should
> do it. So if ýou send a signal to the startup process immediately after
> creating the trigger file, it should take notice sooner.
>
Isn't it an ugly solution for stopping the replication immediately? At the top
of my head, I don't remember the reason for not turn the interval for pooling
trigger file into a configurable option. IMHO, high availability fits into
those cases (switchover immediately).

[poking the git history a little...]

I agree the a short polling interval is not energy efficient [1] but some
scenarios need this short interval. So if we want to stop the replication
immediately, we have two options: (i) advertise that we need to signal the
postmaster after creating a trigger file or (ii) made the pooling interval
configurable. As you said, there are platforms that a signal doesn't wake up a
process, so I suggest (ii) but I'm fine to include (i) at docs too.

Comments?

[1]
http://git.postgresql.org/gitweb?p=postgresql.git;a=commitdiff;h=723d0184e2972f21db0f85feef3d35f0cb9b3298

--
Euler Taveira de Oliveira
http://www.timbira.com/


From: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-01 17:23:09
Message-ID: AANLkTi=P4P4XLBB0dps7QkdTuC+VUkJ0=yev5Qy7ny7X@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Thanks for quick response..
Can I change this 5 second time?
I have seen the postgres code as well.
What is the functionality of WaitLatch() function. I could not understand
completely.
Plz help..

On Wed, Dec 1, 2010 at 5:53 PM, Heikki Linnakangas <
heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:

> On 01.12.2010 13:27, aaliya zarrin wrote:
>
>> I want to know how frequently postgres search for trigger file to switch
>> over.
>>
>
> In 9.0, every 100ms while streaming replication is active and connected. 5
> seconds otherwise. In current git master branch, it's always 5 s.
>
>
> Can this switch over time be reduced?
>>
>
> Not without hacking the sources and compiling.
>
> Although, on many platforms, Linux included I believe, sending a signal to
> the startup process should wake it up from the sleep and make it check the
> trigger file immediately. "pg_ctl reload" for example should do it. So if
> ıou send a signal to the startup process immediately after creating the
> trigger file, it should take notice sooner.
>
>
> Plz let me know where postgres poll for trigger file. I could find it out
>> in
>> "backend/access/trans/xlog.c" ? am i right?
>>
>
> Yes. search for callers of CheckForStandbyTrigger() function.
>
>
> --
> Heikki Linnakangas
> EnterpriseDB http://www.enterprisedb.com
>

--
Thanks & Regards,

Aaliya Zarrin
(+91)-9160665888


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-01 18:58:48
Message-ID: 4CF69AE8.7080608@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 01.12.2010 19:23, aaliya zarrin wrote:
> Thanks for quick response..
> Can I change this 5 second time?
> I have seen the postgres code as well.

You can, if you don't mind changing the sources.

> What is the functionality of WaitLatch() function. I could not understand
> completely.

The recoveryWakupLatch latch allows the startup process to wake up
immediately when new WAL arrives via streaming replication, without
waiting for the whole five seconds to elapse.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-02 09:55:04
Message-ID: AANLkTikv+7aTGKZD9mOqW7DM2E0x3p3YNVQjrhLBXkrH@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hey!!!!!!!!!1
I am able to change the switch over time.. Thanks alot..
2010/12/2 aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>

> Ok.. Thanks I will try!!!
>
> 2010/12/2 Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
>
> Oh, and there's another value for the case we're polling the archive, not
>> streaming from master. Search for "5" in XLogPageRead function to catch them
>> all.
>>
>>
>> On 02.12.2010 08:21, Heikki Linnakangas wrote:
>>
>>> It's the 5000000L argument in the WaitLatch call. It's expressed in
>>> microseconds.
>>>
>>> On 02.12.2010 06:39, aaliya zarrin wrote:
>>>
>>>> Where this 5 Seconds time is defined in the code ???
>>>>
>>>>
>>>>
>>>> On Wed, Dec 1, 2010 at 5:53 PM, Heikki Linnakangas<
>>>> heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:
>>>>
>>>> On 01.12.2010 13:27, aaliya zarrin wrote:
>>>>>
>>>>> I want to know how frequently postgres search for trigger file to
>>>>>> switch
>>>>>> over.
>>>>>>
>>>>>>
>>>>> In 9.0, every 100ms while streaming replication is active and
>>>>> connected. 5
>>>>> seconds otherwise. In current git master branch, it's always 5 s.
>>>>>
>>>>>
>>>>> Can this switch over time be reduced?
>>>>>
>>>>>>
>>>>>>
>>>>> Not without hacking the sources and compiling.
>>>>>
>>>>> Although, on many platforms, Linux included I believe, sending a
>>>>> signal to
>>>>> the startup process should wake it up from the sleep and make it
>>>>> check the
>>>>> trigger file immediately. "pg_ctl reload" for example should do it.
>>>>> So if
>>>>> ıou send a signal to the startup process immediately after creating the
>>>>> trigger file, it should take notice sooner.
>>>>>
>>>>>
>>>>> Plz let me know where postgres poll for trigger file. I could find it
>>>>> out
>>>>>
>>>>>> in
>>>>>> "backend/access/trans/xlog.c" ? am i right?
>>>>>>
>>>>>>
>>>>> Yes. search for callers of CheckForStandbyTrigger() function.
>>>>>
>>>>>
>>>>> --
>>>>> Heikki Linnakangas
>>>>> EnterpriseDB http://www.enterprisedb.com
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>> --
>> Heikki Linnakangas
>> EnterpriseDB http://www.enterprisedb.com
>>
>
>
>
> --
> Thanks & Regards,
>
> Aaliya Zarrin
> (+91)-9160665888
>

--
Thanks & Regards,

Aaliya Zarrin
(+91)-9160665888


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-03 01:55:21
Message-ID: AANLkTik=7TGYaxZrs_4NZH0s_+5vTSUcK2SaZn8tAJXq@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Dec 2, 2010 at 12:16 AM, Euler Taveira de Oliveira
<euler(at)timbira(dot)com> wrote:
> As you said, there are platforms that a signal doesn't wake up a
> process, so I suggest (ii) but I'm fine to include (i) at docs too.

Can we use "pg_ctl kill" to send signal on such platforms?

Regards,

--
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Euler Taveira de Oliveira <euler(at)timbira(dot)com>, aaliya zarrin <aaliya(dot)zarrin(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Hi- How frequently Postgres Poll for trigger file
Date: 2010-12-03 08:18:18
Message-ID: 4CF8A7CA.6090103@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 03.12.2010 03:55, Fujii Masao wrote:
> On Thu, Dec 2, 2010 at 12:16 AM, Euler Taveira de Oliveira
> <euler(at)timbira(dot)com> wrote:
>> As you said, there are platforms that a signal doesn't wake up a
>> process, so I suggest (ii) but I'm fine to include (i) at docs too.
>
> Can we use "pg_ctl kill" to send signal on such platforms?

It won't make a difference, "pg_ctl kill" sends the signal just like
regular "kill". Except that "pg_ctl kill" also works on Windows which
doesn't have the concept of Unix signals.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com