Conversation
…anged under the data The version of libc/ICU that defines text sort order is recorded in the catalog (pg_database.datcollversion, pg_collation.collversion, PG15+). When the library changes underneath — an OS upgrade, a new base image, a restore onto another host — every btree over text sorted by it may be silently out of order: lookups miss rows and UNIQUE stops catching duplicates. Postgres warns at connect time and repairs nothing; nothing in pgbot read the versions. A gauge collector reads this database's mismatches (NULL versions — C/POSIX — cannot drift and are excluded). The finding is critical when the database default drifted, since every unqualified text index uses it, and warn for a named collation. The remediation is REINDEX then REFRESH COLLATION VERSION, and the caveat says why the order matters: refreshing first silences the warning and leaves the indexes corrupt. The integration test forges a stale datcollversion as superuser, runs the real collector, checks the row and the finding, and confirms REFRESH clears it. New `collation` section in --json; SchemaVersion 1.3.0 (additive).
…on on PG14 The version check shared a query with datcollversion, which doesn't exist before PG15, so PG14 errored instead of skipping.
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.
What and why
New finding:
collation_version_mismatch(PG15+).The libc/ICU version that defines text sort order is recorded in the catalog
(
pg_database.datcollversion,pg_collation.collversion). When the library changesunder the data (OS upgrade, new base image, restore onto another host), every btree
over text sorted by it may be silently out of order: lookups miss rows and
UNIQUEstops catching duplicates. Postgres warns at connect time and repairs nothing.
collation.sqlreading this database's mismatches. NULLversions (C/POSIX) can't drift and are excluded.
warn for a named collation. Object
db:<name>, scopeinfra.REFRESH COLLATION VERSION; a caveat says why theorder matters (refreshing first silences the warning and leaves the indexes corrupt).
Meta, summary,docs/findings/collation_version_mismatch.md, regenerateddocs index, CHANGELOG.
collationsection in--json;SchemaVersion→ 1.3.0 (additive).Heads-up: #46 also bumps the schema (to 1.4.0, with its own 1.3.0 file). Whichever
lands second needs a renumber; happy to rebase onto #46 if it goes first.
Verification
PG18 (glibc 2.41), windows/amd64:
TestIntegration_collationVersionMismatchforges a staledatcollversionassuperuser, runs the real collector, checks the row and the finding, then confirms
REFRESH COLLATION VERSIONclears it.collect+cmd/pgbotintegration suites green.collationsection in
--json; cleared after refresh.explain-findingreads the page offline.scripts/gate.shgreen.Checklist
scripts/gate.shpasses (builds HEAD, not just the working tree)EXPLAIN ANALYZE; findings stay deterministic (computed in Go)model.Context/--json/ the store — collation names and versions only--jsonchange is additive,model.SchemaVersionbumped + schema regenerateddocs/findings/<id>.mdpage + catalog entry