Files
cozystack/api
Andrey Kolkov 05477de6f9 fix(postgres): rebuild indexes on C.UTF-8 when the Debian release changes
PostgreSQL records no collation version for a libc locale named
C.<codeset>, so the collation repair never counted a column declared
COLLATE "C.UTF-8", or a database created with LC_COLLATE 'C.UTF-8', as
stale. Yet the C.UTF-8 Debian patched into the glibc of bullseye and the
one glibc ships since 2.35 order characters differently. After the move
to the standard-trixie images an index on such a column misses most of
its keys and amcheck reports "item order invariant violated", on
PostgreSQL 13 as on 17, and the pass said nothing on PostgreSQL 15 and
later.

Such a collation, and a database default of such a locale, now take the
Debian release of the server's build (the pgdg suffix of server_version)
as their version, so their indexes go through the same resumable rebuild
as any other stale collation. PostgreSQL keeps nothing to compare that
release with, so the pass records the release each database was repaired
for in the cozystack.collation_release setting, once the database is
repaired without a failure. A database without the setting gets the
release of the server the pass first finds it on. The pass looks before
it waits for the rollout, so the old release is recorded even when that
run then fails, and a retry after the primary has restarted still
rebuilds. A database first seen when the server already runs the new
glibc is recognised by a libc collation, or a libc database default,
whose recorded version differs from the server's. Anything else, a new
cluster included, is recorded as repaired for the release it runs and
nothing is rebuilt. That includes a database an earlier pass already
repaired on the new glibc: it refreshed the libc versions and left no
sign of the move, so its indexes on C.* collations need a REINDEX by
hand.

Before PostgreSQL 15 the pass warned that a C.<codeset> database default
could not be checked; it is repaired now, so the warning no longer fires
for it. A range partition key on such a collation is reported once, by
the run that rebuilds its indexes, since PostgreSQL logs no version
mismatch for it later.

Refs: #5459
Fixes: b40be51a6b ("fix(postgres): move the default flavor to patched standard-trixie images")
Fixes: a10e449a56 ("fix(postgres): rebuild indexes whose collation changed version")
Assisted-by: LLM
Signed-off-by: Andrey Kolkov <androndo@gmail.com>
2026-11-28 09:32:53 +07:00
..