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 1vNahJ-007iof-1b for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 17:49:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNahH-002e3k-12 for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Nov 2025 17:49:55 +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 1vNahG-002e3b-2y for pgsql-hackers@lists.postgresql.org; Mon, 24 Nov 2025 17:49:55 +0000 Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNahE-001GrE-2f for pgsql-hackers@postgresql.org; Mon, 24 Nov 2025 17:49:54 +0000 Received: from phl-compute-11.internal (phl-compute-11.internal [10.202.2.51]) by mailfhigh.stl.internal (Postfix) with ESMTP id 3FF747A0178; Mon, 24 Nov 2025 12:49:51 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-11.internal (MEProxy); Mon, 24 Nov 2025 12:49:51 -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=fm2; t=1764006591; x= 1764092991; bh=ysBkgJSIkIrhAM1IltDW+c3rA8doS5ggqnxwbmypUHs=; b=l ECscRZ/Epa4jEQ3K7Mh3FeomvfmYyN+9FeQs85YyTOOQJ4Ka6yEd39sUeYP+VelT PKFiPWvLTbLxk+2D12IKxbDkuBUCyk2Qx49c47Gjsdi7hlOpTgUMV0fi16vm3dNY Fp0U+4B3A8rF2qeS3nVMURfFsxLOxC/tvVAzcvhEGbfX5C2sV05UCrKDRgwsSvO+ /trn/mEClKzWjBQEd6GF/QdAns1zjvE3+iqfemvmzvXCwkQ9Y8eOR65MOdqqPagy Xv2bapHuIdeSB16/oFRON51Hh+/U0deIurMYDCDAsfDVPvnKMAh5YlsRMKz8PbQX vZTPWoPhJ0XGcw81P3ooQ== 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=fm3; t=1764006591; x=1764092991; bh=y sBkgJSIkIrhAM1IltDW+c3rA8doS5ggqnxwbmypUHs=; b=jUlNj9IIduQjw+gTg n06IIPwrTOBHUY+XAaX8e/QuFkm2awDpJXxVk5pjyTnPxX/waAXbnZIkq/S0A0If RMGQFub6aGFoqB/EaCxpqXRCyBayymf2USMKvE3uEd/hOoMCFGth3emtnCr3MDM5 WKRrBoSWlc64YgpPylfRSXIMipFCouhTa461ioBXufB4u9rfDIQknoIR/yTGHkME rNJmK/TW+6ICsE8gNkTOAYvMiv08djdpLFM2CL8U27Z0K3CcoYd0WvZT5aHoMgoS OAIfmHE7TON0RjF4L5bsxqf5GCfupf4faKhydC6xEUMqib2xcFgW1hhVr2vNdlVz fE+BA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvfeelvdehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkgggtugfgjgesmhekreertddtjeenucfhrhhomheplmhlvhgrrhho ucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsehkuhhrihhlvghmuhdruggvqeenucggtf frrghtthgvrhhnpeegudetudejheduveevgeehjeegleevveevvdeutdejtdekuefhheeh geevtdejteenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgv sehkuhhrihhlvghmuhdruggvpdhnsggprhgtphhtthhopeegpdhmohguvgepshhmthhpoh huthdprhgtphhtthhopehmihhhrghilhhnihhkrghlrgihvghusehgmhgrihhlrdgtohhm pdhrtghpthhtohepnhhorghhsehlvggruggsohgrthdrtghomhdprhgtphhtthhopehmih gthhgrvghlsehprghquhhivghrrdighiiipdhrtghpthhtohepphhgshhqlhdqhhgrtghk vghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ie3de48e3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 24 Nov 2025 12:49:50 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kurilemu.de; s=schmee; t=1764006587; bh=yJeacpPZgBZhHwWf+TxYEatx7AIE4+PYAIDQPCRF59g=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=6GSxwR8PNfmbkjoHVCVML5U7C/nwVVyQ2o7E1ROX/7tYAt4w2CaYx7pOS1ixXmY/N TX9DDhG3qpD9lWo0I6yFtROq47DSsPRBBqNHkpOKxGFuxQ9gVjyl35NgRE0rkiMKm5 p6NWBhn7Y9F0+y6qODh5MYtwrOh04lw7XmTCxfdfC+dmcFXgdPMiQWQM21PW5lCS+h 2i0KEOfMvPnB7hdQYBTDkneft1bB+P0ATwYmHG3ElrxFe9APEN8DX86ewRgl6xn8sX Wxgeoy7J5JNhZSisAy/Pxuu4+esXCFJg0glsjDpyYatFoV/q1fTY/t+zBeugJy16vi jf3B4wREIcAPw== Received: by schmee.kurilemu.internal (Postfix, from userid 1000) id E3FA576; Mon, 24 Nov 2025 18:49:47 +0100 (CET) Date: Mon, 24 Nov 2025 18:49:47 +0100 From: =?utf-8?Q?=C3=81lvaro?= Herrera To: Mihail Nikalayeu Cc: Michael Paquier , Noah Misch , PostgreSQL Hackers Subject: Re: Issues with ON CONFLICT UPDATE and REINDEX CONCURRENTLY Message-ID: <202511241747.ftgal46yiriw@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5y4cmmlgtowecaaf" 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 --5y4cmmlgtowecaaf Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit On 2025-Nov-22, Mihail Nikalayeu wrote: > 2) some updates for 0001 test stability (related to [0]). This patch would bring the committed test file up to date with what you last submitted. However, I didn't understand what is the problem with the original formulation, and I haven't seen the test fail ... can you explain? -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "El número de instalaciones de UNIX se ha elevado a 10, y se espera que este número aumente" (UPM, 1972) --5y4cmmlgtowecaaf Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-Improve-test-case-stability.patch.txt" From dede9ad2366fb4987af96a8dd4d6a33e9f832676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= Date: Mon, 24 Nov 2025 18:46:24 +0100 Subject: [PATCH] Improve test case stability Author: Mihail Nikalayeu --- src/backend/utils/time/snapmgr.c | 1 + .../index-concurrently-upsert-predicate.out | 11 +++++++--- .../expected/index-concurrently-upsert.out | 11 +++++++--- .../index-concurrently-upsert-predicate.spec | 21 ++++++++++++------- .../specs/index-concurrently-upsert.spec | 19 +++++++++++------ 5 files changed, 44 insertions(+), 19 deletions(-) diff --git a/src/backend/utils/time/snapmgr.c b/src/backend/utils/time/snapmgr.c index 24f73a49d27..434abbf6b6f 100644 --- a/src/backend/utils/time/snapmgr.c +++ b/src/backend/utils/time/snapmgr.c @@ -459,6 +459,7 @@ InvalidateCatalogSnapshot(void) pairingheap_remove(&RegisteredSnapshots, &CatalogSnapshot->ph_node); CatalogSnapshot = NULL; SnapshotResetXmin(); + INJECTION_POINT("pre-invalidate-catalog-snapshot-end", NULL); INJECTION_POINT("invalidate-catalog-snapshot-end", NULL); } } diff --git a/src/test/modules/injection_points/expected/index-concurrently-upsert-predicate.out b/src/test/modules/injection_points/expected/index-concurrently-upsert-predicate.out index af602bdc048..3d9512c8fc7 100644 --- a/src/test/modules/injection_points/expected/index-concurrently-upsert-predicate.out +++ b/src/test/modules/injection_points/expected/index-concurrently-upsert-predicate.out @@ -1,6 +1,6 @@ -Parsed test spec with 4 sessions +Parsed test spec with 5 sessions -starting permutation: s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s4_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 +starting permutation: s5_noop s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 injection_points_attach ----------------------- @@ -16,12 +16,16 @@ injection_points_attach (1 row) +step s5_noop: + step s3_start_create_index: CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_special_duplicate ON test.tbl(abs(i)) WHERE i < 10000; +s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end step s1_start_upsert: INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now(); +step s5_noop: <... completed> step s4_wakeup_define_index_before_set_valid: SELECT injection_points_detach('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid'); @@ -39,7 +43,7 @@ injection_points_wakeup step s2_start_upsert: INSERT INTO test.tbl VALUES(13,now()) ON CONFLICT (abs(i)) WHERE i < 100 DO UPDATE SET updated_at = now(); -step s4_wakeup_s1_from_invalidate_catalog_snapshot: +step s5_wakeup_s1_from_invalidate_catalog_snapshot: SELECT injection_points_detach('invalidate-catalog-snapshot-end'); SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); @@ -81,6 +85,7 @@ injection_points_wakeup (1 row) +s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end step s1_start_upsert: <... completed> step s2_start_upsert: <... completed> step s3_start_create_index: <... completed> diff --git a/src/test/modules/injection_points/expected/index-concurrently-upsert.out b/src/test/modules/injection_points/expected/index-concurrently-upsert.out index eb6fd9592df..a9e8bb5d00e 100644 --- a/src/test/modules/injection_points/expected/index-concurrently-upsert.out +++ b/src/test/modules/injection_points/expected/index-concurrently-upsert.out @@ -1,6 +1,6 @@ -Parsed test spec with 4 sessions +Parsed test spec with 5 sessions -starting permutation: s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s4_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 +starting permutation: s5_noop s3_start_create_index s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 injection_points_attach ----------------------- @@ -16,12 +16,16 @@ injection_points_attach (1 row) +step s5_noop: + step s3_start_create_index: CREATE UNIQUE INDEX CONCURRENTLY tbl_pkey_duplicate ON test.tbl(i); +s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end step s1_start_upsert: INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now(); +step s5_noop: <... completed> step s4_wakeup_define_index_before_set_valid: SELECT injection_points_detach('define-index-before-set-valid'); SELECT injection_points_wakeup('define-index-before-set-valid'); @@ -39,7 +43,7 @@ injection_points_wakeup step s2_start_upsert: INSERT INTO test.tbl VALUES (13,now()) ON CONFLICT (i) DO UPDATE SET updated_at = now(); -step s4_wakeup_s1_from_invalidate_catalog_snapshot: +step s5_wakeup_s1_from_invalidate_catalog_snapshot: SELECT injection_points_detach('invalidate-catalog-snapshot-end'); SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); @@ -81,6 +85,7 @@ injection_points_wakeup (1 row) +s1: NOTICE: notice triggered for injection point pre-invalidate-catalog-snapshot-end step s1_start_upsert: <... completed> step s2_start_upsert: <... completed> step s3_start_create_index: <... completed> diff --git a/src/test/modules/injection_points/specs/index-concurrently-upsert-predicate.spec b/src/test/modules/injection_points/specs/index-concurrently-upsert-predicate.spec index 13897d88bce..725f6f22295 100644 --- a/src/test/modules/injection_points/specs/index-concurrently-upsert-predicate.spec +++ b/src/test/modules/injection_points/specs/index-concurrently-upsert-predicate.spec @@ -5,7 +5,7 @@ # - s2: UPSERT the same tuple # - s3: CREATE UNIQUE INDEX CONCURRENTLY (with a predicate) # -# - s4: control concurrency via injection points +# - s4 and s5: control concurrency via injection points setup { @@ -27,6 +27,7 @@ setup { SELECT injection_points_set_local(); SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait'); + SELECT injection_points_attach('pre-invalidate-catalog-snapshot-end', 'notice'); SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait'); } step s1_start_upsert @@ -62,11 +63,6 @@ step s4_wakeup_s1 SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict'); } -step s4_wakeup_s1_from_invalidate_catalog_snapshot -{ - SELECT injection_points_detach('invalidate-catalog-snapshot-end'); - SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); -} step s4_wakeup_s2 { SELECT injection_points_detach('exec-insert-before-insert-speculative'); @@ -78,11 +74,22 @@ step s4_wakeup_define_index_before_set_valid SELECT injection_points_wakeup('define-index-before-set-valid'); } +session s5 +step s5_noop +{ +} +step s5_wakeup_s1_from_invalidate_catalog_snapshot +{ + SELECT injection_points_detach('invalidate-catalog-snapshot-end'); + SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); +} + permutation + s5_noop(s1_start_upsert notices 1) s3_start_create_index(s1_start_upsert, s2_start_upsert) s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert(s1_start_upsert) - s4_wakeup_s1_from_invalidate_catalog_snapshot + s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 diff --git a/src/test/modules/injection_points/specs/index-concurrently-upsert.spec b/src/test/modules/injection_points/specs/index-concurrently-upsert.spec index b07a6408b3b..4487834aa8e 100644 --- a/src/test/modules/injection_points/specs/index-concurrently-upsert.spec +++ b/src/test/modules/injection_points/specs/index-concurrently-upsert.spec @@ -26,6 +26,7 @@ setup { SELECT injection_points_set_local(); SELECT injection_points_attach('check-exclusion-or-unique-constraint-no-conflict', 'wait'); + SELECT injection_points_attach('pre-invalidate-catalog-snapshot-end', 'notice'); SELECT injection_points_attach('invalidate-catalog-snapshot-end', 'wait'); } step s1_start_upsert @@ -61,11 +62,6 @@ step s4_wakeup_s1 SELECT injection_points_detach('check-exclusion-or-unique-constraint-no-conflict'); SELECT injection_points_wakeup('check-exclusion-or-unique-constraint-no-conflict'); } -step s4_wakeup_s1_from_invalidate_catalog_snapshot -{ - SELECT injection_points_detach('invalidate-catalog-snapshot-end'); - SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); -} step s4_wakeup_s2 { SELECT injection_points_detach('exec-insert-before-insert-speculative'); @@ -77,11 +73,22 @@ step s4_wakeup_define_index_before_set_valid SELECT injection_points_wakeup('define-index-before-set-valid'); } +session s5 +step s5_noop +{ +} +step s5_wakeup_s1_from_invalidate_catalog_snapshot +{ + SELECT injection_points_detach('invalidate-catalog-snapshot-end'); + SELECT injection_points_wakeup('invalidate-catalog-snapshot-end'); +} + permutation + s5_noop(s1_start_upsert notices 1) s3_start_create_index(s1_start_upsert, s2_start_upsert) s1_start_upsert s4_wakeup_define_index_before_set_valid s2_start_upsert(s1_start_upsert) - s4_wakeup_s1_from_invalidate_catalog_snapshot + s5_wakeup_s1_from_invalidate_catalog_snapshot s4_wakeup_s2 s4_wakeup_s1 -- 2.47.3 --5y4cmmlgtowecaaf--