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 1rcD42-001aOG-Iu for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Feb 2024 23:28:46 +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 1rcD40-00HWY5-HN for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Feb 2024 23:28:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcD40-00HWXx-7p for pgsql-hackers@lists.postgresql.org; Mon, 19 Feb 2024 23:28:44 +0000 Received: from wfhigh8-smtp.messagingengine.com ([64.147.123.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rcD3x-007azS-Mb for pgsql-hackers@lists.postgresql.org; Mon, 19 Feb 2024 23:28:43 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.west.internal (Postfix) with ESMTP id D595E1800081; Mon, 19 Feb 2024 18:28:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Mon, 19 Feb 2024 18:28:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708385319; x=1708471719; bh=MlMyI5uwfs 1U6T6GoqmenynmLWf/7RQYWYPXoIQ9L78=; b=loYFubPvXPRYqsmqravC+PbNxh VxbD9N/9AW1HppMCwYMhBFejWKTygZnuk/DQfiB3t7OKNzaYV6yO9++G7SzCyXA2 Cl9c+JcegUMA8pgbD+hZ+ed0RgyMFpQKhw15MsQKSDoD4xiRy/SnmQahpQj47uD6 qsNagHrQzQodho+Fu5NzrJmlkWTYyaCN3lALezkM/fPCOnmCvnGfTBKs8OoKMptp 0hk2LI/F4inq6f5IZTPVdyhIH0gU0h0EmnEwld4P5E1wGh/fZS23W2cPGKqnwytu 5NOTFrxdibwA3byLIexTrT5Q/evd+RY1hZ6MyeR0UsEBQK2/lo2pwIaA60Gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708385319; x=1708471719; bh=MlMyI5uwfs1U6T6GoqmenynmLWf/ 7RQYWYPXoIQ9L78=; b=UqFIrxwoENFfp0ck2bsQ+2IORdBhezHjqC3+LRqobk/1 rUvLH5W1KJrfWPkn9kWbAhv2hg288jHnO3b/1Mp7sv38vwte09USt6skX4NwjUVj UrtohV8dc1dEtqk2LL3AdGNcwOlGckavUuiNc1XTQZSD9JR7BHo8IGIc0h1MjA2k /40N/BZAobYAAPNA6CO5fCxsd+FowIaYB9QUA255zwKei7mvSUnq7BQ4LT+AY3Kc Pn568Wjsa5L9dwuNRpOmlB7kh2vajVL4uTIiJqyRsL3+aMPYejGGohjSn+wmbeVD CeM3VS651d9rJg4puM5A18k6+1SngtY7ltwkwNGu7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelgddtlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddt vdenucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprg hquhhivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeg geffhfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtne curfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Feb 2024 18:28:36 -0500 (EST) Date: Tue, 20 Feb 2024 08:28:28 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Postgres hackers , Ashutosh Bapat Subject: Re: Injection points: some tools to wait and wake Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="AykIMfLkuoKn5BRT" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --AykIMfLkuoKn5BRT Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 19, 2024 at 02:28:04PM +0000, Bertrand Drouvot wrote: > +CREATE FUNCTION injection_points_wake() >=20 > what about injection_points_wakeup() instead? Sure. > +/* Shared state information for injection points. */ > +typedef struct InjectionPointSharedState > +{ > + /* protects accesses to wait_counts */ > + slock_t lock; > + > + /* Counter advancing when injection_points_wake() is called */ > + int wait_counts; >=20 > If slock_t protects "only" one counter, then what about using pg_atomic_u= int64 > or pg_atomic_uint32 instead? And btw do we need wait_counts at all? (see = comment=20 > number 4) We could, indeed, even if we use more than one counter. Still, I would be tempted to keep it in case more data is added to this structure as that would make for less stuff to do while being normally non-critical. This sentence may sound pedantic, though.. > + * SQL function for waking a condition variable >=20 > waking up instead? Okay. > I'm wondering if this loop and wait_counts are needed, why not doing some= thing > like (and completely get rid of wait_counts)? >=20 > " > ConditionVariablePrepareToSleep(&inj_state->wait_point); > ConditionVariableSleep(&inj_state->wait_point, injection_wait_event); > ConditionVariableCancelSleep(); > " >=20 > It's true that the comment above ConditionVariableSleep() mentions that: Perhaps not, but it encourages good practices around the use of condition variables, and we need to track all that in shared memory anyway. Ashutosh has argued in favor of the approach taken by the patch in the original thread when I've sent a version doing exactly what you are saying now to not track a state in shmem. -- Michael --AykIMfLkuoKn5BRT Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmXT5BwACgkQnvQgOdby QH2ovg//fNIRkfVrCrobrTVEAiEcdehSgj7nnBbknOZC74ZJW5hnh0cj1w8s4417 zXmFMxgusKke3zTF9idHQK/Wpz+owUhrMr4sR6054cosMlf30NMNHnfAfxL4pDZE s4mRkbQQBzTf0Geh7QngtLDsopSkloUq1aSYTwhICXiAPG5F7KdKA6XvjoKxGz+L YgpD49N4O4LUEe+/caLva0aBSqraK5qxnRRjy5eqRfuqYfsDcP56HPgvI3kANo1o noXW3pn4dlIONVgCvS3o108vM/FBg3PwnCuoNfVHyKlcdihQMkvank4IjXcCNP/j Xd9ENo5z77/5MqRjTpNw7eMn6UilKSpXiCN+NqIrF4aLIlMiLdkNayCxrwWDW3hp nMVSQjvtg0IvSNx3WKuKZ4lBHuiC2J83g9MbRTz0wcUj8nTzqM/1ppbsbb6apsPN 1i28zbxLO8ozL57t3YYmKqFWgGswAeSdaciCML9oACNj7aGSeRsnQXwGoAsT96Gp qXYmvUD2bXgh9pQJqzACJzH4tGB9IojqUB4JFtTByhbsRz4wLeV6T6QWGmBLcULl 50AeqPPlWOgPtZgihIxP0HoFZX3LFWUg2jmBCvnT7K4iQjSmzj/XT3Fv102/8HeE zFeP2fxd+872rmkQ5hyVTHKAcaDhyJywOQvc6WCs6O75zoQ5Qwk= =2PZC -----END PGP SIGNATURE----- --AykIMfLkuoKn5BRT--