Skip to content

Commit 5cd8e6b

Browse files
committed
fix
1 parent fd821e6 commit 5cd8e6b

File tree

6 files changed

+27
-0
lines changed

6 files changed

+27
-0
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,8 @@ int ReservedBackends;
239239
#define MAXLISTEN 64
240240
static pgsocket ListenSocket[MAXLISTEN];
241241

242+
unsigned char *ForkLock = NULL;
243+
242244
/*
243245
* Set by the -o option
244246
*/
@@ -4498,6 +4500,9 @@ BackendStartup(Port *port)
44984500
#ifdef EXEC_BACKEND
44994501
pid = backend_forkexec(port);
45004502
#else /* !EXEC_BACKEND */
4503+
4504+
if (gp_enable_fork_lock)
4505+
SpinLockAcquire(ForkLock);
45014506
pid = fork_process();
45024507
if (pid == 0) /* child */
45034508
{
@@ -4522,6 +4527,8 @@ BackendStartup(Port *port)
45224527

45234528
/* Perform additional initialization and collect startup packet */
45244529
BackendInitialize(port);
4530+
if (gp_enable_fork_lock)
4531+
SpinLockRelease(ForkLock);
45254532

45264533
/* And run the backend */
45274534
BackendRun(port);

src/backend/storage/ipc/ipci.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@ CreateSharedMemoryAndSemaphores(int port)
372372

373373
if (gp_enable_resqueue_priority)
374374
BackoffStateInit();
375+
if (gp_enable_fork_lock) {
376+
/* Create ProcStructLock spinlock, too */
377+
ForkLock = (slock_t *) ShmemAlloc(sizeof(slock_t));
378+
SpinLockInit(ForkLock);
379+
}
375380

376381
/* Initialize dynamic shared memory facilities. */
377382
if (!IsUnderPostmaster)

src/backend/utils/misc/guc_gp.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ static char *gp_resource_manager_str;
215215

216216
/* Backoff-related GUCs */
217217
bool gp_enable_resqueue_priority;
218+
bool gp_enable_fork_lock;
218219
int gp_resqueue_priority_local_interval;
219220
int gp_resqueue_priority_sweeper_interval;
220221
int gp_resqueue_priority_inactivity_timeout;
@@ -1744,6 +1745,16 @@ struct config_bool ConfigureNamesBool_gp[] =
17441745
NULL, NULL, NULL
17451746
},
17461747

1748+
{
1749+
{"gp_enable_fork_lock", PGC_POSTMASTER, RESOURCES_MGM,
1750+
gettext_noop("Enables priority scheduling."),
1751+
NULL
1752+
},
1753+
&gp_enable_fork_lock,
1754+
true,
1755+
NULL, NULL, NULL
1756+
},
1757+
17471758
{
17481759
{"debug_resource_group", PGC_USERSET, DEVELOPER_OPTIONS,
17491760
gettext_noop("Prints resource groups debug logs."),

src/include/postmaster/backoff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/* GUCs */
1414
extern bool gp_enable_resqueue_priority;
15+
extern bool gp_enable_fork_lock;
1516
extern int gp_resqueue_priority_local_interval;
1617
extern int gp_resqueue_priority_sweeper_interval;
1718
extern int gp_resqueue_priority_inactivity_timeout;

src/include/postmaster/postmaster.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ extern int postmaster_alive_fds[2];
5555
extern const char *progname;
5656
extern PGDLLIMPORT const char *progname;
5757

58+
extern unsigned char *ForkLock;
59+
5860
extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
5961
extern void ClosePostmasterPorts(bool am_syslogger);
6062

src/include/utils/sync_guc_name.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"gp_enable_mk_sort",
2424
"gp_enable_motion_mk_sort",
2525
"gp_enable_segment_copy_checking",
26+
"gp_enable_fork_lock",
2627
"gp_external_enable_filter_pushdown",
2728
"gp_gpperfmon_send_interval",
2829
"gp_hashagg_default_nbatches",

0 commit comments

Comments
 (0)