Public bug reported:

(this bug has been reproduced in an LXC container running on Arch Linux,
that's why the strange kernel version)

On Ubuntu 18.04, systemd runs mysqld in two steps. First:

ExecStartPre=/usr/share/mysql/mysql-systemd-start pre

In this script, one of the steps is: mysqld --verbose --help --innodb-
read-only

Then:

ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

It's the first mysqld (with --help) which is a problem. The problem
happens because, due to PermissionsStartOnly=true, systemd runs
ExecStartPre commands with insane limits. In particular:

Aug 08 18:19:23 mysql57 bash[13131]: core file size          (blocks, -c) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: data seg size           (kbytes, -d) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: scheduling priority             (-e) 0
Aug 08 18:19:23 mysql57 bash[13131]: file size               (blocks, -f) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: pending signals                 (-i) 63701
Aug 08 18:19:23 mysql57 bash[13131]: max locked memory       (kbytes, -l) 16384
Aug 08 18:19:23 mysql57 bash[13131]: max memory size         (kbytes, -m) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: open files                      (-n) 
1073741816 <--- see this?
Aug 08 18:19:23 mysql57 bash[13131]: pipe size            (512 bytes, -p) 8
Aug 08 18:19:23 mysql57 bash[13131]: POSIX message queues     (bytes, -q) 819200
Aug 08 18:19:23 mysql57 bash[13131]: real-time priority              (-r) 0
Aug 08 18:19:23 mysql57 bash[13131]: stack size              (kbytes, -s) 8192
Aug 08 18:19:23 mysql57 bash[13131]: cpu time               (seconds, -t) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: max user processes              (-u) 63701
Aug 08 18:19:23 mysql57 bash[13131]: virtual memory          (kbytes, -v) 
unlimited
Aug 08 18:19:23 mysql57 bash[13131]: file locks                      (-x) 
unlimited

When running with such a high "ulimit -n" (again, this is something
which systemd does by default for ExecStartPre), "mysqld --help"
consumes unimaginable amounts of memory and even causes swapping and
page allocation failures on my PC with 16 GB of RAM.

Workaround in /etc/systemd/system/mysql.service.d/override.conf:

[Service]
ExecStartPre=
ExecStartPre=/bin/sh -c 'ulimit -n 1024 ; /usr/share/mysql/mysql-systemd-start 
pre'

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: mysql-server-5.7 5.7.27-0ubuntu0.18.04.1
Uname: Linux 5.2.5-arch1-1-ARCH x86_64
ApportVersion: 2.20.9-0ubuntu7.7
Architecture: amd64
Date: Thu Aug  8 18:29:38 2019
Logs.var.log.daemon.log:
 
MySQLConf.etc.mysql.conf.d.mysql.cnf: [mysql]
MySQLConf.etc.mysql.conf.d.mysqldump.cnf:
 [mysqldump]
 quick
 quote-names
 max_allowed_packet     = 16M
MySQLConf.etc.mysql.mysql.conf.d.mysqld_safe_syslog.cnf:
 [mysqld_safe]
 syslog
MySQLVarLibDirListing: False
ProcEnviron:
 LANG=en_US.UTF-8
 TERM=xterm-256color
 SHELL=/bin/bash
 XDG_RUNTIME_DIR=<set>
 PATH=(custom, no user)
SourcePackage: mysql-5.7
UpgradeStatus: No upgrade log present (probably fresh install)
modified.conffile..etc.mysql.mysql.conf.d.mysqld.cnf: [modified]
mtime.conffile..etc.mysql.mysql.conf.d.mysqld.cnf: 2019-08-08T17:51:27.927907

** Affects: mysql-5.7 (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug bionic

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1839527

Title:
  mysqld eats more than 16 GB of memory on startup

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1839527/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to