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 1mxEcy-0003SD-8k for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Dec 2021 20:42:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mxEcx-0006sH-5a for pgsql-hackers@arkaria.postgresql.org; Tue, 14 Dec 2021 20:42:23 +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 1mxEcw-0006s8-Hh for pgsql-hackers@lists.postgresql.org; Tue, 14 Dec 2021 20:42:22 +0000 Received: from anastigmatix.net ([68.171.219.55]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mxEcp-00024K-VJ for pgsql-hackers@postgresql.org; Tue, 14 Dec 2021 20:42:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=anastigmatix.net; s=default; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Date:Message-ID:Subject:From:To:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=qS8120ca0hZIYioB77aMhUeQcRnuYJd9nXdKyLxkha8=; b=jHko+2CLKOo0Yio9zKB7E7JH7Q qbOrNpsqH5c6y23PN9aMgSecFi9TkYH6snZt5cOJ2MfLU5t3C/HVEPDNiLvigrOIp4fGkcJqgalAn R1Cdus8ZgMxVs9+k0JlhTVDdk9HhomoV9br9fRZ1qWRKabZAFbZB1O3NX8PKi/cnewvs3RexDckGF Nu4qLmQWiJRq13Qpx4WhFW7vZdpWqUevgvsX0OVPuiLyf8rUlVAsAfuBKQBk/Irh+3XiKRrlKn69A H59nNvu23CCOCrs3P6u7aDZzJCI0Alcq/vsz4GoYvDAr56zmSy0quEjAvOgkjIbTGw+mSb+N0kPRg w0NMQchA==; Received: from [184.19.31.139] (port=54379) by bay.acenet.us with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1mxEcn-00AFuI-Mp for pgsql-hackers@postgresql.org; Tue, 14 Dec 2021 15:42:14 -0500 To: PostgreSQL Hackers From: Chapman Flack Subject: Life cycles of tuple descriptors X-Enigmail-Draft-Status: N1110 Message-ID: <61B901A4.1050808@anastigmatix.net> Date: Tue, 14 Dec 2021 15:42:12 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 X-Authenticated-Sender: bay.acenet.us: chap@anastigmatix.net X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, There are some things about the life cycle of the common TupleDesc that I'm not 100% sure about. 1. In general, if you get one from relcache or typcache, it is reference-counted, right? 2. The only exception I know of is if you ask the typcache for a blessed one (RECORD+typmod), and it is found in the shared-memory cache. It is not refcounted then. If it is found only locally, it is refcounted. 3. Is that shared case the only way you could see a non-refcounted TupleDesc handed to you by the typcache? 4. How long can such a non-refcounted TupleDesc from the typcache be counted on to live? There is a comment in expandedrecord.c: "It it's not refcounted, just assume it will outlive the expanded object." That sounds like confidence, but is it confidence in the longevity of shared TupleDescs, or in the fleeting lives of expanded records? The same comment says "(This can happen for shared record types, for instance.)" Does the "for instance" mean there are now, or just in future might be, other cases where the typcache hands you a non-refcounted TupleDesc? 5. When a constructed TupleDesc is blessed, the copy placed in the cache by assign_record_type_typmod is born with a refcount of 1. Assuming every later user of that TupleDesc plays nicely with balanced pin and release, what event(s), if any, could ever occur to decrease that initial 1 to 0? Thanks for any help getting these points straight! Regards, -Chap