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 1lhJnN-0001Kc-6l for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 22:27:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lhJnM-0003SW-2j for pgsql-hackers@arkaria.postgresql.org; Thu, 13 May 2021 22:27:04 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhJnL-0003SO-RN for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 22:27:03 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhJnJ-0004RC-NL for pgsql-hackers@lists.postgresql.org; Thu, 13 May 2021 22:27:02 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id D49C35C019E; Thu, 13 May 2021 18:26:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 13 May 2021 18:26:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=y8l9+rRNu5a6HAh/zkzRNSV/WYRstmjnuCRt8Z7o0Gs=; b=UTZ6MEXl U+9PIgUccf0InqVjbVluqlHK+ETcucKm+sMbTdC7S+7FcNpUETqSqFHf+PnLsAvg 0ZhvccSY12noX8SzGf1Ar5LwH0oRSL7ANbOqU4PJOwYhAklr4DEa24w2nHXrTVYB E95Ae/q/yZ5mm2PpzTl6HOrj6CeMe4gOpiw6vkwtqSGR/VnJsYdrt1TRAH0bIuJW Zgxop8x/AxVjHXtJPCHFJ3kkEw6Kf9MHMC5NGAMb8C2shopTPWrzV3IRnpW75Y7B ysdZ8X/9wpKTSHGONGnp1TpDcEndiZXAM2NLByHazR5/Z7EhpqNdOtc/wMK8Prlu +DZRuNNlcl6dPg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdehhedgtdelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjfgesthekredttderudenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepueffhfejieeuueffgedvudekgeeltdeviedvieeufeei ieevgfetheeufeethedvnecukfhppeduledtrdelhedrudelrdelheenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghl vhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.19.95]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 May 2021 18:26:59 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 7D3FE2A0ADC; Thu, 13 May 2021 18:26:56 -0400 (-04) Date: Thu, 13 May 2021 18:26:56 -0400 From: Alvaro Herrera To: Tom Lane Cc: Pavel Borisov , Dilip Kumar , PostgreSQL Hackers Subject: Re: OOM in spgist insert Message-ID: <20210513222656.GA14141@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1577069.1620926983@sss.pgh.pa.us> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-May-13, Tom Lane wrote: > Alvaro Herrera writes: > > (Looking again, the nbtpage.c hunk might have been made obsolete by > > c34787f91058 and other commits). > > OK. Here's a revision that adopts your idea, except that I left > out the nbtpage.c change since you aren't sure of that part. Thanks. > I added a macro that allows spgdoinsert to Assert that it's not > called in a context where the infinite-loop-due-to-InterruptPending > risk would arise. This is a little bit fragile, because it'd be > easy for ill-considered changes to ProcessInterrupts to break it, > but it's better than nothing. Hmm, it looks OK to me, but I wonder why you kept the original CHECK_FOR_INTERRUPTS()s since these would be done once we've broken out of the loop anyway. I tested Dilip's original test case and while we still die on OOM, we're able to interrupt it before dying. Not related to this patch -- I was bothered by the UnlockReleaseBuffer calls at the bottom of spgdoinsert that leave the buffer still set in the structs. It's not a problem if you look only at this routine, but I notice that callee doPickSplit does the same thing, so maybe there is some weird situation in which you could end up with the buffer variable set, but we don't hold lock nor pin on the page, so an attempt to clean up would break. I don't know enough about spgist to figure out how to craft a test case, maybe it's impossible to reach for some reason, but it seems glass-in-the-beach sort of thing. -- Álvaro Herrera 39°49'30"S 73°17'W "Someone said that it is at least an order of magnitude more work to do production software than a prototype. I think he is wrong by at least an order of magnitude." (Brian Kernighan)