subscription worker doesn't start immediately on eabled
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
Attachments:
enable_sub_starts_worker.patchtext/x-patch; charset=us-asciiDownload
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;
}
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
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
Hello,
At Fri, 21 Apr 2017 10:15:20 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <77f75a90-a495-6661-68df-e4993bfac3e3@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
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
At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
Attachments:
wakeup_launcher_when_enabled.patchapplication/octet-stream; name=wakeup_launcher_when_enabled.patchDownload
*** a/src/backend/commands/subscriptioncmds.c
--- b/src/backend/commands/subscriptioncmds.c
***************
*** 452,458 **** CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
heap_close(rel, RowExclusiveLock);
! ApplyLauncherWakeupAtCommit();
ObjectAddressSet(myself, SubscriptionRelationId, subid);
--- 452,459 ----
heap_close(rel, RowExclusiveLock);
! if (enabled)
! ApplyLauncherWakeupAtCommit();
ObjectAddressSet(myself, SubscriptionRelationId, subid);
At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao <masao.fujii@gmail.com> wrote in <CAHGQGwEQH4V2aU=wbA4Mcc+uRsrLS2rpRONLZyB2EL=f=UNypA@mail.gmail.com>
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
On Thu, Apr 27, 2017 at 6:32 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:
At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao <masao.fujii@gmail.com> wrote in <CAHGQGwEQH4V2aU=wbA4Mcc+uRsrLS2rpRONLZyB2EL=f=UNypA@mail.gmail.com>
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
On Thu, Apr 27, 2017 at 12:51 AM, Fujii Masao <masao.fujii@gmail.com> wrote:
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
At Fri, 28 Apr 2017 06:43:19 +0900, Fujii Masao <masao.fujii@gmail.com> wrote in <CAHGQGwEq=Cei2Ti7HyYjpbJbut1GALRvFX8nUb9LDiWiX-mbNw@mail.gmail.com>
On Thu, Apr 27, 2017 at 6:32 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Thu, 27 Apr 2017 00:51:03 +0900, Fujii Masao <masao.fujii@gmail.com> wrote in <CAHGQGwEQH4V2aU=wbA4Mcc+uRsrLS2rpRONLZyB2EL=f=UNypA@mail.gmail.com>
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
On 4/26/17 11:51, Fujii Masao wrote:
On Wed, Apr 26, 2017 at 4:03 PM, Kyotaro HORIGUCHI
<horiguchi.kyotaro@lab.ntt.co.jp> wrote:At Tue, 25 Apr 2017 14:45:03 -0400, Peter Eisentraut <peter.eisentraut@2ndquadrant.com> wrote in <3d6a1bd0-08ce-301d-3336-ec9f623a315d@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
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
On Tue, May 2, 2017 at 11:53 AM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> 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