Skip to content

Commit ad5cda6

Browse files
committed
Bug fix. Fix race condition with parallel MERGE
1 parent 13fb048 commit ad5cda6

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/merge.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -352,15 +352,10 @@ merge_files(void *arg)
352352
merge_files_arg *argument = (merge_files_arg *) arg;
353353
pgBackup *to_backup = argument->to_backup;
354354
pgBackup *from_backup = argument->from_backup;
355-
char tmp_file_path[MAXPGPATH];
356355
int i,
357356
num_files = parray_num(argument->files);
358357
int to_root_len = strlen(argument->to_root);
359358

360-
if (to_backup->compress_alg == PGLZ_COMPRESS ||
361-
to_backup->compress_alg == ZLIB_COMPRESS)
362-
join_path_components(tmp_file_path, argument->to_root, "tmp");
363-
364359
for (i = 0; i < num_files; i++)
365360
{
366361
pgFile *file = (pgFile *) parray_get(argument->files, i);
@@ -433,8 +428,11 @@ merge_files(void *arg)
433428
if (to_backup->compress_alg == PGLZ_COMPRESS ||
434429
to_backup->compress_alg == ZLIB_COMPRESS)
435430
{
431+
char tmp_file_path[MAXPGPATH];
436432
char *prev_path;
437433

434+
join_path_components(tmp_file_path, to_path_tmp, "_tmp");
435+
438436
/* Start the magic */
439437

440438
/*

tests/helpers/ptrack_helpers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,15 +616,16 @@ def backup_node(
616616
return self.run_pb(cmd_list + options, async, gdb)
617617

618618
def merge_backup(
619-
self, backup_dir, instance, backup_id, async=False, gdb=False):
619+
self, backup_dir, instance, backup_id, async=False,
620+
gdb=False, options=[]):
620621
cmd_list = [
621622
"merge",
622623
"-B", backup_dir,
623624
"--instance={0}".format(instance),
624625
"-i", backup_id
625626
]
626627

627-
return self.run_pb(cmd_list, async, gdb)
628+
return self.run_pb(cmd_list + options, async, gdb)
628629

629630
def restore_node(
630631
self, backup_dir, instance, node=False,

tests/merge.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def test_merge_full_page(self):
6969
self.assertEqual(show_backup["backup-mode"], "PAGE")
7070

7171
# Merge all backups
72-
self.merge_backup(backup_dir, "node", page_id)
72+
self.merge_backup(backup_dir, "node", page_id,
73+
options=["-j", "4"])
7374
show_backups = self.show_pb(backup_dir, "node")
7475

7576
# sanity check

0 commit comments

Comments
 (0)