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.94.2) (envelope-from ) id 1s4PwH-003h90-T2 for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 18:53:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1s4PwE-004dzF-1d for pgsql-hackers@arkaria.postgresql.org; Tue, 07 May 2024 18:53:18 +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.94.2) (envelope-from ) id 1s4PwD-004dz5-MH for pgsql-hackers@lists.postgresql.org; Tue, 07 May 2024 18:53:18 +0000 Received: from mail-yb1-xb2b.google.com ([2607:f8b0:4864:20::b2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s4PwB-0022md-Vv for pgsql-hackers@postgresql.org; Tue, 07 May 2024 18:53:17 +0000 Received: by mail-yb1-xb2b.google.com with SMTP id 3f1490d57ef6-de5a7b18acdso3400282276.3 for ; Tue, 07 May 2024 11:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1715107994; x=1715712794; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=1k9kdaowjzCSTf8l+hMJGkE9P9kJFiSQCl5WQ9EWE7k=; b=e32i3nyKdzFZYV3wh2GbWsY5NoqtqW5RqfF1VwLrwwwpODfpqu8vR86p4zXBgqHIq+ lD0P3Gqer8LRU5Xds7wl8Hq7vJYxAswBFk3JHpd20EE+6JI1ilgIYRZA3A17miAG/C26 gtMNZe9VDtBGqFT8wRMG4xvLhooPQzY3jqqIM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715107994; x=1715712794; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1k9kdaowjzCSTf8l+hMJGkE9P9kJFiSQCl5WQ9EWE7k=; b=QnpD0BBWsK41hKJ0LI8SCZev0co7RmoiyZjEI+RwY4lOT9KEFSunKLonhVUr10Yy0p drTATa5jGh5KF8sNH8W/fweVwB0umZE8Q7FLDRaQV2Yd7A+WdJKq68GBMtDVMJI4Aj7g +pa0gMZxIL6LebYXZO2u9AyLL/6frTJtNZtlO6Dmbauxv30USXOuQEwZd/EFNAqn6+MA KJlk7xBZfkbkLphOx0OkzpX7pi5RI9V+sM/sFFG2iCpAh/CCLZtigAME787VRlIQKBom 2uDNdn78DpwzSG2V/I1WwXJcbCZwTc4JSIPbg2W3ZvIGeNtCu7BwtDpWvv6dxipDeAcn 0tBg== X-Forwarded-Encrypted: i=1; AJvYcCWB+FMby/yKBceweaLjsXyeghjUXVCO/kKst81wUMHMG3f9hIOBZByWgcP4J7nK+c0PjAxaI5dPCJ16YT5dYs+fBS7b/tMaXrpgM9BT X-Gm-Message-State: AOJu0YzIqEWQ3Btmt8axzyKegV2b9qNs+YG8Rf/2MGc2LoVyKHFekRRQ 5Mx4bQ1Ig8IL1Sm/KzOeBaYSiO4rXPnTdIAPDs/i3p9d0JUCszgtJ4jTUGOKqg== X-Google-Smtp-Source: AGHT+IGVZQ/8m+C60StwvUzhPtOww9bUj3zxxKrph3pdr/jpPWqFhEILeoKH3sPQbw+CAQtEt/sAqQ== X-Received: by 2002:a25:2f4a:0:b0:de5:a15a:7118 with SMTP id 3f1490d57ef6-debb9dbd8e6mr553146276.42.1715107993860; Tue, 07 May 2024 11:53:13 -0700 (PDT) Received: from rfd.leadboat.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id p186-20020a2529c3000000b00dc6d51c8555sm2737217ybp.17.2024.05.07.11.53.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 May 2024 11:53:12 -0700 (PDT) Date: Tue, 7 May 2024 11:53:10 -0700 From: Noah Misch To: Michael Paquier Cc: Heikki Linnakangas , Tom Lane , pgsql-hackers Subject: Re: Weird test mixup Message-ID: <20240507185310.d3@rfd.leadboat.com> References: <2393552.1710458033@sss.pgh.pa.us> <20240501231214.40@rfd.leadboat.com> <20240502193555.a1.nmisch@google.com> <20240506212324.2e.nmisch@google.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="u9qoEUcSzx4glh93" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --u9qoEUcSzx4glh93 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 07, 2024 at 10:17:49AM +0900, Michael Paquier wrote: > On Mon, May 06, 2024 at 02:23:24PM -0700, Noah Misch wrote: > > Here's how I've patched it locally. It does avoid changing the backend-side, > > which has some attraction. Shall I just push this? > > It looks like you did not rebase on top of HEAD Yes, the base was 713cfaf (Sunday). > A side effect is that this causes the conditions to pile > up on a running server when running installcheck, and assuming that > many test suites are run on a server left running this could cause > spurious failures when failing to find a new slot. Yes, we'd be raising INJ_MAX_CONDITION more often under this approach. > Always resetting > condition->name when detaching a point is a simpler flow and saner > IMO. > > Overall, this switches from one detach behavior to a different one, Can you say more about that? The only behavior change known to me is that a given injection point workload uses more of INJ_MAX_CONDITION. If there's another behavior change, it was likely unintended. > which may or may not be intuitive depending on what one is looking > for. FWIW, I see InjectionPointCondition as something that should be > around as long as its injection point exists, with the condition > entirely gone once the point is detached because it should not exist > anymore on the server running, with no information left in shmem. > > Through your patch, you make conditions have a different meaning, with > a mix of "local" definition, but it is kind of permanent as it keeps a > trace of the point's name in shmem. I find the behavior of the patch > less intuitive. Perhaps it would be interesting to see first the bug > and/or problem you are trying to tackle with this different behavior > as I feel like we could do something even with the module as-is. As > far as I understand, the implementation of the module on HEAD allows > one to emulate a breakpoint with a wait/wake, which can avoid the > window mentioned in step 2. Even if a wait point is detached > concurrently, it can be awaken with its traces in shmem removed. The problem I'm trying to tackle in this thread is to make src/test/modules/gin installcheck-safe. $SUBJECT's commit 5105c90 started that work, having seen the intarray test suite break when run concurrently with the injection_points test suite. That combination still does break at the exit-time race condition. To reproduce, apply this attachment to add sleeps, and run: make -C src/test/modules/gin installcheck USE_MODULE_DB=1 & sleep 2; make -C contrib/intarray installcheck USE_MODULE_DB=1 Separately, I see injection_points_attach() populates InjectionPointCondition after InjectionPointAttach(). Shouldn't InjectionPointAttach() come last, to avoid the same sort of race? I've not tried to reproduce that one. --u9qoEUcSzx4glh93 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="repro-inj-exit-race-v1.patch" diff --git a/src/test/modules/gin/expected/gin_incomplete_splits.out b/src/test/modules/gin/expected/gin_incomplete_splits.out index 15574e5..4bc5ef1 100644 --- a/src/test/modules/gin/expected/gin_incomplete_splits.out +++ b/src/test/modules/gin/expected/gin_incomplete_splits.out @@ -126,6 +126,12 @@ SELECT injection_points_attach('gin-leave-leaf-split-incomplete', 'error'); select insert_until_fail(:next_i) as next_i \gset NOTICE: failed with: error triggered for injection point gin-leave-leaf-split-incomplete +SELECT pg_sleep(10); + pg_sleep +---------- + +(1 row) + SELECT injection_points_detach('gin-leave-leaf-split-incomplete'); injection_points_detach ------------------------- diff --git a/src/test/modules/gin/sql/gin_incomplete_splits.sql b/src/test/modules/gin/sql/gin_incomplete_splits.sql index ebf0f62..fb66bac 100644 --- a/src/test/modules/gin/sql/gin_incomplete_splits.sql +++ b/src/test/modules/gin/sql/gin_incomplete_splits.sql @@ -118,6 +118,7 @@ select verify(:next_i); SELECT injection_points_attach('gin-leave-leaf-split-incomplete', 'error'); select insert_until_fail(:next_i) as next_i \gset +SELECT pg_sleep(10); SELECT injection_points_detach('gin-leave-leaf-split-incomplete'); -- Verify that a scan works even though there's an incomplete split diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c index a74a4a2..f9e8a1f 100644 --- a/src/test/modules/injection_points/injection_points.c +++ b/src/test/modules/injection_points/injection_points.c @@ -18,6 +18,7 @@ #include "postgres.h" #include "fmgr.h" +#include "libpq/pqsignal.h" #include "miscadmin.h" #include "storage/condition_variable.h" #include "storage/dsm_registry.h" @@ -213,6 +214,14 @@ injection_points_cleanup(int code, Datum arg) void injection_error(const char *name) { + if (strcmp(name, "gin-leave-leaf-split-incomplete") == 0 && + !injection_point_allowed(name)) + { + sigprocmask(SIG_SETMASK, &BlockSig, NULL); + pg_usleep(20 * USECS_PER_SEC); /* let other suite detach */ + sigprocmask(SIG_SETMASK, &UnBlockSig, NULL); + } + if (!injection_point_allowed(name)) return; --u9qoEUcSzx4glh93--