When I try to start mongod with: sudo service mongod onestart I get the following output: > Starting mongod. > limits: NO: No such file or directory > /usr/local/etc/rc.d/mongod: WARNING: failed to start mongod I've not modified any configuration files yet. It looks like it is a problem with the `mongod_limits` knob, which has the following description: "Set to "NO" by default. Set it to yes to run `limits -e -U mongodb`". I decided to add `set -x` to /usr/local/etc/rc.d/mongod. It turns out that `mongod_limits` is an unfortunate name because of the line 1078 in /etc/rc.subr: _doit="$_cd limits -C $_login_class $_limits $_doit" `_limits` is a variable set in line 957: _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect whereas `${name}_limits` is described as follows: # Name Needed Purpose # ${name}_limits n limits(1) to apply to ${command}. I believe that we have a name collision here as with `set -x` we can see that following command is executed (resulting in "limits: NO: No such file or directory"): limits -C daemon NO su -m mongodb -c 'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"' After renaming `mongod_limits` to `mongod_run_limits` in /usr/local/etc/rc.d/mongod the service runs just fine.
Hi Mateusz, thank you for the report. I can't reproduce that exact behaviour, I'm afraid. mongod_limits="YES" (set -x shows mongod_prestart calling /usr/bin/limits) -- cut here -- $ sudo service mongod onestart /usr/local/etc/rc.d/mongod: DEBUG: pid file (/var/db/mongodb/mongod.lock): no pid in file. /usr/local/etc/rc.d/mongod: DEBUG: checkyesno: mongod_enable is set to YES. /usr/local/etc/rc.d/mongod: DEBUG: run_rc_command: start_precmd: mongod_prestart /usr/local/etc/rc.d/mongod: DEBUG: checkyesno: mongod_limits is set to YES. Starting mongod. /usr/local/etc/rc.d/mongod: DEBUG: run_rc_command: doit: limits -C daemon su -m mongodb -c 'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"' $ -- and here -- mongod_limits="NO" (set -x shows mongod_prestart not calling /usr/bin/limits) -- cut here -- $ sudo service mongod onestart /usr/local/etc/rc.d/mongod: DEBUG: pid file (/var/db/mongodb/mongod.lock): no pid in file. /usr/local/etc/rc.d/mongod: DEBUG: checkyesno: mongod_enable is set to YES. /usr/local/etc/rc.d/mongod: DEBUG: run_rc_command: start_precmd: mongod_prestart /usr/local/etc/rc.d/mongod: DEBUG: checkyesno: mongod_limits is set to NO. Starting mongod. /usr/local/etc/rc.d/mongod: DEBUG: run_rc_command: doit: limits -C daemon su -m mongodb -c 'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"' $ -- and here -- Running 11.1-p8. Not sure how to take this further.
Full set -x output mongod_limits="NO": -- cut here -- + debug 'run_rc_command: start_precmd: mongod_prestart ' + eval 'mongod_prestart ' + mongod_prestart + [ ! -d /var/db/mongodb ] + checkyesno mongod_limits + eval '_value=$mongod_limits' + _value=NO + debug 'checkyesno: mongod_limits is set to NO.' + return 1 + return 0 + _return=0 + [ 0 -ne 0 ] + check_required_after start + local _f _args + return 0 + return 0 + check_startmsgs + [ -n '' ] + return 0 + echo 'Starting mongod.' Starting mongod. + [ -n '' ] + _doit='/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null' + [ -n mongodb ] + _doit=$'su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + [ -n '' ] + [ -n '' ] + _doit=$'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + _run_rc_doit $'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + debug $'run_rc_command: doit: limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + eval $'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + limits -C daemon su -m mongodb -c 'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"' + _return=0 -- and here -- mongod_limits="YES": -- cut here -- + debug 'run_rc_command: start_precmd: mongod_prestart ' + eval 'mongod_prestart ' + mongod_prestart + [ ! -d /var/db/mongodb ] + checkyesno mongod_limits + eval '_value=$mongod_limits' + _value=YES + debug 'checkyesno: mongod_limits is set to YES.' + return 0 + /usr/bin/limits -e -U mongodb + eval ulimit -t 'unlimited;' ulimit -f 'unlimited;' ulimit -d 'unlimited;' ulimit -s 'unlimited;' ulimit -c 'unlimited;' ulimit -m 'unlimited;' ulimit -l '64;' ulimit -u 'unlimited;' ulimit -n 'unlimited;' ulimit -b 'unlimited;' ulimit -v 'unlimited;' ulimit -p 'unlimited;' ulimit -w 'unlimited;' ulimit -k 'unlimited;' ulimit -o 'unlimited;' + _return=0 + [ 0 -ne 0 ] + check_required_after start + local _f _args + return 0 + return 0 + check_startmsgs + [ -n '' ] + return 0 + echo 'Starting mongod.' Starting mongod. + [ -n '' ] + _doit='/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null' + [ -n mongodb ] + _doit=$'su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + [ -n '' ] + [ -n '' ] + _doit=$'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + _run_rc_doit $'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + debug $'run_rc_command: doit: limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + eval $'limits -C daemon su -m mongodb -c \'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"\'' + limits -C daemon su -m mongodb -c 'sh -c "/usr/local/bin/mongod --logpath /var/db/mongodb/mongod.log --logappend --config /usr/local/etc/mongodb.conf --dbpath /var/db/mongodb --fork >/dev/null 2>/dev/null"' + _return=0 -- and here --
(In reply to Vlad Galu from comment #1) > Running 11.1-p8. Not sure how to take this further. Actually, this is the key! :) This change was introduced 2 months ago in r328331[1][2], so effectively only 12.0-CURRENT is affected. I'm running 12.0-CURRENT r330529 here, so I was able to spot the problem. [1]: https://reviews.freebsd.org/D14015 [2]: https://svnweb.freebsd.org/base?view=revision&revision=r328331
Ah I see, that makes sense. I have no issues with renaming the variable in the port provided rc script, you have my blessing :-) As many other ports are affected in a similar way, am I right to assume that _run_limits is proposed as the universal variable suffix and that UPDATING notes will be provided as each port is updated?
(In reply to Vlad Galu from comment #4) There are much more ports which are affected by this change from what I see. I'll keep you updated on a solution to this problem.
databases/mariadb100-server (10.0.34) is one such port affected on 12-CURRENT > Starting mysql. > limits: NO: No such file or directory mysqld_safe does start though.
(In reply to Beeblebrox from comment #6) Thanks for reporting this :) I'll open an issue for mariadb100-server soon. For the time being, there's a general meta-issue.[1] [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227205
Created attachment 192119 [details] Patch adding support for the new ${name}_limits mechanics (databases/mongodb36) Here's a patch, which should fix the issue for the systems with the new behavior. It also should preserve the old behavior for the old systems (10.4, 10-STABLE, 11.1). I've built this port on my dev machine running 12.0-CURRENT r331748 and it seems to build just fine. The service script looks fine as well. Could you please review this patch and test it on the systems with the legacy behavior (10.4, 10-STABLE, 11.1)? Thanks!
Comment on attachment 192119 [details] Patch adding support for the new ${name}_limits mechanics (databases/mongodb36) Thumbs up.
Created attachment 192218 [details] 192119: Patch adding support for the new ${name}_limits mechanics (databases/mongodb36, revision: 1) The previous patch would fail to trigger the new ${name}_limits semantics for __FreeBSD_version 1101514. The new patch fixes it (thanks to mmokhi@).
Created attachment 192404 [details] Patch adding support for the new ${name}_limits mechanics (databases/mongodb36, revision: 4) Due to an increasing number of problems caused by the new ${name}_limits behavior, the revision, which was backported from 12-CURRENT to 11-STABLE, has now been reverted.[1] As a result, the new behavior will not be present in any FreeBSD version < 12. This new patch adapts the port to those latest changes. [1]: https://svnweb.freebsd.org/base?view=revision&revision=r332363
Vlad, it looks like you've submitted a part of an obsolete ${name}_limits patch in the changes upgrading databases/mongodb36 to 3.6.4.[1]: the Makefile parts are outdated and mongod changes are missing entirely. Could you please review the most recent patch I uploaded[2] so that it could be incorporated into the ports tree? At the moment databases/mongodb36 is still broken on 12.0-CURRENT. Cheers :) [1]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=227636 [2]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226907#c11
(In reply to Mateusz Piotrowski from comment #12) Ah, sorry Mateusz, I missed that. It looks good, please feel free to go ahead with the changes. Thanks! Vlad
A commit references this bug: Author: krion Date: Thu May 3 17:52:41 UTC 2018 New revision: 468952 URL: https://svnweb.freebsd.org/changeset/ports/468952 Log: Add support for the new ${name}_limits mechanics on CURRENT and preserve the old behavior for the old systems. PR: 226907 Submitted by: mp0@FreeBSD.org Approved by: maintainer Changes: head/databases/mongodb36/Makefile head/databases/mongodb36/files/mongod.in
This isn't right. mongod_limits is considered to be the USER that will be set by rc.subr. ~ # grep _limits /etc/rc.subr # ${name}_limits n limits(1) to apply to ${command}. _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \ _doit="$_cd limits -C $_login_class $_limits $_doit" ~ # service mongod onestart Starting mongod. limits: NO: No such file or directory /usr/local/etc/rc.d/mongod: WARNING: failed to start mongod Changing all mongod_limits to mongod_limits_enable fixes it.