Skip to content

Commit 8eff099

Browse files
committed
Merge branch 'master' into issue_310
2 parents a596316 + b1dec24 commit 8eff099

16 files changed

+153
-72
lines changed

doc/pgprobackup.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ doc/src/sgml/pgprobackup.sgml
155155
recovery of <productname>PostgreSQL</productname> database clusters.
156156
It is designed to perform periodic backups of the <productname>PostgreSQL</productname>
157157
instance that enable you to restore the server in case of a failure.
158-
<application>pg_probackup</application> supports <productname>PostgreSQL</productname> 9.5 or higher.
158+
<application>pg_probackup</application> supports PostgreSQL 9.5 or higher.
159159
</para>
160160

161161
<itemizedlist spacing="compact">
@@ -389,7 +389,7 @@ doc/src/sgml/pgprobackup.sgml
389389
<itemizedlist spacing="compact">
390390
<listitem>
391391
<para>
392-
<application>pg_probackup</application> only supports <productname>PostgreSQL</productname> 9.5 and higher.
392+
<application>pg_probackup</application> only supports PostgreSQL 9.5 and higher.
393393
</para>
394394
</listitem>
395395
<listitem>
@@ -410,7 +410,7 @@ doc/src/sgml/pgprobackup.sgml
410410
</listitem>
411411
<listitem>
412412
<para>
413-
For PostgreSQL 9.5, functions
413+
For <productname>PostgreSQL</productname> 9.5, functions
414414
<function>pg_create_restore_point(text)</function> and
415415
<function>pg_switch_xlog()</function> can be executed only if
416416
the backup role is a superuser, so backup of a
@@ -599,7 +599,7 @@ pg_probackup add-instance -B <replaceable>backup_dir</replaceable> -D <replaceab
599599
connection</emphasis> to the <productname>PostgreSQL</productname> server:
600600
</para>
601601
<para>
602-
For PostgreSQL 9.5:
602+
For <productname>PostgreSQL</productname> 9.5:
603603
</para>
604604
<programlisting>
605605
BEGIN;
@@ -1202,8 +1202,9 @@ CREATE EXTENSION ptrack;
12021202
together, which leads to false-positive results when tracking changed
12031203
blocks and increases the incremental backup size as unchanged blocks
12041204
can also be copied into the incremental backup.
1205-
Setting <varname>ptrack.map_size</varname> to a higher value
1206-
does not affect PTRACK operation. The maximum allowed value is 1024.
1205+
Setting <varname>ptrack.map_size</varname> to a higher value does not
1206+
affect PTRACK operation, but it is not recommended to set this parameter
1207+
to a value higher than 1024.
12071208
</para>
12081209
</listitem>
12091210
</orderedlist>
@@ -1711,7 +1712,7 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
17111712
<para>
17121713
The speed of restore from backup can be significantly improved
17131714
by replacing only invalid and changed pages in already
1714-
existing PostgreSQL data directory using
1715+
existing <productname>PostgreSQL</productname> data directory using
17151716
<link linkend="pbk-incremental-restore-options">incremental
17161717
restore options</link> with the <xref linkend="pbk-restore"/>
17171718
command.
@@ -1874,11 +1875,11 @@ pg_probackup restore -B <replaceable>backup_dir</replaceable> --instance <replac
18741875
</note>
18751876
<note>
18761877
<para>
1877-
Due to recovery specifics of PostgreSQL versions earlier than 12,
1878+
Due to recovery specifics of <productname>PostgreSQL</productname> versions earlier than 12,
18781879
it is advisable that you set the
18791880
<ulink url="https://postgrespro.com/docs/postgresql/current/runtime-config-replication.html#GUC-HOT-STANDBY">hot_standby</ulink>
18801881
parameter to <literal>off</literal> when running partial
1881-
restore of a PostgreSQL cluster of version earlier than 12.
1882+
restore of a <productname>PostgreSQL</productname> cluster of version earlier than 12.
18821883
Otherwise the recovery may fail.
18831884
</para>
18841885
</note>

