aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2011-08-16 16:56:47 +0200
committerMagnus Hagander <magnus@hagander.net>2011-08-16 16:59:22 +0200
commit0615782b23d3e4a9d9acece919bd77f919928953 (patch)
tree849c4fbca15afafd05b462b5516170b9717e3c62
parentbe78374f160d4a3bb2357d38e3196f8dcd4ffcc1 (diff)
downloadpostgresql-0615782b23d3e4a9d9acece919bd77f919928953.tar.gz
postgresql-0615782b23d3e4a9d9acece919bd77f919928953.zip
Adjust total size in pg_basebackup progress report when reality changes
When streaming including WAL, the size estimate will always be incorrect, since we don't know how much WAL is included. To make sure the output doesn't look completely unreasonable, this patch increases the total size whenever we go past the estimate, to make sure we never go above 100%.
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 51b8e45698b..4dab7ff0f2e 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -207,8 +207,17 @@ progress_report(int tablespacenum, const char *filename)
char totaldone_str[32];
char totalsize_str[32];
+ /*
+ * Avoid overflowing past 100% or the full size. This may make the
+ * total size number change as we approach the end of the backup
+ * (the estimate will always be wrong if WAL is included), but
+ * that's better than having the done column be bigger than the
+ * total.
+ */
if (percent > 100)
percent = 100;
+ if (totaldone / 1024 > totalsize)
+ totalsize = totaldone / 1024;
/*
* Separate step to keep platform-dependent format code out of translatable