From 45bb0fb587a7995e3b3a9dcea5a24fdc986d0a92 Mon Sep 17 00:00:00 2001 From: SaitTalhaNisanci Date: Fri, 2 Oct 2020 09:12:39 +0300 Subject: [PATCH] Do initial cleanup only once in pg_init (#4213) In postmasters execution of _PG_init, IsUnderPostmaster will be false and we want to do the cleanup at that time only, otherwise there is a chance that there will be parallel queries and we might do a cleanup for things that are already in use. --- src/backend/distributed/shared_library_init.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 6b4673a23..7973aaaf9 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -301,7 +301,16 @@ _PG_init(void) PGC_S_OVERRIDE); } - DoInitialCleanup(); + /* + * In postmasters execution of _PG_init, IsUnderPostmaster will be false and + * we want to do the cleanup at that time only, otherwise there is a chance that + * there will be parallel queries and we might do a cleanup for things that are + * already in use. This is only needed in Windows. + */ + if (!IsUnderPostmaster) + { + DoInitialCleanup(); + } }