diff options
author | Masahiko Sawada | 2023-07-05 05:49:46 +0000 |
---|---|---|
committer | Masahiko Sawada | 2023-07-05 05:49:46 +0000 |
commit | 68a59f9e99831cf05a746928a955781503232bbb (patch) | |
tree | c96be39ab2cc3e97fae4292ebfed715ad8f31813 /src/backend/commands/subscriptioncmds.c | |
parent | cccdbc5d95aca276789bbe28783f3e06f9a3ba9c (diff) |
pgstat: fix subscription stats entry leak.
Commit 7b64e4b3 taught DropSubscription() to drop stats entry of
subscription that is not associated with a replication slot for apply
worker at DROP SUBSCRIPTION but missed covering the case where the
subscription is not associated with replication slots for both apply
worker and tablesync worker.
Also add a test to verify that the stats for slot-less subscription is
removed at DROP SUBSCRIPTION time.
Backpatch down to 15.
Author: Masahiko Sawada
Reviewed-by: Nathan Bossart, Hayato Kuroda, Melih Mutlu, Amit Kapila
Discussion: https://postgr.es/m/CAD21AoB71zkP7uPT7JDPsZcvp0749ExEQnOJxeNKPDFisHar+w@mail.gmail.com
Backpatch-through: 15
Diffstat (limited to 'src/backend/commands/subscriptioncmds.c')
-rw-r--r-- | src/backend/commands/subscriptioncmds.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c index 54895ba929a..d4e798baeb1 100644 --- a/src/backend/commands/subscriptioncmds.c +++ b/src/backend/commands/subscriptioncmds.c @@ -1647,6 +1647,12 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel) replorigin_drop_by_name(originname, true, false); /* + * Tell the cumulative stats system that the subscription is getting + * dropped. + */ + pgstat_drop_subscription(subid); + + /* * If there is no slot associated with the subscription, we can finish * here. */ @@ -1734,12 +1740,6 @@ DropSubscription(DropSubscriptionStmt *stmt, bool isTopLevel) } PG_END_TRY(); - /* - * Tell the cumulative stats system that the subscription is getting - * dropped. - */ - pgstat_drop_subscription(subid); - table_close(rel, NoLock); } |