From: Jérémie Galarneau Date: Wed, 20 Nov 2019 21:09:50 +0000 (-0500) Subject: Fix: sessiond: don't wait for a rotation from a null chunk to finish X-Git-Tag: v2.11.1~35 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e60b91893a23150ce4d558799182b4487e77fda3;p=lttng-tools.git Fix: sessiond: don't wait for a rotation from a null chunk to finish 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 --- 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; }