Skip to content

Issue 181 #196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync)

if (prev_backup)
{
if (parse_program_version(prev_backup->program_version) > parse_program_version(PROGRAM_VERSION))
elog(ERROR, "pg_probackup binary version is %s, but backup %s version is %s. "
"pg_probackup do not guarantee to be forward compatible. "
"Please upgrade pg_probackup binary.",
PROGRAM_VERSION, base36enc(prev_backup->start_time), prev_backup->program_version);

char prev_backup_filelist_path[MAXPGPATH];

elog(INFO, "Parent backup: %s", base36enc(prev_backup->start_time));
Expand Down
53 changes: 53 additions & 0 deletions tests/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2746,3 +2746,56 @@ def test_note_sanity(self):

# Clean after yourself
self.del_test_dir(module_name, fname)

# @unittest.skip("skip")
def test_parent_backup_made_by_newer_version(self):
"""incremental backup with parent made by newer version"""
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)
node.slow_start()

backup_id = self.backup_node(backup_dir, 'node', node)

control_file = os.path.join(
backup_dir, "backups", "node", backup_id,
"backup.control")

version = self.probackup_version
fake_new_version = str(int(version.split('.')[0]) + 1) + '.0.0'

with open(control_file, 'r') as f:
data = f.read();

data = data.replace(version, fake_new_version)

with open(control_file, 'w') as f:
f.write(data);

try:
self.backup_node(backup_dir, 'node', node, backup_type="page")
# we should die here because exception is what we expect to happen
self.assertEqual(
1, 0,
"Expecting Error because incremental backup should not be possible "
"if parent made by newer version.\n Output: {0} \n CMD: {1}".format(
repr(self.output), self.cmd))
except ProbackupException as e:
self.assertIn(
"pg_probackup do not guarantee to be forward compatible. "
"Please upgrade pg_probackup binary.",
e.message,
"\n Unexpected Error Message: {0}\n CMD: {1}".format(
repr(e.message), self.cmd))

self.assertEqual(
self.show_pb(backup_dir, 'node')[1]['status'], "ERROR")

# Clean after yourself
self.del_test_dir(module_name, fname)
12 changes: 12 additions & 0 deletions tests/helpers/ptrack_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,18 @@ def __init__(self, *args, **kwargs):
print('pg_probackup binary is not found')
exit(1)

self.probackup_version = None

try:
self.probackup_version_output = subprocess.check_output(
[self.probackup_path, "--version"],
stderr=subprocess.STDOUT,
).decode('utf-8')
except subprocess.CalledProcessError as e:
raise ProbackupException(e.output.decode('utf-8'))

self.probackup_version = re.search(r"\d+\.\d+\.\d+", self.probackup_version_output).group(0)

if os.name == 'posix':
self.EXTERNAL_DIRECTORY_DELIMITER = ':'
os.environ['PATH'] = os.path.dirname(
Expand Down