[MDEV-8917] [PATCH] mysql_install_db should check for missing shared library dependencies Created: 2015-10-08  Updated: 2022-02-15

Status: Open
Project: MariaDB Server
Component/s: Packaging, Scripts & Clients
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Hartmut Holzgraefe Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-8916 binary tarball INSTALL-BINARY instruc... Open
Sprint: 10.1.9-1, 10.1.9-2, 10.1.9-3

 Description   

When missing a required shared library like libaio or libjemalloc mysqld won't start up. mysqld_install_db detects the failed startup but does not provide useful feedback, it suggests to check the mysql error log which mysqld can't even create in this case.

The amount of following output also sort of hides the actual error message.

Feature request: mysql_install_db should check whether all shared library dependencies are met, using ldd output, before trying to start up mysqld for the first time. If any dependencies are found to be unmet it should just report this instead of its rather long general purpose error output.



 Comments   
Comment by Hartmut Holzgraefe [ 2015-10-09 ]

Proposed fix:

diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 15750ff..a36752c 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -324,6 +324,15 @@ then
   exit 1
 fi
 
+# check whether all shared library dependencies are met
+if ldd $mysqld | grep -q "not found"
+then
+    echo "FATAL ERROR: missing shared libraries"
+    echo "the following libraries required by $mysqld are missing:"
+    ldd $mysqld | grep "not found"
+    exit 1
+fi
+
 if test -n "$langdir"
 then
   if test ! -f "$langdir/errmsg.sys"

Comment by Hartmut Holzgraefe [ 2015-10-09 ]

See also https://github.com/MariaDB/server/pull/101

Comment by Sergey Vojtovich [ 2015-10-29 ]

Just for the record, text returned by mysql_install_db:

Installing MariaDB/MySQL system tables in './data' ...
./bin/mysqld: error while loading shared libraries: libjemalloc.so.1: cannot open shared object file: No such file or directory
 
Installation of system tables failed!  Examine the logs in
./data for more information.
 
The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:
 
    shell> ./bin/scripts/mysql_install_db --defaults-file=~/.my.cnf
 
You can also try to start the mysqld daemon with:
 
    shell> ./bin/mysqld --skip-grant --general-log &
 
and use the command line tool ./bin/mysql
to connect to the mysql database and look at the grant tables:
 
    shell> ./bin/mysql -u root mysql
    mysql> show tables;
 
Try 'mysqld --help' if you have problems with paths.  Using
--general-log gives you a log in ./data that may be helpful.
 
The latest information about mysql_install_db is available at
https://mariadb.com/kb/en/installing-system-tables-mysql_install_db
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria
 
Please check all of the above before submitting a bug report
at http://mariadb.org/jira

It's not that bad, but the text doesn't state reason for failure accurately indeed.
This should be relevant to bintars only as DEB/RPM packages should track dependencies properly.
OS X El Capitan doesn't seem to have ldd available, according to google ldd doesn't seem to be well portable.
This patch also checks $mysqld, while I believe it should check $mysqld_bootstrap.

Comment by Sergey Vojtovich [ 2015-10-29 ]

hholzgra, the patch needs to be improved. Will you do that or should I?

Comment by Sergey Vojtovich [ 2015-12-16 ]

Lowering priority, unassigning from myself and removing fix version until new patch is implemented.

Comment by Sergei Golubchik [ 2017-05-30 ]

I don't think mysql_install_db should do that. In bintars we link everything (as much as possible) statically, in packages, the package manager should install all dependencies. In what use case this could be useful?

Comment by Hartmut Holzgraefe [ 2022-02-15 ]

> In bintars we link everything (as much as possible) statically ...

well, that's basically my point: mysql_install_db should check for those libraries being present for which it wasn't possible.

I haven't used binary tarballs for a while, but as far as I remember they always needed libaio and libjemalloc packages to be installed as a prerequisite, so getting a better error message in cases where these are not present should be helpful ...

Generated at Thu Feb 08 07:30:46 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.