marsadm: fix race on join-resource

This commit is contained in:
Thomas Schoebel-Theuer 2018-09-25 16:15:36 +02:00
parent 6c0aa577ee
commit 31a1575182
1 changed files with 10 additions and 1 deletions

View File

@ -2488,7 +2488,7 @@ sub create_res {
mkdir("$resdir/actual-$host"); mkdir("$resdir/actual-$host");
my $todo = "$resdir/todo-$host"; my $todo = "$resdir/todo-$host";
mkdir($todo); mkdir($todo);
set_link("1", "$todo/attach"); set_link("0", "$todo/attach");
set_link("1", "$todo/connect"); set_link("1", "$todo/connect");
set_link("1", "$todo/sync"); set_link("1", "$todo/sync");
set_link("1", "$todo/allow-replay"); set_link("1", "$todo/allow-replay");
@ -2521,8 +2521,17 @@ sub create_res {
set_link("0", "$resdir/syncstatus-$host"); set_link("0", "$resdir/syncstatus-$host");
finish_links(); finish_links();
rsync_cmd($primary, "--max-size=1 --update $file $primary:$mars/resource-$res/", 1); rsync_cmd($primary, "--max-size=1 --update $file $primary:$mars/resource-$res/", 1);
# Re-read the primary replaylink because it might have log-rotated in the meantime
wait_cluster($cmd, $res, $primary);
my $replay = get_link("$resdir/replay-$primary");
if ($replay =~ m/^log-([0-9]+)-/) {
$replay_nr = $1;
_set_replaylink($resdir, $replay_nr, $primary, "");
}
lprint "successfully joined resource '$res'\n"; lprint "successfully joined resource '$res'\n";
} }
set_link("1", "$todo/attach");
finish_links();
_systemd_trigger($cmd); _systemd_trigger($cmd);
} }