mirror of https://github.com/schoebel/mars
marsadm: allow overrides of "marsadm secondary" in disconnected clusters
When the communication is down in partitioned clusters, the command "marsadm seconodary" would normally use the current timestamp of the command execution for the Lamport update protocol. Make an exception for the case that a concurrent "marsadm primary" was given somewhere else on a disconnected / partitioned node: let the "primary" always win over a "secondary" command.
This commit is contained in:
parent
c861a0d202
commit
767bb03060
|
@ -92,22 +92,20 @@ sub set_link {
|
||||||
|
|
||||||
sub finish_links {
|
sub finish_links {
|
||||||
return unless @link_list;
|
return unless @link_list;
|
||||||
my $timestamp = time();
|
my $timestamp = mars_time();
|
||||||
undef $/;
|
lprint "using lamport timestamp $timestamp\n" if $verbose;
|
||||||
my $lamport = "";
|
|
||||||
if (open(my $fh, "<", "/proc/sys/mars/lamport_clock")) {
|
|
||||||
$lamport = <$fh>;
|
|
||||||
}
|
|
||||||
if ($lamport =~ m/lamport_now=([0-9.]+)/) {
|
|
||||||
$timestamp = $1;
|
|
||||||
lprint "using lamport timestamp $timestamp\n" if $verbose;
|
|
||||||
}
|
|
||||||
while (my $link = shift @link_list) {
|
while (my $link = shift @link_list) {
|
||||||
my $link_tmp = to_tmp($link);
|
my $link_tmp = to_tmp($link);
|
||||||
system("touch -h -d \"\@$timestamp\" $link_tmp") == 0 or ldie "cannot set mtime on symlink '$link_tmp'\n";
|
my $target = readlink($link_tmp);
|
||||||
|
my $this_timestamp = $timestamp;
|
||||||
|
# allow overriding of secondaries in partitioned clusters by use of small timestamps
|
||||||
|
if ($target eq "(none)") {
|
||||||
|
my @stat = lstat($link);
|
||||||
|
$this_timestamp = $stat[9] + 1 if @stat;
|
||||||
|
}
|
||||||
|
system("touch -h -d \"\@$this_timestamp\" $link_tmp") == 0 or ldie "cannot set mtime on symlink '$link_tmp'\n";
|
||||||
rename($link_tmp, $link) or ldie "cannot finalize symlink '$link'\n";
|
rename($link_tmp, $link) or ldie "cannot finalize symlink '$link'\n";
|
||||||
if ($verbose) {
|
if ($verbose) {
|
||||||
my $target = readlink($link);
|
|
||||||
lprint "created symlink '$link' -> '$target'\n";
|
lprint "created symlink '$link' -> '$target'\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue