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 1rbzPw-000KOQ-2Y for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Feb 2024 08:54:28 +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 1rbzPu-00ECsn-Oc for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Feb 2024 08:54:26 +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 1rbzPu-00ECsf-Al for pgsql-hackers@lists.postgresql.org; Mon, 19 Feb 2024 08:54:26 +0000 Received: from forwardcorp1a.mail.yandex.net ([178.154.239.72]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rbzPr-007xfl-VX for pgsql-hackers@lists.postgresql.org; Mon, 19 Feb 2024 08:54:25 +0000 Received: from mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net [IPv6:2a02:6b8:c18:595:0:640:e312:0]) by forwardcorp1a.mail.yandex.net (Yandex) with ESMTPS id 6802161115; Mon, 19 Feb 2024 11:54:21 +0300 (MSK) Received: from smtpclient.apple (unknown [2a02:6b8:b081:3::1:31]) by mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net (smtpcorp/Yandex) with ESMTPSA id KsLjCu6IdiE0-FeMQdyhA; Mon, 19 Feb 2024 11:54:21 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1708332861; bh=Q/pGcpHd7ybQZLGOw0ciXckBFP8OK2m6qAL4Ry6zfUU=; h=Message-Id:To:Date:References:Cc:In-Reply-To:From:Subject; b=tNP6YL5Mwz3bVkgbxo5wbphIvMHmwblaI9udoPrDH/1KyUFg3JrCCPBSj4o33WwQc G3dyrBGwITJBwvU0LysaQK1r6UWxdSNZ9JHpXKPlaEgLxo7Ci/Jj1lNoJjDrMYHR7G QNScTt4kck68kJE/ZMDD/dFn0nMTZ3TUQ1Dd4oVE= Authentication-Results: mail-nwsmtp-smtp-corp-main-83.vla.yp-c.yandex.net; dkim=pass header.i=@yandex-team.ru Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.4\)) Subject: Re: Injection points: some tools to wait and wake From: "Andrey M. Borodin" In-Reply-To: Date: Mon, 19 Feb 2024 11:54:20 +0300 Cc: Postgres hackers , Ashutosh Bapat Content-Transfer-Encoding: quoted-printable Message-Id: <59A65AD3-B392-447A-AF12-2073F63F23A7@yandex-team.ru> References: To: Michael Paquier X-Mailer: Apple Mail (2.3696.120.41.1.4) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On 19 Feb 2024, at 09:01, Michael Paquier wrote: >=20 > Thoughts and comments are welcome. Hi Michael, thanks for your work on injection points! I want to test a bunch of = stuff using this facility. I have a wishlist of functionality that I'd like to see in injection = points. I hope you will find some of these ideas useful to improve the = feature. 1. injection_points_wake() will wake all of waiters. But it's not = suitable for complex tests. I think there must be a way to wake only = specific waiter by injection point name. 2. Alexander Korotkov's stopevents could be used in isolation tests. = This kind of tests is perfect for describing complex race conditions. = (as a side note, I'd be happy if we could have primary\standby in = isolation tests too) 3. Can we have some Perl function for this? +# Wait until the checkpointer is in the middle of the restart point +# processing, relying on the custom wait event generated in the +# wait callback used in the injection point previously attached. +ok( $node_standby->poll_query_until( + 'postgres', + qq[SELECT count(*) FROM pg_stat_activity + WHERE backend_type =3D 'checkpointer' AND wait_event =3D = 'injection_wait' ;], + '1'), + 'checkpointer is waiting in restart point' +) or die "Timed out while waiting for checkpointer to run restart = point"; Perhaps something like = $node->do_a_query_and_wait_for_injection_point_observed(sql,injection_poin= t_name); 4. Maybe I missed it, but I'd like to see a guideline on how to name = injection points. 5. In many cases we need to have injection point under critical section. = I propose to have a "prepared injection point". See [0] for example in = v2-0003-Test-multixact-CV-sleep.patch + INJECTION_POINT_PREPARE("GetNewMultiXactId-done"); + START_CRIT_SECTION(); =20 + INJECTION_POINT_RUN_PREPARED(); 6. Currently our codebase have files injection_point.c and = injection_points.c. It's very difficult to remember which is where... 7. This is extremely distant, but some DBMSs allow to enable injection = points by placing files on the filesystem. That would allow to test = something during recovery when no SQL interface is present. Let's test all the neat stuff! Thank you! Best regards, Andrey Borodin. [0] = https://www.postgresql.org/message-id/0925F9A9-4D53-4B27-A87E-3D83A757B0E0= @yandex-team.ru=