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

Finite RLIMIT_AS makes InnoDB publish a non-extent-aligned buffer-pool maximum

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.11, 11.4, 11.8, 12.3, 13.0, 12.3.3
    • 10.11, 11.4, 11.8, 12.3
    • Can result in unexpected behaviour

    Description

      When `RLIMIT_AS` is finite and lower than the default 8 TiB
      `innodb_buffer_pool_size_max`, MariaDB caps the maximum buffer-pool size with a
      bit mask. The mask clears the bits present in the extent value itself instead
      of clearing all lower bits, so the published maximum need not be a multiple of
      the extent size.

      With an address-space limit of 5,000,000,000 bytes, the official release starts
      but reports a maximum of 1,241,611,392 bytes, whose remainder modulo 8 MiB is
      97,408. The same image without the finite limit reports an aligned value.

      Steps to reproduce

      set -eu
      IMAGE='mariadb@sha256:dd9b303aed4f4890ed09f766d8ca9ddfd176c0c6f6267feff53b3192ec65a979'
      CONTROL='mdev-rlimit-control'
      TRIGGER='mdev-rlimit-trigger'
      OWNER="edbf-report-mcfg04-$$"
       
      owned_remove() {
        NAME=$1
        if docker inspect --format '{{ index .Config.Labels "io.encryptiondbfuzz.owner" }}' \
             "$NAME" 2>/dev/null | grep -Fqx "$OWNER"; then
          docker rm -f "$NAME" >/dev/null 2>&1 || true
        fi
      }
      cleanup() {
        owned_remove "$CONTROL"
        owned_remove "$TRIGGER"
      }
      trap cleanup EXIT
       
      run_common() {
        NAME=$1
        shift
        docker run --detach --name "$NAME" \
          --label "io.encryptiondbfuzz.owner=$OWNER" \
          --network none --read-only --cap-drop ALL \
          --security-opt no-new-privileges=true --pids-limit 160 \
          --memory 768m --cpus 1 --user 999:999 \
          --tmpfs /var/lib/mysql:rw,nosuid,nodev,size=512m,uid=999,gid=999 \
          --tmpfs /run/mysqld:rw,nosuid,nodev,size=16m,uid=999,gid=999 \
          --tmpfs /tmp:rw,nosuid,nodev,size=64m,uid=999,gid=999 \
          --env MARIADB_ALLOW_EMPTY_ROOT_PASSWORD=1 "$@"
      }
       
      wait_and_query() {
        NAME=$1
        READY=0
        for I in $(seq 1 90); do
          if docker exec --user 999:999 "$NAME" mariadb --protocol=socket \
               --socket=/run/mysqld/mysqld.sock -uroot -NBe 'SELECT @@port' \
               2>/dev/null | grep -qx 3306; then
            READY=1
            break
          fi
          sleep 1
        done
        test "$READY" -eq 1
        docker exec --user 999:999 "$NAME" mariadb --protocol=socket \
          --socket=/run/mysqld/mysqld.sock -uroot -NBe \
          'SELECT @@innodb_buffer_pool_size_max,@@innodb_buffer_pool_size,
                  MOD(@@innodb_buffer_pool_size_max,8388608)'
      }
       
      run_common "$CONTROL" "$IMAGE"
      echo 'control: max current remainder'
      wait_and_query "$CONTROL"
      owned_remove "$CONTROL"
       
      run_common "$TRIGGER" --entrypoint /usr/bin/prlimit "$IMAGE" \
        --as=5000000000:5000000000 -- docker-entrypoint.sh mariadbd
      echo 'trigger: max current remainder'
      wait_and_query "$TRIGGER"
      

      Actual result

      control: max current remainder
      8796093022208    134217728    0
      trigger: max current remainder
      1241611392       134217728    97408
      

      The trigger server was otherwise healthy. This release build does not execute
      the Debug assertion that requires the maximum to be extent-aligned.

      Expected result

      The finite-limit cap should be rounded down with an extent-alignment mask such
      as `~(extent_size - 1)`. `innodb_buffer_pool_size_max` should remain an exact
      multiple of the configured extent size in both release and Debug builds.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              csfuzz csfuzz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 1.25h
                  1.25h
                  Logged:
                  Time Spent - 0d
                  0d

                  Git Integration

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