Bug 225657 - databases/mysql*server: addition of new ${name}_limits rcvar breaks mysql rc file
Summary: databases/mysql*server: addition of new ${name}_limits rcvar breaks mysql rc ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Mahdi Mokhtari
URL:
Keywords:
Depends on: 227230
Blocks:
  Show dependency treegraph
 
Reported: 2018-02-04 03:13 UTC by robbak
Modified: 2019-02-22 09:53 UTC (History)
6 users (show)

See Also:
mmokhi: maintainer-feedback+


Attachments
Patch for mysql_limit (780 bytes, patch)
2018-02-07 20:42 UTC, Mahdi Mokhtari
mmokhi: maintainer-approval+
Details | Diff
patch-mysql_limit-rc (776 bytes, patch)
2018-02-07 20:59 UTC, Mahdi Mokhtari
mmokhi: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description robbak 2018-02-04 03:13:56 UTC
The recent addition, on -CURRENT at present, of a ${name}_limits rc_var breaks mysql's rc file. The rc scripts now prepend 'limits -C $_login_class ${name}_limits" to the command line. With the current file, this becomes "limits -C daemon NO su -m mysql ....", which fails with "limits: NO: No such file or directory", because it tries to run the command 'NO'.

As a temporary fix, users on CURRENT can delete the : ${mysql_limits="NO"} line from the rc script. The rc file gives an error when it can't find it, but the daemon runs normally. The port could be fixed by removing the limits coding from the rc file if the FreeBSD revision is above 328331
Comment 1 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-06 11:23:26 UTC
(In reply to robbak from comment #0)
Hi,
Can you confirm which mysql version exactly you tested on which FreeBSD.
The mysql_limits variable isn't new thing that we have added recently.
On 'pre-cmd' part it always checks "yesnocheck" if the variable is "NO" it doesn't use it, otherwise it uses it.

Maybe I misinterpreted your report, in this case would you elaborate it more please? 
Thanks :)
Comment 2 robbak 2018-02-06 21:46:33 UTC
(In reply to Mahdi Mokhtari from comment #1)
I'm using mysql56-server. 

The problem started when I upgraded -CURRENT past version 328331, which introduced a ${name}_limits variable to /etc/rc.subr (see https://svnweb.freebsd.org/base/head/etc/rc.subr?view=log). The rc script inserts the contents of that variable into the command line when running the daemon. When ${name}_limits is set to 'NO', this inserts 'NO' to the command line, breaking it.
Comment 3 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-07 10:05:49 UTC
(In reply to robbak from comment #2)
Aha...
Thanks for the complete explanation, now I see the point...
So basically it's a nameing-conflict after r328331 in the base (-CURRENT).
Maybe I should use another name for my "local" limit args in the rc-script...
I'm on it :D
Comment 4 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-07 20:42:16 UTC
Created attachment 190402 [details]
Patch for mysql_limit
Comment 5 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-07 20:43:09 UTC
@robbak, Can you check if this patch fixes the issue for you?
[mine seems fine now]
Comment 6 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-07 20:59:29 UTC
Created attachment 190404 [details]
patch-mysql_limit-rc
Comment 7 Rainer Hurling freebsd_committer freebsd_triage 2018-02-07 21:09:44 UTC
With this patch mysql56-server starts again :)

Thanks for your work!
Comment 8 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-07 21:41:59 UTC
(In reply to Rainer Hurling from comment #7)
Thanks for confirming :)
Will commit the fix ASAP.
Comment 9 commit-hook freebsd_committer freebsd_triage 2018-02-08 12:43:01 UTC
A commit references this bug:

Author: mmokhi
Date: Thu Feb  8 12:42:42 UTC 2018
New revision: 461217
URL: https://svnweb.freebsd.org/changeset/ports/461217

Log:
  databases/mysql56-server: Fix rc-script ${name}_limits conflict for post r328331
  After r328331 changes in head/etc/rc.subr, having "NO" in mysql_limits
  goes into "limits" command params as is.
  So this patch substitutes the "NO" appropriately when needed.

  PR:		225657
  Reported by:	robbak@gmail.com
  Reviewed by:	Rainer Hurling <rhurlin@gwdg.de>
  Sponsored by:	Netzkommune GmbH

Changes:
  head/databases/mysql56-server/Makefile
  head/databases/mysql56-server/files/mysql-server.in
Comment 10 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-08 12:47:42 UTC
Committed.
Thanks.
Comment 11 robbak 2018-02-09 00:26:09 UTC
Just a heads-up to apply the fix to databases/mysql55-server too.
Comment 12 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-02-09 09:59:30 UTC
(In reply to robbak from comment #11)
Aha, Yup.
I'll open a review for that as well :) [since I'm not maintainer of 55 ``:D].
Comment 13 Stefan Bethke 2018-04-08 16:03:23 UTC
After updating to -stable today, MySQL doesn't start any more:

# service mysql-server start
Starting mysql.
limits: NO: No such file or directory
/usr/local/etc/rc.d/mysql-server: WARNING: failed to start mysql

Has this fix been backed out, or is something else necessary?

# pkg info mysql56-server
mysql56-server-5.6.39_2
Name           : mysql56-server
Version        : 5.6.39_2
Installed on   : Sun Apr  8 09:53:31 2018 UTC
Origin         : databases/mysql56-server
Architecture   : FreeBSD:11:amd64
Prefix         : /usr/local
Categories     : databases ipv6
Licenses       : GPLv2
Maintainer     : mmokhi@FreeBSD.org
WWW            : http://www.mysql.com/
Comment        : Multithreaded SQL database (server)
Options        :
	ARCHIVE        : off
	BLACKHOLE      : off
	EXAMPLE        : off
	FEDERATED      : off
	INNOBASE       : off
	PARTITION      : off
	PERFSCHEMA     : off
	PERFSCHM       : on
Annotations    :
	FreeBSD_version: 1101001
	cpe            : cpe:2.3:a:mysql:mysql:5.6.39:::::freebsd11:x64:2
	repo_type      : binary
	repository     : FreeBSD
Flat size      : 82.0MiB
Description    :
MySQL is a very fast, multi-threaded, multi-user and robust SQL
(Structured Query Language) database server.

WWW: http://www.mysql.com/
Comment 14 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-04-09 10:49:33 UTC
Hi,
I think it's related to the PR#227230 that we're currently working on.
I guess if the src-committers tag the commit mentioned in PR, I can easily edit the condition in the Makefile and issue will be solved.
Comment 15 Stefan Bethke 2018-04-09 10:52:01 UTC
As a quick workaround, I've set mysql_limits="" in rc.conf; this produces a warning on startup, but lets mysql start up again.
Comment 16 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-04-09 11:03:00 UTC
(In reply to stb from comment #15)
Yup,
That should work fine as well...

But at the PR I mentioned we had a cleaner/more-portable way, the only con seems to be that we should tag the _FreeBSD_ on the 11-stable to have the "correct" version for include/exclude the "legacy" limit way.
Comment 17 Jack 2018-04-10 09:50:40 UTC
mysql57-server and mysql80-server also suffer from this limits problem.
Comment 18 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-04-10 09:52:23 UTC
(In reply to xxjack12xx from comment #17)
Yes, they do, it's not about mysql only, but the base's rc.subr `:)
Separate PRs are tracking them :)
Comment 19 Mahdi Mokhtari freebsd_committer freebsd_triage 2018-04-11 14:32:22 UTC
The commit in base is reported to be reverted on 11-STABLE.
In the PR in SeeAlso: field there's a PR I got it from.

The problem is fixed in the patch in mentioned PR :)

Thanks from everyone reporter and helped in fix [and sorry for inconvenience you experienced].
Comment 20 Robert Zelaya 2018-08-30 01:05:33 UTC
Request to open this ticket again. 

I having the same issue on FreeBSD CURRENT and MariaDB103-server.
Comment 21 MikeH 2018-12-26 19:18:51 UTC
Upgraded from 11.2-RELEASE to 12.0-RELEASE on Dec26-2018 and this bug came back.
The rc.conf entry "fixes" it, but not be patched for FreeBSD 12.
Comment 22 Christos Chatzaras 2019-02-22 07:34:30 UTC
Same issue here after upgrade to 12.0
Comment 23 Christos Chatzaras 2019-02-22 09:53:47 UTC
After port recompile it doesn't need mysql_limits="" in /etc/rc.conf anymore.