]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: wdt: also consider that waiting in the thread dumper is normal
authorWilly Tarreau <w@1wt.eu>
Wed, 31 Jul 2019 17:20:39 +0000 (19:20 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 31 Jul 2019 17:35:31 +0000 (19:35 +0200)
It happens that upon looping threads the watchdog fires, starts a dump,
and other threads expire their budget while waiting for the other threads
to get dumped and trigger a watchdog event again, adding some confusion
to the traces. With this patch the situation becomes clearer as we export
the list of threads being dumped so that the watchdog can check it before
deciding to trigger. This way such threads in queue for being dumped are
not attempted to be reported in turn.

This should be backported to 2.0 as it helps understand stack traces.

include/common/debug.h
src/debug.c
src/wdt.c

index 333203dd2e2dc02c26fc55dc194ffdfcad88362e..f43258e923efed8ea9e3be2305b4fe67c76ee515 100644 (file)
@@ -70,6 +70,7 @@
 
 struct task;
 struct buffer;
+extern volatile unsigned long threads_to_dump;
 void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx);
 void ha_thread_dump(struct buffer *buf, int thr, int calling_tid);
 void ha_thread_dump_all_to_trash();
index 9f538b6606dac9fae7f23126b04055a620d96da3..0522f88bf7098fbc87fed958e10b40db47c429f7 100644 (file)
 #include <proto/stream_interface.h>
 #include <proto/task.h>
 
+/* mask of threads still having to dump, used to respect ordering. Only used
+ * when USE_THREAD_DUMP is set.
+ */
+volatile unsigned long threads_to_dump = 0;
+
 /* Dumps to the buffer some known information for the desired thread, and
  * optionally extra info for the current thread. The dump will be appended to
  * the buffer, so the caller is responsible for preliminary initializing it.
@@ -404,9 +409,6 @@ void ha_thread_dump_all_to_trash()
  */
 #define DEBUGSIG SIGURG
 
-/* mask of threads still having to dump, used to respect ordering */
-static volatile unsigned long threads_to_dump;
-
 /* ID of the thread requesting the dump */
 static unsigned int thread_dump_tid;
 
index 19d36c34d2a2ca4a95dd11441c7c3f3142f2e207..aa89fd443e76e73c6bcca73a168534c4f3819316 100644 (file)
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -75,7 +75,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
                if (n - p < 1000000000UL)
                        goto update_and_leave;
 
-               if ((threads_harmless_mask|sleeping_thread_mask) & (1UL << thr)) {
+               if ((threads_harmless_mask|sleeping_thread_mask|threads_to_dump) & (1UL << thr)) {
                        /* This thread is currently doing exactly nothing
                         * waiting in the poll loop (unlikely but possible),
                         * waiting for all other threads to join the rendez-vous