Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b4ac9d0

Browse files
committed
Merge branch 'pbckp-129' of github.com:postgrespro/pg_probackup into pbckp-129
2 parents aefb5db + bc38df0 commit b4ac9d0

File tree

11 files changed

+88
-71
lines changed

11 files changed

+88
-71
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ env:
3434
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE
3535
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE
3636
- PG_VERSION=9.5 PG_BRANCH=REL9_5_STABLE
37-
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=archive
37+
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=archive
3838
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=backup
3939
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=catchup
40-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=compression
41-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=delta
42-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=locking
40+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=compression
41+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=delta
42+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=locking
4343
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=merge
44-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=page
44+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=page
4545
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=ptrack
4646
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=replica
47-
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=off MODE=retention
47+
# - PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=OFF MODE=retention
4848
- PG_VERSION=13 PG_BRANCH=REL_13_STABLE PTRACK_PATCH_PG_BRANCH=REL_13_STABLE MODE=restore
4949

5050
jobs:

doc/pgprobackup.xml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ GRANT SELECT ON TABLE pg_catalog.pg_namespace TO backup;
977977
GRANT SELECT ON TABLE pg_catalog.pg_extension TO backup;
978978
GRANT EXECUTE ON FUNCTION bt_index_check(regclass) TO backup;
979979
GRANT EXECUTE ON FUNCTION bt_index_check(regclass, bool) TO backup;
980+
GRANT EXECUTE ON FUNCTION bt_index_check(regclass, bool, bool) TO backup;
980981
</programlisting>
981982
</refsect2>
982983
<refsect2 id="pbk-setting-up-partial-restore">
@@ -4176,7 +4177,7 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
41764177
pg_probackup checkdb
41774178
[-B <replaceable>backup_dir</replaceable>] [--instance <replaceable>instance_name</replaceable>] [-D <replaceable>data_dir</replaceable>]
41784179
[--help] [-j <replaceable>num_threads</replaceable>] [--progress]
4179-
[--skip-block-validation] [--amcheck [--checkunique] [--heapallindexed]]
4180+
[--amcheck [--skip-block-validation] [--checkunique] [--heapallindexed]]
41804181
[<replaceable>connection_options</replaceable>] [<replaceable>logging_options</replaceable>]
41814182
</programlisting>
41824183
<para>
@@ -4191,7 +4192,7 @@ pg_probackup checkdb
41914192
<para>
41924193
Performs logical verification of indexes for the specified
41934194
<productname>PostgreSQL</productname> instance if no corruption was found while checking
4194-
data files. You must have the <application>amcheck</application>
4195+
data files. You must have the <ulink url="https://postgrespro.com/docs/enterprise/current/amcheck.html"><application>amcheck</application></ulink>
41954196
extension or the <application>amcheck_next</application> extension
41964197
installed in the database to check its indexes. For databases
41974198
without <application>amcheck</application>, index verification will be skipped.
@@ -4211,8 +4212,10 @@ pg_probackup checkdb
42114212
installed in the database.
42124213
</para>
42134214
<para>
4214-
This verification is only possible if it is supported by the version of the
4215-
<application>amcheck</application> extension you are using.
4215+
The verification of unique constraints is only possible if in the version of the
4216+
<application>amcheck</application> extension you are using, the
4217+
<function>bt_index_check</function> function takes the
4218+
<parameter>checkunique</parameter> parameter.
42164219
</para>
42174220
</listitem>
42184221
</varlistentry>
@@ -4226,9 +4229,10 @@ pg_probackup checkdb
42264229
<option>--amcheck</option> flag.
42274230
</para>
42284231
<para>
4229-
This check is only possible if it is supported by the version of the
4230-
<application>amcheck</application> extension you are using or
4231-
if the <application>amcheck_next</application> extension is used instead.
4232+
This check is only possible if in the version of the
4233+
<application>amcheck</application>/<application>amcheck_next</application> extension
4234+
you are using, the <function>bt_index_check</function>
4235+
function takes the <parameter>heapallindexed</parameter> parameter.
42324236
</para>
42334237
</listitem>
42344238
</varlistentry>

packaging/pkg/scripts/rpm.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ ulimit -n 1024
2020

