[MDEV-8509] make it possible to change MYSQLD_STARTUP_TIMEOUT on Debian systems Created: 2015-07-20  Updated: 2016-11-25  Resolved: 2016-11-25

Status: Closed
Project: MariaDB Server
Component/s: Packaging, Platform Debian
Fix Version/s: 10.2.3

Type: Task Priority: Minor
Reporter: Nils Meyer Assignee: Otto Kekäläinen
Resolution: Fixed Votes: 1
Labels: None

Issue Links:
Blocks
is blocked by MDEV-6284 Merge downstream Debian/Ubuntu packag... Closed
Relates
relates to MDEV-9382 After updating mariadb server apt-con... Closed
relates to MDEV-5068 import file from init script Closed
relates to MDEV-5540 MariaDB reports failure to start Closed

 Description   

In some cases (think SST, large memory allocation) it takes longer than 30 seconds for the Database server to become available, in which case the init script will report failure. This is especially problematic on systems running systemd, since systemd will erroneously record the service as not started and might at some other time try to launch a second mysqld instance (stop/restart also won't work).

There is already an environment variable referenced when launching (MYSQLD_STARTUP_TIMEOUT) but there seems to be no way to set it. The Debian way would be to specify it in /etc/default/mysql and have something like this inside the init script:

[ -r /etc/default/$NAME ] && . /etc/default/$NAME

This was already fixed for Redhat based distributions in MDEV-5068



 Comments   
Comment by Otto Kekäläinen [ 2015-07-21 ]

I think this is fixed in the Debian packaging: https://anonscm.debian.org/cgit/pkg-mysql/mariadb-10.0.git/tree/debian/mariadb-server-10.0.mysql.init#n112

Does it look what you expect it to be?

Comment by Nils Meyer [ 2015-07-21 ]

The problem is that the env var MYSQLD_STARTUP_TIMEOUT in line is always not set, at least when using Debian stable (jessie), even when I set it on the command line and thus the timeout always defaults to 30 seconds.

The solution for Redhat based distributions is to set the value in /etc/sysconfig/mysql (see MDEV-5068). In Debian, you would usually include a file in /etc/default/mysql if it exists. This allows for the system administrator to change the value without touching the init script.

Comment by Otto Kekäläinen [ 2015-07-21 ]

nils.meyer OK, I now see what you mean. Indeed if would make sense to be able to permanently set such a variable in /etc/default/mariadb

Since you seem to know how to solve it and probably have time to test that the solution also works as expected, would you like to open a pull request at github and have your contribution logged in git history?

The Debian packaging repo http://git.debian.org/?p=pkg-mysql/mariadb-10.0.git is mirrored at https://github.com/ottok/mariadb-10.0
I can also easily run 'git pull git://git.debian.org/users/..../mariadb-10.0.git' if you don't want to collaborate via Github, just send the url of your repo location.

Your contribution would be soon available in Debian unstable and given some time in all Debian and Ubuntu releases and also the mariadb.org repositories.

Comment by Jean Weisbuch [ 2015-07-22 ]

I made a pull request for it : https://github.com/ottok/mariadb-10.0/pull/26

As specified on the pull request : I haven't tested the modifications.
Its also important to note that as the default file use the same name as the package its installed with, it should create a file called "/etc/default/mariadb-server-10.0" which could be problematic for upgrade to 10.1 and further and i don't know what would be the best practice here and what Debian guidelines permits.

For more infos about the ".default" file : https://www.debian.org/doc/manuals/maint-guide/dother.html#initd

Comment by Nils Meyer [ 2015-07-22 ]

I'll create a pull request of my own if time permits, however Jean, consider that the default file SHOULD be generic between release, that is you'll expect it to behave the same on subsequent releases. Therefore you'd go with /etc/default/$(basename).

This point will of course be rendered moot once the systemd integration is merged. .

Comment by Jean Weisbuch [ 2015-07-22 ]

I agree with that.

As the dh_installinit execution is already overrided on "debian.rules" to set its "--name" parameter to "mysql", its possible to create the default file as "debian/mariadb-server-10.0.mysql.default" which would in turn be installed as "/etc/default/mysql".
It would definitely be better to name it "/etc/default/mariadb", unfortunately i don't think that its possible to pass two different "--name" parameters to dh_installinit or to specify another filename than the package name or the one set with "--name".

The change could also be ported to mysql-5.5 (including the use of the MYSQLD_STARTUP_TIMEOUT variable on the init script) which would makes sense as its not MariaDB specific and thus the same file would be used by both packages but it would become a problem if MariaDB specific changes were to be done on that file (but it shouldn't break anything as its only setting variables).

I don't think that creating/modifying the file another way than using dh_installinit would be acceptable.

Comment by Nils Meyer [ 2015-07-22 ]

I think it's fine to keep it /etc/default/mysql in keeping with the naming of the init script since at least a derivative of it is used in all Debian based distributions and an empty file with helpful comments doesn't hurt.

Only thing about your pull request, you should probably just comment out the MYSQLD_STARTUP_TIMEOUT variable since it defaults to 30 seconds anyways. My suggestion:

+# The delay in seconds the init script waits for the server to be up and running after having started "mysqld_safe" to run the "/etc/mysql/debian-start" script.
+# If the server is still not responding after the delay, the script won't be executed and an error will be thrown on the syslog.
+# Default: 30
+#MYSQLD_STARTUP_TIMEOUT=30

It may also be worth mentioned the delay to mlock large areas of memory or the delay for galera SST in the comment.

Notwithstanding, this pull request would solve the problems I had bootstraping a galera cluster with stock MariaDB.

Comment by Otto Kekäläinen [ 2015-07-24 ]

jb-boin Your pull request is merged in Debian packaging and will soon be uploaded to Debian unstable. Now when there is a /etc/default file, would you like to complete you idea in https://github.com/ottok/mariadb-10.0/issues/4 too?

Comment by Jean Weisbuch [ 2015-07-25 ]

I added a new pull request (https://github.com/ottok/mariadb-10.0/pull/27) that fix these :

  • The Debian default file for the mariadb-server-10.0 package is now "/etc/default/mysql" instead of "/etc/default/mariadb-server-10.0" (i think that the Debian "mysql" packages maintener should be notified)
  • The MYCHECK_RCPT variable can now be set from the default file.
  • The check_for_crashed_tables() function on the debian-start script has been fixed to be able to log (and email) the errors it encountered : Errors are sent to stderr by the CLI while only stdout was captured by the function (so errors werent logged to syslog as well).
  • The same function now also checks Aria tables along with MyISAM ones.
  • The function now exclude tables that are in the "INFORMATION_SCHEMA" or "PERFORMANCE_SCHEMA" virtual databases (that are created at the server start and thus cannot be improperly closed) (please not that i forgot to mention this change on the debian/changelog file).

Please note that i havent tested the changes.

An off-topic comment : The "check_for_crashed_tabels()" function is really... ugly : In its comment its noted that its not using CHECK TABLE because it wouldnt work on engines such as.. "HEAP" (MEMORY) while it was only checking MyISAM tables... by doing a COUNT(*) on them, which cannot be used on engines such as InnoDB or TokuDB as it would scan the whole table.
Using directly "CHECK TABLE" or "mysqlcheck" would be cleaner and checking other table engines would also be a good idea as most users havent checked the script code to know that it only does MyISAM (and now Aria).

Comment by Jean Weisbuch [ 2015-08-21 ]

I did forgot to put a followup on this bug here, i did pull other fixes and tested the 28 of July and validated that it worked as expected on my test environment (comments and examples on Github) : https://github.com/ottok/mariadb-10.0/pull/27

I just noticed a detail today, the generic init script shipped with MariaDB (and MySQL) on "support-files/mysql.server.sh" already has a similar option as "MYSQLD_STARTUP_TIMEOUT" named "--service-startup-timeout" and the generic init script already reads "/etc/defaults/mysql" if it exists, maybe making it use the variable if set while the "--service-startup-timeout" option is not set could be a good idea for users installing/upgrading MariaDB debian packages while keeping their manually installed init script.

Comment by Otto Kekäläinen [ 2016-11-25 ]

This was fixed in https://github.com/MariaDB/server/commit/73f1c655

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