From 3b61d9ee2a0611e980fb2817d6dd5fa3c9c7be68 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 20 Nov 2019 16:09:50 -0500 Subject: [PATCH] Fix: sessiond: don't wait for a rotation from a null chunk to finish MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/bin/lttng-sessiond/cmd.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 5a122d8d3..7c9477df9 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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; } -- 2.34.1