Fix: sessiond: don't wait for a rotation from a null chunk to finish
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 20 Nov 2019 21:09:50 +0000 (16:09 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 20 Nov 2019 21:16:30 +0000 (16:16 -0500)
The rotation completion checking does not handle waiting for the
completion of a rotation _from_ a NULL trace chunk. This is correct as
there is essentially nothing to check. Streams always rotate out of a
null trace chunk immediately as it means the stream had no output and
could not receive data.

Concretely, this happens when stopping a session, rotating, and
re-starting a session.

The fix consists in simply re-working the logic of the "rotate"
command to not launch a rotation completion check job and not put the
session in the "rotation ongoing" state.

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

index 5a122d8d3c8dcf7e7f361b34f69f46c4680c0d22..7c9477df938787407dc5eaf8b0c569ddfa0557a5 100644 (file)
@@ -4925,9 +4925,6 @@ int cmd_rotate_session(struct ltt_session *session,
                cmd_ret = LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP;
                goto end;
        }
-
-       session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
-
        if (session->active) {
                new_trace_chunk = session_create_new_trace_chunk(session, NULL,
                                NULL, NULL);
@@ -4951,11 +4948,6 @@ int cmd_rotate_session(struct ltt_session *session,
                goto error;
        }
 
-       assert(chunk_being_archived);
-       chunk_status = lttng_trace_chunk_get_id(chunk_being_archived,
-                       &ongoing_rotation_chunk_id);
-       assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
-
        if (session->kernel_session) {
                cmd_ret = kernel_rotate_session(session);
                if (cmd_ret != LTTNG_OK) {
@@ -4971,6 +4963,26 @@ int cmd_rotate_session(struct ltt_session *session,
                }
        }
 
+       if (!session->active) {
+               session->rotated_after_last_stop = true;
+       }
+
+       if (!chunk_being_archived) {
+               DBG("Rotating session \"%s\" from a \"NULL\" trace chunk to a new trace chunk, skipping completion check",
+                               session->name);
+               if (failed_to_rotate) {
+                       cmd_ret = rotation_fail_code;
+                       goto error;
+               }
+               cmd_ret = LTTNG_OK;
+               goto end;
+       }
+
+       session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
+       chunk_status = lttng_trace_chunk_get_id(chunk_being_archived,
+                       &ongoing_rotation_chunk_id);
+       assert(chunk_status == LTTNG_TRACE_CHUNK_STATUS_OK);
+
        ret = session_close_trace_chunk(session, chunk_being_archived,
                        quiet_rotation ?
                                        NULL :
@@ -4995,10 +5007,6 @@ int cmd_rotate_session(struct ltt_session *session,
                goto error;
        }
 
-       if (!session->active) {
-               session->rotated_after_last_stop = true;
-       }
-
        if (rotate_return) {
                rotate_return->rotation_id = ongoing_rotation_chunk_id;
        }
This page took 0.02823 seconds and 4 git commands to generate.