public inbox for [email protected]
help / color / mirror / Atom feedFrom: Antonin Houska <[email protected]>
To: Chao Li <[email protected]>
Cc: PostgreSQL-development <[email protected]>
Subject: Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode
Date: Mon, 20 Apr 2026 16:52:15 +0200
Message-ID: <65564.1776696735@localhost> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Chao Li <[email protected]> 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
Attachments:
[text/x-diff] fix_identity_check.diff (594B, 2-fix_identity_check.diff)
download | inline diff:
diff --git a/src/backend/commands/repack.c b/src/backend/commands/repack.c
index 67364cc60e3..8cfc3fde5c7 100644
--- a/src/backend/commands/repack.c
+++ b/src/backend/commands/repack.c
@@ -925,7 +925,8 @@ check_concurrent_repack_requirements(Relation rel, Oid *ident_idx_p)
* work and is not implemented yet.
*/
ident_idx = RelationGetReplicaIndex(rel);
- if (!OidIsValid(ident_idx) && OidIsValid(rel->rd_pkindex))
+ if (!OidIsValid(ident_idx) && OidIsValid(rel->rd_pkindex) &&
+ !rel->rd_ispkdeferrable)
ident_idx = rel->rd_pkindex;
if (!OidIsValid(ident_idx))
ereport(ERROR,
view thread (10+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode
In-Reply-To: <65564.1776696735@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox