[MDEV-31222] Outdated mysqld_safe script Created: 2023-05-09 Updated: 2023-05-09 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Scripts & Clients |
| Affects Version/s: | 10.11.2 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor |
| Reporter: | Anthony Shi | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | mysqld_safe | ||
| Description |
|
I was looking through the contents of the script and came across a few lines that didn't make sense to me. More specifically from lines 502 to 536 of the script
I was wondering what's the purpose of the first condition in the conditional above. What is the purpose of testing for MY_BASEDIR_VERSION when the variable obviously hasn't been set at that point? The comment #BASEDIR already overridden in the command line also didn't make sense to me. How could MY_BASEDIR_VERSION be overridden by the --basedir provided by the user at that point when the command line arguments haven't even been parsed yet? MY_BASEDIR_VERSION can only be overridden when the parse_arguments() function is called, which didn't happen until line 583. Out of curiosity, I downloaded a copy of MySQL server just to look at MySQL's version of mysqld_safe. Here is what it looks like.
The mysqld_safe script distributed with MySQL makes sense to me because it locates the --basedir option from the command line first (via the find_basedir_from_cmdline() function) before attempting to test whether it has been overridden. This led me to wonder if the script shipped with MariaDB is outdated. UPDATE: After further investigation, I discovered another aspect of the script that doesn't agree with MariaDB's official documentation. It is implied in the mysqld_safe article on the knowledge base that the script will fallback to using @libexecdir@/mysql/bin as ledir if the directory containing the mysqld_safe script isn't a valid base directory. Now unless I'm mistaken, @libexecdir@ refers to a subdirectory inside /usr/local according to GNU standards. Again, this logic is implemented in the mysqld_safe script shipped with MySQL 8.0.33, but not in the one shipped with MariaDB 10.11.2-2
As you can see, in MariaDB's version, mysqld_safe falls back to /usr/bin as the ledir whereas MySQL falls back to /usr/local/mysql/bin as implied in MariaDB's documentation.
This once against indicates that MariaDB is using an outdated version of the mysqld_safe script. |
| Comments |
| Comment by Daniel Black [ 2023-05-09 ] | |||||||||||||||||||||||||||||||||||
|
If you run mysqld_safe --basedir=/somewhere, then the mariadbd exe is looked for under this directory. | |||||||||||||||||||||||||||||||||||
| Comment by Anthony Shi [ 2023-05-09 ] | |||||||||||||||||||||||||||||||||||
|
Hello, @danblack . Thanks for replying.
Yes, I'm aware that this was the intent behind this:
But from what I understand from the script, the condition if test -n "$MY_BASEDIR_VERSION" -a -d "$MY_BASEDIR_VERSION" will never be true because MY_BASEDIR_VERSION hasn't been set at that point yet because parse_arguments() is called AFTER the condition has already been executed. The script shipped with MySQL made sense because it calls find_basedir_from_cmdline() first before executing the tests. | |||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2023-05-09 ] | |||||||||||||||||||||||||||||||||||
|
Technically, it can be overridden on the command line. Not as an option (which is indeed not parsed yet), but as an environment variable.
I would however agree that it probably wasn't the intent. | |||||||||||||||||||||||||||||||||||
| Comment by Anthony Shi [ 2023-05-09 ] | |||||||||||||||||||||||||||||||||||
|
Hi @elenst. Thank you for your response.
That's what I thought as well. The user must set MY_BASEDIR_VERSION manually in the shell. |