Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
basebackup_progress.c File Reference
#include "postgres.h"
#include "backup/basebackup_sink.h"
#include "commands/progress.h"
#include "pgstat.h"
Include dependency graph for basebackup_progress.c:

Go to the source code of this file.

Functions

static void bbsink_progress_begin_backup (bbsink *sink)
 
static void bbsink_progress_archive_contents (bbsink *sink, size_t len)
 
static void bbsink_progress_end_archive (bbsink *sink)
 
bbsinkbbsink_progress_new (bbsink *next, bool estimate_backup_size, bool incremental)
 
void basebackup_progress_wait_checkpoint (void)
 
void basebackup_progress_estimate_backup_size (void)
 
void basebackup_progress_wait_wal_archive (bbsink_state *state)
 
void basebackup_progress_transfer_wal (void)
 
void basebackup_progress_done (void)
 

Variables

static const bbsink_ops bbsink_progress_ops
 

Function Documentation

◆ basebackup_progress_done()

void basebackup_progress_done ( void  )

Definition at line 244 of file basebackup_progress.c.

245{
247}
void pgstat_progress_end_command(void)

References pgstat_progress_end_command().

Referenced by perform_base_backup().

◆ basebackup_progress_estimate_backup_size()

void basebackup_progress_estimate_backup_size ( void  )

Definition at line 201 of file basebackup_progress.c.

202{
205}
void pgstat_progress_update_param(int index, int64 val)
#define PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE
Definition: progress.h:137
#define PROGRESS_BASEBACKUP_PHASE
Definition: progress.h:128

References pgstat_progress_update_param(), PROGRESS_BASEBACKUP_PHASE, and PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE.

Referenced by perform_base_backup().

◆ basebackup_progress_transfer_wal()

void basebackup_progress_transfer_wal ( void  )

◆ basebackup_progress_wait_checkpoint()

void basebackup_progress_wait_checkpoint ( void  )

◆ basebackup_progress_wait_wal_archive()

void basebackup_progress_wait_wal_archive ( bbsink_state state)

Definition at line 211 of file basebackup_progress.c.

212{
213 const int index[] = {
216 };
217 int64 val[2];
218
219 /*
220 * We report having finished all tablespaces at this point, even if the
221 * archive for the main tablespace is still open, because what's going to
222 * be added is WAL files, not files that are really from the main
223 * tablespace.
224 */
226 val[1] = list_length(state->tablespaces);
228}
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
int64_t int64
Definition: c.h:536
long val
Definition: informix.c:689
static int list_length(const List *l)
Definition: pg_list.h:152
#define PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE
Definition: progress.h:139
#define PROGRESS_BASEBACKUP_TBLSPC_STREAMED
Definition: progress.h:132
Definition: type.h:96
Definition: regguts.h:323

References list_length(), pgstat_progress_update_multi_param(), PROGRESS_BASEBACKUP_PHASE, PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE, PROGRESS_BASEBACKUP_TBLSPC_STREAMED, and val.

Referenced by perform_base_backup().

◆ bbsink_progress_archive_contents()

static void bbsink_progress_archive_contents ( bbsink sink,
size_t  len 
)
static

Definition at line 155 of file basebackup_progress.c.

156{
158 const int index[] = {
161 };
162 int64 val[2];
163 int nparam = 0;
164
165 /* First update bbsink_state with # of bytes done. */
166 state->bytes_done += len;
167
168 /* Now forward to next sink. */
170
171 /* Prepare to set # of bytes done for command progress reporting. */
172 val[nparam++] = state->bytes_done;
173
174 /*
175 * We may also want to update # of total bytes, to avoid overflowing past
176 * 100% or the full size. This may make the total size number change as we
177 * approach the end of the backup (the estimate will always be wrong if
178 * WAL is included), but that's better than having the done column be
179 * bigger than the total.
180 */
181 if (state->bytes_total_is_valid && state->bytes_done > state->bytes_total)
182 val[nparam++] = state->bytes_done;
183
185}
void bbsink_forward_archive_contents(bbsink *sink, size_t len)
const void size_t len
#define PROGRESS_BASEBACKUP_BACKUP_TOTAL
Definition: progress.h:129
#define PROGRESS_BASEBACKUP_BACKUP_STREAMED
Definition: progress.h:130
bbsink_state * bbs_state

References bbsink::bbs_state, bbsink_forward_archive_contents(), len, pgstat_progress_update_multi_param(), PROGRESS_BASEBACKUP_BACKUP_STREAMED, PROGRESS_BASEBACKUP_BACKUP_TOTAL, and val.

◆ bbsink_progress_begin_backup()

static void bbsink_progress_begin_backup ( bbsink sink)
static

Definition at line 89 of file basebackup_progress.c.

90{
91 const int index[] = {
95 };
96 int64 val[3];
97
98 /*
99 * Report that we are now streaming database files as a base backup. Also
100 * advertise the number of tablespaces, and, if known, the estimated total
101 * backup size.
102 */
105 val[1] = sink->bbs_state->bytes_total;
106 else
107 val[1] = -1;
110
111 /* Delegate to next sink. */
113}
void bbsink_forward_begin_backup(bbsink *sink)
#define PROGRESS_BASEBACKUP_TBLSPC_TOTAL
Definition: progress.h:131
#define PROGRESS_BASEBACKUP_PHASE_STREAM_BACKUP
Definition: progress.h:138
bool bytes_total_is_valid
uint64 bytes_total
List * tablespaces

References bbsink::bbs_state, bbsink_forward_begin_backup(), bbsink_state::bytes_total, bbsink_state::bytes_total_is_valid, list_length(), pgstat_progress_update_multi_param(), PROGRESS_BASEBACKUP_BACKUP_TOTAL, PROGRESS_BASEBACKUP_PHASE, PROGRESS_BASEBACKUP_PHASE_STREAM_BACKUP, PROGRESS_BASEBACKUP_TBLSPC_TOTAL, bbsink_state::tablespaces, and val.

◆ bbsink_progress_end_archive()

static void bbsink_progress_end_archive ( bbsink sink)
static

Definition at line 119 of file basebackup_progress.c.

120{
121 /*
122 * We expect one archive per tablespace, so reaching the end of an archive
123 * also means reaching the end of a tablespace. (Some day we might have a
124 * reason to decouple these concepts.)
125 *
126 * If WAL is included in the backup, we'll mark the last tablespace
127 * complete before the last archive is complete, so we need a guard here
128 * to ensure that the number of tablespaces streamed doesn't exceed the
129 * total.
130 */
133 sink->bbs_state->tablespace_num + 1);
134
135 /* Delegate to next sink. */
137
138 /*
139 * This is a convenient place to update the bbsink_state's notion of which
140 * is the current tablespace. Note that the bbsink_state object is shared
141 * across all bbsink objects involved, but we're the outermost one and
142 * this is the very last thing we do.
143 */
144 sink->bbs_state->tablespace_num++;
145}
void bbsink_forward_end_archive(bbsink *sink)

References bbsink::bbs_state, bbsink_forward_end_archive(), list_length(), pgstat_progress_update_param(), PROGRESS_BASEBACKUP_TBLSPC_STREAMED, bbsink_state::tablespace_num, and bbsink_state::tablespaces.

◆ bbsink_progress_new()

bbsink * bbsink_progress_new ( bbsink next,
bool  estimate_backup_size,
bool  incremental 
)

Definition at line 59 of file basebackup_progress.c.

60{
61 bbsink *sink;
62
63 Assert(next != NULL);
64
65 sink = palloc0(sizeof(bbsink));
66 *((const bbsink_ops **) &sink->bbs_ops) = &bbsink_progress_ops;
67 sink->bbs_next = next;
68
69 /*
70 * Report that a base backup is in progress, and set the total size of the
71 * backup to -1, which will get translated to NULL. If we're estimating
72 * the backup size, we'll insert the real estimate when we have it. Also,
73 * the backup type is set.
74 */
78 incremental
81
82 return sink;
83}
void pgstat_progress_start_command(ProgressCommandType cmdtype, Oid relid)
@ PROGRESS_COMMAND_BASEBACKUP
static const bbsink_ops bbsink_progress_ops
static int32 next
Definition: blutils.c:224
Assert(PointerIsAligned(start, uint64))
void * palloc0(Size size)
Definition: mcxt.c:1395
#define InvalidOid
Definition: postgres_ext.h:37
#define PROGRESS_BASEBACKUP_BACKUP_TYPE
Definition: progress.h:133
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL
Definition: progress.h:144
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL
Definition: progress.h:143
bbsink * bbs_next
const bbsink_ops * bbs_ops

References Assert(), bbsink::bbs_next, bbsink::bbs_ops, bbsink_progress_ops, InvalidOid, next, palloc0(), pgstat_progress_start_command(), pgstat_progress_update_param(), PROGRESS_BASEBACKUP_BACKUP_TOTAL, PROGRESS_BASEBACKUP_BACKUP_TYPE, PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL, PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL, and PROGRESS_COMMAND_BASEBACKUP.

Referenced by SendBaseBackup().

Variable Documentation

◆ bbsink_progress_ops

const bbsink_ops bbsink_progress_ops
static
Initial value:
= {
.begin_archive = bbsink_forward_begin_archive,
.archive_contents = bbsink_progress_archive_contents,
.begin_manifest = bbsink_forward_begin_manifest,
.manifest_contents = bbsink_forward_manifest_contents,
.end_manifest = bbsink_forward_end_manifest,
}
static void bbsink_progress_end_archive(bbsink *sink)
static void bbsink_progress_begin_backup(bbsink *sink)
static void bbsink_progress_archive_contents(bbsink *sink, size_t len)
void bbsink_forward_begin_manifest(bbsink *sink)
void bbsink_forward_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
void bbsink_forward_cleanup(bbsink *sink)
void bbsink_forward_manifest_contents(bbsink *sink, size_t len)
void bbsink_forward_begin_archive(bbsink *sink, const char *archive_name)
void bbsink_forward_end_manifest(bbsink *sink)

Definition at line 42 of file basebackup_progress.c.

Referenced by bbsink_progress_new().