Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tTmAT-00AGet-TL for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2025 18:13:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tTmAR-0047oL-Va for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2025 18:13:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tTmAR-0047oD-Mg for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2025 18:13:03 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tTmAP-0004Dz-2V for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2025 18:13:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 503IChIM469549; Fri, 3 Jan 2025 13:12:43 -0500 From: Tom Lane To: Peter Eisentraut cc: Thomas Munro , Robert Haas , Larry Rosenman , Pgsql hackers Subject: Re: Fwd: Re: A new look at old NFS readdir() problems? In-reply-to: References: <04cf05d053e9320012b32370e228fac4@lerctr.org> <302248.1735850933@sss.pgh.pa.us> <309402.1735854754@sss.pgh.pa.us> <319417.1735860015@sss.pgh.pa.us> <338175.1735869481@sss.pgh.pa.us> Comments: In-reply-to Peter Eisentraut message dated "Fri, 03 Jan 2025 18:31:37 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <469547.1735927963.1@sss.pgh.pa.us> Date: Fri, 03 Jan 2025 13:12:43 -0500 Message-ID: <469548.1735927963@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Peter Eisentraut writes: > On 03.01.25 02:58, Tom Lane wrote: >> I poked at this a little further. I made the attached stand-alone >> test case (you don't need any more than "cc -o rmtree rmtree.c" >> to build it, then point the script at some NFS-mounted directory). >> This fails with my NAS at least as far back as FreeBSD 11.0. >> I also tried it on NetBSD 9.2 which seems fine. > If you use some GUI file manager, point at a directory, and select > "remove this directory with everything in it", what does it do > internally? Surely it runs a readdir() loop and unlinks the files as it > gets to them? Or does it indeed slurp the whole directory tree into > memory before starting the deletion? One thing I noticed while testing yesterday is that "rm -rf foo" worked even in cases where "rmtree foo" didn't. I did not look into FreeBSD's rm code, but I'll bet it has the sort of retry logic that was recommended to us upthread. I agree with your point though that it's hard to believe that everyone does that in every case where it would matter. As for pre-existing bug reports, I found https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=57696 but there's basically no new information there, other than the not-so-surprising fact that renaming directory entries triggers the failure as efficiently as unlinking does. regards, tom lane