Skip to content
Open

Bull #266

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/backend/postmaster/postmaster.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ int ReservedBackends;
#define MAXLISTEN 64
static pgsocket ListenSocket[MAXLISTEN];

unsigned char *ForkLock = NULL;

/*
* Set by the -o option
*/
Expand Down Expand Up @@ -4498,6 +4500,10 @@ BackendStartup(Port *port)
#ifdef EXEC_BACKEND
pid = backend_forkexec(port);
#else /* !EXEC_BACKEND */

if (gp_enable_fork_sleep)
pg_usleep(gp_enable_fork_sleep * 1000 /*ms*/);

pid = fork_process();
if (pid == 0) /* child */
{
Expand Down
5 changes: 5 additions & 0 deletions src/backend/storage/ipc/ipci.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,11 @@ CreateSharedMemoryAndSemaphores(int port)

if (gp_enable_resqueue_priority)
BackoffStateInit();
if (gp_enable_fork_sleep) {
/* Create ProcStructLock spinlock, too */
ForkLock = (slock_t *) ShmemAlloc(sizeof(slock_t));
SpinLockInit(ForkLock);
}

/* Initialize dynamic shared memory facilities. */
if (!IsUnderPostmaster)
Expand Down
15 changes: 14 additions & 1 deletion src/backend/utils/misc/guc_gp.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ static char *gp_resource_manager_str;

/* Backoff-related GUCs */
bool gp_enable_resqueue_priority;
int gp_enable_fork_sleep;
int gp_resqueue_priority_local_interval;
int gp_resqueue_priority_sweeper_interval;
int gp_resqueue_priority_inactivity_timeout;
Expand Down Expand Up @@ -1743,7 +1744,6 @@ struct config_bool ConfigureNamesBool_gp[] =
true,
NULL, NULL, NULL
},

{
{"debug_resource_group", PGC_USERSET, DEVELOPER_OPTIONS,
gettext_noop("Prints resource groups debug logs."),
Expand Down Expand Up @@ -3339,6 +3339,19 @@ struct config_bool ConfigureNamesBool_gp[] =

struct config_int ConfigureNamesInt_gp[] =
{

{
{"gp_enable_fork_sleep", PGC_USERSET, RESOURCES_MGM,
gettext_noop("Enables priority scheduling."),
gettext_noop("Enables priority scheduling."),
GUC_UNIT_S | GUC_NOT_IN_SAMPLE
},
&gp_enable_fork_sleep,
1000, 0, 72000,
NULL, NULL, NULL
},


{
{"readable_external_table_timeout", PGC_USERSET, EXTERNAL_TABLES,
gettext_noop("Cancel the query if no data read within N seconds."),
Expand Down
1 change: 1 addition & 0 deletions src/include/postmaster/backoff.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/* GUCs */
extern bool gp_enable_resqueue_priority;
extern int gp_enable_fork_sleep;
extern int gp_resqueue_priority_local_interval;
extern int gp_resqueue_priority_sweeper_interval;
extern int gp_resqueue_priority_inactivity_timeout;
Expand Down
2 changes: 2 additions & 0 deletions src/include/postmaster/postmaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ extern int postmaster_alive_fds[2];
extern const char *progname;
extern PGDLLIMPORT const char *progname;

extern unsigned char *ForkLock;

extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn));
extern void ClosePostmasterPorts(bool am_syslogger);

Expand Down
1 change: 1 addition & 0 deletions src/include/utils/sync_guc_name.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"gp_enable_mk_sort",
"gp_enable_motion_mk_sort",
"gp_enable_segment_copy_checking",
"gp_enable_fork_sleep",
"gp_external_enable_filter_pushdown",
"gp_gpperfmon_send_interval",
"gp_hashagg_default_nbatches",
Expand Down
Loading