src/delete.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -227,22 +227,23 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
227227
{
228228
pgBackup *backup = (pgBackup *) parray_get(backup_list, i);
229229

230-
/* Consider only valid FULL backups for Redundancy */
231-
if (instance_config.retention_redundancy > 0 &&
232-
backup->backup_mode == BACKUP_MODE_FULL &&
233-
(backup->status == BACKUP_STATUS_OK ||
234-
backup->status == BACKUP_STATUS_DONE))
230+
if (backup->backup_mode == BACKUP_MODE_FULL)
235231
{
236-
n_full_backups++;
237-
238232
/* Add every FULL backup that satisfy Redundancy policy to separate list */
239-
if (n_full_backups <= instance_config.retention_redundancy)
233+
if (n_full_backups < instance_config.retention_redundancy)
240234
{
241235
if (!redundancy_full_backup_list)
242236
redundancy_full_backup_list = parray_new();
243237

244238
parray_append(redundancy_full_backup_list, backup);
245239
}
240+
241+
/* Consider only valid FULL backups for Redundancy fulfillment */
242+
if (backup->status == BACKUP_STATUS_OK ||
243+
backup->status == BACKUP_STATUS_DONE)
244+
{
245+
n_full_backups++;
246+
}
246247
}
247248
}
248249
/* Sort list of full backups to keep */
@@ -413,7 +414,10 @@ do_retention_internal(parray *backup_list, parray *to_keep_list, parray *to_purg
413414
pinning_window ? pinning_window : instance_config.retention_window,
414415
action);
415416

416-
if (backup->backup_mode == BACKUP_MODE_FULL)
417+
/* Only valid full backups are count to something */
418+
if (backup->backup_mode == BACKUP_MODE_FULL &&
419+
(backup->status == BACKUP_STATUS_OK ||
420+
backup->status == BACKUP_STATUS_DONE))
417421
cur_full_backup_num++;
418422
}
419423
}
@@ -741,7 +745,10 @@ delete_backup_files(pgBackup *backup)
741745
return;
742746
}
743747

744-
time2iso(timestamp, lengthof(timestamp), backup->recovery_time, false);
748+
if (backup->recovery_time)
749+
time2iso(timestamp, lengthof(timestamp), backup->recovery_time, false);
750+
else
751+
time2iso(timestamp, lengthof(timestamp), backup->start_time, false);
745752

746753
elog(INFO, "Delete: %s %s",
747754
base36enc(backup->start_time), timestamp);

src/restore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,9 +1782,9 @@ read_timeline_history(const char *arclog_path, TimeLineID targetTLI, bool strict
17821782
elog(ERROR, "Timeline IDs must be less than child timeline's ID.");
17831783

17841784
/* History file is empty or corrupted */
1785-
if (parray_num(result) == 0)
1785+
if (parray_num(result) == 0 && targetTLI != 1)
17861786
{
1787-
elog(WARNING, "History file is corrupted: \"%s\"", path);
1787+
elog(WARNING, "History file is corrupted or missing: \"%s\"", path);
17881788
pg_free(result);
17891789
return NULL;
17901790
}

tests/archive.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def test_basic_master_and_replica_concurrent_archiving(self):
981981
self.backup_node(backup_dir, 'master', replica)
982982

983983
# Clean after yourself
984-
self.del_test_dir(module_name, fname, nodes=[master, replica])
984+
self.del_test_dir(module_name, fname)
985985

986986
# @unittest.expectedFailure
987987
# @unittest.skip("skip")
@@ -2016,8 +2016,7 @@ def test_archive_pg_receivexlog_partial_handling(self):
20162016

20172017
# Clean after yourself
20182018
pg_receivexlog.kill()
2019-
self.del_test_dir(
2020-
module_name, fname, [node, replica, node_restored])
2019+
self.del_test_dir(module_name, fname)
20212020

20222021
@unittest.skip("skip")
20232022
def test_multi_timeline_recovery_prefetching(self):

tests/backup.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ def test_basic_tablespace_handling(self):
10651065
self.compare_pgdata(pgdata, pgdata_restored)
10661066

10671067
# Clean after yourself
1068-
self.del_test_dir(module_name, fname, nodes=[node])
1068+
self.del_test_dir(module_name, fname)
10691069

10701070
# @unittest.skip("skip")
10711071
def test_tablespace_handling_1(self):
@@ -1599,7 +1599,7 @@ def test_basic_temp_slot_for_stream_backup(self):
15991599
options=['--stream', '--slot=slot_1', '--temp-slot'])
16001600

16011601
# Clean after yourself
1602-
self.del_test_dir(module_name, fname, [node])
1602+
self.del_test_dir(module_name, fname)
16031603

16041604
# @unittest.skip("skip")
16051605
def test_backup_concurrent_drop_table(self):
@@ -1645,7 +1645,7 @@ def test_backup_concurrent_drop_table(self):
16451645
self.assertEqual(show_backup['status'], "OK")
16461646

16471647
# Clean after yourself
1648-
self.del_test_dir(module_name, fname, nodes=[node])
1648+
self.del_test_dir(module_name, fname)
16491649

16501650
# @unittest.skip("skip")
16511651
def test_pg_11_adjusted_wal_segment_size(self):
@@ -1930,7 +1930,7 @@ def test_basic_missing_file_permissions(self):
19301930
os.chmod(full_path, 700)
19311931

19321932
# Clean after yourself
1933-
self.del_test_dir(module_name, fname, [node])
1933+
self.del_test_dir(module_name, fname)
19341934

19351935
# @unittest.skip("skip")
19361936
def test_basic_missing_dir_permissions(self):
@@ -1973,7 +1973,7 @@ def test_basic_missing_dir_permissions(self):
19731973
os.rmdir(full_path)
19741974

19751975
# Clean after yourself
1976-
self.del_test_dir(module_name, fname, [node])
1976+
self.del_test_dir(module_name, fname)
19771977

19781978
# @unittest.skip("skip")
19791979
def test_backup_with_least_privileges_role(self):

tests/checkdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def test_basic_checkdb_amcheck_only_sanity(self):
349349
log_file_content)
350350

351351
# Clean after yourself
352-
self.del_test_dir(module_name, fname, [node])
352+
self.del_test_dir(module_name, fname)
353353

354354
# @unittest.skip("skip")
355355
def test_checkdb_block_validation_sanity(self):

tests/compression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_basic_compression_stream_zlib(self):
117117
self.assertEqual(delta_result, delta_result_new)
118118

119119
# Clean after yourself
120-
self.del_test_dir(module_name, fname, [node])
120+
self.del_test_dir(module_name, fname)
121121

122122
def test_compression_archive_zlib(self):
123123
"""

tests/delta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def test_basic_delta_vacuum_truncate(self):
8080
node_restored.slow_start()
8181

8282
# Clean after yourself
83-
self.del_test_dir(module_name, fname, [node, node_restored])
83+
self.del_test_dir(module_name, fname)
8484

8585
# @unittest.skip("skip")
8686
def test_delta_vacuum_truncate_1(self):

tests/helpers/ptrack_helpers.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# you need os for unittest to work
22
import os
3+
import gc
34
from sys import exit, argv, version_info
45
import subprocess
56
import shutil
@@ -402,7 +403,6 @@ def make_simple_node(
402403
if node.major_version >= 13:
403404
self.set_auto_conf(
404405
node, {}, 'postgresql.conf', ['wal_keep_segments'])
405-
406406
return node
407407

408408
def create_tblspace_in_node(self, node, tblspc_name, tblspc_path=None, cfs=False):
@@ -1514,15 +1514,15 @@ def get_version(self, node):
15141514
def get_bin_path(self, binary):
15151515
return testgres.get_bin_path(binary)
15161516

1517-
def del_test_dir(self, module_name, fname, nodes=[]):
1517+
def clean_all(self):
1518+
for o in gc.get_referrers(testgres.PostgresNode):
1519+
if o.__class__ is testgres.PostgresNode:
1520+
o.cleanup()
1521+
1522+
def del_test_dir(self, module_name, fname):
15181523
""" Del testdir and optimistically try to del module dir"""
1519-
try:
1520-
testgres.clean_all()
1521-
except:
1522-
pass
15231524

1524-
for node in nodes:
1525-
node.stop()
1525+
self.clean_all()
15261526

15271527
shutil.rmtree(
15281528
os.path.join(
@@ -1532,10 +1532,6 @@ def del_test_dir(self, module_name, fname, nodes=[]):
15321532
),
15331533
ignore_errors=True
15341534
)
1535-
try:
1536-
os.rmdir(os.path.join(self.tmp_path, module_name))
1537-
except:
1538-
pass
15391535

15401536
def pgdata_content(self, pgdata, ignore_ptrack=True, exclude_dirs=None):
15411537
""" return dict with directory content. "

tests/incr_restore.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def test_basic_incr_restore_sanity(self):
720720
repr(e.message), self.cmd))
721721

722722
# Clean after yourself
723-
self.del_test_dir(module_name, fname, [node])
723+
self.del_test_dir(module_name, fname)
724724

725725
# @unittest.skip("skip")
726726
def test_incr_checksum_restore(self):
@@ -809,7 +809,7 @@ def test_incr_checksum_restore(self):
809809
self.compare_pgdata(pgdata, pgdata_restored)
810810

811811
# Clean after yourself
812-
self.del_test_dir(module_name, fname, [node, node_1])
812+
self.del_test_dir(module_name, fname)
813813

814814

815815
# @unittest.skip("skip")
@@ -898,7 +898,7 @@ def test_incr_lsn_restore(self):
898898
self.compare_pgdata(pgdata, pgdata_restored)
899899

900900
# Clean after yourself
901-
self.del_test_dir(module_name, fname, [node, node_1])
901+
self.del_test_dir(module_name, fname)
902902

903903
# @unittest.skip("skip")
904904
def test_incr_lsn_sanity(self):
@@ -967,7 +967,7 @@ def test_incr_lsn_sanity(self):
967967
repr(e.message), self.cmd))
968968

969969
# Clean after yourself
970-
self.del_test_dir(module_name, fname, [node_1])
970+
self.del_test_dir(module_name, fname)
971971

972972
# @unittest.skip("skip")
973973
def test_incr_checksum_sanity(self):
@@ -1026,7 +1026,7 @@ def test_incr_checksum_sanity(self):
10261026
self.compare_pgdata(pgdata, pgdata_restored)
10271027

10281028
# Clean after yourself
1029-
self.del_test_dir(module_name, fname, [node_1])
1029+
self.del_test_dir(module_name, fname)
10301030

10311031

10321032
# @unittest.skip("skip")
@@ -1561,7 +1561,7 @@ def test_make_replica_via_incr_checksum_restore(self):
15611561
pgbench.wait()
15621562

15631563
# Clean after yourself
1564-
self.del_test_dir(module_name, fname, [new_master, old_master])
1564+
self.del_test_dir(module_name, fname)
15651565

15661566
# @unittest.skip("skip")
15671567
def test_make_replica_via_incr_lsn_restore(self):
@@ -1634,7 +1634,7 @@ def test_make_replica_via_incr_lsn_restore(self):
16341634
pgbench.wait()
16351635

16361636
# Clean after yourself
1637-
self.del_test_dir(module_name, fname, [new_master, old_master])
1637+
self.del_test_dir(module_name, fname)
16381638

16391639
# @unittest.skip("skip")
16401640
# @unittest.expectedFailure
@@ -1878,7 +1878,7 @@ def test_incr_lsn_long_xact_2(self):
18781878
'1')
18791879

18801880
# Clean after yourself
1881-
self.del_test_dir(module_name, fname, [node])
1881+
self.del_test_dir(module_name, fname)
18821882

18831883
# @unittest.skip("skip")
18841884
# @unittest.expectedFailure
@@ -2137,7 +2137,7 @@ def test_incremental_partial_restore_exclude_checksum(self):
21372137
self.assertNotIn('PANIC', output)
21382138

21392139
# Clean after yourself
2140-
self.del_test_dir(module_name, fname, [node, node2])
2140+
self.del_test_dir(module_name, fname)
21412141

21422142
def test_incremental_partial_restore_exclude_lsn(self):
21432143
""""""
@@ -2247,7 +2247,7 @@ def test_incremental_partial_restore_exclude_lsn(self):
22472247
self.assertNotIn('PANIC', output)
22482248

22492249
# Clean after yourself
2250-
self.del_test_dir(module_name, fname, [node2])
2250+
self.del_test_dir(module_name, fname)
22512251

22522252
def test_incremental_partial_restore_exclude_tablespace_checksum(self):
22532253
""""""
@@ -2391,7 +2391,7 @@ def test_incremental_partial_restore_exclude_tablespace_checksum(self):
23912391
self.assertNotIn('PANIC', output)
23922392

23932393
# Clean after yourself
2394-
self.del_test_dir(module_name, fname, [node2])
2394+
self.del_test_dir(module_name, fname)
23952395

23962396
def test_incremental_pg_filenode_map(self):
23972397
"""

0 commit comments

Comments
 (0)