From 042670db60ac672661e1bbc8de4da1d8590e20b4 Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Fri, 8 Jul 2022 17:19:32 -0400 Subject: [PATCH] Fix: ust metadata: resample clock on regenerate metadata MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Observed issue ============== The system test jobs complain that the clock regeneration is broken since the move to the tsdl visitor approach for metadata generation. # Test UST local with metadata regeneration # destructive//../../src/bin/lttng/lttng create regen -o /tmp/tmp.metadata_regen_after_data_change.Vzb0vL ok 23 - Create session regen in -o /tmp/tmp.metadata_regen_after_data_change.Vzb0vL # destructive//../../src/bin/lttng/lttng enable-event tp:tptest -s regen -u ok 24 - Enable ust event tp:tptest for session regen # destructive//../../src/bin/lttng/lttng start regen ok 25 - Start tracing for session regen # destructive//../../src/bin/lttng/lttng stop regen ok 26 - Stop lttng tracing for session regen ok 27 - Validate trace at date 1970-02-02 # destructive//../../src/bin/lttng/lttng start regen ok 28 - Start tracing for session regen # destructive//../../src/bin/lttng/lttng regenerate metadata -s regen ok 29 - Metadata regenerate regen # destructive//../../src/bin/lttng/lttng stop regen ok 30 - Stop lttng tracing for session regen # destructive//../../src/bin/lttng/lttng destroy regen ok 31 - Destroy session regen not ok 32 - The trace is not at the expected date # Failed test 'The trace is not at the expected date' # in destructive//../utils/tap/tap.sh:fail() at line 159. Cause ===== Previously the clock was sampled on each call to `ust_metadata_session_statedump` , currently the clock is only sampled on creation of the `lttng::sessiond::ust::registry_session::registry_session` object. Solution ======== On `lsu::registry_session::regenerate_metadata`, sample the clock and replace the registry_session _clock object. Signed-off-by: Jérémie Galarneau Signed-off-by: Jonathan Rajotte Change-Id: I6f671e4c01f71e1574824236cef03915a9c79b36 --- src/bin/lttng-sessiond/clock-class.hpp | 1 + src/bin/lttng-sessiond/ust-registry-session.cpp | 6 +++++- src/bin/lttng-sessiond/ust-registry-session.hpp | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-sessiond/clock-class.hpp b/src/bin/lttng-sessiond/clock-class.hpp index 3a4755d07..58adc8eac 100644 --- a/src/bin/lttng-sessiond/clock-class.hpp +++ b/src/bin/lttng-sessiond/clock-class.hpp @@ -30,6 +30,7 @@ class clock_class { public: using cycles_t = uint64_t; using scycles_t = int64_t; + using cuptr = std::unique_ptr; const std::string name; const std::string description; diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index 5bb8e6094..eced786e0 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -246,6 +246,7 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi, _gid{egid}, _app_tracer_version{.major = major, .minor = minor}, _tracing_id{tracing_id}, + _clock{lttng::make_unique()}, _metadata_generating_visitor{lttng::make_unique(abi, [this](const std::string& fragment) { _append_metadata_fragment(fragment); @@ -487,7 +488,7 @@ void lsu::registry_session::_visit_environment( void lsu::registry_session::_accept_on_clock_classes(lst::trace_class_visitor& visitor) const { ASSERT_LOCKED(_lock); - _clock.accept(visitor); + _clock->accept(visitor); } void lsu::registry_session::_accept_on_stream_classes(lst::trace_class_visitor& visitor) const @@ -613,6 +614,9 @@ void lsu::registry_session::regenerate_metadata() { lttng::pthread::lock_guard registry_lock(_lock); + /* Resample the clock */ + _clock = lttng::make_unique(); + _metadata_version++; _reset_metadata(); _generate_metadata(); diff --git a/src/bin/lttng-sessiond/ust-registry-session.hpp b/src/bin/lttng-sessiond/ust-registry-session.hpp index cce7c5c1b..316703769 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.hpp +++ b/src/bin/lttng-sessiond/ust-registry-session.hpp @@ -191,7 +191,7 @@ private: /* The id of the parent session. */ const ltt_session::id_t _tracing_id; - lttng::sessiond::ust::clock_class _clock; + lttng::sessiond::ust::clock_class::cuptr _clock; const lttng::sessiond::trace::trace_class_visitor::cuptr _metadata_generating_visitor; }; -- 2.34.1