diff options
author | alexvru <alexvru@ydb.tech> | 2023-11-24 18:25:54 +0300 |
---|---|---|
committer | alexvru <alexvru@ydb.tech> | 2023-11-24 19:11:19 +0300 |
commit | 028e5ee7a66ed2c0f83da912ab1e10184b0d20e8 (patch) | |
tree | fdf9f87b77c73933e212d272ff310d72074c1ac1 | |
parent | e1c0089c3585434787e5aa7ef923b916f0807e0a (diff) | |
download | ydb-028e5ee7a66ed2c0f83da912ab1e10184b0d20e8.tar.gz |
Fix VDisk behaviour upon reception of bad VDiskId field KIKIMR-19942
-rw-r--r-- | ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp index c024896ffd..fb518ecd90 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeletonfront.cpp @@ -1470,8 +1470,13 @@ namespace NKikimr { const auto& record = ev->Get()->Record; if (record.HasVDiskID()) { const TVDiskID& vdiskId = VDiskIDFromVDiskID(record.GetVDiskID()); - Y_ABORT_UNLESS(vdiskId.GroupID == SelfVDiskId.GroupID); - Y_ABORT_UNLESS(TVDiskIdShort(vdiskId) == TVDiskIdShort(SelfVDiskId)); + if (!SelfVDiskId.SameExceptGeneration(vdiskId)) { + LOG_CRIT_S(ctx, NKikimrServices::BS_SKELETON, VCtx->VDiskLogPrefix + << "VDiskId mismatch expected# " << SelfVDiskId << " provided# " << vdiskId + << " Marker# BSVSF05"); + Y_DEBUG_ABORT_UNLESS(false, "VDiskId mismatch"); + return Reply(ev, ctx, NKikimrProto::ERROR, "VDiskId mismatch", TAppData::TimeProvider->Now()); + } if (vdiskId != SelfVDiskId) { if (SelfVDiskId.GroupGeneration < vdiskId.GroupGeneration && record.HasRecentGroup()) { auto newInfo = TBlobStorageGroupInfo::Parse(record.GetRecentGroup(), nullptr, nullptr); @@ -1987,19 +1992,25 @@ namespace NKikimr { return true; } - template <class TEv, class Decayed = std::decay_t<TEv>> - static constexpr bool IsWithoutVDiskId = std::is_same_v<TEv, Decayed>; + template<typename TEv> + static constexpr bool IsWithoutVDiskId = std::is_same_v<TEv, TEvGetLogoBlobIndexStatRequest>; template <typename TEventType> void Check(TAutoPtr<TEventHandle<TEventType>>& ev, const TActorContext& ctx) { const auto& record = ev->Get()->Record; - bool isSameVDisk = true; if constexpr (!IsWithoutVDiskId<TEventType>) { - isSameVDisk = SelfVDiskId.SameDisk(record.GetVDiskID()); + const auto& vdiskId = VDiskIDFromVDiskID(record.GetVDiskID()); + if (!vdiskId.SameExceptGeneration(SelfVDiskId)) { + LOG_CRIT_S(ctx, NKikimrServices::BS_SKELETON, VCtx->VDiskLogPrefix + << "VDiskId mismatch expected# " << SelfVDiskId << " provided# " << vdiskId + << " Type# " << TypeName<TEventType>() << " Marker# BSVSF06"); + Y_DEBUG_ABORT_UNLESS(false, "VDiskId mismatch"); + return Reply(ev, ctx, NKikimrProto::ERROR, "VDiskId mismatch", TAppData::TimeProvider->Now()); + } else if (!vdiskId.SameDisk(SelfVDiskId)) { + return Reply(ev, ctx, NKikimrProto::RACE, "group generation mismatch", TAppData::TimeProvider->Now()); + } } - if (!isSameVDisk) { - return Reply(ev, ctx, NKikimrProto::RACE, "group generation mismatch", TAppData::TimeProvider->Now()); - } else if (!GInfo->CheckScope(TKikimrScopeId(ev->OriginScopeId), ctx, true)) { + if (!GInfo->CheckScope(TKikimrScopeId(ev->OriginScopeId), ctx, true)) { DatabaseAccessDeniedHandle(ev, ctx); } else if (Config->BaseInfo.ReadOnly && !IsReadOnlyCompatible<TEventType>) { LOG_INFO_S(ctx, BS_SKELETON, VCtx->VDiskLogPrefix << "Blocking request incompatible with read-only: " << TypeName<TEventType>()); |