[MDEV-18591] mysql_install_db wrong output message for error logs Created: 2019-02-15  Updated: 2022-12-13  Resolved: 2022-12-13

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.11.2, 10.3.38, 10.4.28, 10.5.19, 10.6.12, 10.7.8, 10.8.7, 10.9.5, 10.10.3

Type: Bug Priority: Minor
Reporter: Faustin Lammler Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None
Environment:

Debian



 Description   

Hi,
if the mysql_install_db command fails it says:

Installation of system tables failed!  Examine the logs in /var/lib/mysql for more information.

On Debian the error log goes by default to /var/log/mysql/error.log and not into /var/lib/mysql.
Faustin



 Comments   
Comment by Otto Kekäläinen [ 2020-11-22 ]

faust This was pretty well debugged downstream in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=922018, to fix this I guess you only need to change one string/variable? Could you fix this upstream?

Comment by Faustin Lammler [ 2020-11-23 ]

otto as this is "debian specific" I have no idea on how to cleanly fix this upstream.

Here is the code:
https://github.com/MariaDB/server/blob/10.6/scripts/mysql_install_db.sh#L564

We could add something like:

if debian; then
  log_file_place="/var/log/mysql"
else
  log_file_place=$ldata
fi

Then what is the bast practice for Debian OS detection.
Maybe you or anel or danblack have a better idea?

Comment by Olaf van der Spek [ 2020-11-23 ]

What about using `show variables like 'log_error';`?

Why is it using `/var/lib` for logs on non-Debian platforms, isn't `/var/log` a Linux thing?

You could also choose to not mention the location.

Comment by Faustin Lammler [ 2020-11-23 ]

> What about using `show variables like 'log_error';`?

If I am correct, the mariadb server is not running at that moment (script is preparing data dir) so I guess this is not possible.

> Why is it using `/var/lib` for logs on non-Debian platforms, isn't `/var/log` a Linux thing?

Good Q. There must be a reason but I don't know.

> You could also choose to not mention the location.

That may be a solution, not very user friendly though.

Comment by Olaf van der Spek [ 2020-11-23 ]

Is it the script or the server that writes to the log?
I assume it's the server. Maybe it should write to stdout / stderr (in addition to the log)?

Comment by Anel Husakovic [ 2020-11-23 ]

Hi,
so the script is calling mysqld_install_cmd_line(), which is calling mysqld with some options

mysqld_install_cmd_line()
{
  "$mysqld_bootstrap" $defaults $defaults_group_suffix "$mysqld_opt" --bootstrap $silent_startup\
  "--basedir=$basedir" "--datadir=$ldata" --log-warnings=0 --enforce-storage-engine="" \
  "--plugin-dir=${plugindir}" \
  $args --max_allowed_packet=8M \
  --net_buffer_length=16K
}

Note that above there is no log_error server option.
Based on log_error server variable if the server is started without --log-error errors should be in stderr.
If there is no name (of a file for this option) logs will be in <hostname.err> in the datadir (since $ldata == datadir in your case in /var/lib/mysql).
So in your case the error logs will be in stderr already you can try to find out does it exist.
Even the server code is saying the same:

 case OPT_LOG_ERROR:
    /*
      "No --log-error" == "write errors to stderr",
      "--log-error without argument" == "write errors to a file".
    */

Note that if you have a config file (see option files that is configuring log_error) it can be invoked from there also.
In debian there is postinst script that is using hardcoded value for logs {{mysql_logdir=/var/log/mysql }}.
I think that correct patch for this case is to write Examine the logs in stderr for more information. - since log_error="" and parsing the arguments is already finished before!
But let's wait on danblack review too.

Comment by Daniel Black [ 2020-11-24 ]

it generally sounds better to use log-error is stderr immediately since is already quietened already.

dbdeployer seems to cover the init with --no-defaults https://github.com/datacharmer/dbdeployer/blob/6c64381704783784d164adf865ae02ed907c2c09/sandbox/sandbox.go#L812 so I assume this is stderr already, datacharmer do you have an opinion here?

containter usage of mysql_install_db will process stderr in the logs of the container execution so that use is ok.

The last option that I'd rather avoid is to look at the /proc/

{pid}

/fd/3 (not BSD friendly) symlink during bootstrap to see where its being written to.

As written, going to get tests written first MDEV-24268

Comment by Giuseppe Maxia [ 2020-11-24 ]

dbdeployer uses --no-defaults to prevent the sandboxed server from being
hijacked by existing my.cnf in the recognized paths.
As for the output, mysql_install_db writes regular messages to stdout, and
only errors to stderr.
The error log is defined in the configuration file (my.sandbox.cnf) but
since we use --no-defaults, the output of errors goes to stderr, and it
gets displayed to users if mysql_install_db exits with a non-zero code.

On Tue, Nov 24, 2020 at 6:27 AM Daniel Black (Jira) <jira@mariadb.org>

Comment by Daniel Black [ 2022-12-08 ]

PR for review https://github.com/MariaDB/server/pull/2363

Comment by Daniel Black [ 2022-12-08 ]

Note Debian downstream will still need to pass --log-error on their cmd line in the post-install. Maybe its useful if that is kept different to the user default as its packaging related and reading the error log of the previous combined with the current would be less readable.

Generated at Thu Feb 08 08:45:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.