[MDEV-30734] [ERROR] mariadbd: pam: cannot exec /usr/lib64/mysql/plugin/auth_pam_tool_dir/auth_pam_tool (errno: 12 "Cannot allocate memory") Created: 2023-02-23  Updated: 2023-03-13  Resolved: 2023-02-27

Status: Closed
Project: MariaDB Server
Component/s: Plugin - pam
Affects Version/s: 10.5.18
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Claudio Nanni Assignee: Sergei Golubchik
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

CentOS 7


Issue Links:
Relates
relates to MDEV-26212 PAM authentication fails with ENOMEM Closed

 Description   

A customer reports the problem which is solved by decreasing the memory used by mariadb to less than half the ram.
It is reproducible by having mariadb using 50%+1 of RAM.

It seems similar to this:
MDEV-26212
MDEV-24535

Which is fixed in 10.5.16 and the patch is also present in 10.5.18 enterprise.

So apparently it didn't solve.



 Comments   
Comment by Sergei Golubchik [ 2023-02-27 ]

It's not something we can fix. MDEV-26212 explains the problem:

  • before MDEV-26212 fix the server did
    • fork() — which reserved free memory in the same amount that the server was currently using
    • exec() — which threw all that memory away and replaced the process with a new one
  • the problem was that if the server already takes more than 50% of the RAM and Linux is not allowed to overcommit, fork() will fail.
  • MDEV-26212 replaced fork+exec with posix_spawn() that technically doesn't have to fork, because it knows he process will be replaced anyway.
  • but it depends on how posix_spawn() is implemented in glibc
    • CentOS 7 has glibc-2.17-196.el7.x86_64 where posix_spawn() calls fork() or vfork(). Which brings the problem back
    • On my laptop I see glibc-2.36 and there posix_spawn() does not seem to fork anymore.
Comment by Sergei Golubchik [ 2023-02-27 ]

2.17: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/posix/spawni.c;h=2d3ae941dd19f0348ed95c0b957c68c3c0e9815d;hb=c758a6861537815c759cba2018a3b1abb1943842#l106

2.36: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/spawni.c;h=ee843a2247bb577e9a8bcaca3a93af4831651be0;hb=c804cd1c00adde061ca51711f63068c103e94eef#l375

Comment by Claudio Nanni [ 2023-02-27 ]

Just checked: 2.26 introduced the change ( on 2.25 is still present the vfork()

Generated at Thu Feb 08 10:18:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.