Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEpz4-004SyG-3A for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 14:52:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wEpz3-003SbW-33 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Apr 2026 14:52:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wEpz3-003SbO-1y for pgsql-hackers@lists.postgresql.org; Mon, 20 Apr 2026 14:52:21 +0000 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wEpz0-0000000297N-3c7N for pgsql-hackers@postgresql.org; Mon, 20 Apr 2026 14:52:20 +0000 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-43fe3e22e33so2117473f8f.0 for ; Mon, 20 Apr 2026 07:52:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1776696737; x=1777301537; darn=postgresql.org; h=message-id:date:mime-version:comments:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=zbetJ/MtF0sg2Vota+4AOQXPEUl8hhPkqlivLCjkKIU=; b=r34Qe3w3tHfBwuhcqQqzQT1r0GInrNWuSQB+0VrNQVPX1b26bksmgXGt4sPTxsnVe6 NhjGhdQ7bBZo8PO6CGyHRET9Nf7l0tqcufWSyJmvkz03dWIFWke+DHUaUkV6Wt0DF4y0 iyRTIBIzBRVuun/b4DDwLPN2e/zRWjvBH6Uqm0zOdvQXVICwA456G0MjQK8ngb6ssrj4 TvS0Ke/mwAWC7wk6M+Ikiysib7oaZ1HJiDF1iQIpyg0U3XuzGBEAD2OjXfhUrJbS5uSH qdy2ElvI9r2zNpHnlclxpF11/YovIayZygCTC+7pi1h47tHflhhrdVsI1Tduht0bGcBm 4GbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776696737; x=1777301537; h=message-id:date:mime-version:comments:references:in-reply-to :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=zbetJ/MtF0sg2Vota+4AOQXPEUl8hhPkqlivLCjkKIU=; b=lclkVr8nxhLETe15HJnfbZkFSLneewNPw0YCl2Lf2jOIyq8Sm2W9l3tQgxq1eG7Nhg SAklH7NodmG+f/2vvLj45CZTK09wbsVQQNj5/DMWSk36LOUm91+Q9yiIYO4efJijS84/ NAUfpxMJQz2EFvX2SnDQTdCQDK7i7G5ExhW9bLKUy7f6idSlFpFuFaxG8YuYuVWjIXM3 JPpPXr2bUF3YS829VHFzJKY4jWuj8nuKvOMc5ePXjtRN8PhVV+FUvU8/Eqo45fmpwxqq ftlG/4h3ozmW5CNxz5BsnpWzja6so3WYCffk80Odv68ZiEJbLZd0xOE8qF2lOFZ9RwXt Kzaw== X-Gm-Message-State: AOJu0YwjYv8tXjSSLlWJma+hRHcms9ocIMkjYkP6NYJ3cn/iNHNIb6kT CRtPl7wG9NL7oWRDIMwAkubhmSVhyDyRh7CIQTtVSCYwVw5F6iruABY2sUFtJiVjedc1vMJCg+y 8ApC/ X-Gm-Gg: AeBDiesI3qhm3fTwfFe9caqTL6EKwhgnmtmtnuOFIWmZdhkwFt0l9m0ZRR4paPyUAcI 2ymivfEBegG8f6Uzaa3pITWRHwNFflCs2uv/T6EaUBj2cbFuOPoURy/kYSay/xKrCP/GnY8Zm4g JXe48G9rUAmTU7zIUZuVacvy6xnmc4NTnhcyJZAwGYUfM+Z1oXGbXo/T9LNO4X2anx1nRgZwKOO CX0C9Gi5nmF4QM9tYuSI/M+LcD7K0LjFaqsih0Qp7xwsuT4TsyXLjgsHIMbRrAXa3qspRSZpqQN k+P5ak5c855xPHZO+jXCtyrysrnFs+0Ag9sgtVDVUoyoDlRnYmArhlRAT4u4pKe5EFgY7USTnZ3 GANu15YbiOTOr3G2M1nVLSSme3cbwP43CpnndnqdluKWxzivicITc8EEB/0ivjcnT3XoqpIvfd1 8FBBPLjsTFNg7W6xWNtxumbUE/Tjec0vGW+pDsGfhpnn8qoW10LGmUM4vnHg== X-Received: by 2002:a05:6000:61e:b0:43d:6fb7:fee2 with SMTP id ffacd0b85a97d-43fe3e20b32mr22963417f8f.45.1776696737078; Mon, 20 Apr 2026 07:52:17 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43fe4e3a18csm33640415f8f.20.2026.04.20.07.52.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 07:52:16 -0700 (PDT) From: Antonin Houska To: Chao Li cc: PostgreSQL-development Subject: Re: repack: fix a bug to reject deferrable primary key fallback for concurrent mode In-reply-to: <10DD5E13-B45D-44F1-BE08-C63E00ABCAC0@gmail.com> References: <10DD5E13-B45D-44F1-BE08-C63E00ABCAC0@gmail.com> Comments: In-reply-to Chao Li message dated "Fri, 17 Apr 2026 11:35:14 +0800." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Date: Mon, 20 Apr 2026 16:52:15 +0200 Message-ID: <65564.1776696735@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain Chao Li 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 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=fix_identity_check.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, --=-=-=--