From: Jérémie Galarneau Date: Wed, 6 Jul 2022 16:09:41 +0000 (-0400) Subject: Fix: sessiond: handle empty scheduled rotations X-Git-Tag: v2.13.8~6 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=386d53c1e31caf0154e921c4b6d7aa940dfa602e Fix: sessiond: handle empty scheduled rotations A number of error codes were added to cmd_rotate_session since the implementation of size-based rotations. The rotation thread doesn't expect LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP and LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR which are not fatal failures. These rotations would simply result in an empty trace archive and are, therefore, not produced. In both cases, it is safe to wait for the next size cycle. Signed-off-by: Jérémie Galarneau Change-Id: Ib90526b586de17c0b14d16970c862d9f981ed464 --- diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index e4811bd44..297912c11 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -688,19 +688,28 @@ int handle_condition(const struct lttng_notification *notification, goto end_unlock; } - ret = cmd_rotate_session(session, NULL, false, - LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED); - if (ret == -LTTNG_ERR_ROTATION_PENDING) { + ret = cmd_rotate_session( + session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED); + switch (ret) { + case LTTNG_OK: + break; + case -LTTNG_ERR_ROTATION_PENDING: DBG("Rotate already pending, subscribe to the next threshold value"); - } else if (ret != LTTNG_OK) { - ERR("Failed to rotate on size notification with error: %s", - lttng_strerror(ret)); + break; + case -LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP: + DBG("Rotation already happened since last stop, subscribe to the next threshold value"); + break; + case -LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR: + DBG("Rotation already happened since last stop and clear, subscribe to the next threshold value"); + break; + default: + ERR("Failed to rotate on size notification with error: %s", lttng_strerror(ret)); ret = -1; goto end_unlock; } - ret = subscribe_session_consumed_size_rotation(session, - consumed + session->rotate_size, - notification_thread_handle); + + ret = subscribe_session_consumed_size_rotation( + session, consumed + session->rotate_size, notification_thread_handle); if (ret) { ERR("Failed to subscribe to session consumed size condition"); goto end_unlock;