Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4cNt-0006uh-9K for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 01:11:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4cNq-0005T4-UP for pgsql-hackers@arkaria.postgresql.org; Sat, 07 Apr 2018 01:11:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4cNq-0005Su-N2 for pgsql-hackers@lists.postgresql.org; Sat, 07 Apr 2018 01:11:10 +0000 Received: from bay.acenet.us ([173.230.252.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4cNj-0005qQ-7n for pgsql-hackers@postgresql.org; Sat, 07 Apr 2018 01:11:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:Cc:References:To:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=I0Ow9D44W/dOosOYKWl8RV+aCT3Yxo8cGgX0L9zZEg4=; b=gzaCK4KVNYfTUFZ/KBeQVN/Y7 qo0Z1YMAu3rWHY9xuE8iDOPo6UouFV83d/+OtUmxlVsfpOqDQIlIjIoxpG60F2CIAyl8byABqTdCv hhQ/Dme8szFI67QlrHqg/hHuT+PcqJUSHQhRAjvFI614b47FrqNwniosphxDwju2UlwhLOVWPwnNC WL4jBwbNWO1WkbGso5c1PcdvMsGbM3i7LIQb3SGkbDrV8Up8a6IG+9S5YTIdMq/6QjGi7V09aAtbk NQyVapRhMYcY7WWKsXgDrjgMLGIHHPG8EK/xPQYT4GbrFN3SdDS+V+2n9N7R2X4CzOgt7Cb+pSfID IIczoFRWA==; Received: from [192.182.57.106] (port=44003) by bay.acenet.us with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1f4cNf-002v5m-Je; Fri, 06 Apr 2018 21:11:00 -0400 Subject: Re: [PATCH] Update README for Resource Owners To: Andres Freund References: <5AC806D1.1090608@anastigmatix.net> <20180406235209.k2gfizjfi2xczo6z@alap3.anarazel.de> <5AC80E90.5000407@anastigmatix.net> Cc: PostgreSQL Hackers From: Chapman Flack Message-ID: <5AC81AA3.6090604@anastigmatix.net> Date: Fri, 6 Apr 2018 21:10:59 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <5AC80E90.5000407@anastigmatix.net> Content-Type: multipart/mixed; boundary="------------020006050904060308080302" X-OutGoing-Spam-Status: No, score=-95.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bay.acenet.us X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - anastigmatix.net X-Get-Message-Sender-Via: bay.acenet.us: authenticated_id: chap+anastigmatix.net/only user confirmed/virtual account not confirmed X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------020006050904060308080302 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 04/06/18 20:19, Chapman Flack wrote: > On 04/06/18 19:52, Andres Freund wrote: >> Wouldn't it be a better idea not to have a list there, that's guaranteed >> to get out of date? > > That might look like this, then. > > But I'm not sure how bad it is to have a list. How often does ResourceOwner > get taught a new type? It took nine years to grow these last three. It also seemed worth documenting that the release callbacks are called for *every* ResourceOwnerRelease, but can consult CurrentResourceOwner to learn what owner is really being released. -Chap --------------020006050904060308080302 Content-Type: text/x-patch; name="0001-Update-README-for-Resource-Owners-v3.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Update-README-for-Resource-Owners-v3.patch" From 6541f1b5c28ede3bf0e88bb34d6a4eedc5731cab Mon Sep 17 00:00:00 2001 From: Chapman Flack Date: Fri, 6 Apr 2018 21:08:02 -0400 Subject: [PATCH] Update README for Resource Owners. Built-in support for three more categories of owned object has accreted without mention in the README. Also explain that the release callbacks are global, and can consult CurrentResourceOwner to determine the owner being released. --- src/backend/utils/resowner/README | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/backend/utils/resowner/README b/src/backend/utils/resowner/README index 2998f6b..5049e7c 100644 --- a/src/backend/utils/resowner/README +++ b/src/backend/utils/resowner/README @@ -61,12 +61,20 @@ ResourceOwner transfers lock ownership to the parent instead of actually releasing the lock, if isCommit is true. Currently, ResourceOwners contain direct support for recording ownership of -buffer pins, lmgr locks, and catcache, relcache, plancache, tupdesc, and -snapshot references. Other objects can be associated with a ResourceOwner by -recording the address of the owning ResourceOwner in such an object. There is -an API for other modules to get control during ResourceOwner release, so that -they can scan their own data structures to find the objects that need to be -deleted. +several types of resource managed in the core, with the three operations +ResourceOwnerEnlargeRefs(), ResourceOwnerRememberRef(), and +ResourceOwnerForgetRef() for each type. The first ensures there is room +for at least one more entry of the type, and is separate from Remember... +so that out-of-memory can be detected before the resource is acquired. + +Other objects can be associated with a ResourceOwner by recording the address +of the owning ResourceOwner in such an object. There is an API for other +modules to get control during ResourceOwner release, so that they can scan +their own data structures to find the objects that need to be deleted. +Such callbacks are registered globally, not to a specific ResourceOwner, and +will be called during every ResourceOwnerRelease; to determine which owner is +being released, they can refer to CurrentResourceOwner, which points to it +while the callbacks are invoked. Whenever we are inside a transaction, the global variable CurrentResourceOwner shows which resource owner should be assigned -- 2.7.3 --------------020006050904060308080302--