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 1nHw7j-0005SH-OI for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 23:11:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nHw7i-0003lN-LO for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 23:11:42 +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 1nHw7g-0003lE-Qu for pgsql-hackers@lists.postgresql.org; Wed, 09 Feb 2022 23:11:42 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nHw7Z-0004K0-Jk for pgsql-hackers@postgresql.org; Wed, 09 Feb 2022 23:11:39 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 85CAE5C00D2; Wed, 9 Feb 2022 18:11:31 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 09 Feb 2022 18:11:31 -0500 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=fm3; bh=j1D8cqsU26JE/+IjEiQP0PzV4lUXF6dIk4/7Me KUDmA=; b=U5vfIVsvjl9I78wOvbmWuQoU34EIsxBTSZsEsEkSZsUMpfTa93wej3 U0R3rxVCDu9lUAufl/+EF3TnC1LrJFCnzpMUGbbWZULsh1H0iaEqKlQzENOnB4Fj azLOMhHvceb0XNxivZEI9R+wrQWt4ns++z8Em4YCkGQOLxACm0z019f7oHXZysrE Iq2oWd9s7AdnTZpoUIs4HV/UzV6gJOShMdD21fezDUQ7Mn960F5Mx1shxdSDRluv kr5kjSwJF4ZBPfMmYvvGpTL2vWFXIlQBvomIL3tx0d4HIZTl+VdI4efM6uSBttsl z21Qap7pprwms9xQh6C6sTm+HiYLi9pQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; 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:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=j1D8cqsU26JE/+IjE iQP0PzV4lUXF6dIk4/7MeKUDmA=; b=B4AUltgDqYh1rMSwWC1J2Nw1DnXsHeD52 6leEgFBkfVe7IUP33s7JXRtwSOhgalHv68vdkdk7NxhDj7LYYie+N2oH89qomYb7 nXqHjoziA5mer2MUJ1C6JDPN6dp81mi7TavsHbtjMkROgE0kIywogTr5MhmVbnX0 FASY9i4F/Ojk8sKrmCr+pZ1gx7gt7jle2RNt4zvHIvdh6vd0YZmwNp+lV4/LCnu1 kMIrdryGiz+Xuj98lvi03UFMLZ4b0LkLYyDvyQQTB7djKUx+Xoxphn2VYUCydKbB 5SNTEFxzSOF+KbSNYYfJ1MskuNEi8kTjR9dX8v06x7ufDD+Bitgsg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddriedtgddthecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeffhfeu ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Feb 2022 18:11:31 -0500 (EST) Date: Wed, 9 Feb 2022 15:11:29 -0800 From: Andres Freund To: Justin Pryzby Cc: pgsql-hackers@postgresql.org, Robert Haas , Thomas Munro Subject: Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes Message-ID: <20220209231129.g2hbb624nn33md3k@alap3.anarazel.de> References: <20220209220004.kb3dgtn2x2k2gtdm@alap3.anarazel.de> <20220209224230.GS31460@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220209224230.GS31460@telsasoft.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2022-02-09 16:42:30 -0600, Justin Pryzby wrote: > On Wed, Feb 09, 2022 at 02:00:04PM -0800, Andres Freund wrote: > > On linux we can do so by a) checking if readlink(/proc/self/fd/$fd) points to > > a filename ending in " (deleted)", b) doing fstat(fd) and checking if st_nlink > > == 0. > > You could also stat() the file in proc/self/fd/N and compare st_ino. It > "looks" like a symlink (in which case that wouldn't work) but it's actually a > Very Special File. You can even recover deleted, still-opened files that way.. Yea, the readlink() thing above relies on it being a /proc/self/fd/$fd being a "Very Special File". In most places we'd not have convenient access to a inode / filename to compare it to. I don't think there's any additional information we could gain anyway, compared to looking at st_nlink == 0 and then doing a readlink() to get the filename? > PS. I didn't know pg_upgrade knew about Reply-To ;) Ugh, formatting fail... Greetings, Andres Freund