Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a5283c

Browse files
committed
Merge branch 'PGPROEE9_6_scheduler' into PGPROEE9_6
2 parents90c37c0 +c9bd96b commit1a5283c

12 files changed

+910
-180
lines changed

‎contrib/pgpro_scheduler/pgpro_scheduler--2.0.sql

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,15 @@ CREATE TABLE at_jobs_submitted(
2828
CREATEINDEXON at_jobs_submitted(at,submit_time);
2929
CREATEINDEXON at_jobs_submitted (last_start_available, node);
3030

31-
CREATETABLEat_jobs_process(
32-
start_timetimestamp with time zone default now()
33-
) INHERITS (at_jobs_submitted);
31+
CREATETABLEat_jobs_process (like at_jobs_submitted including all);
32+
ALTERTABLE at_jobs_process ADDstart_timetimestamp with time zone default now();
33+
CREATEINDEXat_jobs_process_node_at_idxon at_jobs_process (node, at);
3434

35-
ALTERTABLE at_jobs_process ADDprimary key (id);
36-
CREATEINDEXat_jobs_process_node_at_idxon at_jobs_process (node, at);
35+
CREATETABLEat_jobs_done (like at_jobs_process including all);
36+
ALTERTABLE at_jobs_done ADD statusboolean;
37+
ALTERTABLE at_jobs_done ADD reasontext;
38+
ALTERTABLE at_jobs_done ADD done_timetimestamp with time zone default now();
3739

38-
CREATETABLEat_jobs_done(
39-
statusboolean,
40-
reasontext,
41-
done_timetimestamp with time zone default now()
42-
) INHERITS (at_jobs_process);
43-
44-
ALTERTABLE at_jobs_done ADDprimary key (id);
45-
CREATEINDEXat_jobs_done_node_at_idxon at_jobs_done (node, at);
4640

4741
CREATETABLEcron(
4842
idSERIALPRIMARY KEY,

‎contrib/pgpro_scheduler/src/pgpro_scheduler.c

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ char *scheduler_databases = NULL;
4646
char*scheduler_nodename=NULL;
4747
char*scheduler_transaction_state=NULL;
4848
intscheduler_max_workers=2;
49-
intscheduler_at_max_workers=2;
49+
intscheduler_max_parallel_workers=2;
50+
intscheduler_worker_job_limit=1;
5051
boolscheduler_service_enabled= false;
5152
char*scheduler_schema=NULL;
5253
/* Custom GUC done */
@@ -163,6 +164,29 @@ bool is_scheduler_enabled(void)
163164
return false;
164165
}
165166

167+
char*set_schema(constchar*name,boolget_old)
168+
{
169+
char*schema_name=NULL;
170+
char*current=NULL;
171+
boolfree_name= false;
172+
173+
if(get_old)
174+
current=_copy_string((char*)GetConfigOption("search_path", true, false));
175+
if(name)
176+
{
177+
schema_name= (char*)name;
178+
}
179+
else
180+
{
181+
schema_name=_copy_string((char*)GetConfigOption("schedule.schema", true, false));
182+
free_name= true;
183+
}
184+
SetConfigOption("search_path",schema_name,PGC_USERSET,PGC_S_SESSION);
185+
if(free_name)pfree(schema_name);
186+
187+
returncurrent;
188+
}
189+
166190

167191
/** END of SOME UTILS **/
168192

@@ -472,10 +496,10 @@ void _PG_init(void)
472496
NULL
473497
);
474498
DefineCustomIntVariable(
475-
"schedule.at_max_workers",
499+
"schedule.max_parallel_workers",
476500
"How much workers can serve at jobs on one database",
477501
NULL,
478-
&scheduler_at_max_workers,
502+
&scheduler_max_parallel_workers,
479503
2,
480504
1,
481505
100,
@@ -497,6 +521,20 @@ void _PG_init(void)
497521
NULL,
498522
NULL
499523
);
524+
DefineCustomIntVariable(
525+
"schedule.worker_job_limit",
526+
"How much job can worker serve before shutdown",
527+
NULL,
528+
&scheduler_worker_job_limit,
529+
1,
530+
1,
531+
20000,
532+
PGC_SUSET,
533+
0,
534+
NULL,
535+
NULL,
536+
NULL
537+
);
500538
pg_scheduler_startup();
501539
}
502540

‎contrib/pgpro_scheduler/src/pgpro_scheduler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ int get_integer_from_string(char *s, int start, int len);
4040
TimestampTzget_timestamp_from_string(char*str);
4141
TimestampTz_round_timestamp_to_minute(TimestampTzts);
4242
boolis_scheduler_enabled(void);
43+
char*set_schema(constchar*name,boolget_old);
4344

4445
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp