Fix: sessiond: domain subdirectory not deleted on empty clear
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 9 Mar 2020 18:45:20 +0000 (14:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 10 Mar 2020 02:17:40 +0000 (22:17 -0400)
Scenario
=====

$ lttng create
$ lttng enable-event -u -a
$ lttng start

// no events are produced.

$ lttng clear

Sessiond fails on clear with this message:

Error: Error removing subdirectory '.tmp_new_chunk' file when deleting
chunk

Cause
=====

The "ust" domain directory is still present preventing the removal of
the ".tmp_new_chunk" directory.

Solution
=====

Use lttng_trace_chunk_create_subdirectory, ensuring that the domain
folder is moved/deleted as necessary.

Fixes #1244

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I81d23ffc9f330f50f718957d460ee7a2718c95a1
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/consumer.c
tests/regression/tools/clear/test_ust

index 5a6c1d5cf1b44970b611726157460e4be50513de..dc945020bf49853edf2e3369c48c4c9096a2acaa 100644 (file)
@@ -1792,6 +1792,7 @@ int consumer_create_trace_chunk(struct consumer_socket *socket,
        char creation_timestamp_buffer[ISO8601_STR_LEN];
        const char *creation_timestamp_str = "(none)";
        const bool chunk_has_local_output = relayd_id == -1ULL;
        char creation_timestamp_buffer[ISO8601_STR_LEN];
        const char *creation_timestamp_str = "(none)";
        const bool chunk_has_local_output = relayd_id == -1ULL;
+       enum lttng_trace_chunk_status tc_status;
        struct lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
                .u.create_trace_chunk.session_id = session_id,
        struct lttcomm_consumer_msg msg = {
                .cmd_type = LTTNG_CONSUMER_CREATE_TRACE_CHUNK,
                .u.create_trace_chunk.session_id = session_id,
@@ -1869,12 +1870,9 @@ int consumer_create_trace_chunk(struct consumer_socket *socket,
                        ret = -LTTNG_ERR_FATAL;
                        goto error;
                }
                        ret = -LTTNG_ERR_FATAL;
                        goto error;
                }
-               ret = lttng_directory_handle_create_subdirectory_as_user(
-                               chunk_directory_handle,
-                               domain_subdir,
-                               S_IRWXU | S_IRWXG,
-                               &chunk_credentials);
-               if (ret) {
+               tc_status = lttng_trace_chunk_create_subdirectory(
+                               chunk, domain_subdir);
+               if (tc_status != LTTNG_TRACE_CHUNK_STATUS_OK) {
                        PERROR("Failed to create chunk domain output directory \"%s\"",
                                domain_subdir);
                        ret = -LTTNG_ERR_FATAL;
                        PERROR("Failed to create chunk domain output directory \"%s\"",
                                domain_subdir);
                        ret = -LTTNG_ERR_FATAL;
index dcfc0ee0c855a413a6cf9211472dde90d4256a33..e121614d239ba00c42e434c570e51636079dd4fc 100755 (executable)
@@ -14,7 +14,7 @@ TESTAPP_PATH="$TESTDIR/utils/testapp"
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 
 TESTAPP_NAME="gen-ust-events"
 TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
 
-NUM_TESTS=1683
+NUM_TESTS=1915
 
 PAGE_SIZE=$(getconf PAGE_SIZE)
 TRACE_PATH=$(mktemp -d)
 
 PAGE_SIZE=$(getconf PAGE_SIZE)
 TRACE_PATH=$(mktemp -d)
@@ -113,6 +113,31 @@ function test_ust_streaming ()
        destroy_lttng_session_ok $SESSION_NAME
 }
 
        destroy_lttng_session_ok $SESSION_NAME
 }
 
+function test_ust_streaming_no_event ()
+{
+       local tracing_active=$1
+       local clear_twice=$2
+       #local rotate_before=$3 ignored
+       #local rotate_after=$4
+       local buffer_type=uid
+       local local_path="${TRACE_PATH}/${HOSTNAME}/${SESSION_NAME}*"
+       local channel_name="chan"
+
+       diag "Test ust streaming clear no event"
+       diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
+       create_lttng_session_uri $SESSION_NAME net://localhost
+       enable_ust_lttng_channel_ok $SESSION_NAME $channel_name --buffers-$buffer_type
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
+       start_lttng_tracing_ok $SESSION_NAME
+
+       do_clear_session $SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
+       stop_lttng_tracing_ok $SESSION_NAME
+
+       validate_directory_empty "$local_path"
+
+       destroy_lttng_session_ok $SESSION_NAME
+}
+
 function test_ust_streaming_rotate_clear ()
 {
        local tracing_active=$1
 function test_ust_streaming_rotate_clear ()
 {
        local tracing_active=$1
@@ -327,6 +352,30 @@ function test_ust_local ()
        destroy_lttng_session_ok $SESSION_NAME
 }
 
        destroy_lttng_session_ok $SESSION_NAME
 }
 
+function test_ust_local_no_event ()
+{
+       local tracing_active=$1
+       local clear_twice=$2
+       #local rotate_before=$3 ignored
+       #local rotate_after=$4 ignored
+       local buffer_type=$5
+       local channel_name="chan"
+
+       diag "Test ust local no event"
+       diag "Parameters: tracing_active=$tracing_active, clear_twice=$clear_twice, rotate_before=$rotate_before, rotate_after=$rotate_after, buffer_type=$buffer_type"
+       create_lttng_session_ok $SESSION_NAME "$TRACE_PATH"
+       enable_ust_lttng_channel_ok $SESSION_NAME $channel_name "--buffers-$buffer_type"
+       enable_ust_lttng_event_ok $SESSION_NAME $EVENT_NAME $channel_name
+       start_lttng_tracing_ok $SESSION_NAME
+
+       do_clear_session $SESSION_NAME "$tracing_active" "$clear_twice" "$rotate_before" "$rotate_after"
+       stop_lttng_tracing_ok $SESSION_NAME
+
+       validate_directory_empty "$TRACE_PATH"
+
+       destroy_lttng_session_ok $SESSION_NAME
+}
+
 function test_ust_local_rotate_clear ()
 {
        local tracing_active=$1
 function test_ust_local_rotate_clear ()
 {
        local tracing_active=$1
@@ -665,6 +714,7 @@ streaming_tests=(test_ust_streaming
        test_ust_streaming_clear_rotate
        test_ust_streaming_tracefile_rotation
        test_ust_streaming_tracefile_rotation_overwrite_files
        test_ust_streaming_clear_rotate
        test_ust_streaming_tracefile_rotation
        test_ust_streaming_tracefile_rotation_overwrite_files
+       test_ust_streaming_no_event
 )
 
 live_tests=(test_ust_streaming_live
 )
 
 live_tests=(test_ust_streaming_live
@@ -675,6 +725,7 @@ live_tests=(test_ust_streaming_live
 local_tests=(test_ust_local
        test_ust_local_rotate_clear
        test_ust_local_clear_rotate
 local_tests=(test_ust_local
        test_ust_local_rotate_clear
        test_ust_local_clear_rotate
+       test_ust_local_no_event
 )
 
 snapshot_uid_tests=(test_ust_streaming_snapshot
 )
 
 snapshot_uid_tests=(test_ust_streaming_snapshot
This page took 0.029082 seconds and 5 git commands to generate.