mirror of
https://github.com/schoebel/mars
synced 2024-12-29 18:32:47 +00:00
test_suite: fix: destroy must wait for apply to stop and proceed to next logfile if necessary.
This commit is contained in:
parent
bf81056d2d
commit
32c9ac2db3
@ -33,6 +33,13 @@ switch2primary_maxtime_fetch=300
|
||||
## the fetch process as having stopped
|
||||
switch2primary_time_constant_fetch=10
|
||||
|
||||
## time for which the amount of data to apply must be constant to declare
|
||||
## the apply process as having stopped
|
||||
switch2primary_time_constant_apply=3
|
||||
|
||||
## maxtime to wait for apply to stop (after pause-apply)
|
||||
switch2primary_maxtime_apply=300
|
||||
|
||||
## maxtime to wait for (new) primary to become disk state = Uptodate and
|
||||
## repl state = Replicating
|
||||
switch2primary_maxtime_state_constant=60
|
||||
|
@ -372,20 +372,22 @@ function switch2primary_correct_split_brain
|
||||
function switch2primary_destroy_log_after_replay_link
|
||||
{
|
||||
local host=$1 res=$2 link link_val replay_offset
|
||||
local logfile length_logfile
|
||||
local logfile length_logfile time_waited
|
||||
lib_vmsg " destroying log after replay link on $host"
|
||||
marsadm_do_cmd $host "pause-replay" "$res" || lib_exit 1
|
||||
link="$(lib_linktree_get_res_host_linkname $host $res replay replay)" || \
|
||||
lib_exit 1
|
||||
link_val="$(lib_remote_idfile $host "readlink $link")" || lib_exit 1
|
||||
logfile=${resource_dir_list[$res]}/${link_val%%,*}
|
||||
lib_wait_until_action_stops "replay" $host $res \
|
||||
$switch2primary_maxtime_apply \
|
||||
$switch2primary_time_constant_apply \
|
||||
"time_waited" 0 ""
|
||||
logfile=$(lib_linktree_get_partial_value_from_replay_link \
|
||||
$host $res "logfilename") || lib_exit 1
|
||||
length_logfile=$(file_handling_get_file_length $host $logfile) || lib_exit 1
|
||||
replay_offset=$(expr "$link_val" : '.*,\(.*\),.*')
|
||||
if [ -z "$replay_offset" ]; then
|
||||
lib_exit 1 "cannot determine replay offset from replay link value $link_val on host $host"
|
||||
fi
|
||||
replay_offset=$(lib_linktree_get_partial_value_from_replay_link \
|
||||
$host $res "replay_offset") || lib_exit 1
|
||||
if [ $replay_offset -ge $length_logfile ]; then
|
||||
lib_exit 1 "logfile $logfile already fully applied on host $host"
|
||||
lib_vmsg " logfile $logfile already fully applied on host $host"
|
||||
logfile=$(lib_linktree_get_next_logfile $logfile) || lib_exit 1
|
||||
replay_offset=0
|
||||
fi
|
||||
lib_vmsg " destroy logfile $host:$logfile at offset $replay_offset"
|
||||
lib_remote_idfile $host "yes | dd bs=1 conv=notrunc seek=$replay_offset of=$logfile count=10000" || lib_exit 1
|
||||
|
@ -132,7 +132,50 @@ function lib_linktree_status_to_string
|
||||
lib_exit 1 "undefined link_status $link_status"
|
||||
}
|
||||
|
||||
|
||||
|
||||
function lib_linktree_get_partial_value_from_replay_link
|
||||
{
|
||||
local host=$1 res=$2 value="$3"
|
||||
local link link_val retval
|
||||
link="$(lib_linktree_get_res_host_linkname $host $res "replay")" || \
|
||||
lib_exit 1
|
||||
link_val="$(lib_remote_idfile $host "readlink $link")" || lib_exit 1
|
||||
case "$value" in # (((
|
||||
logfilename) retval=${resource_dir_list[$res]}/${link_val%%,*}
|
||||
;;
|
||||
replay_offset) retval=$(expr "$link_val" : '.*,\(.*\),.*')
|
||||
;;
|
||||
*) lib_exit 1 "invalid partial value name $value"
|
||||
;;
|
||||
esac
|
||||
if [ -z "$retval" ]; then
|
||||
lib_exit 1 "cannot determine partial value $value from replay link value $link_val on host $host"
|
||||
fi
|
||||
echo "$retval"
|
||||
}
|
||||
|
||||
function lib_linktree_get_nr_of_logfile
|
||||
{
|
||||
local path="$1" leading_zeroes=$2 retval
|
||||
if [ $leading_zeroes -eq 0 ]; then
|
||||
retval=$(expr "$path" : '.*/log-0*\([1-9][0-9]*\)')
|
||||
else
|
||||
retval=$(expr "$path" : '.*/log-\(0*[1-9][0-9]*\)')
|
||||
fi
|
||||
if [ -z "$retval" ]; then
|
||||
lib_exit 1 "cannot determine number of logfile $path"
|
||||
fi
|
||||
echo $retval
|
||||
}
|
||||
|
||||
function lib_linktree_get_next_logfile
|
||||
{
|
||||
local path="$1" retval nr_with_leading_zeroes next_nr
|
||||
nr_with_leading_zeroes=$(lib_linktree_get_nr_of_logfile $path 1) || \
|
||||
lib_exit 1
|
||||
let next_nr=$(($nr_with_leading_zeroes + 1))
|
||||
next_nr=$(printf "%0.${#nr_with_leading_zeroes}d" $next_nr)
|
||||
retval=${path/-${nr_with_leading_zeroes}-/-${next_nr}-}
|
||||
echo "$retval"
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user