PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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)
 
static void bbsink_progress_cleanup (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)
 

Variables

static const bbsink_ops bbsink_progress_ops
 

Function Documentation

◆ basebackup_progress_estimate_backup_size()

void basebackup_progress_estimate_backup_size ( void  )

Definition at line 212 of file basebackup_progress.c.

213{
216}
void pgstat_progress_update_param(int index, int64 val)
#define PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE
Definition progress.h:163
#define PROGRESS_BASEBACKUP_PHASE
Definition progress.h:154

References pgstat_progress_update_param(), PROGRESS_BASEBACKUP_PHASE, and PROGRESS_BASEBACKUP_PHASE_ESTIMATE_BACKUP_SIZE.

Referenced by perform_base_backup().

◆ basebackup_progress_transfer_wal()

◆ basebackup_progress_wait_checkpoint()

◆ basebackup_progress_wait_wal_archive()

void basebackup_progress_wait_wal_archive ( bbsink_state state)

Definition at line 222 of file basebackup_progress.c.

223{
224 const int index[] = {
227 };
228 int64 val[2];
229
230 /*
231 * We report having finished all tablespaces at this point, even if the
232 * archive for the main tablespace is still open, because what's going to
233 * be added is WAL files, not files that are really from the main
234 * tablespace.
235 */
237 val[1] = list_length(state->tablespaces);
239}
void pgstat_progress_update_multi_param(int nparam, const int *index, const int64 *val)
int64_t int64
Definition c.h:680
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:165
#define PROGRESS_BASEBACKUP_TBLSPC_STREAMED
Definition progress.h:158
Definition type.h:97

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 156 of file basebackup_progress.c.

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

References bbsink_forward_archive_contents(), fb(), 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 90 of file basebackup_progress.c.

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

References bbsink_forward_begin_backup(), fb(), list_length(), pgstat_progress_update_multi_param(), PROGRESS_BASEBACKUP_BACKUP_TOTAL, PROGRESS_BASEBACKUP_PHASE, PROGRESS_BASEBACKUP_PHASE_STREAM_BACKUP, PROGRESS_BASEBACKUP_TBLSPC_TOTAL, and val.

◆ bbsink_progress_cleanup()

static void bbsink_progress_cleanup ( bbsink sink)
static

Definition at line 192 of file basebackup_progress.c.

193{
196}
void pgstat_progress_end_command(void)
void bbsink_forward_cleanup(bbsink *sink)

References bbsink_forward_cleanup(), fb(), and pgstat_progress_end_command().

◆ bbsink_progress_end_archive()

static void bbsink_progress_end_archive ( bbsink sink)
static

Definition at line 120 of file basebackup_progress.c.

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

References bbsink_forward_end_archive(), fb(), list_length(), pgstat_progress_update_param(), and PROGRESS_BASEBACKUP_TBLSPC_STREAMED.

◆ bbsink_progress_new()

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

Definition at line 60 of file basebackup_progress.c.

61{
62 bbsink *sink;
63
64 Assert(next != NULL);
65
67 *((const bbsink_ops **) &sink->bbs_ops) = &bbsink_progress_ops;
68 sink->bbs_next = next;
69
70 /*
71 * Report that a base backup is in progress, and set the total size of the
72 * backup to -1, which will get translated to NULL. If we're estimating
73 * the backup size, we'll insert the real estimate when we have it. Also,
74 * the backup type is set.
75 */
79 incremental
82
83 return sink;
84}
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:225
#define Assert(condition)
Definition c.h:1002
#define palloc0_object(type)
Definition fe_memutils.h:90
#define InvalidOid
#define PROGRESS_BASEBACKUP_BACKUP_TYPE
Definition progress.h:159
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL
Definition progress.h:170
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL
Definition progress.h:169

References Assert, bbsink_progress_ops, fb(), InvalidOid, next, palloc0_object, 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_cleanup(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_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 43 of file basebackup_progress.c.

43 {
44 .begin_backup = bbsink_progress_begin_backup,
45 .begin_archive = bbsink_forward_begin_archive,
46 .archive_contents = bbsink_progress_archive_contents,
47 .end_archive = bbsink_progress_end_archive,
48 .begin_manifest = bbsink_forward_begin_manifest,
49 .manifest_contents = bbsink_forward_manifest_contents,
50 .end_manifest = bbsink_forward_end_manifest,
51 .end_backup = bbsink_forward_end_backup,
53};

Referenced by bbsink_progress_new().