]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: debug: don't mask the TH_FL_STUCK flag before dumping threads
authorWilly Tarreau <w@1wt.eu>
Mon, 2 Jan 2023 07:33:18 +0000 (08:33 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 2 Jan 2023 08:51:35 +0000 (09:51 +0100)
Commit f0c86ddfe ("BUG/MEDIUM: debug: fix parallel thread dumps again")
added a clearing of the TH_FL_STUCK flag before dumping threads in case
of parallel dumps, but that was in part a sort of workaround for some
remains of the commit that introduced the flag in 2.0 before the watchdog
existed, and which would set it after dumping a thread: e6a02fa65 ("MINOR:
threads: add a "stuck" flag to the thread_info struct"), and in part an
attempt to avoid that a thread waiting for too long during the dump would
get the flag set. But that is not possible, a thread waiting for being
dumped has the harmless bit set and doesn't get the stuck bit. What happens
in fact is that issuing "show threads" in fast loops ends up causing some
threads to keep their STUCK bit that was set at the end of "show threads",
and confuses the output.

The problem with doing this is that the flag is cleared before the thread
is dumped, and since this flag is used to decide whether to show a backtrace
or not, we don't get backtraces anymore of stuck threads since the commit
above in 2.7.

This patch just removes the two points where the flag was cleared by the
commit above. It should be backported to 2.7.

src/debug.c

index ba396306d35fff963d7cfa93acc33daa917003e8..c9b912e98ce74872a56a5b93465dc797e56efeb7 100644 (file)
@@ -1561,9 +1561,6 @@ void debug_handler(int sig, siginfo_t *si, void *arg)
        while ((HA_ATOMIC_LOAD(&thread_dump_state) & THREAD_DUMP_TMASK) != tid)
                ha_thread_relax();
 
-       /* make sure we don't count all that wait time against us */
-       HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK);
-
        if (!harmless)
                thread_harmless_end();
 
@@ -1610,9 +1607,6 @@ void debug_handler(int sig, siginfo_t *si, void *arg)
        while (HA_ATOMIC_LOAD(&thread_dump_state) & THREAD_DUMP_PMASK)
                ha_thread_relax();
 
-       /* make sure we don't count all that wait time against us */
-       HA_ATOMIC_AND(&th_ctx->flags, ~TH_FL_STUCK);
-
        if (!harmless)
                thread_harmless_end();