From e78756fe20fecf3dc69bcfa629518e44a0a9698c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Mar 2026 14:25:16 +0200 Subject: [PATCH] MDEV-39139 InnoDB fails to start up with small RLIMIT_AS innodb_init_params(): When no innodb_buffer_pool_size_max has been specified, cap the default to a quarter of the address space limit. Reviewed by: Vladislav Vaintroub --- storage/innobase/handler/ha_innodb.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ee9d8e8ceba6a..5fdc5b0f84091 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -3801,6 +3801,20 @@ static int innodb_init_params() min= ut_calc_align (buf_pool.blocks_in_bytes(BUF_LRU_MIN_LEN + BUF_LRU_MIN_LEN / 4), 1U << 20); + +#ifdef RLIMIT_AS + if (innodb_buffer_pool_size_max_default != 0 && + buf_pool.size_in_bytes_max == innodb_buffer_pool_size_max_default) + { + struct rlimit rlimit_as; + if (!getrlimit(RLIMIT_AS, &rlimit_as) && + rlimit_as.rlim_cur != RLIM_INFINITY && + rlimit_as.rlim_cur / 4 < buf_pool.size_in_bytes_max) + buf_pool.size_in_bytes_max= size_t(rlimit_as.rlim_cur / 4) & + ~innodb_buffer_pool_extent_size; + } +#endif + const size_t innodb_buffer_pool_size= buf_pool.size_in_bytes_requested; if (innodb_buffer_pool_size > buf_pool.size_in_bytes_max ||