diff options
author | a-sumin <a-sumin@yandex-team.com> | 2023-04-19 12:43:35 +0300 |
---|---|---|
committer | a-sumin <a-sumin@yandex-team.com> | 2023-04-19 12:43:35 +0300 |
commit | a75913ec6f266ffaf2967f0bc2e18b5cb6df2c8d (patch) | |
tree | 33fd0d117f2431bcb71750a3b5ce18ef1b747b76 | |
parent | d78a7b261977a1969b10e9e6c5c5c2557200e81c (diff) | |
download | ydb-a75913ec6f266ffaf2967f0bc2e18b5cb6df2c8d.tar.gz |
Add IsReadable() checks is vdisk
5 files changed, 36 insertions, 12 deletions
diff --git a/ydb/core/blobstorage/vdisk/common/vdisk_context.h b/ydb/core/blobstorage/vdisk/common/vdisk_context.h index 4f6c749e97..26c166247b 100644 --- a/ydb/core/blobstorage/vdisk/common/vdisk_context.h +++ b/ydb/core/blobstorage/vdisk/common/vdisk_context.h @@ -9,6 +9,7 @@ #include "vdisk_mongroups.h" #include <ydb/core/blobstorage/base/ptr.h> #include <ydb/core/blobstorage/groupinfo/blobstorage_groupinfo.h> +#include <ydb/core/blobstorage/pdisk/blobstorage_pdisk.h> namespace NKikimr { @@ -134,6 +135,18 @@ namespace NKikimr { } } + template <class TActorSystemOrCtx> + bool CheckPDiskResponseReadable(const TActorSystemOrCtx &actorSystemOrCtx, const NPDisk::TEvChunkReadResult &ev, const TString &message = {}) { + if (!ev.Data.IsReadable()) { + LOG_ERROR(actorSystemOrCtx, NKikimrServices::BS_VDISK_OTHER, + VDISKP(VDiskLogPrefix, + "CheckPDiskResponseReadable: not readable chunk from PDisk: %s", + FormatMessage(ev.Status, ev.ErrorReason, ev.StatusFlags, message).data())); + return false; + } + return true; + } + TOutOfSpaceState &GetOutOfSpaceState() { return OutOfSpaceState; } @@ -164,7 +177,7 @@ namespace NKikimr { // to notify some other actors (children) about VDisk/component death. #define CHECK_PDISK_RESPONSE(VCtx, ev, ctx) \ do { \ - if (!((VCtx)->CheckPDiskResponse((ctx), *(ev)->Get()))) { \ + if (!(VCtx)->CheckPDiskResponse((ctx), *(ev)->Get())) { \ TThis::Become(&TThis::TerminateStateFunc); \ return; \ } \ @@ -172,7 +185,7 @@ do { \ #define CHECK_PDISK_RESPONSE_MSG(VCtx, ev, ctx, msg) \ do { \ - if (!((VCtx)->CheckPDiskResponse((ctx), *(ev)->Get(), (msg)))) { \ + if (!(VCtx)->CheckPDiskResponse((ctx), *(ev)->Get(), (msg))) { \ TThis::Become(&TThis::TerminateStateFunc); \ return; \ } \ @@ -185,3 +198,20 @@ STFUNC(TerminateStateFunc) { \ } \ } +#define CHECK_PDISK_RESPONSE_READABLE(VCtx, ev, ctx) \ +do { \ + CHECK_PDISK_RESPONSE(VCtx, ev, ctx); \ + if (!(VCtx)->CheckPDiskResponseReadable((ctx), *(ev)->Get())) { \ + TThis::Become(&TThis::TerminateStateFunc); \ + return; \ + } \ +} while (false) + +#define CHECK_PDISK_RESPONSE_READABLE_MSG(VCtx, ev, ctx, msg) \ +do { \ + CHECK_PDISK_RESPONSE_MSG(VCtx, ev, ctx, msg); \ + if (!(VCtx)->CheckPDiskResponseReadable((ctx), *(ev)->Get(), (msg))) { \ + TThis::Become(&TThis::TerminateStateFunc); \ + return; \ + } \ +} while (false) diff --git a/ydb/core/blobstorage/vdisk/defrag/defrag_rewriter.cpp b/ydb/core/blobstorage/vdisk/defrag/defrag_rewriter.cpp index c8ba107ca9..6978dfc4bf 100644 --- a/ydb/core/blobstorage/vdisk/defrag/defrag_rewriter.cpp +++ b/ydb/core/blobstorage/vdisk/defrag/defrag_rewriter.cpp @@ -101,7 +101,7 @@ namespace NKikimr { FullSnap.reset(); // FIXME: handle read errors gracefully - CHECK_PDISK_RESPONSE(DCtx->VCtx, ev, ctx); + CHECK_PDISK_RESPONSE_READABLE(DCtx->VCtx, ev, ctx); auto *msg = ev->Get(); const TDefragRecord &rec = Recs[RecToReadIdx++]; diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h index d08b3a04d7..ad8f021c73 100644 --- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h +++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hullload.h @@ -220,13 +220,7 @@ namespace NKikimr { void Handle(NPDisk::TEvChunkReadResult::TPtr &ev, const TActorContext &ctx) { auto *msg = ev->Get(); - TString message; - if (msg->Status != NKikimrProto::OK) { - TStringStream str; - str << "{Origin# '" << Origin << "'}"; - message = str.Str(); - } - CHECK_PDISK_RESPONSE_MSG(VCtx, ev, ctx, message); + CHECK_PDISK_RESPONSE_READABLE_MSG(VCtx, ev, ctx, TStringBuilder() << "{Origin# '" << Origin << "'}"); const TBufferWithGaps &data = msg->Data; LevelSegment->IndexParts.push_back({msg->ChunkIdx, msg->Offset, msg->Data.Size()}); diff --git a/ydb/core/blobstorage/vdisk/query/query_readbatch.h b/ydb/core/blobstorage/vdisk/query/query_readbatch.h index b0592a9a20..a1b01305c7 100644 --- a/ydb/core/blobstorage/vdisk/query/query_readbatch.h +++ b/ydb/core/blobstorage/vdisk/query/query_readbatch.h @@ -185,7 +185,7 @@ namespace NKikimr { glue.Part.Offset <= ActualRead.Offset && (ActualRead.Offset + ActualRead.Size) <= (glue.Part.Offset + glue.Part.Size)); - if (glue.Success) { + if (glue.Success && glue.Data.IsReadable(ActualRead.Offset - glue.Part.Offset, ActualRead.Size)) { const char *ptr = glue.Data.DataPtr<const char>(ActualRead.Offset - glue.Part.Offset, ActualRead.Size); const size_t size = ActualRead.Size; processor(ptr, size); diff --git a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp index 5ce14ae584..5d911f9296 100644 --- a/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp +++ b/ydb/core/blobstorage/vdisk/synclog/blobstorage_synclogreader.cpp @@ -337,7 +337,7 @@ namespace NKikimr { void Handle(NPDisk::TEvChunkReadResult::TPtr &ev, const TActorContext &ctx) { // FIXME: optimize, batch reads; use Db->RecommendedReadSize - CHECK_PDISK_RESPONSE(SlCtx->VCtx, ev, ctx); + CHECK_PDISK_RESPONSE_READABLE(SlCtx->VCtx, ev, ctx); Y_VERIFY(DiskIt.Valid()); std::pair<ui32, const TDiskIndexRecord *> p = DiskIt.Get(); |