PostgreSQL Source Code  git master
backend_progress.c File Reference
#include "postgres.h"
#include "access/parallel.h"
#include "libpq/pqformat.h"
#include "utils/backend_progress.h"
#include "utils/backend_status.h"
Include dependency graph for backend_progress.c:

Go to the source code of this file.

Functions

void pgstat_progress_start_command (ProgressCommandType cmdtype, Oid relid)
 
void pgstat_progress_update_param (int index, int64 val)
 
void pgstat_progress_incr_param (int index, int64 incr)
 
void pgstat_progress_parallel_incr_param (int index, int64 incr)
 
void pgstat_progress_update_multi_param (int nparam, const int *index, const int64 *val)
 
void pgstat_progress_end_command (void)
 

Function Documentation

◆ pgstat_progress_end_command()

void pgstat_progress_end_command ( void  )

Definition at line 150 of file backend_progress.c.

151 {
152  volatile PgBackendStatus *beentry = MyBEEntry;
153 
154  if (!beentry || !pgstat_track_activities)
155  return;
156 
158  return;
159 
163  PGSTAT_END_WRITE_ACTIVITY(beentry);
164 }
@ PROGRESS_COMMAND_INVALID
PgBackendStatus * MyBEEntry
bool pgstat_track_activities
#define PGSTAT_END_WRITE_ACTIVITY(beentry)
#define PGSTAT_BEGIN_WRITE_ACTIVITY(beentry)
#define InvalidOid
Definition: postgres_ext.h:36
ProgressCommandType st_progress_command
Oid st_progress_command_target

References InvalidOid, MyBEEntry, PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, pgstat_track_activities, PROGRESS_COMMAND_INVALID, PgBackendStatus::st_progress_command, and PgBackendStatus::st_progress_command_target.

Referenced by AbortSubTransaction(), AbortTransaction(), analyze_rel(), basebackup_progress_done(), cluster_rel(), DefineIndex(), EndCopy(), EndCopyFrom(), heap_vacuum_rel(), reindex_index(), and ReindexRelationConcurrently().

◆ pgstat_progress_incr_param()

void pgstat_progress_incr_param ( int  index,
int64  incr 
)

Definition at line 69 of file backend_progress.c.

70 {
71  volatile PgBackendStatus *beentry = MyBEEntry;
72 
74 
75  if (!beentry || !pgstat_track_activities)
76  return;
77 
79  beentry->st_progress_param[index] += incr;
81 }
#define PGSTAT_NUM_PROGRESS_PARAM
#define Assert(condition)
Definition: c.h:812
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
Definition: type.h:96

References Assert, MyBEEntry, PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, PGSTAT_NUM_PROGRESS_PARAM, pgstat_track_activities, and PgBackendStatus::st_progress_param.

Referenced by DefineIndex(), HandleParallelMessage(), and pgstat_progress_parallel_incr_param().

◆ pgstat_progress_parallel_incr_param()

void pgstat_progress_parallel_incr_param ( int  index,
int64  incr 
)

Definition at line 91 of file backend_progress.c.

92 {
93  /*
94  * Parallel workers notify a leader through a PqMsg_Progress message to
95  * update progress, passing the progress index and incremented value.
96  * Leaders can just call pgstat_progress_incr_param directly.
97  */
98  if (IsParallelWorker())
99  {
100  static StringInfoData progress_message;
101 
102  initStringInfo(&progress_message);
103 
104  pq_beginmessage(&progress_message, PqMsg_Progress);
105  pq_sendint32(&progress_message, index);
106  pq_sendint64(&progress_message, incr);
107  pq_endmessage(&progress_message);
108  }
109  else
111 }
void pgstat_progress_incr_param(int index, int64 incr)
#define IsParallelWorker()
Definition: parallel.h:60
void pq_endmessage(StringInfo buf)
Definition: pqformat.c:296
void pq_beginmessage(StringInfo buf, char msgtype)
Definition: pqformat.c:88
static void pq_sendint32(StringInfo buf, uint32 i)
Definition: pqformat.h:144
static void pq_sendint64(StringInfo buf, uint64 i)
Definition: pqformat.h:152
#define PqMsg_Progress
Definition: protocol.h:69
void initStringInfo(StringInfo str)
Definition: stringinfo.c:56

References initStringInfo(), IsParallelWorker, pgstat_progress_incr_param(), pq_beginmessage(), pq_endmessage(), pq_sendint32(), pq_sendint64(), and PqMsg_Progress.

Referenced by parallel_vacuum_process_one_index().

◆ pgstat_progress_start_command()

void pgstat_progress_start_command ( ProgressCommandType  cmdtype,
Oid  relid 
)

◆ pgstat_progress_update_multi_param()

◆ pgstat_progress_update_param()

void pgstat_progress_update_param ( int  index,
int64  val 
)

Definition at line 48 of file backend_progress.c.

49 {
50  volatile PgBackendStatus *beentry = MyBEEntry;
51 
53 
54  if (!beentry || !pgstat_track_activities)
55  return;
56 
58  beentry->st_progress_param[index] = val;
60 }

References Assert, MyBEEntry, PGSTAT_BEGIN_WRITE_ACTIVITY, PGSTAT_END_WRITE_ACTIVITY, PGSTAT_NUM_PROGRESS_PARAM, pgstat_track_activities, PgBackendStatus::st_progress_param, and val.

Referenced by _bt_leafbuild(), _bt_load(), _bt_parallel_scan_and_sort(), _bt_spools_heapscan(), _h_indexbuild(), acquire_inherited_sample_rows(), acquire_sample_rows(), basebackup_progress_estimate_backup_size(), basebackup_progress_transfer_wal(), basebackup_progress_wait_checkpoint(), bbsink_progress_end_archive(), bbsink_progress_new(), btvacuumscan(), BuildRelationExtStatistics(), cluster_rel(), copy_dest_receive(), CopyFrom(), CopyLoadRawBuf(), CopyMultiInsertBufferFlush(), CopySendEndOfRow(), DefineIndex(), do_analyze_rel(), DoCopyTo(), finish_heap_swap(), hashbuild(), heap_vacuum_rel(), heapam_index_build_range_scan(), heapam_index_validate_scan(), heapam_relation_copy_for_cluster(), lazy_cleanup_all_indexes(), lazy_scan_heap(), lazy_truncate_heap(), lazy_vacuum_all_indexes(), lazy_vacuum_heap_page(), lazy_vacuum_heap_rel(), reindex_index(), reindex_relation(), ReindexRelationConcurrently(), validate_index(), WaitForLockersMultiple(), and WaitForOlderSnapshots().