Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-05-07 Thread Masahiko Sawada
On Tue, May 2, 2017 at 11:53 AM, Peter Eisentraut
 wrote:
> On 4/27/17 21:36, Masahiko Sawada wrote:
>> That makes sense to me. Since NOCONNECT option changes some default
>> values including ENABLED to false I think we should apply it also when
>> NOCONNECT is specified?
>
> That's not necessary, because if NOCONNECT is specified, then "enabled"
> will be set accordingly.
>

You're right, sorry for the noise. Anyway thank you for committing the patch!

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-05-01 Thread Peter Eisentraut
On 4/26/17 11:51, Fujii Masao wrote:
> On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
>  wrote:
>> At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
>>  wrote in 
>> <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
>>> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
 The attached patch wakes up launcher when a subscription is
 enabled. This fails when a subscription is enabled immedaitely
 after disabling but it won't be a matter.
>>>
>>> committed, thanks
>>
>> Thanks!
> 
> This patch makes me think that CREATE SUBSCRIPTION should also wake up
> the launcher only when ENABLE is specified. Patch attached. Thought?

committed

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-05-01 Thread Peter Eisentraut
On 4/27/17 21:36, Masahiko Sawada wrote:
> That makes sense to me. Since NOCONNECT option changes some default
> values including ENABLED to false I think we should apply it also when
> NOCONNECT is specified?

That's not necessary, because if NOCONNECT is specified, then "enabled"
will be set accordingly.

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-28 Thread Kyotaro HORIGUCHI
At Fri, 28 Apr 2017 06:43:19 +0900, Fujii Masao  wrote 
in 
> On Thu, Apr 27, 2017 at 6:32 PM, Kyotaro HORIGUCHI
>  wrote:
> > At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao  
> > wrote in 
> > 
> >> On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
> >>  wrote:
> >> > At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
> >> >  wrote in 
> >> > <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
> >> >> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> >> >> > The attached patch wakes up launcher when a subscription is
> >> >> > enabled. This fails when a subscription is enabled immedaitely
> >> >> > after disabling but it won't be a matter.
> >> >>
> >> >> committed, thanks
> >> >
> >> > Thanks!
> >>
> >> This patch makes me think that CREATE SUBSCRIPTION should also wake up
> >> the launcher only when ENABLE is specified. Patch attached. Thought?
> >
> > I don't think it works as expected. Disabling of a subsciption is
> > detected by the *worker* itself then it terminates by
> > itself. Only open apply transactions can prevent the behavior.
> 
> Sorry I could not understand your point. Could you elaborate this?

Ouch! Very sorry. I read your patch reversely! I misread it as
removing "if(enabled)" from the ALTER_SUBSCRIPTION_ENABLED case.

It actually works as expected.

+1 to this from me.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-27 Thread Masahiko Sawada
On Thu, Apr 27, 2017 at 12:51 AM, Fujii Masao  wrote:
> On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
>  wrote:
>> At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
>>  wrote in 
>> <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
>>> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
>>> > The attached patch wakes up launcher when a subscription is
>>> > enabled. This fails when a subscription is enabled immedaitely
>>> > after disabling but it won't be a matter.
>>>
>>> committed, thanks
>>
>> Thanks!
>
> This patch makes me think that CREATE SUBSCRIPTION should also wake up
> the launcher only when ENABLE is specified. Patch attached. Thought?
>

That makes sense to me. Since NOCONNECT option changes some default
values including ENABLED to false I think we should apply it also when
NOCONNECT is specified?

Regards,

--
Masahiko Sawada
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-27 Thread Fujii Masao
On Thu, Apr 27, 2017 at 6:32 PM, Kyotaro HORIGUCHI
 wrote:
> At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao  wrote 
> in 
>> On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
>>  wrote:
>> > At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
>> >  wrote in 
>> > <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
>> >> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
>> >> > The attached patch wakes up launcher when a subscription is
>> >> > enabled. This fails when a subscription is enabled immedaitely
>> >> > after disabling but it won't be a matter.
>> >>
>> >> committed, thanks
>> >
>> > Thanks!
>>
>> This patch makes me think that CREATE SUBSCRIPTION should also wake up
>> the launcher only when ENABLE is specified. Patch attached. Thought?
>
> I don't think it works as expected. Disabling of a subsciption is
> detected by the *worker* itself then it terminates by
> itself. Only open apply transactions can prevent the behavior.

Sorry I could not understand your point. Could you elaborate this?

Since the launcher starts up the worker only when its subscription is enabled,
ISTM that CREATE SUBSCRIPTION .. DISABLE doesn't need to wake up
the launcher. Even if the launcher wakes up, it doesn't start up the worker
because its subscription is not enabled.

Regards,

-- 
Fujii Masao


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-27 Thread Kyotaro HORIGUCHI
At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao  wrote 
in 
> On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
>  wrote:
> > At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
> >  wrote in 
> > <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
> >> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> >> > The attached patch wakes up launcher when a subscription is
> >> > enabled. This fails when a subscription is enabled immedaitely
> >> > after disabling but it won't be a matter.
> >>
> >> committed, thanks
> >
> > Thanks!
> 
> This patch makes me think that CREATE SUBSCRIPTION should also wake up
> the launcher only when ENABLE is specified. Patch attached. Thought?

