From 0d78217de2ba10e2631fca83469c0bda40fdb0c1 Mon Sep 17 00:00:00 2001 From: "kuroda.hayato%40jp.fujitsu.com" Date: Wed, 14 Sep 2022 10:56:35 +0000 Subject: [PATCH] Make apply workers to read pg_subscription --- src/backend/replication/logical/worker.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index 5181d02356..8654d79992 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -868,6 +868,21 @@ apply_delay(TimestampTz ts) ResetLatch(MyLatch); CHECK_FOR_INTERRUPTS(); + + /* + * The worker may be waken because of the ALTER SUBSCRIPTION ... DISABLE, + * so the catalog pg_subscription should be read again. + * + * Note that MySubscriptionValid must be false by myself because it is modified + * by the syscache callback but it will be called in between of transactions, + * not in the CHECK_FOR_INTERRUPTS(). + */ + if (TimestampDifferenceMilliseconds(GetCurrentTimestamp(), delay_until) > 0) + { + elog(DEBUG2, "check status of MySubscription"); + MySubscriptionValid = false; + maybe_reread_subscription(); + } } } -- 2.27.0