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 1vkkuD-001jvK-0X for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Jan 2026 15:23:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vkkuC-00EJIS-0v for pgsql-hackers@arkaria.postgresql.org; Tue, 27 Jan 2026 15:23:00 +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 1vkkuB-00EJIJ-1p for pgsql-hackers@lists.postgresql.org; Tue, 27 Jan 2026 15:23:00 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vkku8-00000000itE-2ZGJ for pgsql-hackers@postgresql.org; Tue, 27 Jan 2026 15:22:59 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfout.stl.internal (Postfix) with ESMTP id 4124F1D00097; Tue, 27 Jan 2026 10:22:54 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-05.internal (MEProxy); Tue, 27 Jan 2026 10:22:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kurilemu.de; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to; s=fm1; t=1769527374; x= 1769613774; bh=R1YUjLAZ4ytVth9NOjXH+782rTeFP9lR4GYsrKIci5w=; b=V QfzikwdYmoc0zOwzuxny7nJRxs7/tHJDnXzmOsDb8g6dFck6NoHLWcG25rKSF17u Q+Cv/qI5qz8ymO6Txla8veyzlLKcST110siKuG+FhXXSrmhFZv0a0H3rAKmCHyuW BSYNKRvyZA4637mVTjMecvNqYT+NqFiBNeJkZSRAzBJB6quN3f5vKshK3gY1ROhM weC9Cyvs6jfV9XLvyutgcjZ0pYr1PXqU8Fz7ss5WCK5jGhWnv6BdWSLqS6yQvvyN l+TqGw4uLNfa4nGO1bDUyRGClUrFSNiL2ZfRmFHRHoecbo50NnavuKdmGh20lOB1 Ig0xaBOQfnbE/0ynOXukQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1769527374; x=1769613774; bh=R 1YUjLAZ4ytVth9NOjXH+782rTeFP9lR4GYsrKIci5w=; b=PC/CdCx+IfdAVDpSc odsV2Ud4ZWDTg6gzsYioKqdxV6GemITzlwSD0Hbble+QzMnn4zejlAT18JOKVM6c l/ye6sigGibzK4ZRmA7RTHWcfT0iD/3DTqoWe0hC3xsLVlPgftaBVwvdqMZlP/0d 29AVWrb1abgJbQmhZpfhTkIxKkj/JHq8TDgsUyRng0+0etj17LmzGy2h6YhFMZqr Ap3sY/kz8EZqkLKDtyoUqQl0t/Gx+x5yjeCunpGdMeQZIgT9FtI0MrYjPyNl7xOz z9/S7dgiwR5iFngLKCcDWG00PctUscumnpMSlR7YxXFijBppWwoX70MQwoW4Fkwn md2Gg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduiedtkeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesthekredttddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeetuedvheffkeevgfeuheevteevkefggedttdeufeeuheduuddthfef fffhjeefffenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopegvgigtlhhushhiohhnsehgmhgrihhlrdgtohhmpdhrtghpthht ohepmhhihhgrihhlnhhikhgrlhgrhigvuhesghhmrghilhdrtghomhdprhgtphhtthhope hnohgrhheslhgvrggusghorghtrdgtohhmpdhrtghpthhtohepmhhitghhrggvlhesphgr qhhuihgvrhdrgiihiidprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsth hgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Jan 2026 10:22:53 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1769527371; bh=DWX2IYIAYwS+I7tlVAHiMv6TgOOrtFtsE885NDTgdsY=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=W7ZWa1oP591NKLWZ1sYf1/aJft0OJrYMZA6lM4FI2Y4YaBxFZrw9/Qotofck4Dvb6 NTigsAQGfddzfmXuc45e1N6sd8HUI/HDUlINvQs+PAmbWuu+fKd9jbMUEXZ+zJMYmX 1wsJp393T4QF3BFYF/kDB70Ll4SbcC3O8NaJlGuiCXLNqg2hjJDqUouu3XECxF5z6B IC/QPwpijffE8UreWS5yNDvH/jq9/yC/sn0mFTiu56dug7N171fbkVCK6TdC2+/U0c xG4C0k/ZUTqRUuMbqHuQxmFa5/rGqgYWEVbxyiPhRO3D5S1tOr/b4Gm5T5GrBI6e8J AQ0YhJAz1Ckig== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id D79EE7A; Tue, 27 Jan 2026 16:22:51 +0100 (CET) Date: Tue, 27 Jan 2026 16:22:51 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Mihail Nikalayeu Cc: Alexander Lakhin , Michael Paquier , Noah Misch , PostgreSQL Hackers Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY Message-ID: <202601271449.xxtnvk7kbbrt@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-Jan-25, Mihail Nikalayeu wrote: > Hello, Álvaro! > > Fixes are in attachment. I think the comment message and comments are good > enough to explain the changes. Actually, about this fragment ... if we track these ancestors for all indexes, not just the ones that we consider as arbiters, don't we risk doing something stupid when a completely unrelated index is being reindexed? Namely, also consider that unrelated index as arbiter. if (ancestors != NIL && !list_member_oid(ancestors_seen, linitial_oid(ancestors))) { foreach_oid(parent_idx, rootResultRelInfo->ri_onConflictArbiterIndexes) { if (list_member_oid(ancestors, parent_idx)) { arbiterIndexes = lappend_oid(arbiterIndexes, indexoid); arbiters_listidxs = lappend_int(arbiters_listidxs, listidx); break; } } /* * Track which ancestor we saw, add other indexes that seem to have * the same ancestor as "unparented". */ ancestors_seen = lappend_oid(ancestors_seen, linitial_oid(ancestors)); } else unparented_idxs = lappend_int(unparented_idxs, listidx); I think the lappend_oid(ancestors_seen) should happen inside the "if list_member_oid(ancestors)" block instead. I'm imagining a test case like: CREATE TABLE test.tblparted(i int primary key, updated_at timestamp) PARTITION BY RANGE (i); CREATE TABLE test.tbl_partition PARTITION OF test.tblparted FOR VALUES FROM (0) TO (10000) WITH (parallel_workers = 0); CREATE INDEX unrelated_index ON test.tblparted (updated_at); where the reindex is REINDEX INDEX CONCURRENTLY test.tbl_partition_updated_at_idx; This doesn't fail, but I suspect it's just from me not setting up the test case correctly. I'm also missing a comment for why the use linitial_oid(ancestors) is correct. At first I thought we should walk the entire ancestors list, and do this dance if any OID there matches the ancestors_seen list. I convinced myself that this isn't necessary because the scenario is a single table being under REINDEX CONCURRENTLY, so the two indexes would have the same root relation (top-most ancestor index). So comparing linitial() is correct. -- Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/ "La persona que no quería pecar / estaba obligada a sentarse en duras y empinadas sillas / desprovistas, por cierto de blandos atenuantes" (Patricio Vogel)