From 0213aede0fb2cae86b5e6fce94644ef059d9a740 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 15:41:17 +0900
Subject: [PATCH 01/27] developments for postgresql v15
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
・Renamed the functions pg_start_backup()/pg_stop_backup() to
pg_backup_start()/pg_backup_stop() and change the arguments of pg_backup_stop()
pg_rman already supported non-exclusive mode, so we just renamed
the function names and change the arguments to keeps the behavior.
・Default log_checkpoints for regression test is off.
In PostgreSQL15, the default value of log_checkpoints is on.
The checkpoints are automatically triggered when regression tests are run.
The test failed because some log files was updated timestamp and the wrong log was deleted.
So, we turned this feature off before running the test.
---
backup.c | 59 +++++++++++++++++++----------------
pgut/pgut.c | 1 +
sql/arc_srv_log_management.sh | 1 +
3 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/backup.c b/backup.c
index 0a89e29a..2eb075ea 100644
--- a/backup.c
+++ b/backup.c
@@ -46,8 +46,8 @@ static parray *do_backup_database(parray *backup_list, pgBackupOption bkupopt);
static parray *do_backup_arclog(parray *backup_list);
static parray *do_backup_srvlog(parray *backup_list);
static void confirm_block_size(const char *name, int blcksz);
-static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
-static parray *pg_stop_backup(pgBackup *backup);
+static void pg_backup_start(const char *label, bool smooth, pgBackup *backup);
+static parray *pg_backup_stop(pgBackup *backup);
static void pg_switch_wal(pgBackup *backup);
static void get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn);
static void get_xid(PGresult *res, uint32 *xid);
@@ -135,14 +135,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
/* notify start of backup to PostgreSQL server */
time2iso(label, lengthof(label), current.start_time);
strncat(label, " with pg_rman", lengthof(label) - strlen(label) - 1);
- pg_start_backup(label, smooth_checkpoint, ¤t);
+ pg_backup_start(label, smooth_checkpoint, ¤t);
/* Execute restartpoint on standby once replay reaches the backup LSN */
if (current.is_from_standby && !execute_restartpoint(bkupopt, ¤t))
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -266,7 +266,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and save the backup_label and tablespace_map
* files.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
/* stop_backup_files must be listed in file_database.txt. */
files = parray_concat(stop_backup_files, files);
@@ -284,14 +284,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
parray *tblspc_list; /* list of name of TABLESPACE backup from snapshot */
parray *tblspcmp_list; /* list of mounted directory of TABLESPACE in snapshot volume */
PGresult *tblspc_res; /* contain spcname and oid in TABLESPACE */
- parray *stop_backup_files; /* list of files that pg_stop_backup() wrote */
+ parray *stop_backup_files; /* list of files that pg_backup_stop() wrote */
/* if backup is from standby, snapshot backup is unsupported */
if (current.is_from_standby)
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -384,7 +384,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and write backup_label and tablespace_map
* files to backup destination directory.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
files = parray_concat(stop_backup_files, files);
/* create file list of non-snapshot objects */
@@ -569,7 +569,7 @@ execute_restartpoint(pgBackupOption bkupopt, pgBackup *backup)
/*
* Wait for standby server to replay WAL up to the LSN returned by
- * pg_start_backup()
+ * pg_backup_start()
*/
res = execute("SELECT * FROM pg_last_wal_replay_lsn()", 0, NULL);
sscanf(PQgetvalue(res, 0, 0), "%X/%X", &xlogid, &xrecoff);
@@ -647,7 +647,7 @@ do_backup_arclog(parray *backup_list)
files = parray_new();
dir_list_file(files, arclog_path, NULL, true, false);
- /* remove WALs archived after pg_stop_backup()/pg_switch_wal() */
+ /* remove WALs archived after pg_backup_stop()/pg_switch_wal() */
xlog_fname(last_wal, lengthof(last_wal), current.tli, ¤t.stop_lsn,
wal_segment_size);
for (i = 0; i < parray_num(files); i++)
@@ -922,7 +922,7 @@ do_backup(pgBackupOption bkupopt)
/* initialize backup result */
current.status = BACKUP_STATUS_RUNNING;
- current.tli = 0; /* get from result of pg_start_backup() */
+ current.tli = 0; /* get from result of pg_backup_start() */
current.start_lsn = current.stop_lsn = (XLogRecPtr) 0;
current.start_time = time(NULL);
current.end_time = (time_t) 0;
@@ -1107,13 +1107,14 @@ confirm_block_size(const char *name, int blcksz)
* case of taking a backup from standby.
*/
static void
-pg_start_backup(const char *label, bool smooth, pgBackup *backup)
+pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
- const char *params[3];
+ const char *params[2];
+ // const char *params[3];
params[0] = label;
- elog(DEBUG, "executing pg_start_backup()");
+ elog(DEBUG, "executing pg_backup_start()");
/*
* Establish new connection to send backup control commands. The same
@@ -1128,8 +1129,8 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
params[1] = smooth ? "false" : "true";
/* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- params[2] = "false";
- res = execute("SELECT * from pg_walfile_name_offset(pg_start_backup($1, $2, $3))", 3, params);
+ // params[2] = "false";
+ res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
get_lsn(res, &backup->tli, &backup->start_lsn);
@@ -1207,11 +1208,11 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
/*
* Notify the end of backup to PostgreSQL server.
*
- * Contacts the primary server and issues pg_stop_backup(), then waits for
+ * Contacts the primary server and issues pg_backup_stop(), then waits for
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_stop_backup() returns 2 more fields in addition
+ * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1219,7 +1220,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* it to the backup file list.
*/
static parray *
-pg_stop_backup(pgBackup *backup)
+pg_backup_stop(pgBackup *backup)
{
parray *result = parray_new();
pgFile *file;
@@ -1231,12 +1232,12 @@ pg_stop_backup(pgBackup *backup)
int tblspcmap_len;
const char *params[1];
- elog(DEBUG, "executing pg_stop_backup()");
+ elog(DEBUG, "executing pg_backup_stop()");
/*
* Non-exclusive backup requires to use same connection as the one
- * used to issue pg_start_backup(). Remember we did not disconnect
- * in pg_start_backup() nor did we lose our connection when issuing
+ * used to issue pg_backup_start(). Remember we did not disconnect
+ * in pg_backup_start() nor did we lose our connection when issuing
* commands to standby.
*/
Assert(connection != NULL);
@@ -1245,13 +1246,17 @@ pg_stop_backup(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- params[0] = "false";
- res = execute("SELECT * FROM pg_stop_backup($1)", 1, params);
+ /*
+ * This parameter default is true,pg_backup_stop will wait for WAL
+ * pg_backup_startto be archived when archiving is enabled.
+ */
+ params[0] = "true";
+ res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
if (res == NULL || PQntuples(res) != 1 || PQnfields(res) != 3)
ereport(ERROR,
(errcode(ERROR_PG_COMMAND),
- errmsg("result of pg_stop_backup($1) is invalid: %s",
+ errmsg("result of pg_backup_stop($1) is invalid: %s",
PQerrorMessage(connection))));
backup_lsn = PQgetvalue(res, 0, 0);
@@ -1313,7 +1318,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
errmsg("result of pg_walfile_name_offset() is invalid: %s",
PQerrorMessage(connection))));
- /* get TimeLineID, LSN from result of pg_stop_backup() */
+ /* get TimeLineID, LSN from result of pg_backup_stop() */
if (sscanf(PQgetvalue(res, 0, 0), "%08X%08X%08X",
timeline, &xlogid, &off_upper) != 3 ||
sscanf(PQgetvalue(res, 0, 1), "%u", &xrecoff) != 1)
@@ -1332,7 +1337,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
}
/*
- * Get XID from result of txid_current() after pg_stop_backup().
+ * Get XID from result of txid_current() after pg_backup_stop().
*/
static void
get_xid(PGresult *res, uint32 *xid)
diff --git a/pgut/pgut.c b/pgut/pgut.c
index 118defa1..36c8c5ac 100644
--- a/pgut/pgut.c
+++ b/pgut/pgut.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include "pgut.h"
diff --git a/sql/arc_srv_log_management.sh b/sql/arc_srv_log_management.sh
index 9f080dff..78c2c437 100644
--- a/sql/arc_srv_log_management.sh
+++ b/sql/arc_srv_log_management.sh
@@ -47,6 +47,7 @@ wal_level = hot_standby
log_directory = '${SRVLOG_PATH}'
archive_mode = on
archive_command = 'cp %p ${ARCLOG_PATH}/%f'
+log_checkpoints = off
EOF
# start PostgreSQL
From 683524f99d6c5ac2ef4b4d3394c603fd5972c298 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 17:20:24 +0900
Subject: [PATCH 02/27] changed build.yml
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 081475c4..e9608893 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="14.0"
+ ["master"]="15bate1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From 65f7203fd2b269e0d451d274fa66d94f67bf983f Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Fri, 10 Jun 2022 09:26:35 +0900
Subject: [PATCH 03/27] modityed the version
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e9608893..4c2dab7b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="15bate1"
+ ["master"]="15beta1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From 21fd0ec9e09deeaf9b9b2f4b994e18ee1f3aa333 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 21 Jul 2022 13:16:17 +0900
Subject: [PATCH 04/27] change some comment
---
backup.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/backup.c b/backup.c
index 2eb075ea..a840dcd0 100644
--- a/backup.c
+++ b/backup.c
@@ -1111,7 +1111,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
const char *params[2];
- // const char *params[3];
params[0] = label;
elog(DEBUG, "executing pg_backup_start()");
@@ -1123,13 +1122,16 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /* Assumes PG version >= 8.4 */
-
- /* 2nd argument is 'fast' (IOW, !smooth) */
+ /*
+ * Assumes PG version >= 8.4
+ *
+ * When second parameter is given as true,
+ * it specifies executing pg_backup_start as quickly as possible.
+ * This forces an immediate checkpoint which will cause a spike in I/O operations,
+ * slowing any concurrently executing queries.
+ */
params[1] = smooth ? "false" : "true";
- /* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- // params[2] = "false";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1246,10 +1248,6 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- /*
- * This parameter default is true,pg_backup_stop will wait for WAL
- * pg_backup_startto be archived when archiving is enabled.
- */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From c25ff607d40e18fe87fb912574af5563e7a62912 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Wed, 27 Jul 2022 13:13:07 +0900
Subject: [PATCH 05/27] changed some comment
---
backup.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/backup.c b/backup.c
index a840dcd0..2abcac10 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,14 +1122,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /*
- * Assumes PG version >= 8.4
- *
- * When second parameter is given as true,
- * it specifies executing pg_backup_start as quickly as possible.
- * This forces an immediate checkpoint which will cause a spike in I/O operations,
- * slowing any concurrently executing queries.
- */
params[1] = smooth ? "false" : "true";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
@@ -1214,7 +1206,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
+ * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
From d466f13578feb1f537260ac8070bfd976532214e Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 28 Jul 2022 13:49:33 +0900
Subject: [PATCH 06/27] Changed some comments
---
backup.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/backup.c b/backup.c
index 2abcac10..91f16b16 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,8 +1122,10 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
+ /* 2nd argument is 'fast' (IOW, !smooth) */
params[1] = smooth ? "false" : "true";
+ /* non-exclusive' mode (assumes PG version >= 15) */
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1206,7 +1208,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
+ * pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1240,6 +1242,10 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
+ /*
+ * PG version < 15, this parameter means exclusive or non-exclusive mode.
+ * PG version >= 15, this parameter means whether to wait for WAL files to be archived.
+ */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 66bc2146dd29f6a5f29972e205ee02564f06dd93 Mon Sep 17 00:00:00 2001
From: mikecaat <35882227+mikecaat@users.noreply.github.com>
Date: Fri, 26 Aug 2022 10:13:55 +0900
Subject: [PATCH 07/27] Add notes to take a backup at standby-site (#223)
* Add notes to take a backup at standby-site
* Unify 'standby site' to 'standby-site'
Co-authored-by: Masahiro Ikeda
---
docs/index-ja.html | 24 +++++++++++++++++++-----
docs/index.html | 27 +++++++++++++++++++++++----
2 files changed, 42 insertions(+), 9 deletions(-)
diff --git a/docs/index-ja.html b/docs/index-ja.html
index 3d08f97c..f8947cf9 100755
--- a/docs/index-ja.html
+++ b/docs/index-ja.html
@@ -390,19 +390,33 @@ 削除済みバックアップの消去
スタンバイサイトでのバックアップ
-PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでバックアップを取得することができます。
+PostgreSQL 9.0 以降のレプリケーションを利用している場合、スタンバイサイトでもバックアップを取得することができます。
+基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。
-スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。
+
スタンバイサイトでバックアップを取得する場合もアーカイブWALをバックアップ対象にする必要があります。
+共有ディスクなどを用意し、マスタのアーカイブ領域をスタンバイからも参照できるような構成か、
+archive_modeを 'always' として、スタンバイサイトでもアーカイブを出力するような構成にしてください。
-スタンバイサイトで pg_rman を用いたバックアップを行う使用例を示します。 基本的な使用方法は、単体の PostgreSQL で利用する場合と同様なので、注意が必要な点のみ記述します。
+後者の構成の場合は、スタンバイ構築時にプライマリに存在するアーカイブWAL(historyファイルを含む)を同期して、
+リストアに必要なファイルを漏れなく、バックアップ出来るようにしてください。また、--keep-arclog-files / --keep-arclog-daysを
+利用することでバックアップ時に古いアーカイブを削除することが可能ですが、バックアップ取得対象ではないアーカイブ領域は、
+削除対象にならない点に注意してください。そのため、スタンバイサイトでバックアップを取得する場合は、本オプションを利用しても、
+マスタの古いアーカイブを削除することはできません。
+
-まず、バックアップカタログの初期化についてです。 -D
/--pgdata
で指定するものは、スタンバイのデータベースクラスタへのパスとなります。
+バックアップカタログの初期化時には、-D
/--pgdata
で、
+スタンバイのデータベースクラスタへのパスを指定してください。
$ pg_rman init -B <バックアップカタログパス> -D <(スタンバイの)PostgreSQLのデータベースクラスタパス>
-スタンバイサイトでバックアップを取得するには、-D
/--pgdata
オプションでスタンバイサイトのデータベースクラスタを指定し、その他の接続オプション(-d
/--dbname
、-h
/--host
、-p
/--port
など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション (--standby-host
、--standby-port
) でスタンバイサイトの設定情報を指定します。--standby-host
と --standby-port
は両方とも指定する必要があります。
+スタンバイサイトでのバックアップを行うためには、通常の pg_rman の利用方法と異なるオプションを指定する必要があります。
+スタンバイサイトでバックアップを取得するには、-D
/--pgdata
オプションでスタンバイサイトの
+データベースクラスタを指定し、その他の接続オプション(-d
/--dbname
、-h
/--host
、
+-p
/--port
など)でマスタサイトの設定情報を指定します。 スタンバイ接続オプション
+(--standby-host
、--standby-port
) でスタンバイサイトの設定情報を指定します。--standby-host
+と --standby-port
は両方とも指定する必要があります。
以下の環境において、スタンバイサイトからバックアップを取得する際のコマンド例を示します。
diff --git a/docs/index.html b/docs/index.html
index bd0db359..cf336daa 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -379,9 +379,28 @@ Remove deleted backups
Standby-site Backup
-If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site.
+If you use replication feature on PostgreSQL 9.0 later, you can get backup from standby-site.
+The basic usage is the same as when using it with a single master server, so only the points that
+need attention are described.
+
+
+Archive WALs must also be taken when you take a backup of the standby-site.
+So, you need to prepare a shared disk and so on so that the archive area of the master can be
+accessed from the standby, or set archive_mode to 'always' at the standby-site.
+
+
+In the latter case, copy the primary's archive WALs (including history file)
+when the standby-site is created to make sure that you can take back up all the files required for restoring.
+You can delete old archive WALs at the time of backup using --keep-arclog-files / --keep-arclog-days.
+But, since the deletion target is only the one which it take a backup, the master's archived WALs
+are not deleted if you take a backup at standby-site.
+
-You should specify different options from usual use for getting backup from standby-site. In detail, you should specify the database cluster on standby-site by -D
/--pgdata
option. And you should specify information on master-site by connection options (-d
/--dbname
, -h
/--host
, -p
/--port
). In addition, you should specify information to connect standby-site by standby connection options (--standby-host
, --standby-port
).
+You should specify different options from usual use for getting backup from standby-site.
+In detail, you should specify the database cluster on standby-site by -D
/--pgdata
option.
+And you should specify information on master-site by connection options (-d
/--dbname
,
+-h
/--host
, -p
/--port
). In addition, you should specify information
+to connect standby-site by standby connection options (--standby-host
, --standby-port
).
$ pg_rman init -B <a backup catalog path> -D <(the database cluster path(on standby-site)>
@@ -396,7 +415,7 @@ Standby-site Backup
the database cluster path of standby-site: /home/postgres/pgdata_sby
-Then, the backup from standby site can be done with the below command:
+Then, the backup from standby-site can be done with the below command:
$ pg_rman backup --pgdata=/home/postgres/pgdata_sby --backup-mode=full --host=master --standby-host=localhost --standby-port=5432
@@ -744,7 +763,7 @@ Connection options
Standby connection options
-Parameters to connect standby server. They are used only when you get backup from the standby site.
+Parameters to connect standby server. They are used only when you get backup from the standby-site.
--standby-host
From 6958642d415a3295bb99b933faf054292ef4e0d7 Mon Sep 17 00:00:00 2001
From: mikecaat <35882227+mikecaat@users.noreply.github.com>
Date: Fri, 26 Aug 2022 15:43:38 +0900
Subject: [PATCH 08/27] Add documents of --pgconf-path parameter (#222)
---
docs/index-ja.html | 13 +++++++++++--
docs/index.html | 11 ++++++++++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/docs/index-ja.html b/docs/index-ja.html
index f8947cf9..d6c59c0f 100755
--- a/docs/index-ja.html
+++ b/docs/index-ja.html
@@ -670,7 +670,7 @@ バックアップ・オプション
リストア・オプション
-–recovery で始まる変数は recovery.conf のパラメータに対応します。詳細はリカバリの設定を参照してください。
+––recovery で始まる変数は、PostgreSQLのリカバリターゲットのパラメータに対応します。
--recovery-target-timeline TIMELINE
@@ -706,7 +706,7 @@ リストア・オプション
-以下は、リストア時の挙動を指定するパラメータです。
+以下は、リストア時の挙動に関連するパラメータです。
--hard-copy
@@ -717,6 +717,15 @@ リストア・オプション
+
+-G PATH
/ --pgconf-path=PATH
+
+
+- リストアをする際、リカバリの設定も実施します。
data_directory
パラメータなどを利用して、データベースクラスタの保存先と異なる場所にpostgresql.confを保存している場合は、設定ファイルの保存先を絶対パスで指定する必要があります。1.3.14よりも後のバージョンで利用可能です。
+
+
+
+
カタログ・オプション
diff --git a/docs/index.html b/docs/index.html
index cf336daa..92723110 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -657,7 +657,7 @@ Backup options
Restore options
-The parameters which are started with –recovery are same as parameters in recovery.conf. See also “Recovery Configuration” for details.
+The parameters which are started with ––recovery are same as Recovery Target parameters.
--recovery-target-timeline TIMELINE
@@ -704,6 +704,15 @@ Restore options
+
+-G PATH
/ --pgconf-path=PATH
+
+
+- The recovery-related parameters are configured when restoring. If you manage the postgresql.conf in different location of database cluster using
data_directory
and so on, specify the absolute path. This option is provided version higher than 1.3.14.
+
+
+
+
Catalog options
From 31b1e57acf503d575c300e997f0c8604528fa33e Mon Sep 17 00:00:00 2001
From: mikecaat <35882227+mikecaat@users.noreply.github.com>
Date: Mon, 5 Sep 2022 09:08:37 +0900
Subject: [PATCH 09/27] Fix the fail if a tablespace path has PGDATA(#141)
(#210)
Previously, if the server has a tablespace and
its path has PGDATA's path, the restore
fails because mkdirs.sh doesn't work.
For example, the following case fails to restore.
* PGDATA path: /tmp/pgdata
* tablespace path: /tmp/pgdata_tblspc
So, this patch fixes the case. The root cause
is the logic checking whether the file taking backup
is in tablespace or PGDATA.
Because it only considers their prefix, if the prefix
path of tablespace is the same as PGDATA, it decides
the file is in PGDATA.
So, this patch changes the logic to check it has '/'
after the prefix.
---
dir.c | 2 +-
expected/restore.out | 5 +++++
expected/restore_checksum.out | 5 +++++
sql/restore.sh | 31 +++++++++++++++++++++++++++++++
4 files changed, 42 insertions(+), 1 deletion(-)
diff --git a/dir.c b/dir.c
index 5861f610..32531903 100644
--- a/dir.c
+++ b/dir.c
@@ -457,7 +457,7 @@ dir_print_mkdirs_sh(FILE *out, const parray *files, const char *root)
pgFile *file = (pgFile *) parray_get(files, i);
if (S_ISDIR(file->mode))
{
- if (strstr(file->path, root) == file->path)
+ if (strstr(file->path, root) == file->path && file->path[strlen(root)] == '/')
fprintf(out, "mkdir -m 700 -p %s\n", file->path + strlen(root) + 1);
else
fprintf(out, "mkdir -m 700 -p %s\n", file->path);
diff --git a/expected/restore.out b/expected/restore.out
index 60d86b97..31a54288 100644
--- a/expected/restore.out
+++ b/expected/restore.out
@@ -122,3 +122,8 @@ OK: new value is configured for recovery_target_timeline.
0
0
+###### RESTORE COMMAND TEST-0018 ######
+###### check to work even if the path of tablespace has $PGDATA ######
+0
+0
+
diff --git a/expected/restore_checksum.out b/expected/restore_checksum.out
index 265f23af..b10ca9f3 100644
--- a/expected/restore_checksum.out
+++ b/expected/restore_checksum.out
@@ -122,3 +122,8 @@ OK: new value is configured for recovery_target_timeline.
0
0
+###### RESTORE COMMAND TEST-0018 ######
+###### check to work even if the path of tablespace has $PGDATA ######
+0
+0
+
diff --git a/sql/restore.sh b/sql/restore.sh
index 59887cc0..3dabdeaf 100644
--- a/sql/restore.sh
+++ b/sql/restore.sh
@@ -572,6 +572,37 @@ psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches
diff ${TEST_BASE}/TEST-0017-before.out ${TEST_BASE}/TEST-0017-after.out
echo ''
+echo '###### RESTORE COMMAND TEST-0018 ######'
+echo '###### check to work even if the path of tablespace has $PGDATA ######'
+init_backup
+start_postgres
+
+TBLSPC_PATH_HAS_PGDATA_PATH=${PGDATA_PATH}_test_tbl/test
+TEST_DB=test
+
+mkdir -p ${TBLSPC_PATH_HAS_PGDATA_PATH}
+psql --no-psqlrc -p ${TEST_PGPORT} -d postgres > /dev/null 2>&1 << EOF
+CREATE TABLESPACE ${TEST_DB} LOCATION '${TBLSPC_PATH_HAS_PGDATA_PATH}';
+CREATE DATABASE ${TEST_DB} TABLESPACE = ${TEST_DB};
+EOF
+
+pgbench -p ${TEST_PGPORT} -i -s 10 -d ${TEST_DB} > /dev/null 2>&1
+psql -p ${TEST_PGPORT} --no-psqlrc -d ${TEST_DB} -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0018-before.out
+
+pg_rman backup -B ${BACKUP_PATH} -b full -Z -p ${TEST_PGPORT} -d postgres --quiet;echo $?
+pg_rman validate -B ${BACKUP_PATH} --quiet
+stop_postgres
+pg_rman restore -B ${BACKUP_PATH} --quiet;echo $?
+start_postgres
+sleep 1
+
+psql -p ${TEST_PGPORT} --no-psqlrc -d ${TEST_DB} -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0018-after.out
+diff ${TEST_BASE}/TEST-0018-before.out ${TEST_BASE}/TEST-0018-after.out
+
+stop_postgres
+rm -r ${TBLSPC_PATH_HAS_PGDATA_PATH}
+echo ''
+
# clean up the temporal test data
pg_ctl stop -m immediate > /dev/null 2>&1
rm -fr ${PGDATA_PATH}
From 802c593849158503117cd5fd235341c54248ee0d Mon Sep 17 00:00:00 2001
From: Keisuke Kuroda <59189894+kiskk@users.noreply.github.com>
Date: Tue, 15 Nov 2022 13:41:46 +0900
Subject: [PATCH 10/27] Add description for compress target to doc (#235)
---
docs/index-ja.html | 2 +-
docs/index.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/docs/index-ja.html b/docs/index-ja.html
index d6c59c0f..87a140a7 100755
--- a/docs/index-ja.html
+++ b/docs/index-ja.html
@@ -638,7 +638,7 @@ バックアップ・オプション
-Z
/ --compress-data
-- zlibを用いてバックアップファイルを圧縮します。省略時は圧縮なしです。
+- zlibを用いてバックアップファイルを圧縮します。省略時は圧縮なしです。圧縮時は、設定ファイルやbackup_labelファイルもふくめ、すべてのバックアップファイルが圧縮されます。
-C
/ --smooth-checkpoint
diff --git a/docs/index.html b/docs/index.html
index 92723110..100ff031 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -625,7 +625,7 @@ Backup options
-Z
/ --compress-data
-- Compress backup files with zlib if specified.
+- Compress backup files with zlib if specified. When the option is omitted, no compression is performed. When compressing, all backup files are compressed, including configuration files and backup_label.
-C
/ --smooth-checkpoint
From e0c0036050ef941604011b18ac32d5813fbb4e7b Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 15:41:17 +0900
Subject: [PATCH 11/27] developments for postgresql v15
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
・Renamed the functions pg_start_backup()/pg_stop_backup() to
pg_backup_start()/pg_backup_stop() and change the arguments of pg_backup_stop()
pg_rman already supported non-exclusive mode, so we just renamed
the function names and change the arguments to keeps the behavior.
・Default log_checkpoints for regression test is off.
In PostgreSQL15, the default value of log_checkpoints is on.
The checkpoints are automatically triggered when regression tests are run.
The test failed because some log files was updated timestamp and the wrong log was deleted.
So, we turned this feature off before running the test.
---
backup.c | 59 +++++++++++++++++++----------------
pgut/pgut.c | 1 +
sql/arc_srv_log_management.sh | 1 +
3 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/backup.c b/backup.c
index 0a89e29a..2eb075ea 100644
--- a/backup.c
+++ b/backup.c
@@ -46,8 +46,8 @@ static parray *do_backup_database(parray *backup_list, pgBackupOption bkupopt);
static parray *do_backup_arclog(parray *backup_list);
static parray *do_backup_srvlog(parray *backup_list);
static void confirm_block_size(const char *name, int blcksz);
-static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
-static parray *pg_stop_backup(pgBackup *backup);
+static void pg_backup_start(const char *label, bool smooth, pgBackup *backup);
+static parray *pg_backup_stop(pgBackup *backup);
static void pg_switch_wal(pgBackup *backup);
static void get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn);
static void get_xid(PGresult *res, uint32 *xid);
@@ -135,14 +135,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
/* notify start of backup to PostgreSQL server */
time2iso(label, lengthof(label), current.start_time);
strncat(label, " with pg_rman", lengthof(label) - strlen(label) - 1);
- pg_start_backup(label, smooth_checkpoint, ¤t);
+ pg_backup_start(label, smooth_checkpoint, ¤t);
/* Execute restartpoint on standby once replay reaches the backup LSN */
if (current.is_from_standby && !execute_restartpoint(bkupopt, ¤t))
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -266,7 +266,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and save the backup_label and tablespace_map
* files.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
/* stop_backup_files must be listed in file_database.txt. */
files = parray_concat(stop_backup_files, files);
@@ -284,14 +284,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
parray *tblspc_list; /* list of name of TABLESPACE backup from snapshot */
parray *tblspcmp_list; /* list of mounted directory of TABLESPACE in snapshot volume */
PGresult *tblspc_res; /* contain spcname and oid in TABLESPACE */
- parray *stop_backup_files; /* list of files that pg_stop_backup() wrote */
+ parray *stop_backup_files; /* list of files that pg_backup_stop() wrote */
/* if backup is from standby, snapshot backup is unsupported */
if (current.is_from_standby)
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -384,7 +384,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and write backup_label and tablespace_map
* files to backup destination directory.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
files = parray_concat(stop_backup_files, files);
/* create file list of non-snapshot objects */
@@ -569,7 +569,7 @@ execute_restartpoint(pgBackupOption bkupopt, pgBackup *backup)
/*
* Wait for standby server to replay WAL up to the LSN returned by
- * pg_start_backup()
+ * pg_backup_start()
*/
res = execute("SELECT * FROM pg_last_wal_replay_lsn()", 0, NULL);
sscanf(PQgetvalue(res, 0, 0), "%X/%X", &xlogid, &xrecoff);
@@ -647,7 +647,7 @@ do_backup_arclog(parray *backup_list)
files = parray_new();
dir_list_file(files, arclog_path, NULL, true, false);
- /* remove WALs archived after pg_stop_backup()/pg_switch_wal() */
+ /* remove WALs archived after pg_backup_stop()/pg_switch_wal() */
xlog_fname(last_wal, lengthof(last_wal), current.tli, ¤t.stop_lsn,
wal_segment_size);
for (i = 0; i < parray_num(files); i++)
@@ -922,7 +922,7 @@ do_backup(pgBackupOption bkupopt)
/* initialize backup result */
current.status = BACKUP_STATUS_RUNNING;
- current.tli = 0; /* get from result of pg_start_backup() */
+ current.tli = 0; /* get from result of pg_backup_start() */
current.start_lsn = current.stop_lsn = (XLogRecPtr) 0;
current.start_time = time(NULL);
current.end_time = (time_t) 0;
@@ -1107,13 +1107,14 @@ confirm_block_size(const char *name, int blcksz)
* case of taking a backup from standby.
*/
static void
-pg_start_backup(const char *label, bool smooth, pgBackup *backup)
+pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
- const char *params[3];
+ const char *params[2];
+ // const char *params[3];
params[0] = label;
- elog(DEBUG, "executing pg_start_backup()");
+ elog(DEBUG, "executing pg_backup_start()");
/*
* Establish new connection to send backup control commands. The same
@@ -1128,8 +1129,8 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
params[1] = smooth ? "false" : "true";
/* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- params[2] = "false";
- res = execute("SELECT * from pg_walfile_name_offset(pg_start_backup($1, $2, $3))", 3, params);
+ // params[2] = "false";
+ res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
get_lsn(res, &backup->tli, &backup->start_lsn);
@@ -1207,11 +1208,11 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
/*
* Notify the end of backup to PostgreSQL server.
*
- * Contacts the primary server and issues pg_stop_backup(), then waits for
+ * Contacts the primary server and issues pg_backup_stop(), then waits for
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_stop_backup() returns 2 more fields in addition
+ * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1219,7 +1220,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* it to the backup file list.
*/
static parray *
-pg_stop_backup(pgBackup *backup)
+pg_backup_stop(pgBackup *backup)
{
parray *result = parray_new();
pgFile *file;
@@ -1231,12 +1232,12 @@ pg_stop_backup(pgBackup *backup)
int tblspcmap_len;
const char *params[1];
- elog(DEBUG, "executing pg_stop_backup()");
+ elog(DEBUG, "executing pg_backup_stop()");
/*
* Non-exclusive backup requires to use same connection as the one
- * used to issue pg_start_backup(). Remember we did not disconnect
- * in pg_start_backup() nor did we lose our connection when issuing
+ * used to issue pg_backup_start(). Remember we did not disconnect
+ * in pg_backup_start() nor did we lose our connection when issuing
* commands to standby.
*/
Assert(connection != NULL);
@@ -1245,13 +1246,17 @@ pg_stop_backup(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- params[0] = "false";
- res = execute("SELECT * FROM pg_stop_backup($1)", 1, params);
+ /*
+ * This parameter default is true,pg_backup_stop will wait for WAL
+ * pg_backup_startto be archived when archiving is enabled.
+ */
+ params[0] = "true";
+ res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
if (res == NULL || PQntuples(res) != 1 || PQnfields(res) != 3)
ereport(ERROR,
(errcode(ERROR_PG_COMMAND),
- errmsg("result of pg_stop_backup($1) is invalid: %s",
+ errmsg("result of pg_backup_stop($1) is invalid: %s",
PQerrorMessage(connection))));
backup_lsn = PQgetvalue(res, 0, 0);
@@ -1313,7 +1318,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
errmsg("result of pg_walfile_name_offset() is invalid: %s",
PQerrorMessage(connection))));
- /* get TimeLineID, LSN from result of pg_stop_backup() */
+ /* get TimeLineID, LSN from result of pg_backup_stop() */
if (sscanf(PQgetvalue(res, 0, 0), "%08X%08X%08X",
timeline, &xlogid, &off_upper) != 3 ||
sscanf(PQgetvalue(res, 0, 1), "%u", &xrecoff) != 1)
@@ -1332,7 +1337,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
}
/*
- * Get XID from result of txid_current() after pg_stop_backup().
+ * Get XID from result of txid_current() after pg_backup_stop().
*/
static void
get_xid(PGresult *res, uint32 *xid)
diff --git a/pgut/pgut.c b/pgut/pgut.c
index 118defa1..36c8c5ac 100644
--- a/pgut/pgut.c
+++ b/pgut/pgut.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include "pgut.h"
diff --git a/sql/arc_srv_log_management.sh b/sql/arc_srv_log_management.sh
index 9f080dff..78c2c437 100644
--- a/sql/arc_srv_log_management.sh
+++ b/sql/arc_srv_log_management.sh
@@ -47,6 +47,7 @@ wal_level = hot_standby
log_directory = '${SRVLOG_PATH}'
archive_mode = on
archive_command = 'cp %p ${ARCLOG_PATH}/%f'
+log_checkpoints = off
EOF
# start PostgreSQL
From a2c8872ad1c70b14c68c2775affca391d0a88131 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 17:20:24 +0900
Subject: [PATCH 12/27] changed build.yml
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 081475c4..e9608893 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="14.0"
+ ["master"]="15bate1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From 2ce8c2ea6aaf609e7e3015e34726c16ee4c5fc43 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Fri, 10 Jun 2022 09:26:35 +0900
Subject: [PATCH 13/27] modityed the version
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e9608893..4c2dab7b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="15bate1"
+ ["master"]="15beta1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From b1f359aed4a418574845bbf65160fdd44d40da9d Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 21 Jul 2022 13:16:17 +0900
Subject: [PATCH 14/27] change some comment
---
backup.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/backup.c b/backup.c
index 2eb075ea..a840dcd0 100644
--- a/backup.c
+++ b/backup.c
@@ -1111,7 +1111,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
const char *params[2];
- // const char *params[3];
params[0] = label;
elog(DEBUG, "executing pg_backup_start()");
@@ -1123,13 +1122,16 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /* Assumes PG version >= 8.4 */
-
- /* 2nd argument is 'fast' (IOW, !smooth) */
+ /*
+ * Assumes PG version >= 8.4
+ *
+ * When second parameter is given as true,
+ * it specifies executing pg_backup_start as quickly as possible.
+ * This forces an immediate checkpoint which will cause a spike in I/O operations,
+ * slowing any concurrently executing queries.
+ */
params[1] = smooth ? "false" : "true";
- /* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- // params[2] = "false";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1246,10 +1248,6 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- /*
- * This parameter default is true,pg_backup_stop will wait for WAL
- * pg_backup_startto be archived when archiving is enabled.
- */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 05456badbeea46e4d172f8d0242ded0edeb45e3f Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Wed, 27 Jul 2022 13:13:07 +0900
Subject: [PATCH 15/27] changed some comment
---
backup.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/backup.c b/backup.c
index a840dcd0..2abcac10 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,14 +1122,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /*
- * Assumes PG version >= 8.4
- *
- * When second parameter is given as true,
- * it specifies executing pg_backup_start as quickly as possible.
- * This forces an immediate checkpoint which will cause a spike in I/O operations,
- * slowing any concurrently executing queries.
- */
params[1] = smooth ? "false" : "true";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
@@ -1214,7 +1206,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
+ * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
From bdc7e738acb43460a3bbe1ce58f62201e7871235 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 28 Jul 2022 13:49:33 +0900
Subject: [PATCH 16/27] Changed some comments
---
backup.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/backup.c b/backup.c
index 2abcac10..91f16b16 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,8 +1122,10 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
+ /* 2nd argument is 'fast' (IOW, !smooth) */
params[1] = smooth ? "false" : "true";
+ /* non-exclusive' mode (assumes PG version >= 15) */
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1206,7 +1208,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
+ * pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1240,6 +1242,10 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
+ /*
+ * PG version < 15, this parameter means exclusive or non-exclusive mode.
+ * PG version >= 15, this parameter means whether to wait for WAL files to be archived.
+ */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 9050f9067d4ef907349e26311d1cefd5d450a79a Mon Sep 17 00:00:00 2001
From: mikecaat <35882227+mikecaat@users.noreply.github.com>
Date: Fri, 9 Dec 2022 10:29:51 +0900
Subject: [PATCH 17/27] Fix to work --hard-copy #236 (#237)
The following commit(17f7109a5) forgot to change the index of
parameters although it adds a new parameter.
It makes --hard-copy not work in restore.
And there is no test code to check that the default option uses
symbolic links.
So add some test code and modified the manual
about describe the -Z option.
---
docs/index-ja.html | 3 ++-
docs/index.html | 3 ++-
expected/restore.out | 12 +++++++++
expected/restore_checksum.out | 12 +++++++++
pg_rman.c | 4 +--
sql/restore.sh | 48 +++++++++++++++++++++++++++++++++++
6 files changed, 78 insertions(+), 4 deletions(-)
diff --git a/docs/index-ja.html b/docs/index-ja.html
index 87a140a7..08223c03 100755
--- a/docs/index-ja.html
+++ b/docs/index-ja.html
@@ -712,7 +712,8 @@ リストア・オプション
--hard-copy
-- アーカイブ WAL をリストアする際、ファイルをアーカイブ格納領域にコピーします。このオプションを指定しない場合、アーカイブ格納領域には、バックアップカタログ内のアーカイブ WAL へのシンボリックリンクが作られます。
+- アーカイブ WAL をリストアする際、ファイルをアーカイブ格納領域にコピーします。このオプションを指定しない場合、アーカイブ格納領域には、バックアップカタログ内のアーカイブ WAL へのシンボリックリンクが作られます。
+なお、バックアップ時に-Zオプションで圧縮している場合は、本オプションの指定に関わらず、常に解凍したファイルをアーカイブ領域にコピーします。
diff --git a/docs/index.html b/docs/index.html
index 100ff031..3102e75f 100755
--- a/docs/index.html
+++ b/docs/index.html
@@ -699,7 +699,8 @@ Restore options
--hard-copy
-- The archive WAL are copied to archive WAL storage area. If not specified, pg_rman makes symbolic link to archive WAL where are in the backup catalog directory.
+- The archive WAL are copied to archive WAL storage area. If not specified, pg_rman makes symbolic link to archive WAL where are in the backup catalog directory.
+If the files are compressed using -Z option when to take a backup, the files are always copied to archive WAL storage area after decompressed.
diff --git a/expected/restore.out b/expected/restore.out
index 31a54288..784bfbc9 100644
--- a/expected/restore.out
+++ b/expected/restore.out
@@ -127,3 +127,15 @@ OK: new value is configured for recovery_target_timeline.
0
0
+###### RESTORE COMMAND TEST-0019 ######
+###### recovery with hard-copy and without compression option ######
+0
+0
+OK: hard-copy option works well.
+
+###### RESTORE COMMAND TEST-0020 ######
+###### recovery without hard-copy and without compression option ######
+0
+0
+OK: without hard-copy option works well.
+
diff --git a/expected/restore_checksum.out b/expected/restore_checksum.out
index b10ca9f3..73f62115 100644
--- a/expected/restore_checksum.out
+++ b/expected/restore_checksum.out
@@ -127,3 +127,15 @@ OK: new value is configured for recovery_target_timeline.
0
0
+###### RESTORE COMMAND TEST-0019 ######
+###### recovery with hard-copy and without compression option ######
+0
+0
+OK: hard-copy option works well.
+
+###### RESTORE COMMAND TEST-0020 ######
+###### recovery without hard-copy and without compression option ######
+0
+0
+OK: without hard-copy option works well.
+
diff --git a/pg_rman.c b/pg_rman.c
index f1d1c2ee..6b1084b2 100644
--- a/pg_rman.c
+++ b/pg_rman.c
@@ -79,8 +79,8 @@ static pgut_option options[] =
{ 'b', 'Z', "compress-data" , ¤t.compress_data , SOURCE_ENV },
{ 'b', 'C', "smooth-checkpoint" , &smooth_checkpoint , SOURCE_ENV },
{ 'b', 'F', "full-backup-on-error" , ¤t.full_backup_on_error , SOURCE_ENV },
- { 's', 12, "standby-host" , &standby_host , SOURCE_ENV },
- { 's', 13, "standby-port" , &standby_port , SOURCE_ENV },
+ { 's', 13, "standby-host" , &standby_host , SOURCE_ENV },
+ { 's', 14, "standby-port" , &standby_port , SOURCE_ENV },
/* delete options */
{ 'b', 'f', "force" , &force , SOURCE_ENV },
/* options with only long name (keep-xxx) */
diff --git a/sql/restore.sh b/sql/restore.sh
index 3dabdeaf..ecf9df9f 100644
--- a/sql/restore.sh
+++ b/sql/restore.sh
@@ -603,6 +603,54 @@ stop_postgres
rm -r ${TBLSPC_PATH_HAS_PGDATA_PATH}
echo ''
+echo '###### RESTORE COMMAND TEST-0019 ######'
+echo '###### recovery with hard-copy and without compression option ######'
+init_backup
+pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
+psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0012-before.out
+pg_rman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $?
+pg_rman validate -B ${BACKUP_PATH} --quiet
+pg_ctl stop -m immediate > /dev/null 2>&1
+pg_rman restore -B ${BACKUP_PATH} --hard-copy --quiet;echo $?
+FLAGS=0
+for FILENAME in `ls ${ARCLOG_PATH}`
+do
+ if [ -L ${ARCLOG_PATH}/${FILENAME} ]; then
+ echo 'NG: hard-copy option does not work well.' ${FILENAME} 'is a symbolic link.'
+ FLAGS=`expr ${FLAGS} + 1`
+ fi
+done
+if [ ${FLAGS} -eq 0 ]; then
+ echo 'OK: hard-copy option works well.'
+else
+ echo 'NG: hard-copy option does not work well.'
+fi
+echo ''
+
+echo '###### RESTORE COMMAND TEST-0020 ######'
+echo '###### recovery without hard-copy and without compression option ######'
+init_backup
+pgbench -p ${TEST_PGPORT} -d pgbench > /dev/null 2>&1
+psql --no-psqlrc -p ${TEST_PGPORT} -d pgbench -c "SELECT * FROM pgbench_branches;" > ${TEST_BASE}/TEST-0012-before.out
+pg_rman backup -B ${BACKUP_PATH} -b full -p ${TEST_PGPORT} -d postgres --quiet;echo $?
+pg_rman validate -B ${BACKUP_PATH} --quiet
+pg_ctl stop -m immediate > /dev/null 2>&1
+pg_rman restore -B ${BACKUP_PATH} --quiet;echo $?
+FLAGS=0
+for FILENAME in `ls ${ARCLOG_PATH}`
+do
+ if [ ! -L ${ARCLOG_PATH}/${FILENAME} ]; then
+ echo ${FILENAME} 'is not a symbolic link.'
+ FLAGS=`expr ${FLAGS} + 1`
+ fi
+done
+if [ ${FLAGS} -eq 0 ]; then
+ echo 'OK: without hard-copy option works well.'
+else
+ echo 'NG: without hard-copy option does not work well.'
+fi
+echo ''
+
# clean up the temporal test data
pg_ctl stop -m immediate > /dev/null 2>&1
rm -fr ${PGDATA_PATH}
From 9c2619cf1c71f07dffab26f1f0649ca814c16bf0 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Mon, 12 Dec 2022 10:41:09 +0900
Subject: [PATCH 18/27] Modified the build.yml and comment
---
.github/workflows/build.yml | 16 ++++++++--------
backup.c | 5 +----
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4c2dab7b..06f090e6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,19 +4,19 @@ on:
push:
branches:
- master
+ - REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
- - REL_10_STABLE
pull_request:
branches:
- master
+ - REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
- - REL_10_STABLE
schedule:
- cron: "0 1 * * SUN" # only master
@@ -41,12 +41,12 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="15beta1"
- ["REL_14_STABLE"]="14.0"
- ["REL_13_STABLE"]="13.4"
- ["REL_12_STABLE"]="12.8"
- ["REL_11_STABLE"]="11.13"
- ["REL_10_STABLE"]="10.18"
+ ["master"]="15.1"
+ ["REL_15_STABLE"]="15.1"
+ ["REL_14_STABLE"]="14.6"
+ ["REL_13_STABLE"]="13.9"
+ ["REL_12_STABLE"]="12.13"
+ ["REL_11_STABLE"]="11.18"
)
[ -z "${versions[${{ env.BRANCH }}]}" ] && exit 1 # check if the key exists
echo "PGVERSION=${versions[${{ env.BRANCH }}]}" >> $GITHUB_ENV
diff --git a/backup.c b/backup.c
index 91f16b16..7547d09c 100644
--- a/backup.c
+++ b/backup.c
@@ -1242,10 +1242,7 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- /*
- * PG version < 15, this parameter means exclusive or non-exclusive mode.
- * PG version >= 15, this parameter means whether to wait for WAL files to be archived.
- */
+ /* wait for WAL files to be archived */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 054bbaf5d3399b8342e539ca2a6aa74c21532b75 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 15:41:17 +0900
Subject: [PATCH 19/27] developments for postgresql v15
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
・Renamed the functions pg_start_backup()/pg_stop_backup() to
pg_backup_start()/pg_backup_stop() and change the arguments of pg_backup_stop()
pg_rman already supported non-exclusive mode, so we just renamed
the function names and change the arguments to keeps the behavior.
・Default log_checkpoints for regression test is off.
In PostgreSQL15, the default value of log_checkpoints is on.
The checkpoints are automatically triggered when regression tests are run.
The test failed because some log files was updated timestamp and the wrong log was deleted.
So, we turned this feature off before running the test.
---
backup.c | 59 +++++++++++++++++++----------------
pgut/pgut.c | 1 +
sql/arc_srv_log_management.sh | 1 +
3 files changed, 34 insertions(+), 27 deletions(-)
diff --git a/backup.c b/backup.c
index 0a89e29a..2eb075ea 100644
--- a/backup.c
+++ b/backup.c
@@ -46,8 +46,8 @@ static parray *do_backup_database(parray *backup_list, pgBackupOption bkupopt);
static parray *do_backup_arclog(parray *backup_list);
static parray *do_backup_srvlog(parray *backup_list);
static void confirm_block_size(const char *name, int blcksz);
-static void pg_start_backup(const char *label, bool smooth, pgBackup *backup);
-static parray *pg_stop_backup(pgBackup *backup);
+static void pg_backup_start(const char *label, bool smooth, pgBackup *backup);
+static parray *pg_backup_stop(pgBackup *backup);
static void pg_switch_wal(pgBackup *backup);
static void get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn);
static void get_xid(PGresult *res, uint32 *xid);
@@ -135,14 +135,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
/* notify start of backup to PostgreSQL server */
time2iso(label, lengthof(label), current.start_time);
strncat(label, " with pg_rman", lengthof(label) - strlen(label) - 1);
- pg_start_backup(label, smooth_checkpoint, ¤t);
+ pg_backup_start(label, smooth_checkpoint, ¤t);
/* Execute restartpoint on standby once replay reaches the backup LSN */
if (current.is_from_standby && !execute_restartpoint(bkupopt, ¤t))
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -266,7 +266,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and save the backup_label and tablespace_map
* files.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
/* stop_backup_files must be listed in file_database.txt. */
files = parray_concat(stop_backup_files, files);
@@ -284,14 +284,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
parray *tblspc_list; /* list of name of TABLESPACE backup from snapshot */
parray *tblspcmp_list; /* list of mounted directory of TABLESPACE in snapshot volume */
PGresult *tblspc_res; /* contain spcname and oid in TABLESPACE */
- parray *stop_backup_files; /* list of files that pg_stop_backup() wrote */
+ parray *stop_backup_files; /* list of files that pg_backup_stop() wrote */
/* if backup is from standby, snapshot backup is unsupported */
if (current.is_from_standby)
{
/*
* Disconnecting automatically aborts a non-exclusive backup, so no
- * need to call pg_stop_backup() do it for us.
+ * need to call pg_backup_stop() do it for us.
*/
disconnect();
ereport(ERROR,
@@ -384,7 +384,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Notify end of backup and write backup_label and tablespace_map
* files to backup destination directory.
*/
- stop_backup_files = pg_stop_backup(¤t);
+ stop_backup_files = pg_backup_stop(¤t);
files = parray_concat(stop_backup_files, files);
/* create file list of non-snapshot objects */
@@ -569,7 +569,7 @@ execute_restartpoint(pgBackupOption bkupopt, pgBackup *backup)
/*
* Wait for standby server to replay WAL up to the LSN returned by
- * pg_start_backup()
+ * pg_backup_start()
*/
res = execute("SELECT * FROM pg_last_wal_replay_lsn()", 0, NULL);
sscanf(PQgetvalue(res, 0, 0), "%X/%X", &xlogid, &xrecoff);
@@ -647,7 +647,7 @@ do_backup_arclog(parray *backup_list)
files = parray_new();
dir_list_file(files, arclog_path, NULL, true, false);
- /* remove WALs archived after pg_stop_backup()/pg_switch_wal() */
+ /* remove WALs archived after pg_backup_stop()/pg_switch_wal() */
xlog_fname(last_wal, lengthof(last_wal), current.tli, ¤t.stop_lsn,
wal_segment_size);
for (i = 0; i < parray_num(files); i++)
@@ -922,7 +922,7 @@ do_backup(pgBackupOption bkupopt)
/* initialize backup result */
current.status = BACKUP_STATUS_RUNNING;
- current.tli = 0; /* get from result of pg_start_backup() */
+ current.tli = 0; /* get from result of pg_backup_start() */
current.start_lsn = current.stop_lsn = (XLogRecPtr) 0;
current.start_time = time(NULL);
current.end_time = (time_t) 0;
@@ -1107,13 +1107,14 @@ confirm_block_size(const char *name, int blcksz)
* case of taking a backup from standby.
*/
static void
-pg_start_backup(const char *label, bool smooth, pgBackup *backup)
+pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
- const char *params[3];
+ const char *params[2];
+ // const char *params[3];
params[0] = label;
- elog(DEBUG, "executing pg_start_backup()");
+ elog(DEBUG, "executing pg_backup_start()");
/*
* Establish new connection to send backup control commands. The same
@@ -1128,8 +1129,8 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
params[1] = smooth ? "false" : "true";
/* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- params[2] = "false";
- res = execute("SELECT * from pg_walfile_name_offset(pg_start_backup($1, $2, $3))", 3, params);
+ // params[2] = "false";
+ res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
get_lsn(res, &backup->tli, &backup->start_lsn);
@@ -1207,11 +1208,11 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
/*
* Notify the end of backup to PostgreSQL server.
*
- * Contacts the primary server and issues pg_stop_backup(), then waits for
+ * Contacts the primary server and issues pg_backup_stop(), then waits for
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_stop_backup() returns 2 more fields in addition
+ * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1219,7 +1220,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* it to the backup file list.
*/
static parray *
-pg_stop_backup(pgBackup *backup)
+pg_backup_stop(pgBackup *backup)
{
parray *result = parray_new();
pgFile *file;
@@ -1231,12 +1232,12 @@ pg_stop_backup(pgBackup *backup)
int tblspcmap_len;
const char *params[1];
- elog(DEBUG, "executing pg_stop_backup()");
+ elog(DEBUG, "executing pg_backup_stop()");
/*
* Non-exclusive backup requires to use same connection as the one
- * used to issue pg_start_backup(). Remember we did not disconnect
- * in pg_start_backup() nor did we lose our connection when issuing
+ * used to issue pg_backup_start(). Remember we did not disconnect
+ * in pg_backup_start() nor did we lose our connection when issuing
* commands to standby.
*/
Assert(connection != NULL);
@@ -1245,13 +1246,17 @@ pg_stop_backup(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- params[0] = "false";
- res = execute("SELECT * FROM pg_stop_backup($1)", 1, params);
+ /*
+ * This parameter default is true,pg_backup_stop will wait for WAL
+ * pg_backup_startto be archived when archiving is enabled.
+ */
+ params[0] = "true";
+ res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
if (res == NULL || PQntuples(res) != 1 || PQnfields(res) != 3)
ereport(ERROR,
(errcode(ERROR_PG_COMMAND),
- errmsg("result of pg_stop_backup($1) is invalid: %s",
+ errmsg("result of pg_backup_stop($1) is invalid: %s",
PQerrorMessage(connection))));
backup_lsn = PQgetvalue(res, 0, 0);
@@ -1313,7 +1318,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
errmsg("result of pg_walfile_name_offset() is invalid: %s",
PQerrorMessage(connection))));
- /* get TimeLineID, LSN from result of pg_stop_backup() */
+ /* get TimeLineID, LSN from result of pg_backup_stop() */
if (sscanf(PQgetvalue(res, 0, 0), "%08X%08X%08X",
timeline, &xlogid, &off_upper) != 3 ||
sscanf(PQgetvalue(res, 0, 1), "%u", &xrecoff) != 1)
@@ -1332,7 +1337,7 @@ get_lsn(PGresult *res, TimeLineID *timeline, XLogRecPtr *lsn)
}
/*
- * Get XID from result of txid_current() after pg_stop_backup().
+ * Get XID from result of txid_current() after pg_backup_stop().
*/
static void
get_xid(PGresult *res, uint32 *xid)
diff --git a/pgut/pgut.c b/pgut/pgut.c
index 118defa1..36c8c5ac 100644
--- a/pgut/pgut.c
+++ b/pgut/pgut.c
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include "pgut.h"
diff --git a/sql/arc_srv_log_management.sh b/sql/arc_srv_log_management.sh
index 9f080dff..78c2c437 100644
--- a/sql/arc_srv_log_management.sh
+++ b/sql/arc_srv_log_management.sh
@@ -47,6 +47,7 @@ wal_level = hot_standby
log_directory = '${SRVLOG_PATH}'
archive_mode = on
archive_command = 'cp %p ${ARCLOG_PATH}/%f'
+log_checkpoints = off
EOF
# start PostgreSQL
From 412f68d2a15bddb89a60f5dad33850bfc2e4ab02 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 9 Jun 2022 17:20:24 +0900
Subject: [PATCH 20/27] changed build.yml
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 081475c4..e9608893 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="14.0"
+ ["master"]="15bate1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From e1c8d8931c1ec9e69c5ee1929dc027f324c24d10 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Fri, 10 Jun 2022 09:26:35 +0900
Subject: [PATCH 21/27] modityed the version
---
.github/workflows/build.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e9608893..4c2dab7b 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -41,7 +41,7 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="15bate1"
+ ["master"]="15beta1"
["REL_14_STABLE"]="14.0"
["REL_13_STABLE"]="13.4"
["REL_12_STABLE"]="12.8"
From b5150d29c5e4accfe3841665d6f754a19d4f1245 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 21 Jul 2022 13:16:17 +0900
Subject: [PATCH 22/27] change some comment
---
backup.c | 18 ++++++++----------
1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/backup.c b/backup.c
index 2eb075ea..a840dcd0 100644
--- a/backup.c
+++ b/backup.c
@@ -1111,7 +1111,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
{
PGresult *res;
const char *params[2];
- // const char *params[3];
params[0] = label;
elog(DEBUG, "executing pg_backup_start()");
@@ -1123,13 +1122,16 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /* Assumes PG version >= 8.4 */
-
- /* 2nd argument is 'fast' (IOW, !smooth) */
+ /*
+ * Assumes PG version >= 8.4
+ *
+ * When second parameter is given as true,
+ * it specifies executing pg_backup_start as quickly as possible.
+ * This forces an immediate checkpoint which will cause a spike in I/O operations,
+ * slowing any concurrently executing queries.
+ */
params[1] = smooth ? "false" : "true";
- /* 3rd argument is 'non-exclusive' (assumes PG version >= 9.6) */
- // params[2] = "false";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1246,10 +1248,6 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- /*
- * This parameter default is true,pg_backup_stop will wait for WAL
- * pg_backup_startto be archived when archiving is enabled.
- */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 7587614c133903df343997130d718c8726881e3d Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Wed, 27 Jul 2022 13:13:07 +0900
Subject: [PATCH 23/27] changed some comment
---
backup.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/backup.c b/backup.c
index a840dcd0..2abcac10 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,14 +1122,6 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
- /*
- * Assumes PG version >= 8.4
- *
- * When second parameter is given as true,
- * it specifies executing pg_backup_start as quickly as possible.
- * This forces an immediate checkpoint which will cause a spike in I/O operations,
- * slowing any concurrently executing queries.
- */
params[1] = smooth ? "false" : "true";
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
@@ -1214,7 +1206,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version 9.6, pg_backup_stop() returns 2 more fields in addition
+ * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
From 0576a52182807b7e6d0148dda0090b32b466429e Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 28 Jul 2022 13:49:33 +0900
Subject: [PATCH 24/27] Changed some comments
---
backup.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/backup.c b/backup.c
index 2abcac10..91f16b16 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,8 +1122,10 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
+ /* 2nd argument is 'fast' (IOW, !smooth) */
params[1] = smooth ? "false" : "true";
+ /* non-exclusive' mode (assumes PG version >= 15) */
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1206,7 +1208,7 @@ wait_for_archive(pgBackup *backup, const char *sql, int nParams,
* either the primary or standby server to successfully archive the last
* needed WAL segment to be archived. Returns once that's been done.
*
- * As of PG version from 15.0, pg_backup_stop() returns 2 more fields in addition
+ * pg_backup_stop() returns 2 more fields in addition
* to the backup end LSN: backup_label text and tablespace_map text which
* need to be written to files in the backup root directory.
*
@@ -1240,6 +1242,10 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
+ /*
+ * PG version < 15, this parameter means exclusive or non-exclusive mode.
+ * PG version >= 15, this parameter means whether to wait for WAL files to be archived.
+ */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 16f58d6f7eafa93d63b7cc5f1421d8df48d9418e Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Mon, 12 Dec 2022 10:41:09 +0900
Subject: [PATCH 25/27] Modified the build.yml and comment
---
.github/workflows/build.yml | 16 ++++++++--------
backup.c | 5 +----
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 4c2dab7b..06f090e6 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -4,19 +4,19 @@ on:
push:
branches:
- master
+ - REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
- - REL_10_STABLE
pull_request:
branches:
- master
+ - REL_15_STABLE
- REL_14_STABLE
- REL_13_STABLE
- REL_12_STABLE
- REL_11_STABLE
- - REL_10_STABLE
schedule:
- cron: "0 1 * * SUN" # only master
@@ -41,12 +41,12 @@ jobs:
shell: bash -xe {0}
run: |
declare -A versions=(
- ["master"]="15beta1"
- ["REL_14_STABLE"]="14.0"
- ["REL_13_STABLE"]="13.4"
- ["REL_12_STABLE"]="12.8"
- ["REL_11_STABLE"]="11.13"
- ["REL_10_STABLE"]="10.18"
+ ["master"]="15.1"
+ ["REL_15_STABLE"]="15.1"
+ ["REL_14_STABLE"]="14.6"
+ ["REL_13_STABLE"]="13.9"
+ ["REL_12_STABLE"]="12.13"
+ ["REL_11_STABLE"]="11.18"
)
[ -z "${versions[${{ env.BRANCH }}]}" ] && exit 1 # check if the key exists
echo "PGVERSION=${versions[${{ env.BRANCH }}]}" >> $GITHUB_ENV
diff --git a/backup.c b/backup.c
index 91f16b16..7547d09c 100644
--- a/backup.c
+++ b/backup.c
@@ -1242,10 +1242,7 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
- /*
- * PG version < 15, this parameter means exclusive or non-exclusive mode.
- * PG version >= 15, this parameter means whether to wait for WAL files to be archived.
- */
+ /* wait for WAL files to be archived */
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 90a0632eb0ab61bf911feff76d2f763541d958c4 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Thu, 21 Jul 2022 13:16:17 +0900
Subject: [PATCH 26/27] change some comment
---
backup.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/backup.c b/backup.c
index 7547d09c..5d590441 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,10 +1122,23 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
+<<<<<<< HEAD
/* 2nd argument is 'fast' (IOW, !smooth) */
params[1] = smooth ? "false" : "true";
/* non-exclusive' mode (assumes PG version >= 15) */
+=======
+ /*
+ * Assumes PG version >= 8.4
+ *
+ * When second parameter is given as true,
+ * it specifies executing pg_backup_start as quickly as possible.
+ * This forces an immediate checkpoint which will cause a spike in I/O operations,
+ * slowing any concurrently executing queries.
+ */
+ params[1] = smooth ? "false" : "true";
+
+>>>>>>> 21fd0ec (change some comment)
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1242,7 +1255,10 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
+<<<<<<< HEAD
/* wait for WAL files to be archived */
+=======
+>>>>>>> 21fd0ec (change some comment)
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);
From 05a99fbfa224474050d39739d7257203348a8c79 Mon Sep 17 00:00:00 2001
From: zw_yan
Date: Mon, 12 Dec 2022 11:10:54 +0900
Subject: [PATCH 27/27] change comment
---
backup.c | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/backup.c b/backup.c
index 5d590441..7547d09c 100644
--- a/backup.c
+++ b/backup.c
@@ -1122,23 +1122,10 @@ pg_backup_start(const char *label, bool smooth, pgBackup *backup)
*/
reconnect();
-<<<<<<< HEAD
/* 2nd argument is 'fast' (IOW, !smooth) */
params[1] = smooth ? "false" : "true";
/* non-exclusive' mode (assumes PG version >= 15) */
-=======
- /*
- * Assumes PG version >= 8.4
- *
- * When second parameter is given as true,
- * it specifies executing pg_backup_start as quickly as possible.
- * This forces an immediate checkpoint which will cause a spike in I/O operations,
- * slowing any concurrently executing queries.
- */
- params[1] = smooth ? "false" : "true";
-
->>>>>>> 21fd0ec (change some comment)
res = execute("SELECT * from pg_walfile_name_offset(pg_backup_start($1, $2))", 2, params);
if (backup != NULL)
@@ -1255,10 +1242,7 @@ pg_backup_stop(pgBackup *backup)
res = execute("SET client_min_messages = warning;", 0, NULL);
PQclear(res);
-<<<<<<< HEAD
/* wait for WAL files to be archived */
-=======
->>>>>>> 21fd0ec (change some comment)
params[0] = "true";
res = execute("SELECT * FROM pg_backup_stop($1)", 1, params);