From 75186d0253bc021565bb98c88a65a49d3befb5c0 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 18 Feb 2015 04:31:45 +0100 Subject: [PATCH] marsadm: fix predicate is-consistent --- userspace/marsadm | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/userspace/marsadm b/userspace/marsadm index f4827c6b..49e116cc 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -618,6 +618,23 @@ sub get_minmax_replays { ################################################################## +# generic comparisons + +sub compare_replaylinks { + my ($a, $b) = @_; + $a =~ m/log-([0-9]+)[^,]*,([0-9]+)/; + my ($a_log, $a_pos) = ($1, $2); + $b =~ m/log-([0-9]+)[^,]*,([0-9]+)/; + my ($b_log, $b_pos) = ($1, $2); + return -1 if $a_log < $b_log; + return +1 if $a_log > $b_log; + return -1 if $a_pos < $b_pos; + return +1 if $a_pos > $b_pos; + return 0; +} + +################################################################## + # versionlink path handling routines my %visited_pos; @@ -2701,10 +2718,12 @@ sub eval_fn { return 0 if $rest > 0; } # are all logfiles applied which had accumulated during sync? - my $syncpos = make_numeric(eval_fn($env, "syncpos-pos", "")); - if ($syncpos) { - my $applied = make_numeric(eval_fn($env, "replay-pos", "")); - return 0 if $applied < $syncpos; + my $replay = get_link($$env{"resdir"} . "/replay-" . $$env{"host"}, 1); + return 0 unless $replay; + my $syncpos = get_link($$env{"resdir"} . "/syncpos-" . $$env{"host"}, 2); + if (defined($syncpos) && $syncpos) { + my $cmp = compare_replaylinks($syncpos, $replay); + return 0 if $cmp > 0; } return 1; }