aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhor911 <hor911@ydb.tech>2022-07-18 12:11:09 +0300
committerhor911 <hor911@ydb.tech>2022-07-18 12:11:09 +0300
commit36fbc4654ad83724e3425d9da1b0b3b05229e3e1 (patch)
tree9678e26c5dcc95efc2a043b7ff98dccd6b43cef8
parent1c76409f8739c0d8caa4ca6acb2937821b488980 (diff)
downloadydb-36fbc4654ad83724e3425d9da1b0b3b05229e3e1.tar.gz
Better logging
-rw-r--r--library/cpp/yt/threading/fork_aware_spin_lock.h10
-rw-r--r--ydb/core/yq/libs/control_plane_storage/internal/nodes_health_check.cpp2
-rw-r--r--ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h8
-rw-r--r--ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h12
4 files changed, 22 insertions, 10 deletions
diff --git a/library/cpp/yt/threading/fork_aware_spin_lock.h b/library/cpp/yt/threading/fork_aware_spin_lock.h
index 18abb243a6..c6487ce4b0 100644
--- a/library/cpp/yt/threading/fork_aware_spin_lock.h
+++ b/library/cpp/yt/threading/fork_aware_spin_lock.h
@@ -1,6 +1,9 @@
#pragma once
+#include "public.h"
+
#include <util/system/spinlock.h>
+#include <util/system/src_location.h>
namespace NYT::NThreading {
@@ -11,10 +14,15 @@ namespace NYT::NThreading {
class TForkAwareSpinLock
{
public:
- TForkAwareSpinLock() = default;
TForkAwareSpinLock(const TForkAwareSpinLock&) = delete;
TForkAwareSpinLock& operator =(const TForkAwareSpinLock&) = delete;
+ constexpr TForkAwareSpinLock() = default;
+
+ // TODO(babenko): make use of location.
+ explicit constexpr TForkAwareSpinLock(const ::TSourceLocation& /*location*/)
+ { }
+
void Acquire() noexcept;
void Release() noexcept;
diff --git a/ydb/core/yq/libs/control_plane_storage/internal/nodes_health_check.cpp b/ydb/core/yq/libs/control_plane_storage/internal/nodes_health_check.cpp
index cceffc2b1c..fafade39a1 100644
--- a/ydb/core/yq/libs/control_plane_storage/internal/nodes_health_check.cpp
+++ b/ydb/core/yq/libs/control_plane_storage/internal/nodes_health_check.cpp
@@ -27,7 +27,7 @@ void TYdbControlPlaneStorageActor::Handle(TEvControlPlaneStorage::TEvNodesHealth
const auto ttl = TDuration::Seconds(5);
const auto deadline = startTime + ttl * 3;
- CPS_LOG_T("NodesHealthCheck: {" << request.DebugString() << "}");
+ CPS_LOG_T("NodesHealthCheckRequest: {" << request.DebugString() << "}");
NYql::TIssues issues = ValidateNodesHealthCheck(tenant, instanceId, hostName);
if (issues) {
diff --git a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h
index 81a0040570..0938f1ee37 100644
--- a/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h
+++ b/ydb/core/yq/libs/control_plane_storage/ydb_control_plane_storage_impl.h
@@ -535,7 +535,7 @@ private:
const auto& request = ev->Get()->Request;
size_t responseByteSize = 0;
if (issues) {
- CPS_LOG_AS_W(*actorSystem, name << ": {" << request.DebugString() << "} ERROR: " << internalIssues.ToOneLineString());
+ CPS_LOG_AS_W(*actorSystem, name << ": {" << TrimForLogs(request.DebugString()) << "} ERROR: " << internalIssues.ToOneLineString());
auto event = std::make_unique<ResponseEvent>(issues);
event->DebugInfo = debugInfo;
responseByteSize = event->GetByteSize();
@@ -548,7 +548,7 @@ private:
});
}
} else {
- CPS_LOG_AS_T(*actorSystem, name << ": {" << request.DebugString() << "} SUCCESS");
+ CPS_LOG_AS_T(*actorSystem, name << ": {" << TrimForLogs(result.DebugString()) << "} SUCCESS");
auto event = std::make_unique<ResponseEvent>(result);
event->DebugInfo = debugInfo;
responseByteSize = event->GetByteSize();
@@ -742,6 +742,10 @@ private:
return "[" + user + (token ? ", " + NKikimr::MaskTicket(token) : "") + "] ";
}
+ static TString TrimForLogs(const TString& s, ui64 maxLength = 4096) {
+ return s.size() > maxLength ? (s.substr(0, maxLength - 3) + "...") : s;
+ }
+
struct TPickTaskParams {
TString ReadQuery;
TParams ReadParams;
diff --git a/ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h b/ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h
index 8dcb62e906..86d4f979f6 100644
--- a/ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h
+++ b/ydb/library/yql/dq/actors/compute/dq_compute_memory_quota.h
@@ -11,6 +11,8 @@
#include <util/system/types.h>
namespace NYql::NDq {
+#define CAMQ_LOG_T(s) \
+ LOG_TRACE_S(*ActorSystem, NKikimrServices::KQP_COMPUTE, "TxId: " << TxId << ", task: " << TaskId << ". " << s)
#define CAMQ_LOG_D(s) \
LOG_DEBUG_S(*ActorSystem, NKikimrServices::KQP_COMPUTE, "TxId: " << TxId << ", task: " << TaskId << ". " << s)
#define CAMQ_LOG_I(s) \
@@ -53,14 +55,14 @@ namespace NYql::NDq {
MkqlMemoryLimit = newLimit;
alloc->SetLimit(newLimit);
MemoryLimits.FreeMemoryFn(TxId, TaskId, freedSize);
- CAMQ_LOG_I("[Mem] memory shrinked, new limit: " << MkqlMemoryLimit);
+ CAMQ_LOG_D("[Mem] memory shrinked, new limit: " << MkqlMemoryLimit);
}
}
}
if (Y_UNLIKELY(ProfileStats)) {
ProfileStats->MkqlMaxUsedMemory = std::max(ProfileStats->MkqlMaxUsedMemory, alloc->GetPeakAllocated());
- CAMQ_LOG_D("Peak memory usage: " << ProfileStats->MkqlMaxUsedMemory);
+ CAMQ_LOG_T("Peak memory usage: " << ProfileStats->MkqlMaxUsedMemory);
}
}
@@ -95,14 +97,12 @@ namespace NYql::NDq {
void RequestExtraMemory(ui64 memory, NKikimr::NMiniKQL::TScopedAlloc* alloc) {
memory = std::max(AlignMemorySizeToMbBoundary(memory), MemoryLimits.MinMemAllocSize);
- CAMQ_LOG_I("not enough memory, request +" << memory);
-
if (MemoryLimits.AllocateMemoryFn(TxId, TaskId, memory)) {
MkqlMemoryLimit += memory;
- CAMQ_LOG_I("[Mem] memory granted, new limit: " << MkqlMemoryLimit);
+ CAMQ_LOG_D("[Mem] memory " << memory << " granted, new limit: " << MkqlMemoryLimit);
alloc->SetLimit(MkqlMemoryLimit);
} else {
- CAMQ_LOG_W("[Mem] memory not granted");
+ CAMQ_LOG_W("[Mem] memory " << memory << " NOT granted");
// throw yexception() << "Can not allocate extra memory, limit: " << MkqlMemoryLimit
// << ", requested: " << memory << ", host: " << HostName();
}