Fix: sessiond: rotation thread: fatal error when not finding a session
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 9 Dec 2021 21:27:29 +0000 (16:27 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 21 Jan 2022 23:02:26 +0000 (18:02 -0500)
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 <jeremie.galarneau@efficios.com>
Change-Id: I588054bad3542854851f28d34f2c758bdf420a34

src/bin/lttng-sessiond/rotation-thread.c

index ac149c845b79c9436674908ee9c5b942db79c0d2..cf18c8498bccf9889433c6e5abbcf35ee21233ec 100644 (file)
@@ -25,6 +25,7 @@
 #include <lttng/notification/channel-internal.h>
 #include <lttng/rotate-internal.h>
 #include <lttng/location-internal.h>
+#include <lttng/condition/condition-internal.h>
 
 #include "rotation-thread.h"
 #include "lttng-sessiond.h"
@@ -659,10 +660,15 @@ 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("Session \"%s\" not found",
+               DBG("Failed to find session while handling notification: notification type = %s, session name = `%s`",
+                               lttng_condition_type_str(condition_type),
                                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);
This page took 0.026012 seconds and 4 git commands to generate.