Don't perform an implicit rotation on session stop
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 21 Nov 2018 15:41:07 +0000 (10:41 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 10 Dec 2018 20:24:49 +0000 (15:24 -0500)
Performing a periodic rotation on stop does not allow a user to start
and stop a session within a given chunk.

There is no functionality lost from not performing the rotation
implicitly on stop; the user could decide to explicitly perform the
rotation himself.

The timestamp of the last stop command is sampled to allow the trace
archive chunk to be accurately named should a rotation be performed.

Moreover, this change moves the implicit rotation performed at the
moment of the stop to the moment of the session's destruction. This
ensures that users don't end-up with a partially-named trace archive
chunk folder upon destruction (timestamp_begin-id).

In effect, this will perform an implicit session rotation as part of
the "session destroy" command if the session was rotated at any point
during its lifetime.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c

index 1ac133f3606d68d3114bb6405f103d89f30851ea..507274f35568bc421887ebfb88674d476297af1d 100644 (file)
@@ -2747,32 +2747,6 @@ int cmd_stop_trace(struct ltt_session *session)
                goto error;
        }
 
-       if (session->rotation_schedule_timer_enabled) {
-               if (timer_session_rotation_schedule_timer_stop(
-                               session)) {
-                       ERR("Failed to stop the \"rotation schedule\" timer of session %s",
-                                       session->name);
-               }
-       }
-
-       /*
-        * A rotation is still ongoing. The check timer will continue to wait
-        * for the rotation to complete. When the rotation finally completes,
-        * a check will be performed to rename the "active" chunk to the
-        * expected "timestamp_begin-timestamp_end" format.
-        */
-       if (session->current_archive_id > 0 &&
-                       session->rotation_state != LTTNG_ROTATION_STATE_ONGOING) {
-               ret = rename_active_chunk(session);
-               if (ret) {
-                       /*
-                        * This error should not prevent the user from stopping
-                        * the session. However, it will be reported at the end.
-                        */
-                       error_occurred = true;
-               }
-       }
-
        /* Kernel tracer */
        if (ksession && ksession->active) {
                DBG("Stop kernel tracing");
@@ -3056,13 +3030,6 @@ int cmd_destroy_session(struct ltt_session *session,
 
        DBG("Begin destroy session %s (id %" PRIu64 ")", session->name, session->id);
 
-       if (session->rotation_pending_check_timer_enabled) {
-               if (timer_session_rotation_pending_check_stop(session)) {
-                       ERR("Failed to stop the \"rotation pending check\" timer of session %s",
-                                       session->name);
-               }
-       }
-
        if (session->rotation_schedule_timer_enabled) {
                if (timer_session_rotation_schedule_timer_stop(
                                session)) {
@@ -3076,13 +3043,27 @@ int cmd_destroy_session(struct ltt_session *session,
                session->rotate_size = 0;
        }
 
-       /*
-        * The rename of the current chunk is performed at stop, but if we rotated
-        * the session after the previous stop command, we need to rename the
-        * new (and empty) chunk that was started in between.
-        */
-       if (session->rotated_after_last_stop) {
-               rename_active_chunk(session);
+       if (session->current_archive_id != 0) {
+               if (!session->rotated_after_last_stop) {
+                       ret = cmd_rotate_session(session, NULL);
+                       if (ret != LTTNG_OK) {
+                               ERR("Failed to perform an implicit rotation as part of the rotation: %s", lttng_strerror(-ret));
+                       }
+               } else {
+                       /*
+                        * Rename the active chunk to ensure it has a name
+                        * of the form ts_begin-ts_end-id.
+                        *
+                        * Note that no trace data has been produced since
+                        * the last rotation; the directory should be
+                        * removed.
+                        */
+                       ret = rename_active_chunk(session);
+                       if (ret) {
+                               ERR("Failed to rename active chunk during the destruction of session \"%s\"",
+                                               session->name);
+                       }
+               }
        }
 
        if (session->shm_path[0]) {
This page took 0.028234 seconds and 4 git commands to generate.