postmaster.c_0619_win32delay.diff
text/plain
Filename: postmaster.c_0619_win32delay.diff
Type: text/plain
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/postmaster/postmaster.c | 35 | 0 |
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index d6fc2ed..ff03ebd 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -398,6 +398,30 @@ extern int optreset; /* might not be declared by system headers */
static DNSServiceRef bonjour_sdref = NULL;
#endif
+#define USE_AFTER_AUX_FORK_SLEEP 3000
+
+#ifdef USE_AFTER_AUX_FORK_SLEEP
+#ifndef WIN32
+#define AFTER_AUX_FORK_SLEEP()
+#else
+#define AFTER_AUX_FORK_SLEEP() do { SleepEx(USE_AFTER_AUX_FORK_SLEEP, FALSE); } while(0)
+#endif
+#else
+#define AFTER_AUX_FORK_SLEEP()
+#endif
+
+#define USE_AFTER_BACKEND_FORK_SLEEP 500
+
+#ifdef USE_AFTER_BACKEND_FORK_SLEEP
+#ifndef WIN32
+#define AFTER_BACKEND_FORK_SLEEP()
+#else
+#define AFTER_BACKEND_FORK_SLEEP() do { SleepEx(USE_AFTER_BACKEND_FORK_SLEEP, FALSE); } while(0)
+#endif
+#else
+#define AFTER_BACKEND_FORK_SLEEP()
+#endif
+
/*
* postmaster.c - function prototypes
*/
@@ -1709,6 +1733,7 @@ ServerLoop(void)
*/
StreamClose(port->sock);
ConnFree(port);
+ AFTER_BACKEND_FORK_SLEEP();
}
}
}
@@ -2801,11 +2826,20 @@ reaper(SIGNAL_ARGS)
* situation, some of them may be alive already.
*/
if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0)
+ {
AutoVacPID = StartAutoVacLauncher();
+ AFTER_AUX_FORK_SLEEP();
+ }
if (XLogArchivingActive() && PgArchPID == 0)
+ {
PgArchPID = pgarch_start();
+ AFTER_AUX_FORK_SLEEP();
+ }
if (PgStatPID == 0)
+ {
PgStatPID = pgstat_start();
+ AFTER_AUX_FORK_SLEEP();
+ }
/* some workers may be scheduled to start now */
maybe_start_bgworker();
@@ -5259,6 +5293,7 @@ StartChildProcess(AuxProcType type)
/*
* in parent, successful fork
*/
+ AFTER_AUX_FORK_SLEEP();
return pid;
}