Skip to content

Commit 13fe24f

Browse files
committed
More robust watchdog error handling
1 parent 681c869 commit 13fe24f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

config-available/watchdog.pl

+11-4
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,25 @@
4343
Infrequently Pengines escape their time limit.
4444
*/
4545

46+
% When to consider a thread a runaway? CPU time in seconds.
47+
runaway_min_time(1800).
48+
4649
:- initialization
4750
http_schedule_maintenance(daily(02:50), kill_runaway_threads).
4851

4952
kill_runaway_threads :-
50-
forall(runaway_thread(TID, Time),
53+
runaway_min_time(MinTime),
54+
forall(runaway_thread(TID, MinTime, Time),
5155
kill_thread(TID, Time)).
5256

53-
runaway_thread(TID, CPU) :-
57+
runaway_thread(TID, MinTime, CPU) :-
5458
thread_property(TID, id(_)),
59+
catch(anon_thread_cpu(TID, CPU), error(_,_), fail),
60+
CPU > MinTime.
61+
62+
anon_thread_cpu(TID, CPU) :-
5563
\+ thread_property(TID, alias(_)),
56-
thread_statistics(TID, cputime, CPU),
57-
CPU > 1800.
64+
thread_statistics(TID, cputime, CPU).
5865

5966
kill_thread(TID, Time) :-
6067
print_message(warning, kill_runaway(TID, Time)),

0 commit comments

Comments
 (0)