Fix: remove broken health monitoring test `test_thread_exit`
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 28 Feb 2020 23:02:17 +0000 (18:02 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 28 Feb 2020 23:02:17 +0000 (18:02 -0500)
commit89c453960c909e2e793e246715026c5e81a83c3a
treea5af55492923a8aed62d8f670bb0919a824dd161
parentb2081a0f39bce45b3d1cf063308a9b77712f1a9f
Fix: remove broken health monitoring test `test_thread_exit`

The `test_thread_exit` test uses the testpoint() infrastructure to
simulate daemon threads dying at "random" times by calling
pthread_exit() and checks that dead threads are properly reported by
the health check API.

The health check system is implemented as a list of structures that
live in the TLS of the various monitored threads. When the health
thread receives a health-check request, it iterates on this list and
reports the current health status of the threads to the client.

When a thread is stalled, this works fine; the health TLS has not been
updated in some time and that can be observed by the client. However,
for a 'spurious' thread exit, this is a bit more fragile.

Essentially, the test assumes that the thread will not have
unregistered its health TLS, but that it will remain valid until the
thread is joined.

Unfortunately, this behaviour relies on the fact that threads were not
joined until late in the tear down of the session daemon in the
past. This is no longer the case for all threads.

To provide an example of a test sequence that results in a
crash:
  - the test kills the client thread,
  - the session daemon received SIGTERM,
  - the client thread is joined immediately,
  - the next thread to shutdown (gracefully) unregisters itself from
    the health monitoring sybsystem and, in doing so, accesses an
    invalid element while removing itself from the health_app list,
    causing a crash.

As a side note, I could not find a definitive answer on the lifetime
of TLS variables. Are they guaranteed to be accessible until a
pthread_join() or is it undefined to access them after a thread has
returned? I'm guessing this is a very internal implementation detail
of the pthread implementation being used and that we should not rely
on that behaviour.

There are multiple ways we could fix this problem, such as using
heap-allocated structures and ref-counting them to share ownership
with the health thread, using pthread_atexit() to clean-up, etc.

However, the LTTng daemons never pthread_exit() their threads to
handle errors (or even call it directly); handling this behaviour is
of dubious interest at the moment.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I16ec70eb683832fe5f2810885c995988b6194690
tests/long_regression
tests/regression/tools/health/Makefile.am
tests/regression/tools/health/test_thread_exit [deleted file]
This page took 0.025753 seconds and 4 git commands to generate.