summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnaury <[email protected]>2023-05-12 12:51:56 +0300
committersnaury <[email protected]>2023-05-12 12:51:56 +0300
commitacba6a64ac762c62b3a6ef8238b58a2145ed77ca (patch)
treec1ddacb9bbc0f9d940a2c0e93e52027821e04a1c
parent21e94171e7cf3ad5eccf4871e5e3336e307c5179 (diff)
Add lwtrace probes to long tx service
-rw-r--r--ydb/core/tx/long_tx_service/CMakeLists.darwin-x86_64.txt3
-rw-r--r--ydb/core/tx/long_tx_service/CMakeLists.linux-aarch64.txt3
-rw-r--r--ydb/core/tx/long_tx_service/CMakeLists.linux-x86_64.txt3
-rw-r--r--ydb/core/tx/long_tx_service/CMakeLists.windows-x86_64.txt3
-rw-r--r--ydb/core/tx/long_tx_service/long_tx_service_impl.cpp19
-rw-r--r--ydb/core/tx/long_tx_service/long_tx_service_impl.h1
-rw-r--r--ydb/core/tx/long_tx_service/lwtrace_probes.cpp21
-rw-r--r--ydb/core/tx/long_tx_service/lwtrace_probes.h28
-rw-r--r--ydb/core/tx/long_tx_service/public/CMakeLists.darwin-x86_64.txt1
-rw-r--r--ydb/core/tx/long_tx_service/public/CMakeLists.linux-aarch64.txt1
-rw-r--r--ydb/core/tx/long_tx_service/public/CMakeLists.linux-x86_64.txt1
-rw-r--r--ydb/core/tx/long_tx_service/public/CMakeLists.windows-x86_64.txt1
-rw-r--r--ydb/core/tx/long_tx_service/public/events.h20
13 files changed, 97 insertions, 8 deletions
diff --git a/ydb/core/tx/long_tx_service/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/long_tx_service/CMakeLists.darwin-x86_64.txt
index c29cdc89383..4fea1df5425 100644
--- a/ydb/core/tx/long_tx_service/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/CMakeLists.darwin-x86_64.txt
@@ -16,6 +16,8 @@ target_compile_options(core-tx-long_tx_service PRIVATE
target_link_libraries(core-tx-long_tx_service PUBLIC
contrib-libs-cxxsupp
yutil
+ library-cpp-lwtrace
+ cpp-lwtrace-mon
ydb-core-base
core-tx-columnshard
tx-long_tx_service-public
@@ -25,4 +27,5 @@ target_sources(core-tx-long_tx_service PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/commit_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
)
diff --git a/ydb/core/tx/long_tx_service/CMakeLists.linux-aarch64.txt b/ydb/core/tx/long_tx_service/CMakeLists.linux-aarch64.txt
index 9e74c57c6f5..af6f58e84f4 100644
--- a/ydb/core/tx/long_tx_service/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/tx/long_tx_service/CMakeLists.linux-aarch64.txt
@@ -17,6 +17,8 @@ target_link_libraries(core-tx-long_tx_service PUBLIC
contrib-libs-linux-headers
contrib-libs-cxxsupp
yutil
+ library-cpp-lwtrace
+ cpp-lwtrace-mon
ydb-core-base
core-tx-columnshard
tx-long_tx_service-public
@@ -26,4 +28,5 @@ target_sources(core-tx-long_tx_service PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/commit_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
)
diff --git a/ydb/core/tx/long_tx_service/CMakeLists.linux-x86_64.txt b/ydb/core/tx/long_tx_service/CMakeLists.linux-x86_64.txt
index 9e74c57c6f5..af6f58e84f4 100644
--- a/ydb/core/tx/long_tx_service/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/CMakeLists.linux-x86_64.txt
@@ -17,6 +17,8 @@ target_link_libraries(core-tx-long_tx_service PUBLIC
contrib-libs-linux-headers
contrib-libs-cxxsupp
yutil
+ library-cpp-lwtrace
+ cpp-lwtrace-mon
ydb-core-base
core-tx-columnshard
tx-long_tx_service-public
@@ -26,4 +28,5 @@ target_sources(core-tx-long_tx_service PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/commit_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
)
diff --git a/ydb/core/tx/long_tx_service/CMakeLists.windows-x86_64.txt b/ydb/core/tx/long_tx_service/CMakeLists.windows-x86_64.txt
index c29cdc89383..4fea1df5425 100644
--- a/ydb/core/tx/long_tx_service/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/CMakeLists.windows-x86_64.txt
@@ -16,6 +16,8 @@ target_compile_options(core-tx-long_tx_service PRIVATE
target_link_libraries(core-tx-long_tx_service PUBLIC
contrib-libs-cxxsupp
yutil
+ library-cpp-lwtrace
+ cpp-lwtrace-mon
ydb-core-base
core-tx-columnshard
tx-long_tx_service-public
@@ -25,4 +27,5 @@ target_sources(core-tx-long_tx_service PRIVATE
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/commit_impl.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service.cpp
${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
+ ${CMAKE_SOURCE_DIR}/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
)
diff --git a/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp b/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
index eae23c7d317..dda94582ba7 100644
--- a/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
+++ b/ydb/core/tx/long_tx_service/long_tx_service_impl.cpp
@@ -1,4 +1,5 @@
#include "long_tx_service_impl.h"
+#include "lwtrace_probes.h"
#include <ydb/core/base/appdata.h>
#include <library/cpp/actors/core/log.h>
@@ -10,16 +11,19 @@
#define TXLOG_NOTICE(stream) TXLOG_LOG(NActors::NLog::PRI_NOTICE, stream)
#define TXLOG_ERROR(stream) TXLOG_LOG(NActors::NLog::PRI_ERROR, stream)
+LWTRACE_USING(LONG_TX_SERVICE_PROVIDER)
+
namespace NKikimr {
namespace NLongTxService {
static constexpr size_t MaxAcquireSnapshotInFlight = 4;
-static constexpr TDuration AcquireSnapshotBatchDelay = TDuration::MicroSeconds(500);
+static constexpr TDuration AcquireSnapshotBatchDelay = TDuration::MicroSeconds(100);
static constexpr TDuration RemoteLockTimeout = TDuration::Seconds(15);
static constexpr bool InterconnectUndeliveryBroken = true;
void TLongTxServiceActor::Bootstrap() {
LogPrefix = TStringBuilder() << "TLongTxService [Node " << SelfId().NodeId() << "] ";
+ RegisterLongTxServiceProbes();
Become(&TThis::StateWork);
}
@@ -331,14 +335,16 @@ const TString& TLongTxServiceActor::GetDatabaseNameOrLegacyDefault(const TString
}
void TLongTxServiceActor::Handle(TEvLongTxService::TEvAcquireReadSnapshot::TPtr& ev) {
- const auto* msg = ev->Get();
+ auto* msg = ev->Get();
const TString& databaseName = GetDatabaseNameOrLegacyDefault(msg->Record.GetDatabaseName());
TXLOG_DEBUG("Received TEvAcquireReadSnapshot from " << ev->Sender << " for database " << databaseName);
+ LWTRACK(AcquireReadSnapshotRequest, msg->Orbit, databaseName);
+
if (databaseName.empty()) {
NYql::TIssues issues;
issues.AddIssue("Cannot acquire snapshot for an unspecified database");
- Send(ev->Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(Ydb::StatusIds::SCHEME_ERROR, std::move(issues)), 0, ev->Cookie);
+ Send(ev->Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(Ydb::StatusIds::SCHEME_ERROR, std::move(issues), std::move(msg->Orbit)), 0, ev->Cookie);
return;
}
@@ -349,6 +355,7 @@ void TLongTxServiceActor::Handle(TEvLongTxService::TEvAcquireReadSnapshot::TPtr&
auto& req = state.PendingUserRequests.emplace_back();
req.Sender = ev->Sender;
req.Cookie = ev->Cookie;
+ req.Orbit = std::move(msg->Orbit);
}
ScheduleAcquireSnapshot(databaseName, state);
}
@@ -390,7 +397,8 @@ void TLongTxServiceActor::Handle(TEvPrivate::TEvAcquireSnapshotFinished::TPtr& e
if (msg->Status == Ydb::StatusIds::SUCCESS) {
for (auto& userReq : req->UserRequests) {
- Send(userReq.Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(databaseName, msg->Snapshot), 0, userReq.Cookie);
+ LWTRACK(AcquireReadSnapshotSuccess, userReq.Orbit, msg->Snapshot.Step, msg->Snapshot.TxId);
+ Send(userReq.Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(databaseName, msg->Snapshot, std::move(userReq.Orbit)), 0, userReq.Cookie);
}
for (auto& beginReq : req->BeginTxRequests) {
auto txId = beginReq.TxId;
@@ -409,7 +417,8 @@ void TLongTxServiceActor::Handle(TEvPrivate::TEvAcquireSnapshotFinished::TPtr& e
}
} else {
for (auto& userReq : req->UserRequests) {
- Send(userReq.Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(msg->Status, msg->Issues), 0, userReq.Cookie);
+ LWTRACK(AcquireReadSnapshotFailure, userReq.Orbit, int(msg->Status));
+ Send(userReq.Sender, new TEvLongTxService::TEvAcquireReadSnapshotResult(msg->Status, msg->Issues, std::move(userReq.Orbit)), 0, userReq.Cookie);
}
for (auto& beginReq : req->BeginTxRequests) {
Send(beginReq.Sender, new TEvLongTxService::TEvBeginTxResult(msg->Status, msg->Issues), 0, beginReq.Cookie);
diff --git a/ydb/core/tx/long_tx_service/long_tx_service_impl.h b/ydb/core/tx/long_tx_service/long_tx_service_impl.h
index 8a40dc3f720..6a83b790bfc 100644
--- a/ydb/core/tx/long_tx_service/long_tx_service_impl.h
+++ b/ydb/core/tx/long_tx_service/long_tx_service_impl.h
@@ -122,6 +122,7 @@ namespace NLongTxService {
struct TAcquireSnapshotUserRequest {
TActorId Sender;
ui64 Cookie;
+ NLWTrace::TOrbit Orbit;
};
struct TAcquireSnapshotBeginTxRequest {
diff --git a/ydb/core/tx/long_tx_service/lwtrace_probes.cpp b/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
new file mode 100644
index 00000000000..ffad82401c0
--- /dev/null
+++ b/ydb/core/tx/long_tx_service/lwtrace_probes.cpp
@@ -0,0 +1,21 @@
+#include "lwtrace_probes.h"
+
+#include <library/cpp/lwtrace/mon/mon_lwtrace.h>
+
+#include <mutex>
+
+LWTRACE_DEFINE_PROVIDER(LONG_TX_SERVICE_PROVIDER)
+
+namespace NKikimr {
+namespace NLongTxService {
+
+ void RegisterLongTxServiceProbes() {
+ static std::once_flag flag;
+
+ std::call_once(flag, []{
+ NLwTraceMonPage::ProbeRegistry().AddProbesList(LWTRACE_GET_PROBES(LONG_TX_SERVICE_PROVIDER));
+ });
+ }
+
+}
+}
diff --git a/ydb/core/tx/long_tx_service/lwtrace_probes.h b/ydb/core/tx/long_tx_service/lwtrace_probes.h
new file mode 100644
index 00000000000..0468b0b6227
--- /dev/null
+++ b/ydb/core/tx/long_tx_service/lwtrace_probes.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include <library/cpp/lwtrace/all.h>
+
+#define LONG_TX_SERVICE_PROVIDER(PROBE, EVENT, GROUPS, TYPES, NAMES) \
+ PROBE(AcquireReadSnapshotRequest, \
+ GROUPS("LongTxSnapshots"), \
+ TYPES(TString), \
+ NAMES("database")) \
+ PROBE(AcquireReadSnapshotSuccess, \
+ GROUPS("LongTxSnapshots"), \
+ TYPES(ui64, ui64), \
+ NAMES("step", "txId")) \
+ PROBE(AcquireReadSnapshotFailure, \
+ GROUPS("LongTxSnapshots"), \
+ TYPES(int), \
+ NAMES("status")) \
+// LONG_TX_SERVICE_PROVIDER
+
+LWTRACE_DECLARE_PROVIDER(LONG_TX_SERVICE_PROVIDER)
+
+namespace NKikimr {
+namespace NLongTxService {
+
+ void RegisterLongTxServiceProbes();
+
+}
+}
diff --git a/ydb/core/tx/long_tx_service/public/CMakeLists.darwin-x86_64.txt b/ydb/core/tx/long_tx_service/public/CMakeLists.darwin-x86_64.txt
index 81f9839443e..2ac85020c9d 100644
--- a/ydb/core/tx/long_tx_service/public/CMakeLists.darwin-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/public/CMakeLists.darwin-x86_64.txt
@@ -16,6 +16,7 @@ target_link_libraries(tx-long_tx_service-public PUBLIC
contrib-libs-cxxsupp
yutil
library-cpp-cgiparam
+ library-cpp-lwtrace
library-cpp-uri
ydb-core-base
ydb-core-protos
diff --git a/ydb/core/tx/long_tx_service/public/CMakeLists.linux-aarch64.txt b/ydb/core/tx/long_tx_service/public/CMakeLists.linux-aarch64.txt
index 40b13ea0e12..3c948753c9b 100644
--- a/ydb/core/tx/long_tx_service/public/CMakeLists.linux-aarch64.txt
+++ b/ydb/core/tx/long_tx_service/public/CMakeLists.linux-aarch64.txt
@@ -17,6 +17,7 @@ target_link_libraries(tx-long_tx_service-public PUBLIC
contrib-libs-cxxsupp
yutil
library-cpp-cgiparam
+ library-cpp-lwtrace
library-cpp-uri
ydb-core-base
ydb-core-protos
diff --git a/ydb/core/tx/long_tx_service/public/CMakeLists.linux-x86_64.txt b/ydb/core/tx/long_tx_service/public/CMakeLists.linux-x86_64.txt
index 40b13ea0e12..3c948753c9b 100644
--- a/ydb/core/tx/long_tx_service/public/CMakeLists.linux-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/public/CMakeLists.linux-x86_64.txt
@@ -17,6 +17,7 @@ target_link_libraries(tx-long_tx_service-public PUBLIC
contrib-libs-cxxsupp
yutil
library-cpp-cgiparam
+ library-cpp-lwtrace
library-cpp-uri
ydb-core-base
ydb-core-protos
diff --git a/ydb/core/tx/long_tx_service/public/CMakeLists.windows-x86_64.txt b/ydb/core/tx/long_tx_service/public/CMakeLists.windows-x86_64.txt
index 81f9839443e..2ac85020c9d 100644
--- a/ydb/core/tx/long_tx_service/public/CMakeLists.windows-x86_64.txt
+++ b/ydb/core/tx/long_tx_service/public/CMakeLists.windows-x86_64.txt
@@ -16,6 +16,7 @@ target_link_libraries(tx-long_tx_service-public PUBLIC
contrib-libs-cxxsupp
yutil
library-cpp-cgiparam
+ library-cpp-lwtrace
library-cpp-uri
ydb-core-base
ydb-core-protos
diff --git a/ydb/core/tx/long_tx_service/public/events.h b/ydb/core/tx/long_tx_service/public/events.h
index bd46b766809..529e723c8d9 100644
--- a/ydb/core/tx/long_tx_service/public/events.h
+++ b/ydb/core/tx/long_tx_service/public/events.h
@@ -6,6 +6,8 @@
#include <ydb/library/yql/public/issue/yql_issue_message.h>
+#include <library/cpp/lwtrace/shuttle.h>
+
namespace NKikimr {
namespace NLongTxService {
@@ -166,9 +168,17 @@ namespace NLongTxService {
{
TEvAcquireReadSnapshot() = default;
- explicit TEvAcquireReadSnapshot(const TString& databaseName) {
+ template<class... TArgs>
+ explicit TEvAcquireReadSnapshot(const TString& databaseName, TArgs&&... args) {
Record.SetDatabaseName(databaseName);
+ (SetOptionalArg(std::forward<TArgs>(args)), ...);
+ }
+
+ void SetOptionalArg(NLWTrace::TOrbit&& orbit) {
+ Orbit = std::move(orbit);
}
+
+ NLWTrace::TOrbit Orbit;
};
struct TEvAcquireReadSnapshotResult
@@ -177,20 +187,24 @@ namespace NLongTxService {
TEvAcquireReadSnapshotResult() = default;
// Success
- explicit TEvAcquireReadSnapshotResult(const TString& databaseName, const TRowVersion& snapshot) {
+ explicit TEvAcquireReadSnapshotResult(const TString& databaseName, const TRowVersion& snapshot, NLWTrace::TOrbit&& orbit) {
Record.SetStatus(Ydb::StatusIds::SUCCESS);
Record.SetSnapshotStep(snapshot.Step);
Record.SetSnapshotTxId(snapshot.TxId);
Record.SetDatabaseName(databaseName);
+ Orbit = std::move(orbit);
}
// Failure
- explicit TEvAcquireReadSnapshotResult(Ydb::StatusIds::StatusCode status, const NYql::TIssues& issues = {}) {
+ explicit TEvAcquireReadSnapshotResult(Ydb::StatusIds::StatusCode status, const NYql::TIssues& issues, NLWTrace::TOrbit&& orbit) {
Record.SetStatus(status);
if (issues) {
IssuesToMessage(issues, Record.MutableIssues());
}
+ Orbit = std::move(orbit);
}
+
+ NLWTrace::TOrbit Orbit;
};
struct TEvRegisterLock