diff options
author | serg-belyakov <serg-belyakov@yandex-team.com> | 2023-04-18 16:18:50 +0300 |
---|---|---|
committer | serg-belyakov <serg-belyakov@yandex-team.com> | 2023-04-18 16:18:50 +0300 |
commit | e55549ef00ce802a2af3a54ad607b2f7e4f61626 (patch) | |
tree | 015f41fa3f649b8f8bcd20a4fc6e327fbc85a92c | |
parent | 62e03f13d707a48ecdbbf7dd4bbd0702511fbc58 (diff) | |
download | ydb-e55549ef00ce802a2af3a54ad607b2f7e4f61626.tar.gz |
Add Debug Info to BufferWithGaps,
Add DebugInfo string to BufferWithGaps
7 files changed, 48 insertions, 6 deletions
diff --git a/ydb/core/blobstorage/base/bufferwithgaps.h b/ydb/core/blobstorage/base/bufferwithgaps.h index 28fc2f78ed9..506a2c7f641 100644 --- a/ydb/core/blobstorage/base/bufferwithgaps.h +++ b/ydb/core/blobstorage/base/bufferwithgaps.h @@ -6,6 +6,7 @@ #include <util/generic/map.h> #include <util/generic/vector.h> #include <util/generic/algorithm.h> +#include <ydb/core/util/yverify_stream.h> namespace NKikimr { @@ -25,6 +26,8 @@ namespace NKikimr { ui32 Offset; // Data's offset in Gaps space bool IsCommited; + std::function<TString()> DebugInfoGenerator; + public: TBufferWithGaps() : Offset(0) @@ -66,20 +69,21 @@ namespace NKikimr { } TString ToString() const { - Y_VERIFY(IsReadable(), "returned data is corrupt (or was never written) and therefore could not be used safely"); + Y_VERIFY_S(IsReadable(), "returned data is corrupt (or was never written) and therefore could not be used safely, State# " + << PrintState()); return Data; } TString Substr(ui32 offset, ui32 len) const { - Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 - " len# %" PRIu32 " and therefore could not be used safely", offset, len); + Y_VERIFY_S(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" << offset + << " len# " << len << " and therefore could not be used safely, State# " << PrintState()); return Data.substr(offset, len); } template<typename T> const T *DataPtr(ui32 offset, ui32 len = sizeof(T)) const { - Y_VERIFY(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# %" PRIu32 - " len# %" PRIu32 " and therefore could not be used safely", offset, len); + Y_VERIFY_S(IsReadable(offset, len), "returned data is corrupt (or was never written) at offset# " << offset + << " len# " << len << " and therefore could not be used safely, State# " << PrintState()); return reinterpret_cast<T *>(Data.data() + offset); } @@ -173,6 +177,29 @@ namespace NKikimr { } } } + + void SetDebugInfoGenerator(const std::function<TString()>& debugInfoGenerator) { + DebugInfoGenerator = debugInfoGenerator; + } + + void SetDebugInfoGenerator(std::function<TString()>&& debugInfoGenerator) { + DebugInfoGenerator = std::move(debugInfoGenerator); + } + + TString PrintState() const { + TStringStream str; + str << "Offset# " << Offset; + str << " Gaps# { "; + for (auto [begin, size] : Gaps) { + str << "{ Begin# " << begin << " Size# " << size << " } "; + } + str << "}"; + str << " IsCommitted# " << IsCommited; + if (DebugInfoGenerator) { + str << " DebugInfo# " << DebugInfoGenerator(); + } + return str.Str(); + } }; } // NKikimr diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp index b1dd7ac5954..ec48d98fccf 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_actor.cpp @@ -682,6 +682,8 @@ public: PDisk->Mon.GetReadCounter(evChunkRead.PriorityClass)->CountRequest(0); THolder<NPDisk::TEvChunkReadResult> result = MakeHolder<NPDisk::TEvChunkReadResult>(NKikimrProto::CORRUPTED, evChunkRead.ChunkIdx, evChunkRead.Offset, evChunkRead.Cookie, 0, "PDisk is in error state"); + result->Data.SetDebugInfoGenerator(PDisk->DebugInfoGenerator); + LOG_DEBUG(*TlsActivationContext, NKikimrServices::BS_PDISK, "PDiskId# %" PRIu32 " %s To: %" PRIu64 " Marker# BSY02", (ui32)PDisk->PDiskId, result->ToString().c_str(), (ui64)ev->Sender.LocalId()); Send(ev->Sender, result.Release()); @@ -801,6 +803,7 @@ public: void Handle(NPDisk::TEvChunkRead::TPtr &ev) { double burstMs; TChunkRead* request = PDisk->ReqCreator.CreateChunkRead(*ev->Get(), ev->Sender, burstMs, std::move(ev->TraceId)); + request->DebugInfoGenerator = PDisk->DebugInfoGenerator; CheckBurst(request->IsSensitive, burstMs); PDisk->InputRequest(request); } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_completion_impl.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_completion_impl.cpp index f0ecc64539d..e1c10e70acd 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_completion_impl.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_completion_impl.cpp @@ -327,6 +327,9 @@ void TCompletionChunkRead::ReplyError(TActorSystem *actorSystem, TString reason) auto result = MakeHolder<TEvChunkReadResult>(NKikimrProto::CORRUPTED, Read->ChunkIdx, Read->Offset, Read->Cookie, PDisk->GetStatusFlags(Read->Owner, Read->OwnerGroupType), error.Str()); + + result->Data.SetDebugInfoGenerator(PDisk->DebugInfoGenerator); + LOG_WARN_S(*actorSystem, NKikimrServices::BS_PDISK, error.Str()); actorSystem->Send(Read->Sender, result.Release()); Read->IsReplied = true; diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp index 7e804978e31..e4bcef03b0f 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.cpp @@ -95,6 +95,10 @@ TPDisk::TPDisk(const TIntrusivePtr<TPDiskConfig> cfg, const TIntrusivePtr<::NMon JointLogWrites.reserve(16 << 10); JointCommits.reserve(16 << 10); JointChunkForgets.reserve(16 << 10); + + DebugInfoGenerator = [id = PDiskId, type = PDiskCategory]() { + return TStringBuilder() << "PDisk DebugInfo# { Id# " << id << " Type# " << type.TypeStrLong() << " }"; + }; } TString TPDisk::DynamicStateToString(bool isMultiline) { @@ -3595,7 +3599,6 @@ void TPDisk::AddCbsSet(ui32 ownerId) { SchedulerConfigure(conf); } - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // External interface //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h index e2c12017f39..3e80f29a484 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_impl.h @@ -185,6 +185,9 @@ public: // Chunk locking TMap<TOwner, ui32> OwnerLocks; + // Debug + std::function<TString()> DebugInfoGenerator; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Initialization TPDisk(const TIntrusivePtr<TPDiskConfig> cfg, const TIntrusivePtr<::NMonitoring::TDynamicCounters>& counters); diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.cpp b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.cpp index 27f26b1f4d7..cc476b18213 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.cpp +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.cpp @@ -52,6 +52,7 @@ void TChunkRead::Abort(TActorSystem* actorSystem) { <NPDisk::TEvChunkReadResult>(NKikimrProto::ERROR, ChunkIdx, Offset, Cookie, NKikimrBlobStorage::StatusIsValid, error.Str()); + result->Data.SetDebugInfoGenerator(std::move(DebugInfoGenerator)); actorSystem->Send(Sender, result.Release()); IsReplied = true; } diff --git a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.h b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.h index a819fae0d80..60208432cb5 100644 --- a/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.h +++ b/ydb/core/blobstorage/pdisk/blobstorage_pdisk_requestimpl.h @@ -366,6 +366,8 @@ public: const ui64 DoubleFreeCanary; + std::function<TString()> DebugInfoGenerator; + TChunkRead(const NPDisk::TEvChunkRead &ev, const TActorId &sender, TReqId reqId, NWilson::TTraceId traceId) : TRequestBase(sender, reqId, ev.Owner, ev.OwnerRound, ev.PriorityClass, std::move(traceId)) , ChunkIdx(ev.ChunkIdx) |