X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=30f40946df57b118ecf2158c754a80bb1b74dbb1;hp=f6c44d3be16e63096e856874344dd39e11b4d348;hb=7fdbed1c109a618ee160018d121d5096dd14bd08;hpb=70626904265631671312931f3e32d02583ce1e2e diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index f6c44d3be..30f40946d 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -3176,7 +3176,7 @@ int cmd_destroy_session(struct ltt_session *session, * Perform a last rotation on destruction if rotations have * occurred during the session's lifetime. */ - ret = cmd_rotate_session(session, NULL); + ret = cmd_rotate_session(session, NULL, false); if (ret != LTTNG_OK) { ERR("Failed to perform an implicit rotation as part of the destruction of session \"%s\": %s", session->name, lttng_strerror(-ret)); @@ -3184,7 +3184,23 @@ int cmd_destroy_session(struct ltt_session *session, if (reply_context) { reply_context->implicit_rotation_on_destroy = true; } - } + } else if (session->has_been_started && session->current_trace_chunk && + session_output_supports_trace_chunks(session)) { + /* + * The user has not triggered a session rotation. However, to + * ensure all data has been consumed, the session is rotated + * to a 'null' trace chunk before it is destroyed. + * + * This is a "quiet" rotation meaning that no notification is + * emitted and no renaming of the current trace chunk takes + * place. + */ + ret = cmd_rotate_session(session, NULL, true); + if (ret != LTTNG_OK) { + ERR("Failed to perform a quiet rotation as part of the destruction of session \"%s\": %s", + session->name, lttng_strerror(-ret)); + } + } if (session->shm_path[0]) { /* @@ -4713,7 +4729,8 @@ int cmd_set_session_shm_path(struct ltt_session *session, * Returns LTTNG_OK on success or else a negative LTTng error code. */ int cmd_rotate_session(struct ltt_session *session, - struct lttng_rotate_session_return *rotate_return) + struct lttng_rotate_session_return *rotate_return, + bool quiet_rotation) { int ret; uint64_t ongoing_rotation_chunk_id; @@ -4798,13 +4815,16 @@ int cmd_rotate_session(struct ltt_session *session, } ret = session_close_trace_chunk(session, chunk_being_archived, - &((enum lttng_trace_chunk_command_type) { - LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED})); + quiet_rotation ? + NULL : + &((enum lttng_trace_chunk_command_type){ + LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED})); if (ret) { cmd_ret = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER; goto error; } + session->quiet_rotation = quiet_rotation; ret = timer_session_rotation_pending_check_start(session, DEFAULT_ROTATE_PENDING_TIMER); if (ret) { @@ -4822,14 +4842,16 @@ int cmd_rotate_session(struct ltt_session *session, session->chunk_being_archived = chunk_being_archived; chunk_being_archived = NULL; - ret = notification_thread_command_session_rotation_ongoing( - notification_thread_handle, - session->name, session->uid, session->gid, - ongoing_rotation_chunk_id); - if (ret != LTTNG_OK) { - ERR("Failed to notify notification thread that a session rotation is ongoing for session %s", - session->name); - cmd_ret = ret; + if (!quiet_rotation) { + ret = notification_thread_command_session_rotation_ongoing( + notification_thread_handle, + session->name, session->uid, session->gid, + ongoing_rotation_chunk_id); + if (ret != LTTNG_OK) { + ERR("Failed to notify notification thread that a session rotation is ongoing for session %s", + session->name); + cmd_ret = ret; + } } DBG("Cmd rotate session %s, archive_id %" PRIu64 " sent",