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 1nHvfc-0002ny-HW for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 22:42:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nHvfb-0003KD-0q for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Feb 2022 22:42:39 +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 1nHvfa-0003IC-LN for pgsql-hackers@lists.postgresql.org; Wed, 09 Feb 2022 22:42:38 +0000 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nHvfV-00046y-Km for pgsql-hackers@postgresql.org; Wed, 09 Feb 2022 22:42:37 +0000 Received: by mail-qk1-x736.google.com with SMTP id g145so3120434qke.3 for ; Wed, 09 Feb 2022 14:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Jfl+ZgMepZZbyNMgNW23/FZYeWKYJt+IGNLevU+39kA=; b=RMHayuf6D2bRWIkZTQLwM3dIpgYJqaNVhFNAI19uTpEij6DghBLe7Mmra6cyQbjzp7 rrXrjXn+8PQ14N5KxTuAAQGowisUQfBs/eHkkWdWXfx+CYsmUrmi1bjJ7RiPabVx5bjh t2n1HGAzUZr06yjNKs0qFZ0KyKy6fM6e2vFKnOk234gwhx9VwmMNEzcnIzSSeHuxrRip ALorOjQhgvwApwNmfh97EyDDB6gx7StcA0AKVZsktJRJH748q0Iw3CqEulBC9ktcZyQM cPVZD0uc6+15+Shp77gXpqnA/SPWaGvnnwRWXryUGcnPVCZVc/QlKCLRX4DbivIGCSoB GEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Jfl+ZgMepZZbyNMgNW23/FZYeWKYJt+IGNLevU+39kA=; b=Dpvy0wle/MIqwfIt0JvkcUJypOCur80fs/k08A7erOGIEJOnDXTDznQ+fJ9kwtvz74 HmYecQ9gqahoptOmZOJJatgpFxanRjQekDJhS6x/fL98kwVqb3NKai7q9iMb6A8pvzXy QBCPHqqL0L57Q8/T/V7rXYxAH8K/4WzMXLcX0ocT7ewPZa9Ny6DVxN9Pmzat/QmGvS/K j537zXOTq5VpW8VLCTJa5G1HCpiRdQ2IaGTz3zwFn2WeJFTWc7g7dklVinOqBRKE3zT1 yQnScwRQHNA+K2nuG1TWAxt8uus3jwmbUWJD6MUT4Q7DAMEcfxssT+HnaNWMPAU1+5No Djvg== X-Gm-Message-State: AOAM5326uvKzCPbSk2rIZcMaHyY8rD/G2by6TDxy8fh+AYifpEUQu8Hg t6pNRh9Ovp+wbYsRO4eydm/V6w== X-Google-Smtp-Source: ABdhPJzMLzut2DKOPzMo4eQczUItKw6QXiLUQ/7Sva7ZmSITXNcv/Xp2ijuIcwIsaSkIWuWl3L4aKQ== X-Received: by 2002:a05:620a:1669:: with SMTP id d9mr2394485qko.535.1644446552479; Wed, 09 Feb 2022 14:42:32 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id f16sm10254550qtk.8.2022.02.09.14.42.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Feb 2022 14:42:32 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id F1D85800897; Wed, 9 Feb 2022 16:42:30 -0600 (CST) Date: Wed, 9 Feb 2022 16:42:30 -0600 From: Justin Pryzby To: Andres Freund Cc: pgsql-hackers@postgresql.org, Robert Haas , Thomas Munro Subject: Re: wrong fds used for refilenodes after pg_upgrade relfilenode changes Reply-To: Message-ID: <20220209224230.GS31460@telsasoft.com> References: <20220209220004.kb3dgtn2x2k2gtdm@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220209220004.kb3dgtn2x2k2gtdm@alap3.anarazel.de> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.. PS. I didn't know pg_upgrade knew about Reply-To ;)