Re: Strange issue with NFS mounted PGDATA on ugreen NAS

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Larry Rosenman <ler(at)lerctr(dot)org>, Pgsql hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Strange issue with NFS mounted PGDATA on ugreen NAS
Date: 2024-12-31 23:24:10
Message-ID: CA+hUKG+K=BbJOcBH6C15enbr2AZiAOLmrB0kwjD24j=Ye08XjQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jan 1, 2025 at 11:44 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Larry Rosenman <ler(at)lerctr(dot)org> writes:
> > On 12/31/2024 12:22 pm, Larry Rosenman wrote:
> >> When I try to drop a database, PostgreSQL leaves files in the directory
> >> and does not even try to delete them.
> >> PostgreSQL 16.6, FreeBSD 14.2, PGDATA mounted NFS from UGreen NAS.

> What it looks like is that readdir() is skipping over some files,
> which would almost certainly be an NFS server bug. But that
> theory could be wrong.

Hmm. So in 15 and earlier, rmtree() would read all the file names
into memory and then unlink them, but 54e72b66 changed that and
started unlinking in the loop. Perhaps that wasn't a great idea, but
it's hardly the only place that directory contents might change across
readdir() calls (it's just a place that does that itself).

As has been analysed by the pgbackrest guys, readdir() can be flaky
over changing directories on some NFS (and maybe other network FSs)
implementations (unresolved AFAIK and different from this problem,
they were missing files during backups due to concurrent changes).
The implementation-specific cookie scheme for encoding a sort of
cursor position across readdir() calls has various different problems
on various different OSes, NFS implementations and underlying local
file systems (I looked into this quite a bit when that last discussion
happened, it's a mess). I wonder what a UGreen NAS is running.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Larry Rosenman 2024-12-31 23:26:28 Re: Strange issue with NFS mounted PGDATA on ugreen NAS
Previous Message Tomas Vondra 2024-12-31 23:06:59 Adjusting hash join memory limit to handle batch explosion