PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pgstat_subscription.c File Reference
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)
 
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 78 of file pgstat_subscription.c.

79{
80 /* Ensures that stats are dropped if transaction rolls back */
82 InvalidOid, subid);
83
84 /* Create and initialize the subscription stats entry */
86 true, NULL);
88}
#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)
void pgstat_reset_entry(PgStat_Kind kind, Oid dboid, uint64 objid, TimestampTz ts)
void pgstat_create_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)
#define InvalidOid
static int fb(int x)

References fb(), 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 96 of file pgstat_subscription.c.

97{
99 InvalidOid, subid);
100}
void pgstat_drop_transactional(PgStat_Kind kind, Oid dboid, uint64 objid)

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 107 of file pgstat_subscription.c.

108{
109 return (PgStat_StatSubEntry *)
111}
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition pgstat.c:944

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 63 of file pgstat_subscription.c.

64{
65 PgStat_EntryRef *entry_ref;
67
69 InvalidOid, subid, NULL);
70 pending = entry_ref->pending;
71 pending->conflict_count[type]++;
72}
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
Definition pgstat.c:1275
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]
Definition pgstat.h:118
const char * type

References PgStat_BackendSubEntry::conflict_count, fb(), 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)

Definition at line 28 of file pgstat_subscription.c.

29{
30 PgStat_EntryRef *entry_ref;
33
35 InvalidOid, subid, NULL);
36 pending = entry_ref->pending;
37
38 switch (wtype)
39 {
41 pending->apply_error_count++;
42 break;
43
45 pending->sync_seq_error_count++;
46 break;
47
49 pending->sync_table_error_count++;
50 break;
51
52 default:
53 /* Should never happen. */
54 Assert(0);
55 break;
56 }
57}
#define Assert(condition)
Definition c.h:906
PgStat_Counter sync_table_error_count
Definition pgstat.h:117
PgStat_Counter apply_error_count
Definition pgstat.h:115
PgStat_Counter sync_seq_error_count
Definition pgstat.h:116
LogicalRepWorkerType
@ WORKERTYPE_TABLESYNC
@ WORKERTYPE_SEQUENCESYNC
@ WORKERTYPE_APPLY
static LogicalRepWorkerType get_logical_worker_type(void)

References PgStat_BackendSubEntry::apply_error_count, Assert, fb(), get_logical_worker_type(), InvalidOid, PgStat_EntryRef::pending, PGSTAT_KIND_SUBSCRIPTION, pgstat_prep_pending_entry(), PgStat_BackendSubEntry::sync_seq_error_count, PgStat_BackendSubEntry::sync_table_error_count, WORKERTYPE_APPLY, WORKERTYPE_SEQUENCESYNC, and WORKERTYPE_TABLESYNC.

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

◆ pgstat_subscription_flush_cb()

bool pgstat_subscription_flush_cb ( PgStat_EntryRef entry_ref,
bool  nowait 
)

Definition at line 120 of file pgstat_subscription.c.

121{
124
125 localent = (PgStat_BackendSubEntry *) entry_ref->pending;
127
128 /* localent always has non-zero content */
129
130 if (!pgstat_lock_entry(entry_ref, nowait))
131 return false;
132
133#define SUB_ACC(fld) shsubent->stats.fld += localent->fld
134 SUB_ACC(apply_error_count);
135 SUB_ACC(sync_seq_error_count);
136 SUB_ACC(sync_table_error_count);
137 for (int i = 0; i < CONFLICT_NUM_TYPES; i++)
138 SUB_ACC(conflict_count[i]);
139#undef SUB_ACC
140
141 pgstat_unlock_entry(entry_ref);
142 return true;
143}
#define CONFLICT_NUM_TYPES
Definition conflict.h:64
int i
Definition isn.c:77
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
#define SUB_ACC(fld)
PgStatShared_Common * shared_stats

References CONFLICT_NUM_TYPES, fb(), 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 146 of file pgstat_subscription.c.

147{
148 ((PgStatShared_Subscription *) header)->stats.stat_reset_timestamp = ts;
149}