-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
systemd 240 fails to start mariadb + galera on Arch Linux #11510
Comments
I have also raised the same issue on https://bugs.archlinux.org/task/61433 |
hmm, if you lower RLIMIT_NOFILE (both hard and soft) to something low, e.g. 4096, do things work then? |
LimitNOFILE=16364 is already in mariadb.service. |
Just bisected this and found a8b627a to be the first bad commit. |
BTW, kernel is built with |
Rebooting with cgroup_disable=memory kernel parameter does not fix this issue. |
With systemd 239:
... and 240:
So does
And even more interesting... Does it start if we restore just one of both? |
|
Building with Setting the values manually I can still restart mariadb successfully:
So what else does this influence? |
Looks like after changing the values we need a Booted systemd built with Run Run |
so that suggests mariadb proabably uses THere's nothing really actionable on systemd's side I figure. There are two ways out for arch I guess:
|
Thank you for your efforts. I can confirm that with fs.nr_open = 1048576 mariabd will start only after daemon-reexec on systemd 240. How to set fs.nr_open = 1048576 for mariadb without having to recompile systemd? I added fs.nr_open = 1048576 to /etc/sysctl.d but mariadb won't start unless systemctl daemon-reexec is run, not even after a reboot. |
the reexec shouldn't be necessary. I figure you need to combine LimitNOFILE= with the fs.nr_open sysctl change. (background: when systemd determines which RLIMIT_NOFILE to default to for its services it takes the fs.nr_open into account, and won't set the RLIMIT_NOFILE larger than the sysctl. Hence, if you set the sysctl explicitly and set LimitNOFILE= explicitly for that specific service, you should be good) |
I have added
to /etc/systemd/system/mariadb.service.d/extra.conf but it looks that this won't help start mariadb. Apparently this code is executed after mariadb.service ExecStartPre galera_recovery |
mariadb.service has LimitNOFILE=16364 |
I could not find anything in mariadb or galera code base. Where could the value be read other than /proc? |
These are the last lines form strace for the mysqld process:
|
This function looks pretty suspicious. It checks/sets the maximum number of open files, and then immediately calls https://github.com/MariaDB/server/blob/5abc79dd7ab2fccb4b05ca38a512ec816d2f8e52/mysys/my_file.c#L95 |
Created a bug report for MariaDB: |
hmm, if mariadb.service indeed has LimitNOFILE=16364, how come that in the strace @eworm-de posted the limit is 1073741815? Something is strange there. Is it possible that somewhere mariadb internally bumps RLIMIT_NOFILE to fs.nr_open first? |
This is mariadb.service file:
|
Does |
nope, should apply to all processes forked off for the service. |
@eworm-de Thanks a lot for your investigation. This helped me a lot in reproducing. Note that it doesn't crash for me as my workstation has sufficient memory to allocate the mess :) I've investigated this on MariaDB side. The too-big alloc happens here: This happens because of the call from above of set_max_open_files, which looks for the magic number RLIM_INFINITY. If the rlim_cur is not equal to the magic number, but greater than the requested max_file_limit, we'll return the current rlim_cur value. That's bad as it means we can return a very large number. I will push a fix into MariaDB soon, to 5.5, which will end up in all future releases. In the meantime, one can patch MariaDB like so:
Or set max open files within systemd script to a sane number. |
Thanks @cvicentiu ! I was looking at that code myself, but it was too late for me to get the facts. :-p This change looks promising, I pushed new packages with this patch to [testing]. |
The permission denied issue I mentioned above is caused by enabling fs.protected_regular by default. Already opened a pull request for MariaDB, perhaps interesting for @cvicentiu ? |
I'd still be really keen on figuring out why the LimitNOFILE= line didn't work to fix this. If you temporarily replace the mysqld binary with a shell script that just dumps ulimit -a -H and ulimit -a -S somewhere and thengoes on and exec()s the realy mysqld, what do you see there? is the rlimit properly set? |
Looks like the limits are not applied to
... and the result:
The limit on open files is applied to last invocation only. |
FYI: Was fixed. Each subsequent release from this point on should have it incorporated. |
Well, the service file has Wondering if having this in the service file has a good reason... But that's not systemd's issue, I guess we can close here. |
Created another pull request for MariaDB... Running commands with root privileges just to pass an environment value is not that smart. Another one for @cvicentiu ? This would have prevented the complete issue. |
Oh, right. That makes sense. Of course, one might argue whether LimitXYZ= should apply to ExecStartPre= or not... (I do wonder though why ExecStartPre= is used at all here, maybe whatever is started there should actually be started in a separate service ordered before.) but yeah, i think the behaviour in systemd does make some sense the way it is hence. Given that mariadb is fixing this already upstream I guess we can close this here as @eworm-de suggested. |
systemd version the issue has been seen with
Used distribution
Expected behaviour you didn't see
Unexpected behaviour you saw
Steps to reproduce the problem
Upgrade from systemd 239 to 240 and mariadb + galera will not start after reboot
journalctl -u mariadb output:
Jan 20 18:30:36 black systemd[1]: Starting MariaDB 10.3.12 database server...
Jan 20 18:31:03 black sh[13666]: WSREP: Failed to start mysqld for wsrep recovery: '2019-01-20 18:30:37 0 [Note] ./bin/mysqld (mysqld 10.3.12-MariaDB-log) start>
Jan 20 18:31:03 black sh[13666]: /usr/bin/galera_recovery: line 71: 13797 Killed ./bin/mysqld --user=mysql --wsrep_recover --disable-log-error'
Jan 20 18:31:03 black systemd[1]: mariadb.service: Control process exited, code=exited, status=1/FAILURE
Jan 20 18:31:03 black systemd[1]: mariadb.service: Failed with result 'exit-code'.
Jan 20 18:31:03 black systemd[1]: Failed to start MariaDB 10.3.12 database server.
dmesg output:
[125744.312898] Out of memory: Kill process 13797 (mysqld) score 608 or sacrifice child
[125744.312907] Killed process 13797 (mysqld) total-vm:21035008kB, anon-rss:6903752kB, file-rss:4kB, shmem-rss:0kB
[125744.488378] oom_reaper: reaped process 13797 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
mariadb + galera starts successfully on systemd 239
The text was updated successfully, but these errors were encountered: