From 3049fe7cfa994208cb15cf0c9a20e773839ebf8f Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 1 Dec 2006 19:55:28 +0000 Subject: [PATCH] Make the bgwriter's error recovery path do smgrcloseall(). On Windows this should allow delete-pending files to actually go away, and thereby work around the various complaints we've seen about 'permission denied' errors in such cases. Should be reasonably harmless in any case... --- src/backend/postmaster/bgwriter.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend/postmaster/bgwriter.c b/src/backend/postmaster/bgwriter.c index 4d5c1d1cca..9062b4f7de 100644 --- a/src/backend/postmaster/bgwriter.c +++ b/src/backend/postmaster/bgwriter.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.32 2006/11/30 18:29:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/bgwriter.c,v 1.33 2006/12/01 19:55:28 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -304,6 +304,13 @@ BackgroundWriterMain(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) */