From c19ea82db9e8afbfb4bb52e1cb15630863b3cf74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 9 Dec 2021 16:27:29 -0500 Subject: [PATCH] Fix: sessiond: rotation thread: fatal error when not finding a session MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The rotation thread implements scheduled rotations (by size) by registering a trigger that monitors the session's consumed size and notifies when the next rotation's size threshold is exceeded. The notification is delivered asynchronously which doesn't prevent the session from being destroyed before the rotation thread has had the time to process the notification (and perform a rotation). Since it is possible for a session to be destroyed by the time the notification is processed, the rotation thread shouldn't handle this eventuality as a fatal error (shutting down the thread). Note that nobody reported this issue nor did I attempt to reproduce it. Signed-off-by: Jérémie Galarneau Change-Id: I588054bad3542854851f28d34f2c758bdf420a34 --- src/bin/lttng-sessiond/rotation-thread.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index fa6808005..7ca9142ce 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "rotation-thread.h" #include "lttng-sessiond.h" @@ -662,10 +663,14 @@ int handle_condition(const struct lttng_condition *condition, session_lock_list(); session = session_find_by_name(condition_session_name); if (!session) { - ret = -1; - session_unlock_list(); - ERR("[rotation-thread] Session \"%s\" not found", + DBG("[rotation-thread] Failed to find session while handling notification: session name = `%s`", condition_session_name); + /* + * Not a fatal error: a session can be destroyed before we get + * the chance to handle the notification. + */ + ret = 0; + session_unlock_list(); goto end; } session_lock(session); -- 2.34.1