Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes - Mailing list pgsql-hackers

From Andres Freund
Subject Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes
Date
Msg-id 20220209231129.g2hbb624nn33md3k@alap3.anarazel.de
Whole thread Raw
In response to Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes Reply-To:  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Dong Wook Lee
Date:
Subject: Re: [PATCH] Improve function toast_delete_external (src/backend/access/table/toast_helper.c)
Next
From: Alexander Korotkov
Date:
Subject: Re: [PATCH] nodeindexscan with reorder memory leak