PMM-15161 False auto increment. - #391
Open
JiriCtvrtka wants to merge 5 commits into
Open
Conversation
Author
|
@copilot review |
JiriCtvrtka
marked this pull request as ready for review
July 22, 2026 13:00
JiriCtvrtka
requested review from
4nte,
ademidoff and
maxkondr
and removed request for
a team
July 22, 2026 13:00
Author
|
@copilot review |
Author
|
@copilot review |
4nte
approved these changes
Jul 28, 2026
maxkondr
approved these changes
Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PMM-15161
FB: Percona-Lab/pmm-submodules#4504
Problem
The
max_intexpression ininfoSchemaAutoIncrementQuerydetects unsignedcolumns with an anchored pattern:
end + (column_type like '% unsigned') - 1
ZEROFILL appends a further attribute after unsigned, so column_type is e.g. int unsigned zerofill and the LIKE '% unsigned' no longer matches. Such columns get the signed bit count, so mysql_info_schema_auto_increment_column_max is reported as half of the real limit (e.g. 2^31-1 instead of 2^32-1) — the column looks twice as full as it is, and any dashboard/alert built on auto_increment / max fires far too early.
Fix
Match unsigned anywhere in column_type:
end + (column_type like '%unsigned%') - 1
unsigned only ever appears in column_type as the numeric attribute, so the
unanchored pattern cannot produce a false positive.
Tests
The collector had no test coverage at all, so this adds both levels:
collector/info_schema_auto_increment_test.go — sqlmock unit test covering the rows → metrics mapping (both metrics per row, labels, gauge type, no extra metrics, expectations met).
collector/info_schema_auto_increment_live_test.go — runs the real query against the server started by docker-compose, so every flavor of the CI database matrix verifies the max_int expression. It creates one table per case — signed int, int unsigned, int unsigned zerofill, smallint unsigned, bigint unsigned — and asserts the exact expected maximum. Skipped under -short.