Add a view to show the stats of subscription workers.
authorAmit Kapila <akapila@postgresql.org>
Tue, 30 Nov 2021 03:24:30 +0000 (08:54 +0530)
committerAmit Kapila <akapila@postgresql.org>
Tue, 30 Nov 2021 03:24:30 +0000 (08:54 +0530)
commit8d74fc96db5fd547e077bf9bf4c3b67f821d71cd
tree3037345a7edabd025edcc5d9b431fb14f780e817
parent98105e53e0ab472b7721a3e8d7b9f1750a635120
Add a view to show the stats of subscription workers.

This commit adds a new system view pg_stat_subscription_workers, that
shows information about any errors which occur during the application of
logical replication changes as well as during performing initial table
synchronization. The subscription statistics entries are removed when the
corresponding subscription is removed.

It also adds an SQL function pg_stat_reset_subscription_worker() to reset
single subscription errors.

The contents of this view can be used by an upcoming patch that skips the
particular transaction that conflicts with the existing data on the
subscriber.

This view can be extended in the future to track other xact related
statistics like the number of xacts committed/aborted for subscription
workers.

Author: Masahiko Sawada
Reviewed-by: Greg Nancarrow, Hou Zhijie, Tang Haiying, Vignesh C, Dilip Kumar, Takamichi Osumi, Amit Kapila
Discussion: https://postgr.es/m/CAD21AoDeScrsHhLyEPYqN3sydg6PxAPVBboK=30xJfUVihNZDA@mail.gmail.com
13 files changed:
doc/src/sgml/monitoring.sgml
src/backend/catalog/system_functions.sql
src/backend/catalog/system_views.sql
src/backend/commands/subscriptioncmds.c
src/backend/postmaster/pgstat.c
src/backend/replication/logical/worker.c
src/backend/utils/adt/pgstatfuncs.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.dat
src/include/pgstat.h
src/test/regress/expected/rules.out
src/test/subscription/t/026_worker_stats.pl [new file with mode: 0644]
src/tools/pgindent/typedefs.list