Skip to content

Commit

Permalink
MDEV-33750: Make SysV init more verbose in case of MariaDB start fail…
Browse files Browse the repository at this point in the history
…ures

MariaDB installs/upgrades in Docker containers (and elsewhere where
systemd is not used) occasionally fail with output like:

  Starting MariaDB database server: mariadbd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . failed!
  invoke-rc.d: initscript mariadb, action "start" failed.
  dpkg: error processing package mariadb-server-10.5 (--configure):
   installed mariadb-server-10.5 package post-installation script subprocess returned error exit status 1

This is not very helpful. Thus extend the init script to try the server
start/restart one more time but with error log defined separately,
and then print out the error log contents of this single start attempt.

  ...
  Starting MariaDB database server: mariadbd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
  230103 01:06:48 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
  230103 01:06:48 mysqld_safe Logging to '/tmp/tmp.JlE4sdUMZz.err'.
  230103 01:06:49 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql
  Running '/etc/init.d/mariadb start' failed with error log:
  230103 01:06:49 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql
  2023-01-03  1:06:49 0 [Note] /usr/sbin/mariadbd (mysqld 10.5.18-MariaDB-0+deb11u1) starting as process 10417 ...
  2023-01-03  1:06:49 0 [Note] InnoDB: Uses event mutexes
  2023-01-03  1:06:49 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
  2023-01-03  1:06:49 0 [Note] InnoDB: Number of pools: 1
  2023-01-03  1:06:49 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
  2023-01-03  1:06:49 0 [Note] InnoDB: Using Linux native AIO
  2023-01-03  1:06:49 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
  2023-01-03  1:06:49 0 [Note] InnoDB: Completed initialization of buffer pool
  2023-01-03  1:06:49 0 [ERROR] InnoDB: Invalid flags 0x4800 in ./ibdata1
  ...
  • Loading branch information
ottok authored and illuusio committed Mar 22, 2024
1 parent dc289d7 commit 805be1a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions debian/mariadb-server.mariadb.init
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ case "${1:-''}" in
log_action_msg "$output"
fi
else
# Try one more time but save error log separately, then spit it out
# before logging ends and init script execution ends.
if pgrep -ax mariadbd > /dev/null
then
echo "ERROR: The mariadbd process is running but not responding:"
# shellcheck disable=SC2009
# Show the mariadbd process and it's parent and next line (if there is a child process)
ps faxu | grep mariadbd -C 1
else
ERROR_LOG_FILE="$(mktemp).err"
echo # ensure newline
timeout --kill-after=20 10 /usr/bin/mysqld_safe "${@:2}" --log-error="$ERROR_LOG_FILE"
echo "Running '/etc/init.d/mariadb start' failed with error log:"
cat "$ERROR_LOG_FILE"
fi

log_end_msg 1
log_failure_msg "Please take a look at the syslog"
fi
Expand Down

0 comments on commit 805be1a

Please sign in to comment.