Skip to content
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 with COLLATE "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_CTYPE versions. Changes in character classification or case conversion can make a lower() expression index miss rows or leave stored rows violating a CHECK still 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 CHECK constraints as NOT VALID, then run VALIDATE CONSTRAINT to 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 running ANALYZE.
  • 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.

Read Official Source

Related PostgreSQL Reference