Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8T5B-0000mM-9P for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2022 20:54:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o8T59-0005dx-C8 for pgsql-hackers@arkaria.postgresql.org; Mon, 04 Jul 2022 20:54:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8T58-0005do-8u for pgsql-hackers@lists.postgresql.org; Mon, 04 Jul 2022 20:54:11 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o8T55-0002Gc-F9 for pgsql-hackers@postgresql.org; Mon, 04 Jul 2022 20:54:09 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id B74745C00A8; Mon, 4 Jul 2022 16:54:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Mon, 04 Jul 2022 16:54:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm2; t=1656968045; x=1657054445; bh=h4nCQ5yD+m tZ2o2vms+mq4jFAcDSieX2nkuckogVgbg=; b=nrOZEyEcGgxy4HAbFV7PaYMGss SkgCV+dlmwNonl3HHQ5HL6EpVqQH4Lp3Qpjf8ilGl80htdEdw7n4V1JA57KxuWJ2 9KcXYNcyOQiC3gXDH2wRvHkJFewVdYw6oJojieZX9hkZ8XZ5Um6uL/Y1y4Mi+kA+ 3OT/1IWwl4/z6jTiLoA8X7FVAponZLv9SHpcsRh7rjd6mmnhhHg1DK2DHvkkP+4h 3ev5jYvkJd2ltPfiRShs+kF5XVIin3Zp3elVrP6z9r1DeBOMheYUIfIGdOmsZdmY vS9XJqfbJhZQXF7eJZMyL+yI+Cj0L6x/Z0vweolDCtd25VFAd+psM/FoAw2w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1656968045; x=1657054445; bh=h4nCQ5yD+mtZ2o2vms+mq4jFAcDS ieX2nkuckogVgbg=; b=wIAhbgB8DI3aDcsoKJwPlDEFM5LZsXPWLgvNwyMVCrMy q6pI4UVMy9KmA1b6HChBaJwFsYeewGqE2VQB/2faswwAkVEz9Ivt1nM/IQnXSVFZ xjgySw5MS8iAqhxSCaFODzUw5gtGwtrrfz5UALbYc1HBw2BR3S+81xpPRZYDqJki hQkUy5Pf8sE2cW7plkDhatKi8oNhz3EdrCFIIj6aTkV+nfPn1l+j1W1CpM5Hr9M8 7h1V4HBEj8Bgp5mU8i9d8WxknV2hlx3+6ZWpPxtHD+gdd6RmpBOxAO1JOU6gF3ux kLLghuC00E0Z6y+oycPz97Mx1eMDvkFBqhsm9SD9JQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudehledgudehiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehttdertddttddvnecuhfhrohhmpeetnhgu rhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtf frrghtthgvrhhnpedvffefvefhteevffegieetfefhtddvffejvefhueetgeeludehteev udeitedtudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpegrnhgurhgvshesrghnrghrrgiivghlrdguvg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 4 Jul 2022 16:54:05 -0400 (EDT) Date: Mon, 4 Jul 2022 13:54:04 -0700 From: Andres Freund To: Thomas Munro Cc: Tom Lane , Kyotaro HORIGUCHI , pgsql-hackers Subject: Re: pgsql: dshash: Add sequential scan support. Message-ID: <20220704205404.vfppvvurbf64ujfg@awork3.anarazel.de> References: <758107.1646960996@sss.pgh.pa.us> <20220311012712.botrpsikaufzteyt@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-07-04 14:55:43 +1200, Thomas Munro wrote: > Right, as seen in the build farm at [1]. Also reproducible with something like: > > @@ -269,6 +269,14 @@ dsm_impl_posix(dsm_op op, dsm_handle handle, Size > request_size, > return false; > } > > + /* XXX random fault injection */ > + if (op == DSM_OP_ATTACH && random() < RAND_MAX / 8) > + { > + close(fd); > + elog(ERROR, "chaos"); > + return false; > + } > + > > I must have thought that it was easy and practical to write no-throw > straight-line code and be sure to reach dshash_release_lock(), but I > concede that it was a bad idea: even dsa_get_address() can throw*, and > you're often likely to need to call that while accessing dshash > elements. For example, in lookup_rowtype_tupdesc_internal(), there is > a sequence dshash_find(), ..., dsa_get_address(), ..., > dshash_release_lock(), and I must have considered the range of code > between find and release to be no-throw, but now I know that it is > not. Yea - I'd go as far as saying that it's almost never feasible. > > It's per-backend state at least and just used for assertions. We could remove > > it. Or stop checking it in places where it could be set wrongly: dshash_find() > > and dshash_detach() couldn't check anymore, but the rest of the assertions > > would still be valid afaics? > > Yeah, it's all for assertions... let's just remove it. Those > assertions were useful to me at some stage in development but won't > hold as well as I thought, at least without widespread PG_FINALLY(), > which wouldn't be nice. Hm. I'd be inclined to at least add a few more Assert(!LWLockHeldByMe[InMode]()) style assertions. E.g. to dshash_find_or_insert(). > @@ -572,13 +552,8 @@ dshash_release_lock(dshash_table *hash_table, void *entry) > size_t partition_index = PARTITION_FOR_HASH(item->hash); > > Assert(hash_table->control->magic == DSHASH_MAGIC); > - Assert(hash_table->find_locked); > - Assert(LWLockHeldByMeInMode(PARTITION_LOCK(hash_table, partition_index), > - hash_table->find_exclusively_locked > - ? LW_EXCLUSIVE : LW_SHARED)); > + Assert(LWLockHeldByMe(PARTITION_LOCK(hash_table, partition_index))); > > - hash_table->find_locked = false; > - hash_table->find_exclusively_locked = false; > LWLockRelease(PARTITION_LOCK(hash_table, partition_index)); > } This LWLockHeldByMe() doesn't add much - the LWLockRelease() will error out if we don't hold the lock. Greetings, Andres Freund