marsadm: adapt timeout window

This commit is contained in:
Thomas Schoebel-Theuer 2017-12-13 12:27:02 +01:00 committed by Thomas Schoebel-Theuer
parent 4624518627
commit 04cf38e4e7

View File

@ -32,7 +32,7 @@ umask 0077;
# global defaults # global defaults
my $threshold = 10 * 1024 * 1024; my $threshold = 10 * 1024 * 1024;
my $window = 30; my $window = 60;
my $verbose = 0; my $verbose = 0;
my $max_deletions = 512; my $max_deletions = 512;
my $thresh_logfiles = 10; my $thresh_logfiles = 10;
@ -245,7 +245,7 @@ sub get_link_stamp {
sub is_link_recent { sub is_link_recent {
my ($path, $wind) = @_; my ($path, $wind) = @_;
$wind = $window unless defined($wind); $wind = $window * 2 unless defined($wind);
my @stat = lstat($path); my @stat = lstat($path);
return 0 if (!@stat); return 0 if (!@stat);
return 1 if $stat[9] + $wind >= mars_time(); return 1 if $stat[9] + $wind >= mars_time();
@ -1259,7 +1259,7 @@ sub log_purge_res {
sub try_to_avoid_splitbrain { sub try_to_avoid_splitbrain {
my ($cmd, $res, $old_primary) = @_; my ($cmd, $res, $old_primary) = @_;
my $old_timeout = $timeout; my $old_timeout = $timeout;
$timeout = $window * 2 if $timeout < 0; $timeout = $window if $timeout < 0;
$old_primary = "" if $old_primary eq "(none)"; $old_primary = "" if $old_primary eq "(none)";
wait_cluster($cmd, $res, $old_primary); wait_cluster($cmd, $res, $old_primary);
if (!detect_splitbrain($res, 0)) { if (!detect_splitbrain($res, 0)) {
@ -1274,7 +1274,7 @@ sub try_to_avoid_splitbrain {
my @host_list = glob("$mars/resource-$res/replay-*"); my @host_list = glob("$mars/resource-$res/replay-*");
$timeout = $old_timeout; $timeout = $old_timeout;
return if scalar(@host_list) < 2; return if scalar(@host_list) < 2;
$timeout = $window * 2 if $timeout < 0; $timeout = $window if $timeout < 0;
my $old_situation = ""; my $old_situation = "";
for (;;) { for (;;) {
my ($min, $max) = get_minmax_versions($res); my ($min, $max) = get_minmax_versions($res);
@ -1337,7 +1337,7 @@ sub try_to_avoid_splitbrain {
my $tpl = get_macro("replinfo"); my $tpl = get_macro("replinfo");
my $new_situation = eval_macro($cmd, $res, $tpl, @_); my $new_situation = eval_macro($cmd, $res, $tpl, @_);
print $new_situation; print $new_situation;
$timeout = $window * 2 if $new_situation ne $old_situation; $timeout = $window if $new_situation ne $old_situation;
sleep_timeout(); sleep_timeout();
$old_situation = $new_situation; $old_situation = $new_situation;
} }