I have a problem tying to figure out, how the resource management in systemd works.
To make clear where I am and how I got there, I should start with explaining my situation:
After migrating a mysql-db from ubuntu 14.04 to 16.04 I have to deal with systemd. Not my first time and no problem till this day. On 16.04 I noticed the log entry during mysql-startup:
Changed limits: max_open_files: 1024 (requested 5000)
I found out, that the mysql-variable
max_open_files is not set in my current config!) is dynamic, depending on 4 different scenarios (see: https://dev.mysql.com/doc/refman/5.6/en/server-system-variables.html#sysvar_open_files_limit)
and in my case, obviously scenario no. 4 is used.
So my point is:
The mysql-config on 14.04 and 16.04 is the same, but it looks like the resource management acts different with systemd as it did on 14.04 (with
The condition that mysql uses scenario no 4 is, that 'if operating system limit is Infinity' is true ... why is the operating system limit Infinity?
Another thing that I am struggling with:
If I define
max_open_files in my mysql-config as lets say '1000' and have a look into
/proc/[myslq-pid]/limits I can see that the soft-limit is set to 1000 and the hard-limit is 4096.
Question 1: Why is the limit 4096, as condition 4 from above hits true on 'if operating system limit is Infinity' ...
And I can set
max_open_files to any value between 1 and 4096, and it defines limit - which is the expected behavior. But if it get set higher than 4096, it falls back to softlimit=1024 & hardlimit=4096.
I do not understand this behavior, because again, condition 4 from above hits true on
if operating system limit is Infinity ...
That leads to my Question 2: Where does this 'default value' come from?? And why I am not able to set the limit higher than 4096?
As soon as I define
LimitNOFILE=number in the mysql-service-unit of systemd, 'number' gets set as soft AND hardlimit and I am able to define values higher than 4096. Confirmed by looking into
I had a look into the docs of systemd, but for some reason the only thing that got mentioned in terms of 'defaults' are the
/etc/systemd/user.conf files, where I can define
DefaultLimitNOFILE=, which is unset by default - so is there a
I seriously do not get behind this behavior... hope someone has a Tip on how to get this sorted.
I take any advice or hint you have!
I even would be happy to read more documentations, that explains this - but I just have not found the right ones ... everything I found leads me back to systemd.resource-control, setrlimit, systemd.exec and systemd/ControlGroupInterface which does not took me further than endig up here :)