Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-39139

InnoDB fails to start up with small RLIMIT_AS

    XMLWordPrintable

Details

    • Related to install and upgrade

    Description

      MDEV-38671 changed the default value of the parameter innodb_buffer_pool_size_max to 8 TiB.

      This default value may conflict with a setrlimit(3) setting RLIMIT_AS. On my system, there is a command prlimit whose output starts as follows:

      prlimit

      RESOURCE   DESCRIPTION                             SOFT      HARD UNITS
      AS         address space limit                unlimited unlimited bytes
      

      The shell built-in command ulimit -v on my GNU/Linux system is tied to RLIMIT_AS as well.

      If we configure a small RLIMIT_AS, InnoDB will fail to start up:

      ulimit -v 1048576
      mkdir /tmp/f
      sql/mariadbd --no-defaults --innodb --datadir=/tmp/f
      

      2026-03-20  8:32:43 0 [ERROR] mariadbd: Out of memory (Needed 0 bytes)
      2026-03-20  8:32:43 0 [ERROR] InnoDB: Cannot map innodb_buffer_pool_size_max=8388608m
      

      Side note: The message ER_OUTOFMEMORY is misleading, because it is displaying a 32-bit signed number instead of a 64-bit integer. On big-endian systems, it might report the incorrect value 8<<(40-32) as Needed 2048 bytes, but I did not test that. This was reported as MDEV-39138.
      InnoDB will start up successfully given a suitably small innodb_buffer_pool_size_max:

      sql/mariadbd --no-defaults --innodb --innodb-buffer-pool-size-max=128m --datadir=/tmp/f
      

      2026-03-20  8:39:09 0 [Note] InnoDB: log sequence number 0; transaction id 3
      2026-03-20  8:39:09 0 [Note] Plugin 'FEEDBACK' is disabled.
      2026-03-20  8:39:09 0 [Note] Plugin 'wsrep-provider' is disabled.
      2026-03-20  8:39:09 0 [ERROR] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some plugins may be not loaded
      2026-03-20  8:39:09 0 [ERROR] Can't open and lock privilege tables: Table 'mysql.servers' doesn't exist
      2026-03-20  8:39:09 0 [Note] Server socket created on IP: '0.0.0.0', port: '3306'.
      2026-03-20  8:39:09 0 [Note] Server socket created on IP: '::', port: '3306'.
      2026-03-20  8:39:09 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.db' doesn't exist
      2026-03-20  8:39:09 0 [ERROR] Aborting
      

      I tested the following patch:

      diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
      index 96ae8155377..dc4771a430f 100644
      --- a/storage/innobase/handler/ha_innodb.cc
      +++ b/storage/innobase/handler/ha_innodb.cc
      @@ -3744,6 +3744,15 @@ static int innodb_init_params()
         min= ut_calc_align<size_t>
           (buf_pool.blocks_in_bytes(BUF_LRU_MIN_LEN + BUF_LRU_MIN_LEN / 4),
            1U << 20);
      +
      +#ifdef RLIMIT_AS
      +  struct rlimit rlimit_as;
      +  if (!getrlimit(RLIMIT_AS, &rlimit_as) &&
      +      rlimit_as.rlim_cur / 4 < buf_pool.size_in_bytes_max)
      +    buf_pool.size_in_bytes_max= 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 ||
      

      With this patch in place, the innodb_buffer_pool_size_max would be limited to a quarter of RLIMIT_AS, leaving some space for further virtual memory allocation, such as heap memory allocation as well as innodb_log_file_mmap=ON for a moderate innodb_log_file_size:

      sql/mariadbd --no-defaults --innodb --datadir=/tmp/f
      

      with RLIMIT_AS of 1GiB and the above patch

      2026-03-20  8:48:03 0 [Note] InnoDB: innodb_buffer_pool_size_max=256m, innodb_buffer_pool_size=128m
      ...
      2026-03-20  8:48:03 0 [Note] InnoDB: log sequence number 0; transaction id 3
      ...
      

      If a similar resource limit exists on Microsoft Windows, we would have to account for it as well. I found out that there was a Windows System Resource Manager (WSRM) that was deprecated beginning with Windows Server® 2012.

      Attachments

        Issue Links

          Activity

            People

              wlad Vladislav Vaintroub
              marko Marko Mäkelä
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.