[MDEV-26542] Memory allocation pre-flight check feature Created: 2021-09-05 Updated: 2021-09-07 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Server |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Roel Van de Paar | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | affects-tests, memory | ||
| Description |
|
A command like
Cannot possibly succeed when a limited amount of free memory is available. However, both optimized and debug builds will immediately commence executing the command and attempt memory allocation, thereby quickly and needlessly filling up all available memory, leading to OOM termination by the kernel of either this process or any other running on the server, and all consequences thereof. This feature request for a simple pre-flight check. Pseudo code:
|
| Comments |
| Comment by Daniel Black [ 2021-09-07 ] |
|
Problems on "free memory" checks is it can be a far margin from what is measure to what is really free once normal operations begin. There's also a disparity between allocated (in a virtual memory space manner) and paged in. There's also the potential for VMs to be resized with more ram (balooning), and other effects. With the amount of things that can go wrong, I think its over engineering to try to guess that amount upfrount. I'd suggest a lazy allocation approach like MDEV-25340, lazily initialize each of the key blocks as needed. Its a quick check ahead of a moderately quick initialization and this would allow a very large allocation to not consume very much memory until its actually used. This would also help with MDEV-16607, by even with the default values, only consuming what is used rather than being wasted with amounts of initialized cache that won't be used. Tied in with the mechanisms of |