pg_stat_subscription_stats

显示逻辑复制订阅错误的视图

pg_stat_subscription_stats 是一个统计视图,显示有关逻辑复制订阅错误的信息。

pg_stat_subscription_statsPostgreSQL 15 中被添加。

用法

以下列仅在订阅者上启用了 track_commit_timestamp 时才会更新(PostgreSQL 18 及更高版本)。

  • confl_update_origin_differs
  • confl_delete_origin_differs

按 PostgreSQL 版本定义

pg_stat_subscription_stats (PostgreSQL 19)

                        View "pg_catalog.pg_stat_subscription_stats"
             Column              |           Type           | Collation | Nullable | Default 
---------------------------------+--------------------------+-----------+----------+---------
 subid                           | oid                      |           |          | 
 subname                         | name                     |           |          | 
 apply_error_count               | bigint                   |           |          | 
 sync_error_count                | bigint                   |           |          | 
 confl_insert_exists             | bigint                   |           |          | 
 confl_update_origin_differs     | bigint                   |           |          | 
 confl_update_exists             | bigint                   |           |          | 
 confl_update_missing            | bigint                   |           |          | 
 confl_delete_origin_differs     | bigint                   |           |          | 
 confl_delete_missing            | bigint                   |           |          | 
 confl_multiple_unique_conflicts | bigint                   |           |          | 
 stats_reset                     | timestamp with time zone |           |          |
    

文档pg_stat_subscription_stats

pg_stat_subscription_stats (PostgreSQL 18)

                        View "pg_catalog.pg_stat_subscription_stats"
             Column              |           Type           | Collation | Nullable | Default 
---------------------------------+--------------------------+-----------+----------+---------
 subid                           | oid                      |           |          | 
 subname                         | name                     |           |          | 
 apply_error_count               | bigint                   |           |          | 
 sync_error_count                | bigint                   |           |          | 
 confl_insert_exists             | bigint                   |           |          | 
 confl_update_origin_differs     | bigint                   |           |          | 
 confl_update_exists             | bigint                   |           |          | 
 confl_update_missing            | bigint                   |           |          | 
 confl_delete_origin_differs     | bigint                   |           |          | 
 confl_delete_missing            | bigint                   |           |          | 
 confl_multiple_unique_conflicts | bigint                   |           |          | 
 stats_reset                     | timestamp with time zone |           |          |
    

文档pg_stat_subscription_stats

pg_stat_subscription_stats (PostgreSQL 17)

                 View "pg_catalog.pg_stat_subscription_stats"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 subid             | oid                      |           |          | 
 subname           | name                     |           |          | 
 apply_error_count | bigint                   |           |          | 
 sync_error_count  | bigint                   |           |          | 
 stats_reset       | timestamp with time zone |           |          |
    

文档pg_stat_subscription_stats

pg_stat_subscription_stats (PostgreSQL 16)

                 View "pg_catalog.pg_stat_subscription_stats"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 subid             | oid                      |           |          | 
 subname           | name                     |           |          | 
 apply_error_count | bigint                   |           |          | 
 sync_error_count  | bigint                   |           |          | 
 stats_reset       | timestamp with time zone |           |          |
    

文档pg_stat_subscription_stats

pg_stat_subscription_stats (PostgreSQL 15)

                 View "pg_catalog.pg_stat_subscription_stats"
      Column       |           Type           | Collation | Nullable | Default 
-------------------+--------------------------+-----------+----------+---------
 subid             | oid                      |           |          | 
 subname           | name                     |           |          | 
 apply_error_count | bigint                   |           |          | 
 sync_error_count  | bigint                   |           |          | 
 stats_reset       | timestamp with time zone |           |          |
    

文档pg_stat_subscription_stats

变更历史

  • PostgreSQL 18
    • 添加了以下列(提交 6c2b5ede
      • confl_insert_exists
      • confl_update_origin_differs
      • confl_update_exists
      • confl_update_missing
      • confl_delete_origin_differs
      • confl_delete_missing
  • PostgreSQL 15
    • 添加(提交 8d74fc96,最初命名为 pg_stat_subscription_workers,但在 7a850732 中重命名)

示例

发生应用错误后 pg_stat_subscription_stats 的示例内容

postgres=# SELECT * FROM pg_stat_subscription_stats;
 subid | subname  | apply_error_count | sync_error_count | stats_reset 
-------+----------+-------------------+------------------+-------------
 16392 | test_sub |                 1 |                0 | 
(1 row)

相应的日志条目是

ERROR:  23505: duplicate key value violates unique constraint "foo_pkey"
DETAIL:  Key (id)=(6) already exists.
CONTEXT:  processing remote data for replication origin "pg_16392" during message type "INSERT" for replication target relation "public.foo" in transaction 730, finished at 0/2508608

分类

逻辑复制, 统计/监控视图, 系统目录

另请参阅

pg_stat_subscription

反馈

在此处 提交有关 "pg_stat_subscription_stats" 的任何评论、建议或更正。