WL#7895: Add systemd support to server
Affects: Parser-5.7 — Status: Complete — Priority: Medium
Background The major Linux distributions are moving from legacy SystemV init or upstart init to new, more powerful systemd init system. systemd has a lot of new features for daemons such as mysqld, among the most important are - handling of user and group running the daemon - resource control (max open files for example) - and automatic restarts in case of failure However, to let MySQL server be good citizen in this new enviroments some changes are required. This WL tries to list those requirements. Benefits References : http://www.freedesktop.org/wiki/Software/systemd/ : http://www.freedesktop.org/software/systemd/man/systemd.service.html : http://www.freedesktop.org/software/systemd/man/systemd-tmpfiles.html : http://www.freedesktop.org/software/systemd/man/daemon.html Details MySQL gets a modern init system for Linux systems and native SysV daemon option on other supported platforms. Testing Exit status, start status Package verification Failure/restart tests
Requirements F1: Create systemd specific files a) mysqld.service systemd service unit configuration, with details about the mysqld service. b) mysqld.tmpfiles file to support the tmpfiles feature c) mysql-systemd-start support script for the unit file Repo project can provide contents of files and locations. F2: Add cmake option. Add new -DWITH_SYSTEMD=on|off (off by default) Install F1 when enabled F3: Modification of initial startup of server. systemd expect server to do standard SysV daemon init, or init of "New-Style Daemons". We should implement standard SysV init as then we can reuse the feature outside systemd context and be the default way server starts on all platforms (except Windows). See  for detailed description of how this should be implemented. An option to use current non daemon mode should be present. F4: Clean up of exit codes. systemd is monitoring daemons started and restarts them if they stops with exit code > 0. mysqld must therefore return exit 0 on normal shutdown and basically return sane exit code everywhere. F5: Clarify malloc libs status. To use alternative malloc libs mysqld_safe has an --malloc-lib option (implemented by a LD_PRELOAD hack). With systemd support and mysqld_safe out of the picture there is no way to inject other malloc libs. Solutions: a) build with jemalloc/tcmalloc statically by default b) add LD_PRELOAD of malloc libs mechanism in systemd service file c) only use system malloc on systemd platforms F6: Disable mysqld_safe when running under systemd. When F4 and F5 are done, we can remove mysqld_safe and leave it to systemd to restart server in case of failure. F7: Improve packages, enable systemd.
Copyright (c) 2000, 2019, Oracle Corporation and/or its affiliates. All rights reserved.