[MDEV-21367] mysqld_safe log don't log to err.log Created: 2019-12-20  Updated: 2020-12-07  Resolved: 2020-12-07

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients, Server
Affects Version/s: 10.2.29, 10.3.20, 10.5.0, 10.4
Fix Version/s: 10.2.37, 10.3.28, 10.4.18, 10.5.9

Type: Bug Priority: Major
Reporter: willhan Assignee: Anel Husakovic
Resolution: Fixed Votes: 0
Labels: None


 Description   

mysqld_safe.sh from https://github.com/MariaDB/server/blob/10.5/scripts/mysqld_safe.sh

As the following code in mysqld_safe, the helper would always be "". As a result, we could not record the mysqld_safe log into error log.

helper=`find_in_bin mysqld_safe_helper`
print_defaults=`find_in_bin my_print_defaults`
 
# Check if helper exists
$helper --help >/dev/null 2>&1 || helper=""

"$helper --help >/dev/null 2>&1" would always be 0 in mariadb, so the helper would always be "";

log_generic () {
  [ $dry_run -eq 1 ] && return
  priority="$1"
  shift
 
  msg="`date +'%y%m%d %H:%M:%S'` mysqld_safe $*"
  echo "$msg"
  case $logging in
    init) ;;  # Just echo the message, don't save it anywhere
    file)
      if [ -n "$helper" ]; then    ### would always be FALSE, don't log into err.log
        echo "$msg" | "$helper" "$user" log "$err_log"
      fi
    ;;
    syslog) logger -t "$syslog_tag_mysqld_safe" -p "$priority" "$*" ;;
    *)
      echo "Internal program error (non-fatal):" \
           " unknown logging method '$logging'" >&2
      ;;
  esac
}



 Comments   
Comment by Anel Husakovic [ 2020-03-05 ]

Indeed, introduced with 6b7918d524d5 in 10.2.

Comment by Anel Husakovic [ 2020-03-06 ]

Added to branch bb-10.2-anel-MDEV-21367.
Test cases - I supposed that if helper exist log should be saved:

anel@anel:~/mariadb/builds/RelWithDeb-10.2/usr/local/mysql$ PS4='$LINENO: ' && bash -x ./bin/mysqld_safe --defaults
.
564: command -v /home/anel/mariadb/builds/RelWithDeb-10.2/usr/local/mysql/bin/mysqld_safe_helper --help
565: helper_exist=0
.
973: log_notice 'Starting mysqld daemon with databases from /home/anel/datadir-anel'
175: log_generic daemon.notice 'Starting mysqld daemon with databases from /home/anel/datadir-anel'
149: '[' 0 -eq 1 ']'
150: priority=daemon.notice
151: shift
1153: date '+%y%m%d %H:%M:%S'   # THIS IS WEIRD IN SHOWING THE NUMBER (bash)
153: msg='200306 14:59:37 mysqld_safe Starting mysqld daemon with databases from /home/anel/datadir-anel'
154: echo '200306 14:59:37 mysqld_safe Starting mysqld daemon with databases from /home/anel/datadir-anel'
200306 14:59:37 mysqld_safe Starting mysqld daemon with databases from /home/anel/datadir-anel
155: case $logging in
158: '[' 0 -eq 0 ']'
159: echo '200306 14:59:37 mysqld_safe Starting mysqld daemon with databases from /home/anel/datadir-anel'
159: /home/anel/mariadb/builds/RelWithDeb-10.2/usr/local/mysql/bin/mysqld_safe_helper mysql log /home/anel/datadir-anel/mysqld_safe_anel.err

Stop the mysqld_safe daemon and see results:

anel@anel:~/mariadb/builds/RelWithDeb-10.2/usr/local/mysql$ cat ~/datadir-anel/mysqld_safe_anel.err | grep mysqld_safe
 
200306 14:59:37 mysqld_safe Starting mysqld daemon with databases from /home/anel/datadir-anel
200306 15:01:42 mysqld_safe mysqld from pid file /home/anel/datadir-anel/anel.pid ended

serg or cvicentiu, can you please take a look ?

Comment by Anel Husakovic [ 2020-12-07 ]

Pushed to 10.2 with eb7b14ec9a4e0

Generated at Thu Feb 08 09:06:36 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.