pgsql: Collect statistics about conflicts in logical replication.

From: Amit Kapila <akapila(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Collect statistics about conflicts in logical replication.
Date: 2024-09-04 03:37:58
Message-ID: E1slgqD-0003ah-LA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Collect statistics about conflicts in logical replication.

This commit adds columns in view pg_stat_subscription_stats to show the
number of times a particular conflict type has occurred during the
application of logical replication changes. The following columns are
added:

confl_insert_exists:
Number of times a row insertion violated a NOT DEFERRABLE unique
constraint.
confl_update_origin_differs:
Number of times an update was performed on a row that was
previously modified by another origin.
confl_update_exists:
Number of times that the updated value of a row violates a
NOT DEFERRABLE unique constraint.
confl_update_missing:
Number of times that the tuple to be updated is missing.
confl_delete_origin_differs:
Number of times a delete was performed on a row that was
previously modified by another origin.
confl_delete_missing:
Number of times that the tuple to be deleted is missing.

The update_origin_differs and delete_origin_differs conflicts can be
detected only when track_commit_timestamp is enabled.

Author: Hou Zhijie
Reviewed-by: Shveta Malik, Peter Smith, Anit Kapila
Discussion: https://postgr.es/m/OS0PR01MB57160A07BD575773045FC214948F2@OS0PR01MB5716.jpnprd01.prod.outlook.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6c2b5edecc0d6c936e27775c9451d32bb3141c90

Modified Files
--------------
doc/src/sgml/logical-replication.sgml | 17 +++---
doc/src/sgml/monitoring.sgml | 77 +++++++++++++++++++++++-
src/backend/catalog/system_views.sql | 6 ++
src/backend/replication/logical/conflict.c | 5 +-
src/backend/utils/activity/pgstat_subscription.c | 17 ++++++
src/backend/utils/adt/pgstatfuncs.c | 33 +++++++---
src/include/catalog/catversion.h | 2 +-
src/include/catalog/pg_proc.dat | 6 +-
src/include/pgstat.h | 4 ++
src/include/replication/conflict.h | 8 +++
src/test/regress/expected/rules.out | 8 ++-
src/test/subscription/t/026_stats.pl | 61 +++++++++++++------
12 files changed, 204 insertions(+), 40 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2024-09-04 04:58:57 pgsql: Apply more quoting to GUC names in messages
Previous Message Richard Guo 2024-09-04 03:20:48 pgsql: Check the validity of commutators for merge/hash clauses