Skip to content

Commit deb6744

Browse files
Add backup_type column to pg_stat_progress_basebackup.
This commit introduces a new column backup_type that indicates the type of backup being performed: either 'full' or 'incremental'. Bump catalog version. Author: Shinya Kato <shinya11.kato@gmail.com> Reviewed-by: Yugo Nagata <nagata@sraoss.co.jp> Discussion: https://postgr.es/m/CAOzEurQuzbHwTj1ehk1a+eeQDidJPyrE5s6mYumkjwjZnurhkQ@mail.gmail.com
1 parent 295a397 commit deb6744

File tree

8 files changed

+36
-7
lines changed

8 files changed

+36
-7
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6791,6 +6791,16 @@ FROM pg_stat_get_backend_idset() AS backendid;
67916791
advances when the phase is <literal>streaming database files</literal>.
67926792
</para></entry>
67936793
</row>
6794+
6795+
<row>
6796+
<entry role="catalog_table_entry"><para role="column_definition">
6797+
<structfield>backup_type</structfield> <type>text</type>
6798+
</para>
6799+
<para>
6800+
Backup type. Either <literal>full</literal> or
6801+
<literal>incremental</literal>.
6802+
</para></entry>
6803+
</row>
67946804
</tbody>
67956805
</tgroup>
67966806
</table>

src/backend/backup/basebackup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ SendBaseBackup(BaseBackupCmd *cmd, IncrementalBackupInfo *ib)
10481048
sink = bbsink_zstd_new(sink, &opt.compression_specification);
10491049

10501050
/* Set up progress reporting. */
1051-
sink = bbsink_progress_new(sink, opt.progress);
1051+
sink = bbsink_progress_new(sink, opt.progress, opt.incremental);
10521052

10531053
/*
10541054
* Perform the base backup, but make sure we clean up the bbsink even if

src/backend/backup/basebackup_progress.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static const bbsink_ops bbsink_progress_ops = {
5656
* forwards data to a successor sink.
5757
*/
5858
bbsink *
59-
bbsink_progress_new(bbsink *next, bool estimate_backup_size)
59+
bbsink_progress_new(bbsink *next, bool estimate_backup_size, bool incremental)
6060
{
6161
bbsink *sink;
6262

@@ -69,10 +69,15 @@ bbsink_progress_new(bbsink *next, bool estimate_backup_size)
6969
/*
7070
* Report that a base backup is in progress, and set the total size of the
7171
* 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.
72+
* the backup size, we'll insert the real estimate when we have it. Also,
73+
* the backup type is set.
7374
*/
7475
pgstat_progress_start_command(PROGRESS_COMMAND_BASEBACKUP, InvalidOid);
7576
pgstat_progress_update_param(PROGRESS_BASEBACKUP_BACKUP_TOTAL, -1);
77+
pgstat_progress_update_param(PROGRESS_BASEBACKUP_BACKUP_TYPE,
78+
incremental
79+
? PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL
80+
: PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL);
7681

7782
return sink;
7883
}

src/backend/catalog/system_views.sql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,7 +1327,10 @@ CREATE VIEW pg_stat_progress_basebackup AS
13271327
CASE S.param2 WHEN -1 THEN NULL ELSE S.param2 END AS backup_total,
13281328
S.param3 AS backup_streamed,
13291329
S.param4 AS tablespaces_total,
1330-
S.param5 AS tablespaces_streamed
1330+
S.param5 AS tablespaces_streamed,
1331+
CASE S.param6 WHEN 1 THEN 'full'
1332+
WHEN 2 THEN 'incremental'
1333+
END AS backup_type
13311334
FROM pg_stat_get_progress_info('BASEBACKUP') AS S;
13321335

13331336

src/include/backup/basebackup_sink.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ extern bbsink *bbsink_copystream_new(bool send_to_client);
287287
extern bbsink *bbsink_gzip_new(bbsink *next, pg_compress_specification *);
288288
extern bbsink *bbsink_lz4_new(bbsink *next, pg_compress_specification *);
289289
extern bbsink *bbsink_zstd_new(bbsink *next, pg_compress_specification *);
290-
extern bbsink *bbsink_progress_new(bbsink *next, bool estimate_backup_size);
290+
extern bbsink *bbsink_progress_new(bbsink *next, bool estimate_backup_size,
291+
bool incremental);
291292
extern bbsink *bbsink_server_new(bbsink *next, char *pathname);
292293
extern bbsink *bbsink_throttle_new(bbsink *next, uint32 maxrate);
293294

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202508041
60+
#define CATALOG_VERSION_NO 202508051
6161

6262
#endif

src/include/commands/progress.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
#define PROGRESS_BASEBACKUP_BACKUP_STREAMED 2
131131
#define PROGRESS_BASEBACKUP_TBLSPC_TOTAL 3
132132
#define PROGRESS_BASEBACKUP_TBLSPC_STREAMED 4
133+
#define PROGRESS_BASEBACKUP_BACKUP_TYPE 5
133134

134135
/* Phases of pg_basebackup (as advertised via PROGRESS_BASEBACKUP_PHASE) */
135136
#define PROGRESS_BASEBACKUP_PHASE_WAIT_CHECKPOINT 1
@@ -138,6 +139,10 @@
138139
#define PROGRESS_BASEBACKUP_PHASE_WAIT_WAL_ARCHIVE 4
139140
#define PROGRESS_BASEBACKUP_PHASE_TRANSFER_WAL 5
140141

142+
/* Types of pg_basebackup (as advertised via PROGRESS_BASEBACKUP_BACKUP_TYPE) */
143+
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_FULL 1
144+
#define PROGRESS_BASEBACKUP_BACKUP_TYPE_INCREMENTAL 2
145+
141146
/* Progress parameters for PROGRESS_COPY */
142147
#define PROGRESS_COPY_BYTES_PROCESSED 0
143148
#define PROGRESS_COPY_BYTES_TOTAL 1

src/test/regress/expected/rules.out

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1977,7 +1977,12 @@ pg_stat_progress_basebackup| SELECT pid,
19771977
END AS backup_total,
19781978
param3 AS backup_streamed,
19791979
param4 AS tablespaces_total,
1980-
param5 AS tablespaces_streamed
1980+
param5 AS tablespaces_streamed,
1981+
CASE param6
1982+
WHEN 1 THEN 'full'::text
1983+
WHEN 2 THEN 'incremental'::text
1984+
ELSE NULL::text
1985+
END AS backup_type
19811986
FROM pg_stat_get_progress_info('BASEBACKUP'::text) s(pid, datid, relid, param1, param2, param3, param4, param5, param6, param7, param8, param9, param10, param11, param12, param13, param14, param15, param16, param17, param18, param19, param20);
19821987
pg_stat_progress_cluster| SELECT s.pid,
19831988
s.datid,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy