Skip to content

Instantly share code, notes, and snippets.

@eliasp
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eliasp/370ca2b60c3371d1d275 to your computer and use it in GitHub Desktop.
Save eliasp/370ca2b60c3371d1d275 to your computer and use it in GitHub Desktop.
eMail conversation with MySQL team wrt native systemd support

Hi Thayumanavar,

thanks for your response. Some further comments from my side inline below.

best Elias

On 07/30/2015 12:15 PM, thayumanavar wrote:

Hello Elias, There are some additional information in our docs page at

https://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html

Please see reply inline below from Terje:

Thanks, Thayumanavar S.

-------- Forwarded Message -------- Subject: Re: Fwd: MySQL 5.7 - systemd support - further comments Date: Thu, 30 Jul 2015 12:04:09 +0200 From: Terje Røsten terje.rosten@oracle.com To: thayumanavar thayumanavar.x.sachithanantha@oracle.com

On 07/30/2015 11:36 AM, thayumanavar wrote:

Hello Terje, There is some comment about systemd related to configuration paths.. Please kindly see below. Thanks, Thayumanavar S.

-------- Forwarded Message --------y Subject: MySQL 5.7 - systemd support - further comments Date: Thu, 30 Jul 2015 11:04:57 +0200 From: Elias Probst mail@eliasprobst.eu To: thayumanavar.x.sachithanantha@oracle.com

Hello,

I hope it's ok I'm contacting you directly. If I'm right, you're the author of http://mysqlserverteam.com/mysql-5-7-native-systemd-support

I wanted to make some further comments to your reply in the comments section, but it seems the blogengine is not accepting any further comments from me, so please find below what I wanted to add as comment to this blog post.

Best regards, Elias P.

Ok, so I understand your motivation at least now why you implemented it the way you did.

Some more comments regarding the "Passing Custom Options to mysqld" section:

Instead of setting LD_PRELOAD in /etc/sysconfig/mysqld, which is a non-standard (RedHat-specific) path, the proper solution would be to:

  • run "systemctl edit mysqld.service" (this will create/edit the drop-in file in /etc/systemd/system/mysqld.service.d/override.conf) and place those lines in it: [Service]

Environment=LD_PRELOAD=/path/of/malloc/library.so

  • run "systemctl daemon-reload"
  • run "systemctl restart mysqld"

Besides that, using "systemctl set-environment" for setting service specific environment variables is strongly discouraged, as this will inject the defined environment variables into the global systemd environment which will be inherited by all services. This tampers with the concept of starting processes from a clean/deterministic environment. The process outlined above for setting service-specific environment variables should be used instead.

edit command of systemctl is very new and not available in RHEL7, SLES12 as far as I know.

'edit' is basically just a convencience wrapper doing:

  • create the file /etc/systemd/system/mysql.service.d/override.conf
  • open it in a editor

So if it's about also supporting older releases/versions, the instruction should be to just create a *.conf file in said directory and place any customizations in it instead of injecting environment variables into the global environment (for the reasons outlined above).

The documentation at https://dev.mysql.com/doc/refman/5.7/en/server-management-using-systemd.html gets this mostly right, but also still mentions 'systemctl set-environment …' which is harmful.

It would be nice if the blog article and the docs would be updated/edited/annotated to reflect this as many people finding it when googling for help might just keep doing this - causing unwanted side-effects.

Regarding the "Systemd Service and Support Files" section:

  • "After=syslog.target" is obsolete since quite some time. [1], This talks about Requires=syslog.target, not After=syslog.target. [2] For newer systemd syslog.target is not needed, for RHEL7/SLES12 it's needed it seems.

OK, makes sense in this case.

  • Is there a specific reason to set PrivateTmp=false? PrivateTmp= is a useful feature to prevent other users/services from accessing data stored in /tmp. Besides that, it also auto-cleans the private /tmp dir on each service restart. Replication and other parts of server saves file in /tmp and we don't those files to be removed during mysql restart or server reboot.

One should never rely on files in /tmp being persistent in any way. Most systems wipe /tmp on boot. Temporarily persistent files should be placed in a location controlled by the application (e.g. /var/lib/${application}/, which /tmp isn't.

Placing files which should persist across service restarts and even reboots in /tmp is asking for trouble. By established best practices, more or less every admin goes by the assumption that file in /tmp which isn't held open by any process can be safely deleted. Content of /tmp is only considered persistent "from the outside" as long as a filehandle is open on it.

  • The tmpfiles.d entry could point to /run/mysqld instead of /var/run/mysqld - /var/run is nowadays just a symlink to /run for backwards compatibility (same goes for the PIDFile= entry which points to /var/run). Ack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment