Skip to content

Commit e9d950f

Browse files
committed
Merge branch 'release_2_4' into issue_66
2 parents ae832a9 + 08b9cb7 commit e9d950f

File tree

8 files changed

+157
-42
lines changed

8 files changed

+157
-42
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ Regardless of the chosen backup type, all backups taken with `pg_probackup` supp
5454

5555
## Current release
5656

57-
[2.3.4](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.4)
57+
[2.3.5](https://github.com/postgrespro/pg_probackup/releases/tag/2.3.5)
5858

5959
## Documentation
6060

6161
Documentation can be found at [github](https://postgrespro.github.io/pg_probackup) and [Postgres Professional documentation](https://postgrespro.com/docs/postgrespro/current/app-pgprobackup)
6262

6363
## Installation and Setup
6464
### Windows Installation
65-
Installers are available in release **assets**. [Latests](https://github.com/postgrespro/pg_probackup/releases/2.3.3).
65+
Installers are available in release **assets**. [Latests](https://github.com/postgrespro/pg_probackup/releases/2.3.5).
6666

6767
### Linux Installation
6868
#### pg_probackup for vanilla PostgreSQL
@@ -96,64 +96,64 @@ yum install pg_probackup-{12,11,10,9.6,9.5}-debuginfo
9696
#SRPM Packages
9797
yumdownloader --source pg_probackup-{12,11,10,9.6,9.5}
9898

99-
#RPM ALT Linux p7
99+
#RPM ALT Linux 7
100100
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p7 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
101101
sudo apt-get update
102102
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
103103
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo
104104

105-
#RPM ALT Linux p8
105+
#RPM ALT Linux 8
106106
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p8 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
107107
sudo apt-get update
108108
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
109109
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo
110110

111-
#RPM ALT Linux p9
111+
#RPM ALT Linux 9
112112
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p9 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
113113
sudo apt-get update
114114
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
115115
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo
116116
```
117117

118-
#### pg_probackup for PostgresPro Standart and Enterprise
118+
#### pg_probackup for PostgresPro Standard and Enterprise
119119
```shell
120120
#DEB Ubuntu|Debian Packages
121121
sudo echo "deb [arch=amd64] https://repo.postgrespro.ru/pg_probackup-forks/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" > /etc/apt/sources.list.d/pg_probackup-forks.list
122122
sudo wget -O - https://repo.postgrespro.ru/pg_probackup-forks/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update
123-
sudo apt-get install pg-probackup-{std,ent}-{11,10,9.6}
124-
sudo apt-get install pg-probackup-{std,ent}-{11,10,9.6}-dbg
123+
sudo apt-get install pg-probackup-{std,ent}-{12,11,10,9.6}
124+
sudo apt-get install pg-probackup-{std,ent}-{12,11,10,9.6}-dbg
125125

126126
#RPM Centos Packages
127127
rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-centos.noarch.rpm
128-
yum install pg_probackup-{std,ent}-{11,10,9.6}
129-
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
128+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}
129+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
130130

131131
#RPM RHEL Packages
132132
rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-rhel.noarch.rpm
133-
yum install pg_probackup-{std,ent}-{11,10,9.6}
134-
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
133+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}
134+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
135135

136136
#RPM Oracle Linux Packages
137137
rpm -ivh https://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-oraclelinux.noarch.rpm
138-
yum install pg_probackup-{std,ent}-{11,10,9.6}
139-
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
138+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}
139+
yum install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
140140

141-
#RPM ALT Linux p7
141+
#RPM ALT Linux 7
142142
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p7 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list
143143
sudo apt-get update
144-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
145-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
144+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}
145+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
146146

147-
#RPM ALT Linux p8
147+
#RPM ALT Linux 8
148148
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p8 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list
149149
sudo apt-get update
150-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
151-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
150+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}
151+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
152152

