action executor: execute action only if the associated trigger is registered
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 12 Apr 2021 19:41:36 +0000 (15:41 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 18 Apr 2021 23:28:57 +0000 (19:28 -0400)
It was decided that a trigger removal should have immediate effect and
not result in a waiting on action queued to be executed.

There was two major way to do this:

1) On unregistrer trigger, lock the action executor queue and remove
all work-item related to the trigger ebing unregistered.

2) Mark the trigger as "unregistered" and validate its state when a work
item is ready for execution. If the trigger is marked as "unregistered",
simply consume and skip the work item.

To isolate the un-registration and the execution of a work item
depending on that trigger, we use the trigger lock to have exclusivity
during the execution for that trigger.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I9f42a323e0ec0dc51339f39f07536ec8060dc02a

src/bin/lttng-sessiond/action-executor.c

index 6c828c8f05221536e6a887337591a34e30dfe7ae..f150dbb44af438b37aac1734ebffd85d116e1beb 100644 (file)
@@ -593,7 +593,41 @@ static void *action_executor_thread(void *_data)
                 * allowing new items to be queued.
                 */
                pthread_mutex_unlock(&executor->work.lock);
+
+               /* Execute item only if a trigger is registered. */
+               lttng_trigger_lock(work_item->trigger);
+               if (!lttng_trigger_is_registered(work_item->trigger)) {
+                       const char *trigger_name = NULL;
+                       uid_t trigger_owner_uid;
+                       enum lttng_trigger_status trigger_status;
+
+                       trigger_status = lttng_trigger_get_name(
+                                       work_item->trigger, &trigger_name);
+                       switch (trigger_status) {
+                       case LTTNG_TRIGGER_STATUS_OK:
+                               break;
+                       case LTTNG_TRIGGER_STATUS_UNSET:
+                               trigger_name = "(unset)";
+                               break;
+                       default:
+                               abort();
+                       }
+
+                       trigger_status = lttng_trigger_get_owner_uid(
+                                       work_item->trigger, &trigger_owner_uid);
+                       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+
+                       DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d",
+                                       work_item->id, trigger_name,
+                                       (int) trigger_owner_uid);
+                       ret = 0;
+                       goto skip_execute;
+               }
+
                ret = action_work_item_execute(executor, work_item);
+
+       skip_execute:
+               lttng_trigger_unlock(work_item->trigger);
                action_work_item_destroy(work_item);
                if (ret) {
                        /* Fatal error. */
This page took 0.027477 seconds and 4 git commands to generate.