Skip to content
/ server Public

MDEV-38936 Proactive handling of InnoDB tablespace full condition#4721

Open
FarihaIS wants to merge 1 commit intoMariaDB:mainfrom
FarihaIS:mdev-38936
Open

MDEV-38936 Proactive handling of InnoDB tablespace full condition#4721
FarihaIS wants to merge 1 commit intoMariaDB:mainfrom
FarihaIS:mdev-38936

Conversation

@FarihaIS
Copy link
Contributor

@FarihaIS FarihaIS commented Mar 2, 2026

Description

InnoDB write failures occur when tablespace files exceed filesystem size limits (e.g. 16TB on ext4, 2TB on ext3 - varies by filesystem). Current behavior logs errors but continues accepting transactions, causing repeated failures, user disruption, and potential data integrity issues.

Add proactive monitoring by emitting warnings when InnoDB tablespaces approach a configurable size threshold. Warnings use a tiered frequency approach to balance early notification with log spam prevention.

Key features:

  • Three new system variables:
    • innodb_tablespace_size_warning_threshold (default 16TB): Maximum
      tablespace size in bytes before warnings begin
    • innodb_tablespace_size_warning_pct (default 70%): Percentage of
      threshold at which to start emitting warnings
    • innodb_tablespace_size_warning_enabled (default ON): Andon cord to
      enable/disable the warning feature
  • Tiered warning frequency:
    • Below warning_pct: No warnings
    • Between warning_pct and 90%: At most twice per 10% interval with
      minimum 5% gap (e.g., 70%, 77%, 81%, 89%)
    • Above 90%: Every 1% increase (90%, 91%, 92%, etc.)
  • Per-tablespace tracking with automatic reset on TRUNCATE/DROP or
    threshold changes
  • Zero overhead when disabled
  • Progressive warnings capped at 100%

Implementation hooks into fsp_try_extend_data_file() for O(1) size checking during tablespace extension. Adds 11 bytes per tablespace (m_last_size_warning_pct, m_last_warning_threshold, m_warning_count_in_decade) to fil_space_t structure.

Release Notes

Added proactive InnoDB tablespace size monitoring to prevent filesystem size limit failures. Three new system variables enable configurable warning thresholds with tiered warning frequency:

  • innodb_tablespace_size_warning_threshold (default 16TB): Maximum size before warnings
  • innodb_tablespace_size_warning_pct (default 70%): When to start warnings
  • innodb_tablespace_size_warning_enabled (default ON): Feature toggle

Warnings use tiered frequency: none below threshold, at most twice per 10% between threshold and 90%, then every 1% above 90%. This provides early notification without flooding error logs.

How can this PR be tested?

Execute the innodb.tablespace_size_warning test in mysql-test-run. This commit adds a test in the innodb suite.

The test validates:

  1. All three system variables are visible and have correct default values
  2. Basic warning emission when tablespace exceeds configured percentage
  3. Configurable warning percentage (tests both 70% and 80% thresholds)
  4. Threshold set to 0 disables warnings
  5. Enable/disable toggle (innodb_tablespace_size_warning_enabled)
  6. TRUNCATE TABLE resets warning state

Expected warning behavior in error log:

  • Below innodb_tablespace_size_warning_pct (default 70%): No warnings
  • Between 70-89%: At most twice per 10% with minimum 5% gap
    Example: [Warning] InnoDB: Tablespace 'test/t1' size 7340032 bytes (70%) exceeds warning threshold of 10485760 bytes
    Example: [Warning] InnoDB: Tablespace 'test/t1' size 8388608 bytes (77%) exceeds warning threshold of 10485760 bytes
  • Above 90%: Every 1% increase
    Example: [Warning] InnoDB: Tablespace 'test/t1' size 9437184 bytes (90%) exceeds warning threshold of 10485760 bytes
    Example: [Warning] InnoDB: Tablespace 'test/t1' size 9543680 bytes (91%) exceeds warning threshold of 10485760 bytes

Basing the PR against the correct MariaDB version

  • This is a new feature, and the PR is based against the main branch.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@grooverdan grooverdan added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Mar 2, 2026
@mikegriffin
Copy link
Contributor

Feature request, allow additional use cases (example, tablespace becomes larger than expected):

  • Make a configurable warning percent (tablespace_size_warning_pct) so warnings can start earlier without changing the byte threshold
  • Replace hard-coded 90 with a named constant (high_resolution_pct)
  • No change above high_resolution_pct: print on every 1% increase
  • Between tablespace_size_warning_pct and high_resolution_pct: print at most twice per 10% (example, 70%, 77%, 81%, 89%, 90%, 91%, 92%)

@FarihaIS FarihaIS marked this pull request as ready for review March 2, 2026 23:10
@Thirunarayanan Thirunarayanan requested review from dr-m and iMineLink March 3, 2026 05:01
@FarihaIS FarihaIS force-pushed the mdev-38936 branch 2 times, most recently from a1c335d to 64ab2ed Compare March 3, 2026 17:29
InnoDB write failures occur when tablespace files exceed filesystem size
limits. Current behavior logs errors but continues accepting
transactions, causing repeated failures and potential data integrity
issues.

Add proactive monitoring by emitting warnings when InnoDB tablespaces
approach a configurable size threshold. Warnings use a tiered frequency
approach to balance early notification with log spam prevention.

Key features:
- Three new system variables:
  * innodb_tablespace_size_warning_threshold (default 16TB): Maximum
    tablespace size in bytes before warnings begin
  * innodb_tablespace_size_warning_pct (default 70%): Percentage of
    threshold at which to start emitting warnings
  * innodb_tablespace_size_warning_enabled (default ON): Andon cord to
    enable/disable the warning feature
- Tiered warning frequency:
  * Below warning_pct: No warnings
  * Between warning_pct and 90%: At most twice per 10% interval with
    minimum 5% gap (e.g., 70%, 77%, 81%, 89%)
  * Above 90%: Every 1% increase (90%, 91%, 92%, etc.)
- Per-tablespace tracking with automatic reset on TRUNCATE/DROP or
  threshold changes
- Zero overhead when disabled
- Progressive warnings capped at 100%

Implementation hooks into fsp_try_extend_data_file() for O(1) size
checking during tablespace extension. Adds 11 bytes per tablespace
(m_last_size_warning_pct, m_last_warning_threshold,
m_warning_count_in_decade) to fil_space_t structure.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
@FarihaIS
Copy link
Contributor Author

FarihaIS commented Mar 3, 2026

@mikegriffin I have just pushed some new changes. Could you please take a look and confirm whether the new implementation addresses the additional use cases you mentioned above? Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

4 participants