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 1mECqC-0001TU-78 for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Aug 2021 15:41:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mECqA-0001tt-Lb for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Aug 2021 15:41:54 +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 1mEA8N-0006lj-Qf for pgsql-hackers@lists.postgresql.org; Thu, 12 Aug 2021 12:48:32 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mEA8K-00017S-Re for pgsql-hackers@postgresql.org; Thu, 12 Aug 2021 12:48:31 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 27E063200900; Thu, 12 Aug 2021 08:48:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Aug 2021 08:48:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm2; bh=dtC1yqacBrRZmH2KLhteSzKsN4K P61GSxaqBsu2Qbjo=; b=uzuemBSMvkPgFMGKlCj8MuItloVn5n4FSEjR0OKWW5N FwtlRnl22mi0ba32/of5X5OzY3rY2W/W+GVd/6lko27Q3Rrw3T09lkrwyDRuOGNu G3W2eZMMbDMTa5QjP1ixupKKyrvsx6eJ/bnaDxZqT5LqiNORqKhnRlajNttq4Tsv WCIp80ez892rGZkgq0pcgLb+VF2X8ZCiyLtXNUCba2JoGGPlb9Vh+vkFUhYW+Fr3 HKe6Gr747moD+5Xpr7dbGaJ5GWugfsTS0ir8cy3zLP1yEhUafVBGtLl3GQzooMp3 r60WO64xT/kTn7w1baFcCGRHlMDcyIZqWRk6uZBl71Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=dtC1yq acBrRZmH2KLhteSzKsN4KP61GSxaqBsu2Qbjo=; b=A45TuXomqNnvPZN/2upNGd NO0LT9Rz9DjRlIrK6Yyc3W8VMxoeU1SyHfzV9EsGzHuvweEt2vg3wcepqpCB3s/X 6/xYCCvLyjiU8BxnTBQaa1czXoBwpcb0lloKgsq58ztWM3EcEUYk9jgL2e+XLhoo CyKrnG9bVKsDbR3ji93i8NqAx9dp8gh77xMDqS/xa6kK7JnmH6RGjEVHEjxLz+Y2 ePvI4/bMBIyAzjxxo6bxPq6PIpV+Fpak+PyQ/qe5R8We6svsr8xi6wNiBsup8ghQ dMbuoRw+uXW1Xr8pG+RfhD8trswi1SQiRt78tecn2O80gcpk5sSZmD68a1XzAMKA == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrkeefgdehgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Aug 2021 08:48:23 -0400 (EDT) Date: Thu, 12 Aug 2021 05:48:19 -0700 From: Andres Freund To: Amit Kapila Cc: pgsql-hackers , Dilip Kumar , Masahiko Sawada , Tom Lane , pgsql-committers Subject: Re: pgsql: pgstat: Bring up pgstat in BaseInit() to fix uninitialized use o Message-ID: <20210812124819.5mrurb6ueizmqgru@alap3.anarazel.de> References: <20210807164850.52atvo2qkmtfnzgt@alap3.anarazel.de> <20210807190131.2bm24acbebl4wl6i@alap3.anarazel.de> <20210808022435.svp4spxlrfoi3w4p@alap3.anarazel.de> <20210812082237.in7l5x3rc4gxhgjh@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 2021-08-12 15:06:23 +0530, Amit Kapila wrote: > On Thu, Aug 12, 2021 at 1:52 PM Andres Freund wrote: > > I'm not so sure. Why does sharedfileset have its own proc exit hook in the > > first place? ISTM that this should be dealt with using resowners, rathers than > > a sharedfileset specific mechanism? > > > The underlying temporary files need to be closed at xact end but need > to survive across transactions. Why do they need to be closed at xact end? To avoid wasting memory due to too many buffered files? > These are registered with the resource owner via > PathNameOpenTemporaryFile/PathNameCreateTemporaryFile and then closed > at xact end. So, we need a way to remove the files used by the process > (apply worker in this particular case) before process exit and used > this proc_exit hook (possibly on the lines of AtProcExit_Files). What I'm wondering is why it is a good idea to have a SharedFileSet specific cleanup mechanism. One that only operates on process lifetime level, rather than something more granular. I get that the of the files here needs to be longer than a transaction, but that can easily be addressed by having a longer lived resource owner. Process lifetime may work well for the current worker.c, but even there it doesn't seem optimal. One e.g. could easily imagine that we'd want to handle connection errors or configuration changes without restarting the worker, in which case process lifetime obviously isn't a good idea anymore. I think SharedFileSetInit() needs a comment explaining that it needs to be called in a process-lifetime memory context if used without dsm segments. Because otherwise SharedFileSetDeleteOnProcExit() will access already freed memory (both for filesetlist and the SharedFileSet itself). Greetings, Andres Freund