Fix: ust metadata: resample clock on regenerate metadata
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Fri, 8 Jul 2022 21:19:32 +0000 (17:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 22 Aug 2022 15:54:29 +0000 (11:54 -0400)
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 <jeremie.galarneau@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Change-Id: I6f671e4c01f71e1574824236cef03915a9c79b36

src/bin/lttng-sessiond/clock-class.hpp
src/bin/lttng-sessiond/ust-registry-session.cpp
src/bin/lttng-sessiond/ust-registry-session.hpp

index 3a4755d07cb08a682b57675e69546ee61af88b82..58adc8eac5192a605fd85bdd6b75edd677ddd027 100644 (file)
@@ -30,6 +30,7 @@ class clock_class {
 public:
        using cycles_t = uint64_t;
        using scycles_t = int64_t;
+       using cuptr = std::unique_ptr<const clock_class>;
 
        const std::string name;
        const std::string description;
index 5bb8e6094e43726d93f7dc503e3a66dd39415de8..eced786e0446836f54ffbadf47a0607f5eb04775 100644 (file)
@@ -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<lsu::clock_class>()},
        _metadata_generating_visitor{lttng::make_unique<ls::tsdl::trace_class_visitor>(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<lsu::clock_class>();
+
        _metadata_version++;
        _reset_metadata();
        _generate_metadata();
index cce7c5c1b7baef7958f80f10c0e9eef9ceca883c..316703769fe57e92d2391fa36cb3159a28972bae 100644 (file)
@@ -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;
 };
 
This page took 0.028708 seconds and 4 git commands to generate.