2121
if [ ${DISTRIB} = 'centos' ] ; then
2222
sed -i 's|^baseurl=http://|baseurl=https://|g' /etc/yum.repos.d/*.repo
23+
if [ ${DISTRIB_VERSION} = '8' ]; then
24+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
25+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
26+
fi
2327
yum update -y
28+
if [ ${DISTRIB_VERSION} = '8' ]; then
29+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
30+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
31+
fi
2432
fi
2533

2634
# PACKAGES NEEDED

packaging/test/scripts/rpm.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@ PG_TOG=$(echo $PG_VERSION | sed 's|\.||g')
1515

1616
if [ ${DISTRIB} != 'rhel' -o ${DISTRIB_VERSION} != '7' ]; then
1717
# update of rpm package is broken in rhel-7 (26/12/2022)
18-
yum update -y
18+
#yum update -y
19+
if [ ${DISTRIB} = 'centos' -a ${DISTRIB_VERSION} = '8' ]; then
20+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
21+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
22+
fi
23+
yum update -y
24+
if [ ${DISTRIB} = 'centos' -a ${DISTRIB_VERSION} = '8' ]; then
25+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
26+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
27+
fi
1928
fi
2029
# yum upgrade -y || echo 'some packages in docker failed to upgrade'
2130
# yum install -y sudo

packaging/test/scripts/rpm_forks.sh

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ PG_TOG=$(echo $PG_VERSION | sed 's|\.||g')
1515

1616
if [ ${DISTRIB} != 'rhel' -o ${DISTRIB_VERSION} != '7' ]; then
1717
# update of rpm package is broken in rhel-7 (26/12/2022)
18+
if [ ${DISTRIB} = 'centos' -a ${DISTRIB_VERSION} = '8' ]; then
19+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
20+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
21+
fi
1822
yum update -y
23+
if [ ${DISTRIB} = 'centos' -a ${DISTRIB_VERSION} = '8' ]; then
24+
sed -i 's|mirrorlist|#mirrorlist|g' /etc/yum.repos.d/CentOS-*.repo
25+
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*.repo
26+
fi
1927
fi
2028

2129
if [ ${PBK_EDITION} == 'ent' ]; then
@@ -80,11 +88,13 @@ if [ $PBK_EDITION == 'std' ] ; then
8088

8189
# install POSTGRESQL
8290
# rpm -ivh https://download.postgresql.org/pub/repos/yum/reporpms/EL-${DISTRIB_VERSION}-x86_64/pgdg-redhat-repo-latest.noarch.rpm
83-
if [[ ${PG_VERSION} == '11' ]] || [[ ${PG_VERSION} == '12' ]]; then
84-
rpm -ivh https://repo.postgrespro.ru/pgpro-${PG_VERSION}/keys/postgrespro-std-${PG_VERSION}.${DISTRIB}.yum-${PG_VERSION}-0.3.noarch.rpm
85-
else
86-
rpm -ivh https://repo.postgrespro.ru/pgpro-${PG_VERSION}/keys/postgrespro-std-${PG_VERSION}.${DISTRIB}.yum-${PG_VERSION}-0.3.noarch.rpm
87-
fi
91+
#if [[ ${PG_VERSION} == '11' ]] || [[ ${PG_VERSION} == '12' ]]; then
92+
# rpm -ivh https://repo.postgrespro.ru/pgpro-${PG_VERSION}/keys/postgrespro-std-${PG_VERSION}.${DISTRIB}.yum-${PG_VERSION}-0.3.noarch.rpm
93+
#else
94+
# rpm -ivh https://repo.postgrespro.ru/pgpro-${PG_VERSION}/keys/postgrespro-std-${PG_VERSION}.${DISTRIB}.yum-${PG_VERSION}-0.3.noarch.rpm
95+
#fi
96+
curl -o pgpro-repo-add.sh https://repo.postgrespro.ru/pgpro-${PG_VERSION}/keys/pgpro-repo-add.sh
97+
sh pgpro-repo-add.sh
8898

8999
if [[ ${PG_VERSION} == '9.6' ]]; then
90100
yum install -y postgrespro${PG_TOG}-server.x86_64

src/data.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,10 +2030,10 @@ get_page_header(FILE *in, const char *fullpath, BackupPageHeader* bph,
20302030
return false; /* EOF found */
20312031
else if (read_len != 0 && feof(in))
20322032
elog(ERROR,
2033-
"Odd size page found at offset %lu of \"%s\"",
2033+
"Odd size page found at offset %ld of \"%s\"",
20342034
ftello(in), fullpath);
20352035
else
2036-
elog(ERROR, "Cannot read header at offset %lu of \"%s\": %s",
2036+
elog(ERROR, "Cannot read header at offset %ld of \"%s\": %s",
20372037
ftello(in), fullpath, strerror(errno));
20382038
}
20392039

