Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode
Antonin Houska <ah@cybertec.at>
From: Antonin Houska <ah@cybertec.at>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-04-20T14:52:15Z
Lists: pgsql-hackers
Attachments
- fix_identity_check.diff (text/x-diff) patch
Chao Li <li.evan.chao@gmail.com> wrote: > I am continuing to test REPACK, and I found another issue. > > In check_concurrent_repack_requirements(), if a table has no replica identity index, the code falls back to using the primary key if one exists. The problem is that a deferrable primary key cannot be used for this purpose. WAL generation does not consider a deferrable primary key to be a replica identity, so concurrent mode may not receive enough old tuple information to replay concurrent changes. Thanks for finding it, this is certainly a problem. I'm just thinking if it's worth a separate error message. RelationGetIndexList() just ignores the deferrable PK if (replident == REPLICA_IDENTITY_DEFAULT && OidIsValid(pkeyIndex) && !pkdeferrable) relation->rd_replidindex = pkeyIndex; and if there's no other suitable index, the result is that there is no identity index for the table. So the change attached here should be consistent with this approach. -- Antonin Houska Web: https://www.cybertec-postgresql.com
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Remove working test that was supposed to fail
- 2fd787d0aac1 19 (unreleased) landed
-
REPACK CONCURRENTLY: Don't use deferrable primary keys
- 832e220d99af 19 (unreleased) landed