PostgreSQL Source Code git master
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, LogicalRepWorkerType wtype)
 
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 77 of file pgstat_subscription.c.

78{
79 /* Ensures that stats are dropped if transaction rolls back */
81 InvalidOid, subid);
82
83 /* Create and initialize the subscription stats entry */
85 true, NULL);
87}
#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:469
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 95 of file pgstat_subscription.c.

96{
98 InvalidOid, subid);
99}
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 106 of file pgstat_subscription.c.

107{
108 return (PgStat_StatSubEntry *)
110}
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, uint64 objid)
Definition: pgstat.c:934

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

63{
64 PgStat_EntryRef *entry_ref;
66
68 InvalidOid, subid, NULL);
69 pending = entry_ref->pending;
70 pending->conflict_count[type]++;
71}
PgStat_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, uint64 objid, bool *created_entry)
Definition: pgstat.c:1265
PgStat_Counter conflict_count[CONFLICT_NUM_TYPES]
Definition: pgstat.h:114
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,
LogicalRepWorkerType  wtype 
)

Definition at line 28 of file pgstat_subscription.c.

29{
30 PgStat_EntryRef *entry_ref;
32
34 InvalidOid, subid, NULL);
35 pending = entry_ref->pending;
36
37 switch (wtype)
38 {
40 pending->apply_error_count++;
41 break;
42
44 pending->sync_seq_error_count++;
45 break;
46
48 pending->sync_table_error_count++;
49 break;
50
51 default:
52 /* Should never happen. */
53 Assert(0);
54 break;
55 }
56}
Assert(PointerIsAligned(start, uint64))
PgStat_Counter sync_table_error_count
Definition: pgstat.h:113
PgStat_Counter apply_error_count
Definition: pgstat.h:111
PgStat_Counter sync_seq_error_count
Definition: pgstat.h:112
@ WORKERTYPE_TABLESYNC
@ WORKERTYPE_SEQUENCESYNC
@ WORKERTYPE_APPLY

References PgStat_BackendSubEntry::apply_error_count, Assert(), 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 119 of file pgstat_subscription.c.

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

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