On 01/02/2025 3:42 pm, Thomas Munro wrote:
On Fri, Jan 3, 2025 at 10:16 AM Larry Rosenman <l...@lerctr.org> wrote:
What about doing what Rick suggests?
do {
       dir = opendir("X");
        dp = readdir(dir);
        if (dp != NULL)
             unlink(dp->d_name);
         close(dir);
} while (dp != NULL);
?

That only works for unlink loops where we expect no concurrent
modifications.  DROP DATABASE qualifies, but we use readdir() on
directories that might be changing in various other places, including
backups.  They'd silently fail to do their job, and can't use that
technique as they aren't unlinking as they go and so they would never
make progress.  Which leads to the lipstick/pig conclusion: we'd have
other, worse, buggy behaviour still.

It might be possible to make our own readdir snapshot thing that
checks a shmem counter of all links/unlinks before and after and
retries.  But ugh...

Would it make sense for ONLY drop database to have the above loop?

--
Larry Rosenman                     http://www.lerctr.org/~ler
Phone: +1 214-642-9640                 E-Mail: l...@lerctr.org
US Mail: 13425 Ranch Road 620 N, Apt 718, Austin, TX 78717-1010


Reply via email to