Remove some obsolete smgrcloseall() calls.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 31 Jan 2024 09:40:29 +0000 (11:40 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 31 Jan 2024 09:40:29 +0000 (11:40 +0200)
Before the advent of PROCSIGNAL_BARRIER_SMGRRELEASE, we didn't have a
comprehensive way to deal with Windows file handles that get in the way
of unlinking directories.  We had smgrcloseall() calls in a few places
to try to mitigate.

It's still a good idea for bgwriter and checkpointer to do that once per
checkpoint so they don't accumulate unbounded SMgrRelation objects, but
there is no longer any reason to close them at other random places such
as the error path, and the explanation as given in the comments is now
obsolete.

Author: Thomas Munro
Reviewed-by: Heikki Linnakangas, Robert Haas
Discussion: https://www.postgresql.org/message-id/CA%2BhUKGJ8NTvqLHz6dqbQnt2c8XCki4r2QvXjBQcXpVwxTY_pvA@mail.gmail.com

src/backend/postmaster/bgwriter.c
src/backend/postmaster/checkpointer.c
src/backend/postmaster/walwriter.c

index d7d6cc0cd7bfa17659aea878645c7ecbfabd3e5b..6736a66006295a6d9674e4f92b548b0e74fe87eb 100644 (file)
@@ -197,13 +197,6 @@ BackgroundWriterMain(void)
         */
        pg_usleep(1000000L);
 
-       /*
-        * Close all open files after any error.  This is helpful on Windows,
-        * where holding deleted files open causes various strange errors.
-        * It's not clear we need it elsewhere, but shouldn't hurt.
-        */
-       smgrcloseall();
-
        /* Report wait end here, when there is no further possibility of wait */
        pgstat_report_wait_end();
    }
index 5e949fc885b3eb97ea8ccc5d12bec1e6924204c8..a7bf00b06069299996b819c96ee25b3c36d4eb9e 100644 (file)
@@ -301,13 +301,6 @@ CheckpointerMain(void)
         * fast as we can.
         */
        pg_usleep(1000000L);
-
-       /*
-        * Close all open files after any error.  This is helpful on Windows,
-        * where holding deleted files open causes various strange errors.
-        * It's not clear we need it elsewhere, but shouldn't hurt.
-        */
-       smgrcloseall();
    }
 
    /* We can now handle ereport(ERROR) */
index 75c9f8707b719bcb664895a7b9749d78c1cb22e1..e079dc65c88c70fde14737a5cc1a198c87583f83 100644 (file)
@@ -186,13 +186,6 @@ WalWriterMain(void)
         * fast as we can.
         */
        pg_usleep(1000000L);
-
-       /*
-        * Close all open files after any error.  This is helpful on Windows,
-        * where holding deleted files open causes various strange errors.
-        * It's not clear we need it elsewhere, but shouldn't hurt.
-        */
-       smgrcloseall();
    }
 
    /* We can now handle ereport(ERROR) */