153-
#RPM ALT Linux p9
153+
#RPM ALT Linux 9
154154
sudo echo "rpm https://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p9 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list && sudo apt-get update
155-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
156-
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo
155+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}
156+
sudo apt-get install pg_probackup-{std,ent}-{12,11,10,9.6}-debuginfo
157157
```
158158

159159
Once you have `pg_probackup` installed, complete [the setup](https://github.com/postgrespro/pg_probackup/blob/master/Documentation.md#installation-and-setup).

src/backup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1855,7 +1855,7 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
18551855
}
18561856

18571857
elog(LOG, "stop_lsn: %X/%X",
1858-
(uint32) (stop_backup_lsn >> 32), (uint32) (stop_backup_lsn));
1858+
(uint32) (stop_backup_lsn_tmp >> 32), (uint32) (stop_backup_lsn_tmp));
18591859

18601860
/* Write backup_label and tablespace_map */
18611861
if (!exclusive_backup)

src/init.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,28 +67,31 @@ do_add_instance(InstanceConfig *instance)
6767

6868
/* Ensure that all root directories already exist */
6969
if (access(backup_path, F_OK) != 0)
70-
elog(ERROR, "%s directory does not exist.", backup_path);
70+
elog(ERROR, "Directory does not exist: '%s'", backup_path);
7171

7272
join_path_components(path, backup_path, BACKUPS_DIR);
7373
if (access(path, F_OK) != 0)
74-
elog(ERROR, "%s directory does not exist.", path);
74+
elog(ERROR, "Directory does not exist: '%s'", path);
7575

7676
join_path_components(arclog_path_dir, backup_path, "wal");
7777
if (access(arclog_path_dir, F_OK) != 0)
78-
elog(ERROR, "%s directory does not exist.", arclog_path_dir);
78+
elog(ERROR, "Directory does not exist: '%s'", arclog_path_dir);
7979

80-
/* Create directory for data files of this specific instance */
8180
if (stat(instance->backup_instance_path, &st) == 0 && S_ISDIR(st.st_mode))
82-
elog(ERROR, "instance '%s' already exists", instance->backup_instance_path);
83-
dir_create_dir(instance->backup_instance_path, DIR_PERMISSION);
81+
elog(ERROR, "Instance '%s' backup directory already exists: '%s'",
82+
instance->name, instance->backup_instance_path);
8483

8584
/*
8685
* Create directory for wal files of this specific instance.
8786
* Existence check is extra paranoid because if we don't have such a
8887
* directory in data dir, we shouldn't have it in wal as well.
8988
*/
9089
if (stat(instance->arclog_path, &st) == 0 && S_ISDIR(st.st_mode))
91-
elog(ERROR, "arclog_path '%s' already exists", instance->arclog_path);
90+
elog(ERROR, "Instance '%s' WAL archive directory already exists: '%s'",
91+
instance->name, instance->arclog_path);
92+
93+
/* Create directory for data files of this specific instance */
94+
dir_create_dir(instance->backup_instance_path, DIR_PERMISSION);
9295
dir_create_dir(instance->arclog_path, DIR_PERMISSION);
9396

9497
/*

src/validate.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,19 @@ pgBackupValidate(pgBackup *backup, pgRestoreParams *params)
5858
int i;
5959
// parray *dbOid_exclude_list = NULL;
6060

61-
/* Check backup version */
61+
/* Check backup program version */
6262
if (parse_program_version(backup->program_version) > parse_program_version(PROGRAM_VERSION))
6363
elog(ERROR, "pg_probackup binary version is %s, but backup %s version is %s. "
6464
"pg_probackup do not guarantee to be forward compatible. "
6565
"Please upgrade pg_probackup binary.",
6666
PROGRAM_VERSION, base36enc(backup->start_time), backup->program_version);
6767

68+
/* Check backup server version */
69+
if (strcmp(backup->server_version, PG_MAJORVERSION) != 0)
70+
elog(ERROR, "Backup %s has server version %s, but current pg_probackup binary "
71+
"compiled with server version %s",
72+
base36enc(backup->start_time), backup->server_version, PG_MAJORVERSION);
73+
6874
if (backup->status == BACKUP_STATUS_RUNNING)
6975
{
7076
elog(WARNING, "Backup %s has status %s, change it to ERROR and skip validation",

tests/expected/option_version.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pg_probackup 2.3.4
1+
pg_probackup 2.3.5

tests/init.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
import unittest
33
from .helpers.ptrack_helpers import dir_files, ProbackupTest, ProbackupException
4+
import shutil
45

56

67
module_name = 'init'
@@ -104,3 +105,53 @@ def test_abs_path(self):
104105

105106
# Clean after yourself
106107
self.del_test_dir(module_name, fname)
108+
109+
# @unittest.skip("skip")
110+
# @unittest.expectedFailure
111+
def test_add_instance_idempotence(self):
112+
"""
113+
https://github.com/postgrespro/pg_probackup/issues/219
114+
"""
115+
fname = self.id().split(".")[3]
116+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
117+
node = self.make_simple_node(base_dir=os.path.join(module_name, fname, 'node'))
118+
self.init_pb(backup_dir)
119+
120+
self.add_instance(backup_dir, 'node', node)
121+
shutil.rmtree(os.path.join(backup_dir, 'backups', 'node'))
122+
123+
dir_backups = os.path.join(backup_dir, 'backups', 'node')
124+
dir_wal = os.path.join(backup_dir, 'wal', 'node')
125+
126+
try:
127+
self.add_instance(backup_dir, 'node', node)
128+
# we should die here because exception is what we expect to happen
129+
self.assertEqual(
130+
1, 0,
131+
"Expecting Error because page backup should not be possible "
132+
"\n Output: {0} \n CMD: {1}".format(
133+
repr(self.output), self.cmd))
134+
except ProbackupException as e:
135+
self.assertIn(
136+
"ERROR: Instance 'node' WAL archive directory already exists: ",
137+
e.message,
138+
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
139+
repr(e.message), self.cmd))
140+
141+
try:
142+
self.add_instance(backup_dir, 'node', node)
143+
# we should die here because exception is what we expect to happen
144+
self.assertEqual(
145+
1, 0,
146+
"Expecting Error because page backup should not be possible "
147+
"\n Output: {0} \n CMD: {1}".format(
148+
repr(self.output), self.cmd))
149+
except ProbackupException as e:
150+
self.assertIn(
151+
"ERROR: Instance 'node' WAL archive directory already exists: ",
152+
e.message,
153+
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
154+
repr(e.message), self.cmd))
155+
156+
# Clean after yourself
157+
self.del_test_dir(module_name, fname)

tests/merge.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import unittest
44
import os
55
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
6+
from testgres import QueryException
67
import shutil
78
from datetime import datetime, timedelta
89
import time
@@ -175,18 +176,15 @@ def test_merge_compressed_backups_1(self):
175176
node = self.make_simple_node(
176177
base_dir=os.path.join(module_name, fname, 'node'),
177178
set_replication=True, initdb_params=["--data-checksums"],
178-
pg_options={
179-
'autovacuum': 'off'
180-
}
181-
)
179+
pg_options={'autovacuum': 'off'})
182180

183181
self.init_pb(backup_dir)
184182
self.add_instance(backup_dir, "node", node)
185183
self.set_archiving(backup_dir, "node", node)
186184
node.slow_start()
187185

188186
# Fill with data
189-
node.pgbench_init(scale=5)
187+
node.pgbench_init(scale=10)
190188

191189
# Do compressed FULL backup
192190
self.backup_node(backup_dir, "node", node, options=['--compress', '--stream'])
@@ -196,7 +194,7 @@ def test_merge_compressed_backups_1(self):
196194
self.assertEqual(show_backup["backup-mode"], "FULL")
197195

198196
# Change data
199-
pgbench = node.pgbench(options=['-T', '20', '-c', '2', '--no-vacuum'])
197+
pgbench = node.pgbench(options=['-T', '10', '-c', '1', '--no-vacuum'])
200198
pgbench.wait()
201199

202200
# Do compressed DELTA backup
@@ -205,7 +203,7 @@ def test_merge_compressed_backups_1(self):
205203
backup_type="delta", options=['--compress', '--stream'])
206204

207205
# Change data
208-
pgbench = node.pgbench(options=['-T', '20', '-c', '2', '--no-vacuum'])
206+
pgbench = node.pgbench(options=['-T', '10', '-c', '1', '--no-vacuum'])
209207
pgbench.wait()
210208

211209
# Do compressed PAGE backup
@@ -1478,10 +1476,12 @@ def test_crash_after_opening_backup_control_1(self):
14781476

14791477
self.del_test_dir(module_name, fname)
14801478

1479+
@unittest.skip("skip")
14811480
def test_crash_after_opening_backup_control_2(self):
14821481
"""
14831482
check that crashing after opening backup_content.control
14841483
for writing will not result in losing metadata about backup files
1484+
TODO: rewrite
14851485
"""
14861486
fname = self.id().split('.')[3]
14871487
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
@@ -1531,7 +1531,7 @@ def test_crash_after_opening_backup_control_2(self):
15311531
gdb.run_until_break()
15321532

15331533
gdb.set_breakpoint('sprintf')
1534-
gdb.continue_execution_until_break(20)
1534+
gdb.continue_execution_until_break(1)
15351535

15361536
gdb._execute('signal SIGKILL')
15371537

@@ -1568,10 +1568,12 @@ def test_crash_after_opening_backup_control_2(self):
15681568

15691569
self.del_test_dir(module_name, fname)
15701570

1571+
@unittest.skip("skip")
15711572
def test_losing_file_after_failed_merge(self):
15721573
"""
15731574
check that crashing after opening backup_content.control
15741575
for writing will not result in losing metadata about backup files
1576+
TODO: rewrite
15751577
"""
15761578
fname = self.id().split('.')[3]
15771579
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')

tests/validate.py

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3716,6 +3716,59 @@ def test_partial_validate_include(self):
37163716
# Clean after yourself
37173717
self.del_test_dir(module_name, fname)
37183718

3719+
# @unittest.skip("skip")
3720+
def test_not_validate_diffenent_pg_version(self):
3721+
"""Do not validate backup, if binary is compiled with different PG version"""
3722+
fname = self.id().split('.')[3]
3723+
node = self.make_simple_node(
3724+
base_dir=os.path.join(module_name, fname, 'node'),
3725+
initdb_params=['--data-checksums'])
3726+
3727+
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
3728+
self.init_pb(backup_dir)
3729+
self.add_instance(backup_dir, 'node', node)
3730+
self.set_archiving(backup_dir, 'node', node)
3731+
node.slow_start()
3732+
3733+
backup_id = self.backup_node(backup_dir, 'node', node)
3734+
3735+
control_file = os.path.join(
3736+
backup_dir, "backups", "node", backup_id,
3737+
"backup.control")
3738+
3739+
pg_version = node.major_version
3740+
3741+
if pg_version.is_integer():
3742+
pg_version = int(pg_version)
3743+
3744+
fake_new_pg_version = pg_version + 1
3745+
3746+
with open(control_file, 'r') as f:
3747+
data = f.read();
3748+
3749+
data = data.replace(str(pg_version), str(fake_new_pg_version))
3750+
3751+
with open(control_file, 'w') as f:
3752+
f.write(data);
3753+
3754+
try:
3755+
self.validate_pb(backup_dir)
3756+
self.assertEqual(
3757+
1, 0,
3758+
"Expecting Error because validation is forbidden if server version of backup "
3759+
"is different from the server version of pg_probackup.\n Output: {0} \n CMD: {1}".format(
3760+
repr(self.output), self.cmd))
3761+
except ProbackupException as e:
3762+
self.assertIn(
3763+
"ERROR: Backup {0} has server version".format(backup_id),
3764+
e.message,
3765+
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
3766+
repr(e.message), self.cmd))
3767+
3768+
# Clean after yourself
3769+
self.del_test_dir(module_name, fname)
3770+
3771+
37193772
# validate empty backup list
37203773
# page from future during validate
37213774
# page from future during backup
@@ -3727,4 +3780,4 @@ def test_partial_validate_include(self):
37273780
# 715 MAXALIGN(header.compressed_size), in);
37283781
# 716 if (read_len != MAXALIGN(header.compressed_size))
37293782
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
3730-
# 718 blknum, file->path, read_len, header.compressed_size);
3783+
# 718 blknum, file->path, read_len, header.compressed_size);

0 commit comments

Comments
 (0)