aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryuryalekseev <yuryalekseev@yandex-team.com>2022-09-02 13:35:36 +0300
committeryuryalekseev <yuryalekseev@yandex-team.com>2022-09-02 13:35:36 +0300
commit6075e8adbf361a8666f671ad399d9aa730a63f87 (patch)
tree49f6e917445966fcb04aa14e55dfba05d5c8d20f
parent76fdecbc0c4710dae08a990a664594b37ea471b0 (diff)
downloadydb-6075e8adbf361a8666f671ad399d9aa730a63f87.tar.gz
Add a check for blocked gen to TEvGet.
-rw-r--r--ydb/core/base/blobstorage.h10
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp9
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h7
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp7
-rw-r--r--ydb/core/blobstorage/dsproxy/dsproxy_request.cpp11
-rw-r--r--ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp2
-rw-r--r--ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h9
-rw-r--r--ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp4
-rw-r--r--ydb/core/protos/blobstorage.proto3
9 files changed, 60 insertions, 2 deletions
diff --git a/ydb/core/base/blobstorage.h b/ydb/core/base/blobstorage.h
index a8ce64d7e7c..0748eb6f780 100644
--- a/ydb/core/base/blobstorage.h
+++ b/ydb/core/base/blobstorage.h
@@ -20,6 +20,8 @@
#include <util/stream/str.h>
#include <util/generic/xrange.h>
+#include <optional>
+
namespace NKikimr {
static constexpr ui32 MaxProtobufSize = 67108000;
@@ -1046,6 +1048,8 @@ struct TEvBlobStorage {
ui32 RestartCounter = 0;
bool PhantomCheck = false;
bool Decommission = false; // is it generated by decommission actor and should be handled by the underlying proxy?
+ std::optional<ui64> ReaderTabletId;
+ std::optional<ui32> ReaderTabletGeneration;
// NKikimrBlobStorage::EGetHandleClass::FastRead
@@ -1112,6 +1116,12 @@ struct TEvBlobStorage {
}
str << "}";
}
+ if (ReaderTabletId) {
+ str << " ReaderTabletId# " << *ReaderTabletId;
+ }
+ if (ReaderTabletGeneration) {
+ str << " ReaderTabletGeneration# " << *ReaderTabletGeneration;
+ }
str << "}";
return str.Str();
}
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp
index 2640bb7c862..cb66db83460 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp
+++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp
@@ -284,6 +284,15 @@ void TGetImpl::PrepareRequests(TLogContext &logCtx, TDeque<std::unique_ptr<TEvBl
vGet->Record.SetSuppressBarrierCheck(IsInternal);
vGet->Record.SetTabletId(TabletId);
vGet->Record.SetAcquireBlockedGeneration(AcquireBlockedGeneration);
+
+ if (ReaderTabletId) {
+ vGet->Record.SetReaderTabletId(*ReaderTabletId);
+ }
+
+ if (ReaderTabletGeneration) {
+ vGet->Record.SetReaderTabletGeneration(*ReaderTabletGeneration);
+ }
+
R_LOG_DEBUG_SX(logCtx, "BPG14", "Send get to orderNumber# " << diskOrderNumber
<< " beginIdx# " << beginIdx
<< " endIdx# " << endIdx
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h
index c2d266b62ca..e9821ce7edb 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h
+++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h
@@ -51,6 +51,9 @@ class TGetImpl {
const bool PhantomCheck;
const bool Decommission;
+ std::optional<ui64> ReaderTabletId;
+ std::optional<ui32> ReaderTabletGeneration;
+
public:
TGetImpl(const TIntrusivePtr<TBlobStorageGroupInfo> &info, const TIntrusivePtr<TGroupQueues> &groupQueues,
TEvBlobStorage::TEvGet *ev, TNodeLayoutInfoPtr&& nodeLayout, const TString& requestPrefix = {})
@@ -69,6 +72,8 @@ public:
, RequestPrefix(requestPrefix)
, PhantomCheck(ev->PhantomCheck)
, Decommission(ev->Decommission)
+ , ReaderTabletId(ev->ReaderTabletId)
+ , ReaderTabletGeneration(ev->ReaderTabletGeneration)
{
Y_VERIFY(QuerySize > 0);
}
@@ -80,6 +85,8 @@ public:
ev->RestartCounter = counter;
ev->PhantomCheck = PhantomCheck;
ev->Decommission = Decommission;
+ ev->ReaderTabletId = ReaderTabletId;
+ ev->ReaderTabletGeneration = ReaderTabletGeneration;
return ev;
}
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp
index 9b2f53f4c09..5ce00fbcc0e 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp
+++ b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp
@@ -5,6 +5,8 @@
#include <util/generic/set.h>
+#include <optional>
+
namespace NKikimr {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -35,6 +37,9 @@ class TBlobStorageGroupMultiGetRequest : public TBlobStorageGroupRequestActor<TB
TStackVec<TRequestInfo, TypicalDisksInGroup> RequestInfos;
+ std::optional<ui64> ReaderTabletId;
+ std::optional<ui32> ReaderTabletGeneration;
+
void Handle(TEvBlobStorage::TEvGetResult::TPtr &ev) {
RequestsInFlight--;
@@ -116,6 +121,8 @@ public:
auto ev = std::make_unique<TEvBlobStorage::TEvGet>(queries, endIdx - beginIdx, Deadline, GetHandleClass,
MustRestoreFirst, false, ForceBlockedGeneration);
ev->IsInternal = IsInternal;
+ ev->ReaderTabletId = ReaderTabletId;
+ ev->ReaderTabletGeneration = ReaderTabletGeneration;
PendingGets.emplace_back(std::move(ev), cookie);
}
diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp
index 87b4d72b5df..ed3ca4ad388 100644
--- a/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp
+++ b/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp
@@ -10,6 +10,17 @@ namespace NKikimr {
return;
}
+ if (ev->Get()->ReaderTabletId.has_value() != ev->Get()->ReaderTabletGeneration.has_value()) {
+ LOG_ERROR_S(*TlsActivationContext,
+ NKikimrServices::BS_PROXY_GET,
+ "HandleNormal TEvGet:"
+ << " reader tablet params must either be both set or unset"
+ << " " << ev->Get()->Print(true));
+
+ HandleError(ev);
+ return;
+ }
+
if (StopGetBatchingEvent) {
TActivationContext::Send(StopGetBatchingEvent.Release());
}
diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp
index a69d627727e..940cae78c93 100644
--- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp
+++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.cpp
@@ -408,7 +408,7 @@ namespace NKikimr {
if (!CheckGC(ctx, record))
return {NKikimrProto::ERROR, 0, false}; // record has duplicates
- auto blockStatus = IsBlocked(record);
+ auto blockStatus = THullDbRecovery::IsBlocked(record);
switch (blockStatus.Status) {
case TBlocksCache::EStatus::OK:
break;
diff --git a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h
index 938230dce42..d8ed15a3b08 100644
--- a/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h
+++ b/ydb/core/blobstorage/vdisk/hullop/blobstorage_hull.h
@@ -1,6 +1,7 @@
#pragma once
#include "defs.h"
#include <ydb/core/blobstorage/vdisk/common/vdisk_hulllogctx.h>
+#include <ydb/core/blobstorage/vdisk/hulldb/hullds_cache_block.h>
#include <ydb/core/blobstorage/vdisk/hulldb/hulldb_recovery.h>
#include <ydb/core/blobstorage/vdisk/hulldb/hulldb_bulksst_add.h>
#include <ydb/core/blobstorage/vdisk/synclog/blobstorage_synclog_public_events.h>
@@ -157,6 +158,14 @@ namespace NKikimr {
return BlocksCache.Find(tabletID, outGen);
}
+ bool IsBlocked(ui64 tabletID, TBlocksCache::TBlockedGen tabletGeneration) {
+ auto res = BlocksCache.IsBlocked(tabletID, tabletGeneration);
+ if (res.Status == TBlocksCache::EStatus::OK) {
+ return false;
+ }
+ return true;
+ }
+
////////////////////////////////////////////////////////////////////////
// GC
////////////////////////////////////////////////////////////////////////
diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp
index 66ba099cdc3..d0ceef02639 100644
--- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp
+++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp
@@ -880,6 +880,10 @@ namespace NKikimr {
ReplyError(NKikimrProto::RACE, "group generation mismatch", ev, ctx, now);
} else if (!CheckVGetQuery(record)) {
ReplyError(NKikimrProto::ERROR, "get query is invalid", ev, ctx, now);
+ } else if (record.HasReaderTabletId()
+ && record.HasReaderTabletGeneration()
+ && Hull->IsBlocked(record.GetReaderTabletId(), {record.GetReaderTabletGeneration(), 0})) {
+ ReplyError(NKikimrProto::ERROR, "tablet's generation is blocked", ev, ctx, now);
} else {
std::optional<THullDsSnap> fullSnap;
if (record.HasSnapshotId()) {
diff --git a/ydb/core/protos/blobstorage.proto b/ydb/core/protos/blobstorage.proto
index 8e1c393c748..e8d154d4873 100644
--- a/ydb/core/protos/blobstorage.proto
+++ b/ydb/core/protos/blobstorage.proto
@@ -491,7 +491,8 @@ message TEvVGet {
optional bool AcquireBlockedGeneration = 22 [default = false]; // set to true to get the blocked generation
optional TTimestamps Timestamps = 23;
optional uint32 ForceBlockedGeneration = 24 [default = 0]; // non-zero means a successfull block must be done first
-
+ optional uint64 ReaderTabletId = 25;
+ optional uint32 ReaderTabletGeneration = 26;
optional bytes SnapshotId = 30; // read data from specific snapshot (if set)
}