Skip to content

Commit 1397803

Browse files
committed
Add 'contrib/pgpro_scheduler/' from commit 'b8b4a8689dfa05949cd48902d506541be19af87d'
git-subtree-dir: contrib/pgpro_scheduler git-subtree-mainline: 8b16c8f git-subtree-split: b8b4a86
2 parents 8b16c8f + b8b4a86 commit 1397803

32 files changed

+6652
-0
lines changed

contrib/pgpro_scheduler/Makefile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
MODULE_big = pgpro_scheduler
2+
OBJS = src/pgpro_scheduler.o src/cron_string.o src/sched_manager_poll.o \
3+
src/char_array.o src/scheduler_spi_utils.o src/scheduler_manager.o \
4+
src/bit_array.o src/scheduler_job.o src/memutils.o \
5+
src/scheduler_executor.o \
6+
$(WIN32RES)
7+
EXTENSION = pgpro_scheduler
8+
DATA = pgpro_scheduler--1.0.sql
9+
#SCRIPTS = bin/pgpro_scheduler
10+
#REGRESS = install_pgpro_scheduler cron_string
11+
#REGRESS_OPTS = --create-role=robot --user=postgres
12+
CFLAGS=-ggdb -Og -g3 -fno-omit-frame-pointer
13+
14+
ifdef USE_PGXS
15+
PG_CONFIG = pg_config
16+
PGXS := $(shell $(PG_CONFIG) --pgxs)
17+
include $(PGXS)
18+
else
19+
subdir = contrib/pgpro_scheduler
20+
top_builddir = ../..
21+
include $(top_builddir)/src/Makefile.global
22+
include $(top_srcdir)/contrib/contrib-global.mk
23+
endif

contrib/pgpro_scheduler/README.md

Lines changed: 538 additions & 0 deletions
Large diffs are not rendered by default.

contrib/pgpro_scheduler/internals.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# pgpro_scheduler internals
2+
3+
Extention creates 3 tables in schema `schedule`. They are not accessable
4+
by public.
5+
6+
**schedule.cron** - table contains records to be scheduled to porces job.
7+
Analog for crontab.
8+
9+
CREATE TABLE schedule.cron(
10+
id SERIAL PRIMARY KEY,
11+
name text, -- name of job
12+
node text, -- name of node
13+
comments text, -- comments on job
14+
rule jsonb, -- json object with shedule, see description below
15+
next_time_statement text, -- sql statement to be executed to
16+
-- calculate next execution time
17+
do_sql text[], -- SQL statements to be executed
18+
same_transaction boolean DEFAULT false, -- if sequence in do_sql will be
19+
-- executed in one transaction
20+
onrollback_statement text, -- sql statement to be executed after ROLLBACK
21+
active boolean DEFAULT true, -- is job active
22+
broken boolean DEFAULT false, -- is job broken
23+
executor text, -- name of executor user
24+
owner text, -- neme of user who owns (created) job
25+
postpone interval, -- on what time execution could be delayed if there
26+
-- are no free session to execute it in time
27+
retry integer default 0, -- number of retrys if error
28+
max_run_time interval, -- how long job can be processed
29+
max_instances integer default 1, -- how much instances of the same
30+
-- job could be executed simultaneously
31+
start_date timestamp, -- begin of time period within job can
32+
-- be performed, can be NULL
33+
end_date timestamp, -- end of time period within job can
34+
-- be performed, can be NULL
35+
reason text -- text reason why job marked as broken
36+
);
37+
38+
**schedule.at** - table stores nearest jobs to be executed or
39+
being executed at the moment. Each record contains information about
40+
time the job must begin, reference to cron table, time of last start allowed
41+
(if specified), time of actual start (if being performed), state - waiting
42+
execution or executing.
43+
44+
CREATE TABLE schedule.at(
45+
start_at timestamp, -- time job will start
46+
last_start_available timestamp, -- time last start allowed
47+
retry integer,
48+
cron integer REFERENCES schedule.cron (id), -- cron table reference
49+
node text,
50+
started timestamp, -- time of actual start
51+
active boolean -- true - execution, false - waiting
52+
);
53+
54+
**scedule.log** - table with job executed. When job has been performed
55+
it moved from **schedule.at** to this table, so tables has about the same
56+
structure except this table has information about result of execution.
57+
58+
CREATE TABLE schedule.log(
59+
start_at timestamp, -- time at job were to be started
60+
last_start_available timestamp, -- time of last start available
61+
retry integer,
62+
cron integer, -- reference to cron table
63+
node text, -- reference to cron table node
64+
started timestamp, -- time job has been started
65+
finished timestamp, -- time job has been finished
66+
status boolean, -- true - success, false - failure
67+
message text -- error message
68+
);
69+

0 commit comments

Comments
 (0)