Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode

From: Antonin Houska <ah(at)cybertec(dot)at>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode
Date: 2026-04-20 14:52:15
Message-ID: 65564.1776696735@localhost
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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

Attachment Content-Type Size
fix_identity_check.diff text/x-diff 594 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Burd 2026-04-20 14:55:09 Re: Add bms_offset_members() function for bitshifting Bitmapsets
Previous Message Tom Lane 2026-04-20 14:42:06 Re: Adding REPACK [concurrently]