PostgreSQL Source Code git master
Loading...
Searching...
No Matches
pgstat_archiver.c File Reference
#include "postgres.h"
#include "utils/pgstat_internal.h"
#include "utils/timestamp.h"
Include dependency graph for pgstat_archiver.c:

Go to the source code of this file.

Functions

void pgstat_report_archiver (const char *xlog, bool failed)
 
PgStat_ArchiverStatspgstat_fetch_stat_archiver (void)
 
void pgstat_archiver_init_shmem_cb (void *stats)
 
void pgstat_archiver_reset_all_cb (TimestampTz ts)
 
void pgstat_archiver_snapshot_cb (void)
 

Function Documentation

◆ pgstat_archiver_init_shmem_cb()

void pgstat_archiver_init_shmem_cb ( void stats)

Definition at line 66 of file pgstat_archiver.c.

67{
69
71}
void LWLockInitialize(LWLock *lock, int tranche_id)
Definition lwlock.c:698
static int fb(int x)

References fb(), and LWLockInitialize().

◆ pgstat_archiver_reset_all_cb()

void pgstat_archiver_reset_all_cb ( TimestampTz  ts)

Definition at line 74 of file pgstat_archiver.c.

75{
77
78 /* see explanation above PgStatShared_Archiver for the reset protocol */
81 &stats_shmem->stats,
82 sizeof(stats_shmem->stats),
83 &stats_shmem->changecount);
84 stats_shmem->stats.stat_reset_timestamp = ts;
86}
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1176
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1793
@ LW_EXCLUSIVE
Definition lwlock.h:112
PgStat_LocalState pgStatLocal
Definition pgstat.c:212
static void pgstat_copy_changecounted_stats(void *dst, void *src, size_t len, uint32 *cc)
PgStat_ShmemControl * shmem
PgStatShared_Archiver archiver

References PgStat_ShmemControl::archiver, fb(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), pgstat_copy_changecounted_stats(), pgStatLocal, and PgStat_LocalState::shmem.

◆ pgstat_archiver_snapshot_cb()

void pgstat_archiver_snapshot_cb ( void  )

Definition at line 89 of file pgstat_archiver.c.

90{
93 PgStat_ArchiverStats *reset_offset = &stats_shmem->reset_offset;
95
97 &stats_shmem->stats,
98 sizeof(stats_shmem->stats),
99 &stats_shmem->changecount);
100
102 memcpy(&reset, reset_offset, sizeof(stats_shmem->stats));
104
105 /* compensate by reset offsets */
106 if (stat_snap->archived_count == reset.archived_count)
107 {
108 stat_snap->last_archived_wal[0] = 0;
109 stat_snap->last_archived_timestamp = 0;
110 }
111 stat_snap->archived_count -= reset.archived_count;
112
113 if (stat_snap->failed_count == reset.failed_count)
114 {
115 stat_snap->last_failed_wal[0] = 0;
116 stat_snap->last_failed_timestamp = 0;
117 }
118 stat_snap->failed_count -= reset.failed_count;
119}
@ LW_SHARED
Definition lwlock.h:113
void reset(void)
PgStat_Snapshot snapshot
PgStat_ArchiverStats archiver

References PgStat_ShmemControl::archiver, PgStat_Snapshot::archiver, fb(), LW_SHARED, LWLockAcquire(), LWLockRelease(), pgstat_copy_changecounted_stats(), pgStatLocal, reset(), PgStat_LocalState::shmem, and PgStat_LocalState::snapshot.

◆ pgstat_fetch_stat_archiver()

PgStat_ArchiverStats * pgstat_fetch_stat_archiver ( void  )

Definition at line 58 of file pgstat_archiver.c.

59{
61
63}
void pgstat_snapshot_fixed(PgStat_Kind kind)
Definition pgstat.c:1070
#define PGSTAT_KIND_ARCHIVER
Definition pgstat_kind.h:35

References PgStat_Snapshot::archiver, PGSTAT_KIND_ARCHIVER, pgstat_snapshot_fixed(), pgStatLocal, and PgStat_LocalState::snapshot.

Referenced by pg_stat_get_archiver().

◆ pgstat_report_archiver()

void pgstat_report_archiver ( const char xlog,
bool  failed 
)

Definition at line 28 of file pgstat_archiver.c.

29{
32
34
35 if (failed)
36 {
37 ++stats_shmem->stats.failed_count;
38 memcpy(&stats_shmem->stats.last_failed_wal, xlog,
39 sizeof(stats_shmem->stats.last_failed_wal));
40 stats_shmem->stats.last_failed_timestamp = now;
41 }
42 else
43 {
44 ++stats_shmem->stats.archived_count;
45 memcpy(&stats_shmem->stats.last_archived_wal, xlog,
46 sizeof(stats_shmem->stats.last_archived_wal));
47 stats_shmem->stats.last_archived_timestamp = now;
48 }
49
51}
TimestampTz GetCurrentTimestamp(void)
Definition timestamp.c:1645
Datum now(PG_FUNCTION_ARGS)
Definition timestamp.c:1609
int64 TimestampTz
Definition timestamp.h:39
static void pgstat_end_changecount_write(uint32 *cc)
static void pgstat_begin_changecount_write(uint32 *cc)

References PgStat_ShmemControl::archiver, fb(), GetCurrentTimestamp(), now(), pgstat_begin_changecount_write(), pgstat_end_changecount_write(), pgStatLocal, and PgStat_LocalState::shmem.

Referenced by pgarch_ArchiverCopyLoop().