@@ -2321,7 +2321,7 @@ copy_pages(const char *to_fullpath, const char *from_fullpath,
23212321
elog(ERROR, "Cannot seek to end of file position in destination file \"%s\": %s",
23222322
to_fullpath, strerror(errno));
23232323
{
2324-
size_t pos = ftell(out);
2324+
long pos = ftell(out);
23252325

23262326
if (pos < 0)
23272327
elog(ERROR, "Cannot get position in destination file \"%s\": %s",

src/delete.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ do_delete(InstanceState *instanceState, time_t backup_id)
3636
parray *backup_list,
3737
*delete_list;
3838
pgBackup *target_backup = NULL;
39-
size_t size_to_delete = 0;
39+
int64 size_to_delete = 0;
4040
char size_to_delete_pretty[20];
4141

4242
/* Get complete list of backups */
@@ -682,12 +682,11 @@ do_retention_wal(InstanceState *instanceState, bool dry_run)
682682
* at least one backup and no file should be removed.
683683
* Unless wal-depth is enabled.
684684
*/
685-
if ((tlinfo->closest_backup) && instance_config.wal_depth <= 0)
685+
if ((tlinfo->closest_backup) && instance_config.wal_depth == 0)
686686
continue;
687687

688688
/* WAL retention keeps this timeline from purge */
689-
if (instance_config.wal_depth >= 0 && tlinfo->anchor_tli > 0 &&
690-
tlinfo->anchor_tli != tlinfo->tli)
689+
if (tlinfo->anchor_tli > 0 && tlinfo->anchor_tli != tlinfo->tli)
691690
continue;
692691

693692
/*
@@ -701,7 +700,7 @@ do_retention_wal(InstanceState *instanceState, bool dry_run)
701700
*/
702701
if (tlinfo->oldest_backup)
703702
{
704-
if (instance_config.wal_depth >= 0 && !(XLogRecPtrIsInvalid(tlinfo->anchor_lsn)))
703+
if (!(XLogRecPtrIsInvalid(tlinfo->anchor_lsn)))
705704
{
706705
delete_walfiles_in_tli(instanceState, tlinfo->anchor_lsn,
707706
tlinfo, instance_config.xlog_seg_size, dry_run);
@@ -714,7 +713,7 @@ do_retention_wal(InstanceState *instanceState, bool dry_run)
714713
}
715714
else
716715
{
717-
if (instance_config.wal_depth >= 0 && !(XLogRecPtrIsInvalid(tlinfo->anchor_lsn)))
716+
if (!(XLogRecPtrIsInvalid(tlinfo->anchor_lsn)))
718717
delete_walfiles_in_tli(instanceState, tlinfo->anchor_lsn,
719718
tlinfo, instance_config.xlog_seg_size, dry_run);
720719
else
@@ -942,7 +941,7 @@ delete_walfiles_in_tli(InstanceState *instanceState, XLogRecPtr keep_lsn, timeli
942941
join_path_components(wal_fullpath, instanceState->instance_wal_subdir_path, wal_file->file.name);
943942

944943
/* save segment from purging */
945-
if (instance_config.wal_depth >= 0 && wal_file->keep)
944+
if (wal_file->keep)
946945
{
947946
elog(VERBOSE, "Retain WAL segment \"%s\"", wal_fullpath);
948947
continue;
@@ -1027,7 +1026,7 @@ do_delete_status(InstanceState *instanceState, InstanceConfig *instance_config,
10271026
parray *backup_list, *delete_list;
10281027
const char *pretty_status;
10291028
int n_deleted = 0, n_found = 0;
1030-
size_t size_to_delete = 0;
1029+
int64 size_to_delete = 0;
10311030
char size_to_delete_pretty[20];
10321031
pgBackup *backup;
10331032

tests/backup.py

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2351,47 +2351,45 @@ def test_backup_with_less_privileges_role(self):
23512351

23522352
replica.slow_start(replica=True)
23532353

2354-
# Archive backups from replica in this test are disabled,
2355-
# because WAL archiving on replica in idle DB in PostgreSQL is broken:
2356-
# replica will not archive the previous WAL until it receives new records in the next WAL file,
2357-
# this "lazy" archiving can be seen in src/backend/replication/walreceiver.c:XLogWalRcvWrite()
2358-
# (see !XLByteInSeg checking and XLogArchiveNotify() calling).
2359-
#
23602354
# self.switch_wal_segment(node)
2361-
#self.backup_node(
2362-
# backup_dir, 'replica', replica,
2363-
# datname='backupdb', options=['-U', 'backup'])
2355+
# self.switch_wal_segment(node)
2356+
2357+
self.backup_node(
2358+
backup_dir, 'replica', replica,
2359+
datname='backupdb', options=['-U', 'backup'])
23642360

23652361
# stream full backup from replica
23662362
self.backup_node(
23672363
backup_dir, 'replica', replica,
23682364
datname='backupdb', options=['--stream', '-U', 'backup'])
23692365

2366+
# self.switch_wal_segment(node)
2367+
23702368
# PAGE backup from replica
2371-
#self.switch_wal_segment(node)
2372-
#self.backup_node(
2373-
# backup_dir, 'replica', replica, backup_type='page',
2374-
# datname='backupdb', options=['-U', 'backup', '--archive-timeout=30s'])
2369+
self.switch_wal_segment(node)
2370+
self.backup_node(
2371+
backup_dir, 'replica', replica, backup_type='page',
2372+
datname='backupdb', options=['-U', 'backup', '--archive-timeout=30s'])
23752373

23762374
self.backup_node(
23772375
backup_dir, 'replica', replica, backup_type='page',
23782376
datname='backupdb', options=['--stream', '-U', 'backup'])
23792377

23802378
# DELTA backup from replica
2381-
#self.switch_wal_segment(node)
2382-
#self.backup_node(
2383-
# backup_dir, 'replica', replica, backup_type='delta',
2384-
# datname='backupdb', options=['-U', 'backup'])
2379+
self.switch_wal_segment(node)
2380+
self.backup_node(
2381+
backup_dir, 'replica', replica, backup_type='delta',
2382+
datname='backupdb', options=['-U', 'backup'])
23852383
self.backup_node(
23862384
backup_dir, 'replica', replica, backup_type='delta',
23872385
datname='backupdb', options=['--stream', '-U', 'backup'])
23882386

23892387
# PTRACK backup from replica
23902388
if self.ptrack:
2391-
#self.switch_wal_segment(node)
2392-
#self.backup_node(
2393-
# backup_dir, 'replica', replica, backup_type='ptrack',
2394-
# datname='backupdb', options=['-U', 'backup'])
2389+
self.switch_wal_segment(node)
2390+
self.backup_node(
2391+
backup_dir, 'replica', replica, backup_type='ptrack',
2392+
datname='backupdb', options=['-U', 'backup'])
23952393
self.backup_node(
23962394
backup_dir, 'replica', replica, backup_type='ptrack',
23972395
datname='backupdb', options=['--stream', '-U', 'backup'])

tests/replica.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,16 +291,6 @@ def test_replica_archive_page_backup(self):
291291

292292
self.wait_until_replica_catch_with_master(master, replica)
293293

294-
master.pgbench_init(scale=5)
295-
# Continuous making some changes on master,
296-
# because WAL archiving on replica in idle DB in PostgreSQL is broken:
297-
# replica will not archive the previous WAL until it receives new records in the next WAL file,
298-
# this "lazy" archiving can be seen in src/backend/replication/walreceiver.c:XLogWalRcvWrite()
299-
# (see !XLByteInSeg checking and XLogArchiveNotify() calling).
300-
pgbench = master.pgbench(
301-
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
302-
options=['-T', '3', '-c', '1', '--no-vacuum'])
303-
304294
backup_id = self.backup_node(
305295
backup_dir, 'replica', replica,
306296
options=[
@@ -309,9 +299,6 @@ def test_replica_archive_page_backup(self):
309299
'--master-db=postgres',
310300
'--master-port={0}'.format(master.port)])
311301

312-
pgbench.wait()
313-
pgbench.stdout.close()
314-
315302
self.validate_pb(backup_dir, 'replica')
316303
self.assertEqual(
317304
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
@@ -334,6 +321,8 @@ def test_replica_archive_page_backup(self):
334321
# Change data on master, make PAGE backup from replica,
335322
# restore taken backup and check that restored data equal
336323
# to original data
324+
master.pgbench_init(scale=5)
325+
337326
pgbench = master.pgbench(
338327
options=['-T', '30', '-c', '2', '--no-vacuum'])
339328

travis/make_dockerfile.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if [ -z ${MODE+x} ]; then
1515
fi
1616

1717
if [ -z ${PTRACK_PATCH_PG_BRANCH+x} ]; then
18-
PTRACK_PATCH_PG_BRANCH=off
18+
PTRACK_PATCH_PG_BRANCH=OFF
1919
fi
2020

2121
if [ -z ${PGPROBACKUP_GDB+x} ]; then

0 commit comments

Comments
 (0)