|
43 | 43 | Infrequently Pengines escape their time limit.
|
44 | 44 | */
|
45 | 45 |
|
| 46 | +% When to consider a thread a runaway? CPU time in seconds. |
| 47 | +runaway_min_time(1800). |
| 48 | + |
46 | 49 | :- initialization
|
47 | 50 | http_schedule_maintenance(daily(02:50), kill_runaway_threads).
|
48 | 51 |
|
49 | 52 | kill_runaway_threads :-
|
50 |
| - forall(runaway_thread(TID, Time), |
| 53 | + runaway_min_time(MinTime), |
| 54 | + forall(runaway_thread(TID, MinTime, Time), |
51 | 55 | kill_thread(TID, Time)).
|
52 | 56 |
|
53 |
| -runaway_thread(TID, CPU) :- |
| 57 | +runaway_thread(TID, MinTime, CPU) :- |
54 | 58 | thread_property(TID, id(_)),
|
| 59 | + catch(anon_thread_cpu(TID, CPU), error(_,_), fail), |
| 60 | + CPU > MinTime. |
| 61 | + |
| 62 | +anon_thread_cpu(TID, CPU) :- |
55 | 63 | \+ thread_property(TID, alias(_)),
|
56 |
| - thread_statistics(TID, cputime, CPU), |
57 |
| - CPU > 1800. |
| 64 | + thread_statistics(TID, cputime, CPU). |
58 | 65 |
|
59 | 66 | kill_thread(TID, Time) :-
|
60 | 67 | print_message(warning, kill_runaway(TID, Time)),
|
|
0 commit comments