Percona PostgreSQL Blog· Pablo Svampa·· 22d ago
Percona Maps How glibc Changes Can Break PostgreSQL Clusters
Ten ways a glibc change can break your PostgreSQL cluster
Key Takeaway
Percona compares PostgreSQL clusters on Rocky Linux 8. 9 and 9. 3 using the sv_SE locale, showing that glibc changes can affect indexes, constraints, partitions, generated columns, materialized views, and query results.
Why It Matters
The article maps how glibc locale changes affect indexes, constraints, partitions, and stored results, showing why REINDEX alone is insufficient.
Technical Breakdown · Distilled from the original source
New collation rules leave old data in place
- The experiment promotes a Rocky Linux 9.3 replica of an 8.9 primary. Under
sv_SE, glibc 2.28 treats W as a variant of V, while 2.34 sorts W as a separate letter after V. Byte ordering withCOLLATE "C"is unchanged. - A B-tree built under the old rules can miss existing rows under the new ones. A unique index can then admit duplicates, and a foreign key can reject an insert even though the parent exists. Compare index and sequential scan results and check B-trees with
amcheck. - PostgreSQL does not track
LC_CTYPEversions. Changes in character classification or case conversion can make alower()expression index miss rows or leave stored rows violating aCHECKstill marked valid.
Repair beyond reindexing
- If writes occurred after the switch, find duplicate keys with a sequential scan and decide which rows to keep before reindexing. Check for exclusion constraint conflicts as well. For text range partitions, check for cross-partition duplicates, then delete misplaced rows from their child partitions and reinsert them through the parent for routing under the new rules.
- Drop and re-add affected
CHECKconstraints asNOT VALID, then runVALIDATE CONSTRAINTto check existing rows. How to handle violations is a business decision. Recompute stored generated columns and refresh materialized views before refreshing the recorded collation versions and runningANALYZE. - Inventory collations at the database and column levels, among others, and rehearse with real data. Even after dump and restore with all index checks passing, a text range query can return a different row count under the new comparison rules.
Source: Percona PostgreSQL Blog· percona.com
PG Radar summarizes verified changes and impact. Read the original post for full technical details and code samples.