From a754ea45596eab7bb1193dd5ae9b9dc1d30eb4e7 Mon Sep 17 00:00:00 2001 From: Taras Pashkin <32797206+tpashkin@users.noreply.github.com> Date: Fri, 3 Jul 2026 13:54:50 +0300 Subject: Correctly fork orbits with multiple active shuttles in LWTrace lib Original fix merged to the nbs repo a while ago: https://github.com/ydb-platform/nbs/pull/4479 Can you bring to the upstream? --- Pull Request resolved: https://github.com/ytsaurus/ytsaurus/pull/1771 Co-authored-by: Alexander Smirnov commit_hash:5bf628be8a9c7b591f290ed05754e206b23efc34 --- library/cpp/lwtrace/log_shuttle.cpp | 4 +++- library/cpp/lwtrace/shuttle.h | 4 +++- library/cpp/lwtrace/trace_ut.cpp | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) (limited to 'library/cpp') diff --git a/library/cpp/lwtrace/log_shuttle.cpp b/library/cpp/lwtrace/log_shuttle.cpp index 695aa90b316..a6563efb5b9 100644 --- a/library/cpp/lwtrace/log_shuttle.cpp +++ b/library/cpp/lwtrace/log_shuttle.cpp @@ -22,7 +22,9 @@ namespace NLWTrace { template bool TLogShuttle::DoFork(TShuttlePtr& child) { - if (child = Executor->RentShuttle()) { + if (auto shuttle = Executor->RentShuttle()) { + shuttle->SetNext(child); + child = shuttle; child->SetParentSpanId(GetSpanId()); Executor->Cast(child)->SetIgnore(true); TParams params; diff --git a/library/cpp/lwtrace/shuttle.h b/library/cpp/lwtrace/shuttle.h index 6950b3877a4..c4519cbb876 100644 --- a/library/cpp/lwtrace/shuttle.h +++ b/library/cpp/lwtrace/shuttle.h @@ -309,7 +309,9 @@ namespace NLWTrace { if (shuttle->IsDead()) { *ref = shuttle->Drop(); } else { - result = result && shuttle->Fork(cHead); + if (Y_UNLIKELY(!shuttle->Fork(cHead))) { + result = false; + } ref = &shuttle->GetNext(); } } diff --git a/library/cpp/lwtrace/trace_ut.cpp b/library/cpp/lwtrace/trace_ut.cpp index 9a29923e28c..5c81a6419a7 100644 --- a/library/cpp/lwtrace/trace_ut.cpp +++ b/library/cpp/lwtrace/trace_ut.cpp @@ -789,6 +789,7 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) { UNIT_ASSERT(parsed); mngr.New("Query1", q); + mngr.New("Query2", q); { TOrbit a, b, c, d; @@ -849,6 +850,7 @@ Y_UNIT_TEST_SUITE(LWTraceTrace) { } } reader; mngr.ReadDepot("Query1", reader); + mngr.ReadDepot("Query2", reader); } Y_UNIT_TEST(TrackForkError) { -- cgit v1.3