[SERVER-25080] MongoDB 3.2.8 ignores ulimit in systemd distributions Created: 14/Jul/16  Updated: 23/Nov/16  Resolved: 25/Aug/16

Status: Closed
Project: Core Server
Component/s: Admin
Affects Version/s: 3.2.8
Fix Version/s: 3.2.10, 3.3.12

Type: Bug Priority: Major - P3
Reporter: Emmanuel Chambon Assignee: Sam Kleinman (Inactive)
Resolution: Done Votes: 2
Labels: code-only
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-24885 The systemd MaxTasks feature can prev... Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Steps To Reproduce:

Install mongod on debian 8 with 'deb http://repo.mongodb.org/apt/debian jessie/mongodb-org/3.2 main' as source

Sprint: Build 2016-08-26
Participants:

 Description   

Hello, I just update some mongod servers to 3.2.8 and I noticed that max open files setting is not respected. db.serverStatus().connections returns a maximum of 819 connections while the ulimit -n is correctly set at 65536

My servers runs under Debian Jessie and before upgrading package I changed the source from wheezy to jessie repository

This affects only the jessie version.

I also tested this on a fresh new server to check if this was coming from my previous configuration and the result is the same, still capped at 819 connections.

As I can't download pre 3.2.8 version with the Jessie source I wasn't able to see if this was affecting previous versions.

Is the max open files limitation handled differently on Jessie ?

Thanks



 Comments   
Comment by Sam Kleinman (Inactive) [ 25/Aug/16 ]

I have pushed the change to set process limits in the systemd service file.

I've tested running MongoDB using the change to the service file and have found that it does not impact existing functioning of the package (starting, stopping, restarting,) and have run some nominal tests with MongoDB, but I have not extensively tested running MongoDB under load with this configuration.

Thanks for your patience on this and I hope that this change resolves your issue, please let us know if you have additional issues or encounter problems with the service file.

Comment by Githook User [ 25/Aug/16 ]

Author:

{u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: SERVER-25080 SERVER-24885: fix systemd process limits
Branch: master
https://github.com/mongodb/mongo/commit/906a6f057f87fb4e51c4a698d9d6fe490fb293a2

Comment by Githook User [ 25/Aug/16 ]

Author:

{u'username': u'tychoish', u'name': u'Sam Kleinman', u'email': u'samk@10gen.com'}

Message: SERVER-25080 SERVER-24885: fix systemd process limits

(cherry picked from commit 6803a1fb257be78949b5fa08d2e4ad4186793e2b)
Branch: v3.2
https://github.com/mongodb/mongo/commit/60781ebcd9647506bf4a385832c2ea4097b3263a

Comment by Chad Kreimendahl [ 09/Aug/16 ]

It may not be a duplicate. On our system we previously set the ulimits in the limits.conf file, which worked fine. Then, someone put ulimit settings into the init.d mongod file. Now, for those on Jessie, it's in the mongod.service file in the systemd folder. You'll have to add the appropriate LimitNOPROC, etc, to get it to work.

Comment by Kelsey Schubert [ 08/Aug/16 ]

Hi all,

Thank you for the reports. This issue is a duplicate of SERVER-24885; please feel free to vote for SERVER-24885 and watch it for updates.

Best regards,
Thomas

Comment by Dave M [ 17/Jul/16 ]

Ran into the same issue, ulimits were ignored after upgrade and server immediately died with errors after restart.

I believe that happens because package for jessie now includes systemd configuration file (/lib/systemd/system/mongod.service), the presence of which overrides legacy /etc/init.d script completely.
So ulimit directives there never get executed.

For my system I made a quick fix by creating file named /etc/systemd/system/mongod.service.d/ulimit.conf (you should create mongod.service.d directory, file name itself is arbitrary) with following contents:

[Service]
LimitFSIZE=infinity
LimitCPU=infinity
LimitAS=infinity
LimitNOFILE=64000
LimitNPROC=64000

Then ran "systemctl daemon-reload", then "systemctl start mongod" and everything went OK.

These lines should probably be added into vendor-supplied systemd unit.

Comment by Emmanuel Chambon [ 17/Jul/16 ]

The init.d file seems to be the same as the one on Wheezy with the ulimit also set at start

The only other problem I had since the upgrade to Jessie is that DB Storage on MMS is wrong (doubled compared to what it must be).

Comment by Chad Kreimendahl [ 17/Jul/16 ]

Check the init.d file. It appears to set it in there as well (it should probably inherit from the system and just warn on setup), as we have set it at boot to be much larger than the init script, which may get overwritten by upgrades.

Did you have any other issues w/ the Jessie build?

I'm curious if the build script was the same, as I was getting a much more unique set of errors on startup w/ Jessie builds versus Wheezy builds (both running on Jessie). For now, we remain on Wheezy mongo in Jessie debian.

Generated at Thu Feb 08 04:08:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.