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

47 {
48  /* Ensures that stats are dropped if transaction rolls back */
50  InvalidOid, subid);
51 
52  /* Create and initialize the subscription stats entry */
54  true, NULL);
56 }
@ PGSTAT_KIND_SUBSCRIPTION
Definition: pgstat.h:45
void pgstat_reset_entry(PgStat_Kind kind, Oid dboid, Oid objoid, TimestampTz ts)
Definition: pgstat_shmem.c:934
PgStat_EntryRef * pgstat_get_entry_ref(PgStat_Kind kind, Oid dboid, Oid objoid, bool create, bool *created_entry)
Definition: pgstat_shmem.c:398
void pgstat_create_transactional(PgStat_Kind kind, Oid dboid, Oid objoid)
Definition: pgstat_xact.c:357
#define InvalidOid
Definition: postgres_ext.h:36

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

65 {
67  InvalidOid, subid);
68 }
void pgstat_drop_transactional(PgStat_Kind kind, Oid dboid, Oid objoid)
Definition: pgstat_xact.c:379

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

76 {
77  return (PgStat_StatSubEntry *)
79 }
void * pgstat_fetch_entry(PgStat_Kind kind, Oid dboid, Oid objoid)
Definition: pgstat.c:812

References InvalidOid, pgstat_fetch_entry(), and PGSTAT_KIND_SUBSCRIPTION.

Referenced by pg_stat_get_subscription_stats().

◆ 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;
30  PgStat_BackendSubEntry *pending;
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_EntryRef * pgstat_prep_pending_entry(PgStat_Kind kind, Oid dboid, Oid objoid, bool *created_entry)
Definition: pgstat.c:1105
PgStat_Counter apply_error_count
Definition: pgstat.h:136
PgStat_Counter sync_error_count
Definition: pgstat.h:137

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

89 {
90  PgStat_BackendSubEntry *localent;
91  PgStatShared_Subscription *shsubent;
92 
93  localent = (PgStat_BackendSubEntry *) entry_ref->pending;
94  shsubent = (PgStatShared_Subscription *) entry_ref->shared_stats;
95 
96  /* localent always has non-zero content */
97 
98  if (!pgstat_lock_entry(entry_ref, nowait))
99  return false;
100 
101 #define SUB_ACC(fld) shsubent->stats.fld += localent->fld
102  SUB_ACC(apply_error_count);
103  SUB_ACC(sync_error_count);
104 #undef SUB_ACC
105 
106  pgstat_unlock_entry(entry_ref);
107  return true;
108 }
void pgstat_unlock_entry(PgStat_EntryRef *entry_ref)
Definition: pgstat_shmem.c:604
bool pgstat_lock_entry(PgStat_EntryRef *entry_ref, bool nowait)
Definition: pgstat_shmem.c:576
#define SUB_ACC(fld)
PgStatShared_Common * shared_stats

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

112 {
113  ((PgStatShared_Subscription *) header)->stats.stat_reset_timestamp = ts;
114 }