Skip to content
/ server Public

MDEV-22186 : Add innodb_buffer_pool_in_core_file to control buffer pool in core#4651

Open
mariadb-TafzeelShams wants to merge 1 commit into10.11from
10.11-MDEV-22186
Open

MDEV-22186 : Add innodb_buffer_pool_in_core_file to control buffer pool in core#4651
mariadb-TafzeelShams wants to merge 1 commit into10.11from
10.11-MDEV-22186

Conversation

@mariadb-TafzeelShams
Copy link
Contributor

@mariadb-TafzeelShams mariadb-TafzeelShams commented Feb 14, 2026

  • The Jira issue number for this PR is: MDEV-22186

Description

MDEV-22186: Add innodb_buffer_pool_in_core_file to control buffer pool in cores

Problem:
There is no control to include or exclude the InnoDB buffer pool from core files,
which can lead to unnecessarily large core dumps or prevent capturing useful
memory state.

Solution:
Introduce a dynamic global system variable innodb_buffer_pool_in_core_file.
When set to OFF (or via --skip-innodb-buffer-pool-in-core-file),
the server attempts to exclude the buffer pool from core dumps using
madvise(MADV_DONTDUMP) where supported. If exclusion cannot be guaranteed,
@@core_file is automatically disabled and a warning is emitted to respect the
user’s intention.

Inspired from mysql commit@891460995137598a6e0ae3684ba1cc6ccd0c3ca3

How can this PR be tested?

Added
mysql-test/suite/innodb/t/mysqld_core_dump_without_buffer_pool.test
mysql-test/suite/innodb/t/mysqld_core_dump_without_buffer_pool_dynamic.test
mysql-test/suite/innodb/t/mysqld_core_dump_without_buffer_pool_with_resizing.test

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch
  • This is a bug fix and the PR is based against the earliest branch in which the bug can be reproduced

Backward compatibility

The default value of innodb_buffer_pool_in_core_file preserves existing behavior:

  • Debug builds (or builds without MADV_DONTDUMP support) will dump the buffer pool.
  • Non-debug builds on systems with MADV_DONTDUMP support will not dump the buffer pool.

This ensures the new variable behaves the same way as previous versions by default.

@mariadb-TafzeelShams mariadb-TafzeelShams changed the title Add innodb_buffer_pool_in_core_file to control buffer pool in core MDEV-22186 : Add innodb_buffer_pool_in_core_file to control buffer pool in core Feb 14, 2026
…l in cores

Problem:
There is no control to include or exclude the InnoDB buffer pool from core files,
which can lead to unnecessarily large core dumps or prevent capturing useful
memory state.

Solution:
Introduce a dynamic global system variable innodb_buffer_pool_in_core_file.
When set to OFF (or via --skip-innodb-buffer-pool-in-core-file),
the server attempts to exclude the buffer pool from core dumps using
madvise(MADV_DONTDUMP) where supported. If exclusion cannot be guaranteed,
@@core_file is automatically disabled and a warning is emitted to respect the
user’s intention.

- innodb_buffer_pool_in_core_file
  Determines whether the buffer pool should be included in core files when
  @@core_file=ON. No effect if @@core_file=OFF.
  Default: OFF on non-debug builds with MADV_DONTDUMP support, ON otherwise.

- innobase_should_madvise_buf_pool()
  Evaluates @@core_file and @@innodb_buffer_pool_in_core_file to determine if
  MADV_DONTDUMP should be applied.

- innobase_disable_core_dump()
  Clears TEST_CORE_ON_SIGNAL, disabling @@core_file when buffer pool exclusion
  cannot be guaranteed.

- buf_pool_t::madvise_dont_dump()
  Applies MADV_DONTDUMP to buffer pool memory. Emits warning and returns false
  if unsupported or fails.

- buf_pool_t::madvise_dump()
  Applies MADV_DODUMP to re-include buffer pool in core dumps. Returns false
  if unsupported or fails.

- buf_pool_t::madvise_update_dump()
  Reevaluates and updates madvise state. If exclusion fails, invokes
  innobase_disable_core_dump().

- buf_pool_t::buf_pool_should_madvise_dont_dump
  Tracks current dump state, protected by buf_pool_t::mutex.

- buf_pool_t::create()
  Initializes buf_pool_should_madvise_dont_dump and conditionally applies
  MADV_DONTDUMP after allocation; disables core dumps on failure.

- buf_pool_t::close()
  Calls madvise_dump() before releasing memory if MADV_DONTDUMP was applied.

- buf_pool_t::resize()
  Invokes madvise_update_dump(true) to reapply correct madvise state after
  resizing.

- innodb_srv_buffer_pool_in_core_file_update()
  Update hook that updates srv_buffer_pool_in_core_file and calls
  buf_pool.madvise_update_dump().

- srv_buffer_pool_in_core_file
  Global variable backing @@innodb_buffer_pool_in_core_file.

Inspired from mysql commit@891460995137598a6e0ae3684ba1cc6ccd0c3ca3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant