PostgreSQL Source Code git master
pgstat_subscription.c File Reference
#include "postgres.h"
#include "utils/pgstat_internal.h"
Include dependency graph for pgstat_subscription.c:

Go to the source code of this file.

Macros

#define SUB_ACC(fld)   shsubent->stats.fld += localent->fld
 

Functions

void pgstat_report_subscription_error (Oid subid, bool is_apply_error)
 
void pgstat_report_subscription_conflict (Oid subid, ConflictType type)
 
void pgstat_create_subscription (Oid subid)
 
void pgstat_drop_subscription (Oid subid)
 
PgStat_StatSubEntrypgstat_fetch_stat_subscription (Oid subid)
 
bool pgstat_subscription_flush_cb (PgStat_EntryRef *entry_ref, bool nowait)
 
void pgstat_subscription_reset_timestamp_cb (PgStatShared_Common *header, TimestampTz ts)
 

Macro Definition Documentation

◆ SUB_ACC

#define SUB_ACC (   fld)    shsubent->stats.fld += localent->fld

Function Documentation

◆ pgstat_create_subscription()

void pgstat_create_subscription ( Oid  subid)

Definition at line 61 of file pgstat_subscription.c.

62{
63 /* Ensures that stats are dropped if transaction rolls back */
65 InvalidOid, subid);
66
67 /* Create and initialize the subscription stats entry */
69 true, NULL);
71}
#define PGSTAT_KIND_SUBSCRIPTION
Definition: pgstat_kind.h:31
PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, uint64 objid, bool create, bool *created_entry)
Definition: pgstat_shmem.c:444
void pgstat_reset_entry(PgStat_Kind kind, Oid dboid, uint64 objid, TimestampTz ts)
void pgstat_create_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat_xact.c:361
#define InvalidOid
Definition: postgres_ext.h:37

References InvalidOid, pgstat_create_transactional(), pgstat_get_entry_ref(), PGSTAT_KIND_SUBSCRIPTION, and pgstat_reset_entry().

Referenced by CreateSubscription().

◆ pgstat_drop_subscription()

void pgstat_drop_subscription ( Oid  subid)

Definition at line 79 of file pgstat_subscription.c.

80{
82 InvalidOid, subid);
83}
void pgstat_drop_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat_xact.c:384

References InvalidOid, pgstat_drop_transactional(), and PGSTAT_KIND_SUBSCRIPTION.

Referenced by DropSubscription().

◆ pgstat_fetch_stat_subscription()

PgStat_StatSubEntry * pgstat_fetch_stat_subscription ( Oid  subid)

Definition at line 90 of file pgstat_subscription.c.

91{
92 return (PgStat_StatSubEntry *)
94}
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat.c:949

References InvalidOid, pgstat_fetch_entry(), and PGSTAT_KIND_SUBSCRIPTION.

Referenced by pg_stat_get_subscription_stats().

◆ pgstat_report_subscription_conflict()

void pgstat_report_subscription_conflict ( Oid  subid,
ConflictType  type 
)

Definition at line 46 of file pgstat_subscription.c.

47{
48 PgStat_EntryRef *entry_ref;
50
52 InvalidOid, subid, NULL);
53 pending = entry_ref->pending;
54 pending->conflict_count[type]++;
55}
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
Definition: pgstat.c:1283
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]
Definition: pgstat.h:111
const char * type

References PgStat_BackendSubEntry::conflict_count, InvalidOid, PgStat_EntryRef::pending, PGSTAT_KIND_SUBSCRIPTION, pgstat_prep_pending_entry(), and type.

Referenced by ReportApplyConflict().

◆ pgstat_report_subscription_error()

void pgstat_report_subscription_error ( Oid  subid,
bool  is_apply_error 
)

Definition at line 27 of file pgstat_subscription.c.

28{
29 PgStat_EntryRef *entry_ref;
31
33 InvalidOid, subid, NULL);
34 pending = entry_ref->pending;
35
36 if (is_apply_error)
37 pending->apply_error_count++;
38 else
39 pending->sync_error_count++;
40}
PgStat_Counter apply_error_count
Definition: pgstat.h:109
PgStat_Counter sync_error_count
Definition: pgstat.h:110

References PgStat_BackendSubEntry::apply_error_count, InvalidOid, PgStat_EntryRef::pending, PGSTAT_KIND_SUBSCRIPTION, pgstat_prep_pending_entry(), and PgStat_BackendSubEntry::sync_error_count.

Referenced by DisableSubscriptionAndExit(), start_apply(), and start_table_sync().

◆ pgstat_subscription_flush_cb()

bool pgstat_subscription_flush_cb ( PgStat_EntryRef entry_ref,
bool  nowait 
)

Definition at line 103 of file pgstat_subscription.c.

104{
105 PgStat_BackendSubEntry *localent;
107
108 localent = (PgStat_BackendSubEntry *) entry_ref->pending;
109 shsubent = (PgStatShared_Subscription *) entry_ref->shared_stats;
110
111 /* localent always has non-zero content */
112
113 if (!pgstat_lock_entry(entry_ref, nowait))
114 return false;
115
116#define SUB_ACC(fld) shsubent->stats.fld += localent->fld
117 SUB_ACC(apply_error_count);
118 SUB_ACC(sync_error_count);
119 for (int i = 0; i < CONFLICT_NUM_TYPES; i++)
120 SUB_ACC(conflict_count[i]);
121#undef SUB_ACC
122
123 pgstat_unlock_entry(entry_ref);
124 return true;
125}
#define CONFLICT_NUM_TYPES
Definition: conflict.h:51
int i
Definition: isn.c:74
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
Definition: pgstat_shmem.c:675
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
Definition: pgstat_shmem.c:647
#define SUB_ACC(fld)
PgStatShared_Common * shared_stats

References CONFLICT_NUM_TYPES, i, PgStat_EntryRef::pending, pgstat_lock_entry(), pgstat_unlock_entry(), PgStat_EntryRef::shared_stats, and SUB_ACC.

◆ pgstat_subscription_reset_timestamp_cb()

void pgstat_subscription_reset_timestamp_cb ( PgStatShared_Common header,
TimestampTz  ts 
)

Definition at line 128 of file pgstat_subscription.c.

129{
130 ((PgStatShared_Subscription *) header)->stats.stat_reset_timestamp = ts;
131}