You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
INTO STRICT t_id, t_worker, t_status, t_failure_count, t_last_task_start, t_last_task_end, t_last_success_start
23
+
FROMpublic.sync_infoWHERE sync_target = s_target AND sync_function = s_function;
24
+
ASSERT s_status >'active';
25
+
ASSERT t_worker = s_worker, 'Wrong worker';
26
+
ASSERT s_status >= t_status, 'do not go back in status';
27
+
IF s_status ='complete' THEN
28
+
t_last_task_end := now();
29
+
t_last_success_start := t_last_task_start;
30
+
t_failure_count :=0;
31
+
ELSE
32
+
IF t_status != s_status THEN
33
+
t_failure_count := t_failure_count +1;
34
+
END IF;
35
+
END IF;
36
+
37
+
UPDATEpublic.sync_info
38
+
SET status = s_status,
39
+
task_times_out_at=null,
40
+
last_task_end=t_last_task_end,
41
+
last_success_start=t_last_success_start,
42
+
failure_count=t_failure_count
43
+
WHERE id=t_id;
44
+
END;
45
+
$function$
46
+
;
47
+
48
+
49
+
CREATE OR REPLACEFUNCTIONpublic.propose_sync_task(s_target bigint, s_function character varying, s_worker character varying, timeout interval, task_interval interval)
50
+
RETURNS timestamp with time zone
51
+
LANGUAGE plpgsql
52
+
SET search_path TO ''
53
+
AS $function$
54
+
DECLARE s_id INTEGER;
55
+
DECLARE start_time TIMESTAMP WITH TIME ZONE := now();
56
+
DECLARE t_status public.task_status;
57
+
DECLARE t_failure_count SMALLINT;
58
+
DECLARE t_last_task_start TIMESTAMP WITH TIME ZONE;
59
+
DECLARE t_last_task_end TIMESTAMP WITH TIME ZONE;
60
+
DECLARE t_times_out_at TIMESTAMP WITH TIME ZONE;
61
+
DECLARE t_last_success_start TIMESTAMP WITH TIME ZONE;
0 commit comments