Skip to content

PMM-15161 False auto increment. - #391

Open
JiriCtvrtka wants to merge 5 commits into
mainfrom
PMM-15161-false-auto-increment
Open

PMM-15161 False auto increment.#391
JiriCtvrtka wants to merge 5 commits into
mainfrom
PMM-15161-false-auto-increment

Conversation

@JiriCtvrtka

@JiriCtvrtka JiriCtvrtka commented Jul 22, 2026

Copy link
Copy Markdown

PMM-15161

FB: Percona-Lab/pmm-submodules#4504

Problem

The max_int expression in infoSchemaAutoIncrementQuery detects unsigned
columns 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.

@JiriCtvrtka

Copy link
Copy Markdown
Author

@copilot review

@JiriCtvrtka
JiriCtvrtka marked this pull request as ready for review July 22, 2026 13:00
@JiriCtvrtka
JiriCtvrtka requested a review from a team as a code owner July 22, 2026 13:00
@JiriCtvrtka
JiriCtvrtka requested review from 4nte, ademidoff and maxkondr and removed request for a team July 22, 2026 13:00
@JiriCtvrtka
JiriCtvrtka changed the base branch from main to pmm-3.9.0 July 24, 2026 13:07
@JiriCtvrtka
JiriCtvrtka changed the base branch from pmm-3.9.0 to main July 24, 2026 13:07
@JiriCtvrtka

Copy link
Copy Markdown
Author

@copilot review

@JiriCtvrtka

Copy link
Copy Markdown
Author

@copilot review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants