1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

Initial merge result with mariaDB 10: lp:maria

This commit is contained in:
Seppo Jaakola
2013-07-13 13:01:13 +03:00
parent 58926b5e19
commit 0a9216835f
160 changed files with 9800 additions and 939 deletions

View File

@@ -147,7 +147,7 @@ log_notice () {
}
eval_log_error () {
cmd="$1"
local cmd="$1"
case $logging in
file) cmd="$cmd >> "`shell_quote_string "$err_log"`" 2>&1" ;;
syslog)
@@ -183,6 +183,73 @@ shell_quote_string() {
echo "$1" | sed -e 's,\([^a-zA-Z0-9/_.=-]\),\\\1,g'
}
wsrep_pick_url() {
[ $# -eq 0 ] && return 0
log_error "WSREP: 'wsrep_urls' is DEPRECATED! Use wsrep_cluster_address to specify multiple addresses instead."
if ! which nc >/dev/null; then
log_error "ERROR: nc tool not found in PATH! Make sure you have it installed."
return 1
fi
local url
# Assuming URL in the form scheme://host:port
# If host and port are not NULL, the liveness of URL is assumed to be tested
# If port part is absent, the url is returned literally and unconditionally
# If every URL has port but none is reachable, nothing is returned
for url in `echo $@ | sed s/,/\ /g` 0; do
local host=`echo $url | cut -d \: -f 2 | sed s/^\\\/\\\///`
local port=`echo $url | cut -d \: -f 3`
[ -z "$port" ] && break
nc -z "$host" $port >/dev/null && break
done
if [ "$url" == "0" ]; then
log_error "ERROR: none of the URLs in '$@' is reachable."
return 1
fi
echo $url
}
# Run mysqld with --wsrep-recover and parse recovered position from log.
# Position will be stored in wsrep_start_position_opt global.
wsrep_start_position_opt=""
wsrep_recover_position() {
local mysqld_cmd="$@"
local wr_logfile=$(mktemp)
local euid=$(id -u)
local ret=0
[ "$euid" = "0" ] && chown $user $wr_logfile
chmod 600 $wr_logfile
log_notice "WSREP: Running position recovery with --log_error=$wr_logfile"
eval_log_error $mysqld_cmd --log_error=$wr_logfile --wsrep-recover
local rp="$(grep 'WSREP: Recovered position:' $wr_logfile)"
if [ -z "$rp" ]; then
local skipped="$(grep WSREP $wr_logfile | grep 'skipping position recovery')"
if [ -z "$skipped" ]; then
log_error "WSREP: Failed to recover position: " `cat $wr_logfile`;
ret=1
else
log_notice "WSREP: Position recovery skipped"
fi
else
local start_pos="$(echo $rp | sed 's/.*WSREP\:\ Recovered\ position://' \
| sed 's/^[ \t]*//')"
log_notice "WSREP: Recovered position $start_pos"
wsrep_start_position_opt="--wsrep_start_position=$start_pos"
fi
rm $wr_logfile
return $ret
}
parse_arguments() {
# We only need to pass arguments through to the server if we don't
# handle them here. So, we collect unrecognized options (passed on
@@ -244,7 +311,13 @@ parse_arguments() {
--skip-syslog) want_syslog=0 ;;
--syslog-tag=*) syslog_tag="$val" ;;
--timezone=*) TZ="$val"; export TZ; ;;
--wsrep[-_]urls=*) wsrep_urls="$val"; ;;
--wsrep[-_]provider=*)
if test -n "$val" && test "$val" != "none"
then
wsrep_restart=1
fi
;;
--help) usage ;;
*)
@@ -788,7 +861,8 @@ do
done
cmd="$cmd $args"
# Avoid 'nohup: ignoring input' warning
test -n "$NOHUP_NICENESS" && cmd="$cmd < /dev/null"
nohup_redir=""
test -n "$NOHUP_NICENESS" && nohup_redir=" < /dev/null"
log_notice "Starting $MYSQLD daemon with databases from $DATADIR"
@@ -799,13 +873,31 @@ max_fast_restarts=5
# flag whether a usable sleep command exists
have_sleep=1
# maximum number of wsrep restarts
max_wsrep_restarts=0
# maximum number of wsrep restarts
max_wsrep_restarts=0
while true
do
rm -f "$pid_file" # Some extra safety
start_time=`date +%M%S`
eval_log_error "$cmd"
# this sets wsrep_start_position_opt
wsrep_recover_position "$cmd"
[ $? -ne 0 ] && exit 1 #
[ -n "$wsrep_urls" ] && url=`wsrep_pick_url $wsrep_urls` # check connect address
if [ -z "$url" ]
then
eval_log_error "$cmd $wsrep_start_position_opt $nohup_redir"
else
eval_log_error "$cmd $wsrep_start_position_opt --wsrep_cluster_address=$url $nohup_redir"
fi
if [ $want_syslog -eq 0 -a ! -f "$err_log" ]; then
touch "$err_log" # hypothetical: log was renamed but not
@@ -875,6 +967,20 @@ do
I=`expr $I + 1`
done
fi
if [ -n "$wsrep_restart" ]
then
if [ $wsrep_restart -le $max_wsrep_restarts ]
then
wsrep_restart=`expr $wsrep_restart + 1`
log_notice "WSREP: sleeping 15 seconds before restart"
sleep 15
else
log_notice "WSREP: not restarting wsrep node automatically"
break
fi
fi
log_notice "mysqld restarted"
if test -n "$CRASH_SCRIPT"
then