1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2025-01-05 13:20:31 +02:00

[Issue #290] check WAL archive directory presence at the start of backup

This commit is contained in:
Grigory Smolkin 2021-01-20 15:55:25 +03:00
parent 4edc9d94ad
commit d624863d14
2 changed files with 55 additions and 5 deletions

View File

@ -257,12 +257,19 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
/* In PAGE mode or in ARCHIVE wal-mode wait for current segment */
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE || !stream_wal)
{
/* Check that archive_dir can be reached */
if (fio_access(arclog_path, F_OK, FIO_BACKUP_HOST) != 0)
elog(ERROR, "WAL archive directory is not accessible \"%s\": %s",
arclog_path, strerror(errno));
/*
* Do not wait start_lsn for stream backup.
* Because WAL streaming will start after pg_start_backup() in stream
* mode.
*/
wait_wal_lsn(current.start_lsn, true, current.tli, false, true, ERROR, false);
}
/* start stream replication */
if (stream_wal)

View File

@ -2872,10 +2872,6 @@ class BackupTest(ProbackupTest, unittest.TestCase):
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
# self.set_archiving(backup_dir, 'node', node)
# os.rmdir(
# os.path.join(backup_dir, "wal", "node"))
node.slow_start()
@ -2905,7 +2901,54 @@ class BackupTest(ProbackupTest, unittest.TestCase):
self.assertEqual(
self.show_pb(backup_dir, 'node')[0]['status'], "ERROR")
exit(1)
# Clean after yourself
self.del_test_dir(module_name, fname)
# @unittest.skip("skip")
def test_issue_290(self):
"""
https://github.com/postgrespro/pg_probackup/issues/290
"""
fname = self.id().split('.')[3]
node = self.make_simple_node(
base_dir=os.path.join(module_name, fname, 'node'),
initdb_params=['--data-checksums'])
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
self.init_pb(backup_dir)
self.add_instance(backup_dir, 'node', node)
self.set_archiving(backup_dir, 'node', node)
os.rmdir(
os.path.join(backup_dir, "wal", "node"))
node.slow_start()
try:
self.backup_node(
backup_dir, 'node', node,
options=['--archive-timeout=10s'])
# we should die here because exception is what we expect to happen
self.assertEqual(
1, 0,
"Expecting Error because full backup is missing"
"\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertNotIn(
"INFO: Wait for WAL segment",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
self.assertIn(
"WAL archive directory is not accessible",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))
self.assertEqual(
self.show_pb(backup_dir, 'node')[0]['status'], "ERROR")
# Clean after yourself
self.del_test_dir(module_name, fname)