I don't think it works as expected. Disabling of a subsciption is
detected by the *worker* itself then it terminates by
itself. Only open apply transactions can prevent the behavior.

However, of course waking up the launcher either on enabling and
disabling doesn't harm anything.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-26 Thread Fujii Masao
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
 wrote:
> At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
>  wrote in 
> <3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
>> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
>> > The attached patch wakes up launcher when a subscription is
>> > enabled. This fails when a subscription is enabled immedaitely
>> > after disabling but it won't be a matter.
>>
>> committed, thanks
>
> Thanks!

This patch makes me think that CREATE SUBSCRIPTION should also wake up
the launcher only when ENABLE is specified. Patch attached. Thought?

Regards,

-- 
Fujii Masao


wakeup_launcher_when_enabled.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-26 Thread Kyotaro HORIGUCHI
At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut 
 wrote in 
<3d6a1bd0-08ce-301d-3336-ec9f623a3...@2ndquadrant.com>
> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> > The attached patch wakes up launcher when a subscription is
> > enabled. This fails when a subscription is enabled immedaitely
> > after disabling but it won't be a matter.
> 
> committed, thanks

Thanks!

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-25 Thread Peter Eisentraut
On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> The attached patch wakes up launcher when a subscription is
> enabled. This fails when a subscription is enabled immedaitely
> after disabling but it won't be a matter.

committed, thanks

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-24 Thread Kyotaro HORIGUCHI
Hello,

At Fri, 21 Apr 2017 10:15:20 -0400, Peter Eisentraut 
 wrote in 
<77f75a90-a495-6661-68df-e4993bfac...@2ndquadrant.com>
> On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> > Hello. I found dubious behavior while playing with logical
> > replication.
> > 
> > When we disable a subscription, replication worker immediately stops.
> > 
> > =# ALTER SUBSCRIPTION s1 DISABLE;
> > 
> > On the other hand even if we enable a subscription, worker
> > doesn't start immediately. It takes 3 minutes in the worst
> > case. (DEFAULT_NAPTIME_PER_CYCLE)
> > 
> > The attached patch wakes up launcher when a subscription is
> > enabled. This fails when a subscription is enabled immedaitely
> > after disabling but it won't be a matter.
> 
> What do you mean by "this fails"?

Mmm. Is the sentsnce below makes sense?

"What the patch is doing doesn't work" when a subscription is
 enabled immedaitely after disabling but it won't be a matter.

Or,

It takes a short but not-zero time to shutdown a worker by
updating subenabled to false.  On enablling subenabled just
after, AlterSubScription tells the backend to notify the launcher
of the update of pg_subscription on commit. But if the launcher
has not been notified that the worker is terminated, the
notification is ignored and sleep for a certain interval. (I
haven't confirmed whether it is 180s or 5s, though.)


regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-21 Thread Peter Eisentraut
On 4/6/17 08:24, Kyotaro HORIGUCHI wrote:
> Hello. I found dubious behavior while playing with logical
> replication.
> 
> When we disable a subscription, replication worker immediately stops.
> 
> =# ALTER SUBSCRIPTION s1 DISABLE;
> 
> On the other hand even if we enable a subscription, worker
> doesn't start immediately. It takes 3 minutes in the worst
> case. (DEFAULT_NAPTIME_PER_CYCLE)
> 
> The attached patch wakes up launcher when a subscription is
> enabled. This fails when a subscription is enabled immedaitely
> after disabling but it won't be a matter.

What do you mean by "this fails"?

-- 
Peter Eisentraut  http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


Re: [HACKERS] subscription worker doesn't start immediately on eabled

2017-04-06 Thread Petr Jelinek
On 06/04/17 14:24, Kyotaro HORIGUCHI wrote:
> Hello. I found dubious behavior while playing with logical
> replication.
> 
> When we disable a subscription, replication worker immediately stops.
> 
> =# ALTER SUBSCRIPTION s1 DISABLE;
> 
> On the other hand even if we enable a subscription, worker
> doesn't start immediately. It takes 3 minutes in the worst
> case. (DEFAULT_NAPTIME_PER_CYCLE)
> 
> The attached patch wakes up launcher when a subscription is
> enabled. This fails when a subscription is enabled immedaitely
> after disabling but it won't be a matter.
> 

Makes sense, I think this got lost in all the refactoring, thanks.

-- 
  Petr Jelinek  http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers


[HACKERS] subscription worker doesn't start immediately on eabled

2017-04-06 Thread Kyotaro HORIGUCHI
Hello. I found dubious behavior while playing with logical
replication.

When we disable a subscription, replication worker immediately stops.

=# ALTER SUBSCRIPTION s1 DISABLE;

On the other hand even if we enable a subscription, worker
doesn't start immediately. It takes 3 minutes in the worst
case. (DEFAULT_NAPTIME_PER_CYCLE)

The attached patch wakes up launcher when a subscription is
enabled. This fails when a subscription is enabled immedaitely
after disabling but it won't be a matter.

regards,

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 5bf8d93..63550f8 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -608,6 +608,9 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
 	BoolGetDatum(enabled);
 replaces[Anum_pg_subscription_subenabled - 1] = true;
 
+if (enabled)
+	ApplyLauncherWakeupAtCommit();
+
 update_tuple = true;
 break;
 			}

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers