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 1x1LS8-00588w-2l for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2026 10:10:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x1LS5-005eaB-1u for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Sep 2026 10:10:49 +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 1x1LS5-005ea3-0r for pgsql-hackers@lists.postgresql.org; Tue, 01 Sep 2026 10:10:49 +0000 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x1LS2-00000002Lu9-3EEf for pgsql-hackers@postgresql.org; Tue, 01 Sep 2026 10:10:48 +0000 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-482fc2b44a7so755164f8f.2 for ; Tue, 01 Sep 2026 03:10:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1788257446; x=1788862246; darn=postgresql.org; h=message-id:date:content-transfer-encoding:content-type:mime-version :comments:references:in-reply-to:subject:cc:to:from:from:to:cc :subject:date:message-id:reply-to:content-type; bh=Ww46fWUaaHtKjHO4yS0itvoTU5MQl5h5jX+DXuLDQuI=; b=rFh3PKgz017y9la8nQIw+JZALmIM9o6PlAg5cV+DJU3BAVkaJIfhicP5Vkw7/60Lsm rkxBzYQ/Gkie2PNk4dWzaPZ3L7FKG3f0wP3lFooUpSBf3W3KxCxaEtsgDNU4MfmU/mwO oizbVbMnXiMLa2Mpa3hDIQrWDQk4xVdMnCgdL3s57pVV9JrkVQOmJH0Ko2mghiROftM2 55g/k4P302ckRsIPeJNdy/jbkPjKMlxEY1VLoeY26pV8fK7rJGfWfts+xRzQTxD2qEo3 vIibFjx8GpxsQY5/p+Fa0KszvkhS9+VaDaMSLxByLsNH4erZVnuKyYADUbz2PQOMWn5A mI9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788257446; x=1788862246; h=message-id:date:content-transfer-encoding:content-type: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 :content-type; bh=Ww46fWUaaHtKjHO4yS0itvoTU5MQl5h5jX+DXuLDQuI=; b=buwFWO5iCThuPGIe7Orq1lBirwgginCAz2lJiw5OpS36y1JtbNp9aRAaNl8ip7U4u+ dg0bV/6JePewZzEiT7i3erFOeqII3+aecC8fRuLXgmiYRNU8iH1qo4iPgV8R4Hk2KPWH c4Zt+M952ChO9Gd/gA+SINJjfOcFBFPYNcX8gRAqG54MEvOwtijkEPN8pr9683OYz306 x8+jfbevP3TqB3VnEGoqLIPVcQjle6PnvPvRs0kL6lCWqfJ+KiARCUFGGIN3qWvaKIFN Y0+XMAJeCWUb7I4SXeP+gRXvdPMisXS1gQTbHQwMv5NgxeZQNnm/VYsOlEJ49GQ5gbCz M9Og== X-Forwarded-Encrypted: i=1; AKwUvBxPnOGY0SV/h+eYe3imvtf54y/SHxMxuLpRCu59WPxj5YPA4HjEvIAWpHQChxWdJuRYt1zNKQoXewld4WrR@postgresql.org X-Gm-Message-State: AFuF++mAWASbNzHWeBtYr/ac5MdvivSR/+J9aqEAjpALCW+srtX2f2PP owXJ1kjYW+RcssHnPGx08zVUj+i2Gtahi9vofiaYFliPRRZCIIxb0hKMWscCmWE7SGs= X-Gm-Gg: AYBFou1dDGPGYlol8uzPhmGvvmoOn+zMyvRqAtNSiI0YhaAyR48OJ9kT3UVemC8zbWm f1nbYRiVimjtHS+OhcsTIW8q30oK+IYWcc6DTv5zabQIZEQlGimFyITZTloo0/LhyXS3cPwrQV+ GaiavrXrPXo644rYFlbwgW55qntcP0a40udj6ywRD8hscVjZYpwD9jg4FQNijKrm/sENwa6SXYT N2PbdKFN0tgpTzTK02IJ6SaMbeVxgLsQbgMCgBuYOZDO9/QgmBkNTUXv40Q9HQdc+iyRSBzOx8y KlSAYDviLiFIi/zu9OshyVhHIM//nkLhuMfnrnSPqwAMGu1rm5Y61X36ZE2dJgevuot/6OHwAPC hW57dtOQULYliIjtEXD0KQ7g14hh2hh5xZmM+iPpYh/yVEJHvre2G0AIml0ECtieswoRJs1yfp6 oVAUA9BAn7os9ZExnyiBrMQFj1/moZ7s+Y7jrP1f2Mym/n3rBHjy8qXVymaPd2QdsxxfEQoHhpt A== X-Received: by 2002:a5d:5d86:0:b0:47f:773f:2d68 with SMTP id ffacd0b85a97d-482f79bac52mr46177717f8f.16.1788257445798; Tue, 01 Sep 2026 03:10:45 -0700 (PDT) Received: from localhost (109-81-170-190.rct.o2.cz. [109.81.170.190]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48442d791a7sm3987636f8f.31.2026.09.01.03.10.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Sep 2026 03:10:45 -0700 (PDT) From: Antonin Houska To: Chao Li cc: Matthias van de Meent , Nathan Bossart , pgsql-hackers@postgresql.org, alvherre@kurilemu.de Subject: Re: REPACK (CONCURRENTLY) fails when replica identity index is dropped In-reply-to: <54DABC65-787E-4DA9-895C-140A3CF862CF@gmail.com> References: <54DABC65-787E-4DA9-895C-140A3CF862CF@gmail.com> Comments: In-reply-to Chao Li message dated "Fri, 28 Aug 2026 14:04:15 +0800." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Sep 2026 12:10:44 +0200 Message-ID: <30425.1788257444@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Chao Li wrote: > After dropping the index, pg_class.relreplident is still 'i', but the cor= responding pg_index entry is deleted, so the table is left in a stale state= . If we only check whether the REPLICA IDENTITY index is valid in REPACK, t= hat prevents REPACK from starting, but doesn=E2=80=99t resolve the stale st= ate itself. >=20 > We cannot assume the intended replacement replica identity after removing= an explicitly selected index. For example, the user might want DEFAULT, FU= LL, or maybe another index. Should we instead prevent dropping of an index = while it is used as REPLICA IDENTITY? >=20 > The attached diff makes a change in the direction, like this: > ``` > evantest=3D# CREATE TABLE t (a INT PRIMARY KEY, b INT, c TEXT); > CREATE TABLE > evantest=3D# CREATE UNIQUE INDEX i ON t (a); > CREATE INDEX > evantest=3D# ALTER TABLE t REPLICA IDENTITY USING INDEX i; > ALTER TABLE > evantest=3D# DROP INDEX i; > ERROR: cannot drop index "i" because it is used as replica identity > HINT: Use ALTER TABLE ... REPLICA IDENTITY to change the table's replica= identity first. I agree that the core issue is that we allow dropping an index that is being used as replica identity. Regarding catalog entries already broken this way, it appears that pg_upgra= de fixes them because pg_dump does not issue "ALTER TABLE ... REPLICA IDENTITY USING INDEX ..." if there is not identity index. Thus after pg_restore, pg_class(relreplident) becomes REPLICA_IDENTITY_DEFAULT. --=20 Antonin Houska Web: https://www.cybertec-postgresql.com