PostgreSQL Source Code  git master
backend_progress.c File Reference
#include "postgres.h"
#include "access/parallel.h"
#include "libpq/pqformat.h"
#include "port/atomics.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 151 of file backend_progress.c.

152 {
153  volatile PgBackendStatus *beentry = MyBEEntry;
154 
155  if (!beentry || !pgstat_track_activities)
156  return;
157 
159  return;
160 
164  PGSTAT_END_WRITE_ACTIVITY(beentry);
165 }
@ 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 70 of file backend_progress.c.

71 {
72  volatile PgBackendStatus *beentry = MyBEEntry;
73 
75 
76  if (!beentry || !pgstat_track_activities)
77  return;
78 
80  beentry->st_progress_param[index] += incr;
82 }
#define PGSTAT_NUM_PROGRESS_PARAM
#define Assert(condition)
Definition: c.h:861
int64 st_progress_param[PGSTAT_NUM_PROGRESS_PARAM]
Definition: type.h:95

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 92 of file backend_progress.c.

93 {
94  /*
95  * Parallel workers notify a leader through a PqMsg_Progress message to
96  * update progress, passing the progress index and incremented value.
97  * Leaders can just call pgstat_progress_incr_param directly.
98  */
99  if (IsParallelWorker())
100  {
101  static StringInfoData progress_message;
102 
103  initStringInfo(&progress_message);
104 
105  pq_beginmessage(&progress_message, PqMsg_Progress);
106  pq_sendint32(&progress_message, index);
107  pq_sendint64(&progress_message, incr);
108  pq_endmessage(&progress_message);
109  }
110  else
112 }
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:59

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 49 of file backend_progress.c.

50 {
51  volatile PgBackendStatus *beentry = MyBEEntry;
52 
54 
55  if (!beentry || !pgstat_track_activities)
56  return;
57 
59  beentry->st_progress_param[index] = val;
61 }

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().