Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit67e0adf

Browse files
committed
Report NULL as total backup size if it's not estimated.
Previously 0 was reported in pg_stat_progress_basebackup.total_backupif the total backup size was not estimated. Per discussion, our consensusis that NULL is better choise as the value in total_backup in that case.So this commit makes pg_stat_progress_basebackup view report NULLin total_backup column if the estimation is disabled.Bump catversion.Author: Fujii MasaoReviewed-by: Amit Langote, Magnus Hagander, Alvaro HerreraDiscussion:https://postgr.es/m/CABUevExnhOD89zBDuPvfAAh243RzNpwCPEWNLtMYpKHMB8gbAQ@mail.gmail.com
1 parent64fe602 commit67e0adf

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed

‎doc/src/sgml/monitoring.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4403,7 +4403,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS pid,
44034403
total size. If the estimation is disabled in
44044404
<application>pg_basebackup</application>
44054405
(i.e., <literal>--no-estimate-size</literal> option is specified),
4406-
this is <literal>0</literal>.
4406+
this is <literal>NULL</literal>.
44074407
</entry>
44084408
</row>
44094409
<row>

‎doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ PostgreSQL documentation
546546
amount of backup data that will be streamed, resulting in the
547547
<literal>backup_total</literal> column in the
548548
<structname>pg_stat_progress_basebackup</structname>
549-
to be <literal>0</literal>.
549+
to be <literal>NULL</literal>.
550550
</para>
551551
<para>
552552
Without this option, the backup will start by enumerating

‎src/backend/catalog/system_views.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ CREATE VIEW pg_stat_progress_basebackup AS
10701070
WHEN4 THEN'waiting for wal archiving to finish'
10711071
WHEN5 THEN'transferring wal files'
10721072
ENDAS phase,
1073-
S.param2AS backup_total,
1073+
CASES.param2 WHEN-1 THENNULL ELSES.param2 ENDAS backup_total,
10741074
S.param3AS backup_streamed,
10751075
S.param4AS tablespaces_total,
10761076
S.param5AS tablespaces_streamed

‎src/backend/replication/basebackup.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ static long long int total_checksum_failures;
123123
/* Do not verify checksums. */
124124
staticboolnoverify_checksums= false;
125125

126-
/* Total amount of backup data that will be streamed */
126+
/*
127+
* Total amount of backup data that will be streamed.
128+
* -1 means that the size is not estimated.
129+
*/
127130
staticint64backup_total=0;
128131

129132
/* Amount of backup data already streamed */
@@ -258,6 +261,18 @@ perform_base_backup(basebackup_options *opt)
258261
backup_streamed=0;
259262
pgstat_progress_start_command(PROGRESS_COMMAND_BASEBACKUP,InvalidOid);
260263

264+
/*
265+
* If the estimation of the total backup size is disabled, make the
266+
* backup_total column in the view return NULL by setting the parameter to
267+
* -1.
268+
*/
269+
if (!opt->progress)
270+
{
271+
backup_total=-1;
272+
pgstat_progress_update_param(PROGRESS_BASEBACKUP_BACKUP_TOTAL,
273+
backup_total);
274+
}
275+
261276
datadirpathlen=strlen(DataDir);
262277

263278
backup_started_in_recovery=RecoveryInProgress();
@@ -1842,7 +1857,7 @@ update_basebackup_progress(int64 delta)
18421857
* will always be wrong if WAL is included), but that's better than having
18431858
* the done column be bigger than the total.
18441859
*/
1845-
if (backup_total>0&&backup_streamed>backup_total)
1860+
if (backup_total>-1&&backup_streamed>backup_total)
18461861
{
18471862
backup_total=backup_streamed;
18481863
val[nparam++]=backup_total;

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO202003191
56+
#defineCATALOG_VERSION_NO202003241
5757

5858
#endif

‎src/test/regress/expected/rules.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,10 @@ pg_stat_progress_basebackup| SELECT s.pid,
18861886
WHEN 5 THEN 'transferring wal files'::text
18871887
ELSE NULL::text
18881888
END AS phase,
1889-
s.param2 AS backup_total,
1889+
CASE s.param2
1890+
WHEN '-1'::integer THEN NULL::bigint
1891+
ELSE s.param2
1892+
END AS backup_total,
18901893
s.param3 AS backup_streamed,
18911894
s.param4 AS tablespaces_total,
18921895
s.param5 AS tablespaces_streamed

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp