Skip to content

Commit 4ab117b

Browse files
committed
[Issue #326] some minor fixes
1 parent 74cd9c5 commit 4ab117b

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

src/restore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
290290
timelines = read_timeline_history(arclog_path, rt->target_tli, true);
291291

292292
if (!timelines)
293-
elog(WARNING, "Failed to get history file for target timeline %i", rt->target_tli);
293+
elog(ERROR, "Failed to get history file for target timeline %i", rt->target_tli);
294294

295295
if (!satisfy_timeline(timelines, current_backup))
296296
{
@@ -1782,7 +1782,7 @@ 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) != 1)
1785+
if (parray_num(result) == 0)
17861786
{
17871787
elog(WARNING, "History file is corrupted: \"%s\"", path);
17881788
pg_free(result);

tests/archive.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,23 +2485,13 @@ def test_archive_empty_history_file(self):
24852485
node = self.make_simple_node(
24862486
base_dir=os.path.join(module_name, fname, 'node'),
24872487
set_replication=True,
2488-
initdb_params=['--data-checksums'],
2489-
pg_options={
2490-
'archive_timeout': '30s',
2491-
'checkpoint_timeout': '30s',
2492-
'autovacuum': 'off'})
2493-
2494-
if self.get_version(node) < self.version_to_num('9.6.0'):
2495-
self.del_test_dir(module_name, fname)
2496-
return unittest.skip(
2497-
'Skipped because backup from replica is not supported in PG 9.5')
2488+
initdb_params=['--data-checksums'])
24982489

24992490
self.init_pb(backup_dir)
25002491
self.add_instance(backup_dir, 'node', node)
25012492
self.set_archiving(backup_dir, 'node', node)
25022493

25032494
node.slow_start()
2504-
25052495
node.pgbench_init(scale=5)
25062496

25072497
# FULL
@@ -2516,7 +2506,6 @@ def test_archive_empty_history_file(self):
25162506
'--recovery-target=latest',
25172507
'--recovery-target-action=promote'])
25182508

2519-
# '--recovery-target-timeline=2',
25202509
# Node in timeline 2
25212510
node.slow_start()
25222511

@@ -2545,22 +2534,35 @@ def test_archive_empty_history_file(self):
25452534

25462535
# Node in timeline 4
25472536
node.slow_start()
2548-
node.pgbench_init(scale=1)
2537+
node.pgbench_init(scale=5)
25492538

25502539
# Truncate history files
2551-
for tli in range(2, 4):
2540+
for tli in range(2, 5):
25522541
file = os.path.join(
25532542
backup_dir, 'wal', 'node', '0000000{0}.history'.format(tli))
25542543
with open(file, "w+") as f:
25552544
f.truncate()
25562545

2557-
show = self.show_archive(backup_dir, 'node')
2546+
timelines = self.show_archive(backup_dir, 'node', options=['--log-level-file=INFO'])
25582547

2559-
timelines = show['timelines']
2548+
# check that all timelines has zero switchpoint
2549+
for timeline in timelines:
2550+
self.assertEqual(timeline['switchpoint'], '0/0')
25602551

2561-
# check that all timelines are ok
2562-
for timeline in replica_timelines:
2563-
print(timeline)
2552+
log_file = os.path.join(backup_dir, 'log', 'pg_probackup.log')
2553+
with open(log_file, 'r') as f:
2554+
log_content = f.read()
2555+
wal_dir = os.path.join(backup_dir, 'wal', 'node')
2556+
2557+
self.assertIn(
2558+
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000002.history')),
2559+
log_content)
2560+
self.assertIn(
2561+
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000003.history')),
2562+
log_content)
2563+
self.assertIn(
2564+
'WARNING: History file is corrupted: "{0}"'.format(os.path.join(wal_dir, '00000004.history')),
2565+
log_content)
25642566

25652567
self.del_test_dir(module_name, fname)
25662568

0 commit comments

Comments
 (0)