Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 215535 - dev-db/mysql-init-scripts: dev-db/mysql-5.0.54 initscript fails with /var/run on tmpfs (patch provided)
Summary: dev-db/mysql-init-scripts: dev-db/mysql-5.0.54 initscript fails with /var/run...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: High normal with 2 votes (vote)
Assignee: Gentoo Linux MySQL bugs team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-31 08:24 UTC by Josh Cepek
Modified: 2011-01-13 20:07 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for mysql initscript with tmpfs (mysql-tmpfs-initscript.patch,776 bytes, patch)
2008-03-31 08:26 UTC, Josh Cepek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Cepek 2008-03-31 08:24:21 UTC
The initscript for mysql (as of 5.0.54) assumes it can write to the /var/run/mysqld/ directory as the mysql user - this directory was created by the ebuild during installation. However, for users running /var/tmp on tmpfs (or any other ram-based filesystem) this directory is wiped out on reboots.

The attached patch to the /etc/init.d/mysql initscript corrects this by including a check to see if the directory containing the pidfile exists. If it does not, the directory is created and chown-ed to the mysql user. This patch will be harmless for users who don't run /var/run on tmpfs as the directory will already exist.

Reproducible: Always

Steps to Reproduce:
1. emerge =dev-db/mysql-5.0.54
2. Set /var/run to be on tmpfs as in the following fstab line:
   tmpfs  /var/run  tmpfs  mode=0755,size=10M  0 0
3. Reboot to initialize tmpfs mount (be sure /var/run is empty upon reboot - junk is often left here after reboots)
4. Attempt to start mysql. It fails to start and provides no useful information why since the initscript expected to create the PID file through start-stop-daemon.
Actual Results:  
mysql fails to start.

Expected Results:  
The initscript should create the /var/run/mysqld directory and chown it if necessary.
Comment 1 Josh Cepek 2008-03-31 08:26:55 UTC
Created attachment 147775 [details, diff]
Patch for mysql initscript with tmpfs

This patch allows the mysql initscript to determine the mysql run directory (taken from the pidfile up to the final slash) and creates it if necessary with the proper user ownership. It will not affect users running /var/run on a standard persistent filesystem, so it should be safe for everyone.
Comment 2 Josh Cepek 2008-03-31 08:29:59 UTC
(In reply to comment #0)

For clarification: I meant "for users running /var/run on tmpfs", but above wrote "/var/tmp".  I do mean /var/run in this case.
Comment 3 Alex Funk 2010-09-10 15:20:28 UTC
I found this patch very useful.  Even for those not using tmpfs for their /var/run, it's not a bad idea to have this sanity check during the startup process.
Comment 4 Jorge Manuel B. S. Vicetto (RETIRED) Gentoo Infrastructure gentoo-dev 2010-11-16 14:14:40 UTC
This seems to be a user configuration issue to me.
If we (Gentoo) want to address this issue, it probably should be addressed globally. To me this means providing a way for users to have /var/run on a tmpfs filesystem, which probably should create a tarball of everything under /var/run on shutdown and unpack it on startup.
Thus, I'd suggest any user still interested on this issue to mail the gentoo-dev mailing list to determine if there's any interest or support for this feature.
I don't think it makes any sense to fix this on a per-package basis.
Comment 5 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2011-01-13 20:07:20 UTC
Implemented in new mysql-init-scripts-2.0_pre1