Create subscription stats entry at CREATE SUBSCRIPTION time
authorAndres Freund <andres@anarazel.de>
Thu, 6 Oct 2022 23:45:20 +0000 (16:45 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 7 Oct 2022 00:17:16 +0000 (17:17 -0700)
commite0b0142959066f3a9de1c6867f4ec8d41d104f33
tree24ce07203d35a3f37aaa8ba679e6c830fa138ed9
parentcd4e8caaa0eb5c3d3b12a45b29035e7a4bdfa4a8
Create subscription stats entry at CREATE SUBSCRIPTION time

Previously, the subscription stats entry was created when the first
stats, i.e., an error on apply worker or tablesync worker,  were
reported. Therefore, the stats_reset field was not updated by
pg_stat_reset_subscription_stats() if the stats entry was not
populated yet, which was different behavior than other statistics.

This change creates the subscription stats entry and initializes it at
CREATE SUBSCRIPTION time.

Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Author: Masahiko Sawada <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAAKRu_Zqd-e5imT_3-ZiQv1cfsWuy16OJTiUaCvqpq4V7GVdSg@mail.gmail.com
src/backend/utils/activity/pgstat_subscription.c
src/test/regress/expected/subscription.out
src/test/regress/sql/subscription.sql