Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-21367

mysqld_safe log don't log to err.log

Details

    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
      }
      

      Attachments

        Activity

          Indeed, introduced with 6b7918d524d5 in 10.2.

          anel Anel Husakovic added a comment - Indeed, introduced with 6b7918d524d5 in 10.2 .

          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 ?

          anel Anel Husakovic added a comment - 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 ?

          Pushed to 10.2 with eb7b14ec9a4e0

          anel Anel Husakovic added a comment - Pushed to 10.2 with eb7b14ec9a4e0

          People

            anel Anel Husakovic
            willhan willhan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.