You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
2.7 KiB

  1. commit 445b2b7c52a13678241a190c4ff52e77a09ef0a6
  2. Author: Willy Tarreau <w@1wt.eu>
  3. Date: Wed Jul 31 19:20:39 2019 +0200
  4. MINOR: wdt: also consider that waiting in the thread dumper is normal
  5. It happens that upon looping threads the watchdog fires, starts a dump,
  6. and other threads expire their budget while waiting for the other threads
  7. to get dumped and trigger a watchdog event again, adding some confusion
  8. to the traces. With this patch the situation becomes clearer as we export
  9. the list of threads being dumped so that the watchdog can check it before
  10. deciding to trigger. This way such threads in queue for being dumped are
  11. not attempted to be reported in turn.
  12. This should be backported to 2.0 as it helps understand stack traces.
  13. (cherry picked from commit a37cb1880c81b1f038e575d88ba7210aea0b7b8f)
  14. Signed-off-by: Willy Tarreau <w@1wt.eu>
  15. diff --git a/include/common/debug.h b/include/common/debug.h
  16. index 333203dd..f43258e9 100644
  17. --- a/include/common/debug.h
  18. +++ b/include/common/debug.h
  19. @@ -70,6 +70,7 @@
  20. struct task;
  21. struct buffer;
  22. +extern volatile unsigned long threads_to_dump;
  23. void ha_task_dump(struct buffer *buf, const struct task *task, const char *pfx);
  24. void ha_thread_dump(struct buffer *buf, int thr, int calling_tid);
  25. void ha_thread_dump_all_to_trash();
  26. diff --git a/src/debug.c b/src/debug.c
  27. index 07624ca5..3077e97c 100644
  28. --- a/src/debug.c
  29. +++ b/src/debug.c
  30. @@ -29,6 +29,11 @@
  31. #include <proto/stream_interface.h>
  32. #include <proto/task.h>
  33. +/* mask of threads still having to dump, used to respect ordering. Only used
  34. + * when USE_THREAD_DUMP is set.
  35. + */
  36. +volatile unsigned long threads_to_dump = 0;
  37. +
  38. /* Dumps to the buffer some known information for the desired thread, and
  39. * optionally extra info for the current thread. The dump will be appended to
  40. * the buffer, so the caller is responsible for preliminary initializing it.
  41. @@ -405,9 +410,6 @@ void ha_thread_dump_all_to_trash()
  42. */
  43. #define DEBUGSIG SIGURG
  44. -/* mask of threads still having to dump, used to respect ordering */
  45. -static volatile unsigned long threads_to_dump;
  46. -
  47. /* ID of the thread requesting the dump */
  48. static unsigned int thread_dump_tid;
  49. diff --git a/src/wdt.c b/src/wdt.c
  50. index 19d36c34..aa89fd44 100644
  51. --- a/src/wdt.c
  52. +++ b/src/wdt.c
  53. @@ -75,7 +75,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg)
  54. if (n - p < 1000000000UL)
  55. goto update_and_leave;
  56. - if ((threads_harmless_mask|sleeping_thread_mask) & (1UL << thr)) {
  57. + if ((threads_harmless_mask|sleeping_thread_mask|threads_to_dump) & (1UL << thr)) {
  58. /* This thread is currently doing exactly nothing
  59. * waiting in the poll loop (unlikely but possible),
  60. * waiting for all other threads to join the rendez-vous