diff options
author | yuryalekseev <yuryalekseev@yandex-team.com> | 2022-09-26 21:27:46 +0300 |
---|---|---|
committer | yuryalekseev <yuryalekseev@yandex-team.com> | 2022-09-26 21:27:46 +0300 |
commit | af53974093c8c71962be69186e1d453b96017f5f (patch) | |
tree | cdd7a3d8877f1ba05b00af70729a3cfe9faf9aec | |
parent | 141fe23a8ace89f84fd7b4c7aac8cca332608c3a (diff) | |
download | ydb-af53974093c8c71962be69186e1d453b96017f5f.tar.gz |
Refactor ReaderTablet params in TEvGet requests.
-rw-r--r-- | ydb/core/base/blobstorage.h | 17 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/agent_impl.h | 3 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/read.cpp | 3 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/storage_discover.cpp | 1 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/storage_get.cpp | 7 | ||||
-rw-r--r-- | ydb/core/blob_depot/agent/storage_range.cpp | 1 | ||||
-rw-r--r-- | ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp | 10 | ||||
-rw-r--r-- | ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h | 9 | ||||
-rw-r--r-- | ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp | 6 | ||||
-rw-r--r-- | ydb/core/blobstorage/dsproxy/dsproxy_request.cpp | 11 | ||||
-rw-r--r-- | ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp | 5 | ||||
-rw-r--r-- | ydb/core/blobstorage/ut_blobstorage/get.cpp | 13 | ||||
-rw-r--r-- | ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp | 5 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_storage_read_request.cpp | 3 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_storage_request.cpp | 3 | ||||
-rw-r--r-- | ydb/core/keyvalue/keyvalue_ut.cpp | 8 | ||||
-rw-r--r-- | ydb/core/protos/blobstorage.proto | 10 |
17 files changed, 47 insertions, 68 deletions
diff --git a/ydb/core/base/blobstorage.h b/ydb/core/base/blobstorage.h index c6aab74f2c..f99b575bc5 100644 --- a/ydb/core/base/blobstorage.h +++ b/ydb/core/base/blobstorage.h @@ -1066,8 +1066,13 @@ 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; + + struct TReaderTabletData { + ui64 Id; + ui32 Generation; + }; + + std::optional<TReaderTabletData> ReaderTabletData; // NKikimrBlobStorage::EGetHandleClass::FastRead @@ -1134,11 +1139,9 @@ struct TEvBlobStorage { } str << "}"; } - if (ReaderTabletId) { - str << " ReaderTabletId# " << *ReaderTabletId; - } - if (ReaderTabletGeneration) { - str << " ReaderTabletGeneration# " << *ReaderTabletGeneration; + if (ReaderTabletData) { + str << " ReaderTabletId# " << ReaderTabletData->Id; + str << " ReaderTabletGeneration# " << ReaderTabletData->Generation; } str << "}"; return str.Str(); diff --git a/ydb/core/blob_depot/agent/agent_impl.h b/ydb/core/blob_depot/agent/agent_impl.h index 5bcbce49e6..5bf717cf54 100644 --- a/ydb/core/blob_depot/agent/agent_impl.h +++ b/ydb/core/blob_depot/agent/agent_impl.h @@ -323,8 +323,7 @@ namespace NKikimr::NBlobDepot { ui64 Offset = 0; ui64 Size = 0; ui64 Tag = 0; - std::optional<ui64> ReaderTabletId; - std::optional<ui32> ReaderTabletGeneration; + std::optional<TEvBlobStorage::TEvGet::TReaderTabletData> ReaderTabletData; }; bool IssueRead(const TReadArg& arg, TString& error); diff --git a/ydb/core/blob_depot/agent/read.cpp b/ydb/core/blob_depot/agent/read.cpp index 92d785115c..6c82e24c42 100644 --- a/ydb/core/blob_depot/agent/read.cpp +++ b/ydb/core/blob_depot/agent/read.cpp @@ -101,8 +101,7 @@ namespace NKikimr::NBlobDepot { TInstant::Max(), arg.GetHandleClass, arg.MustRestoreFirst); - event->ReaderTabletId = arg.ReaderTabletId; - event->ReaderTabletGeneration = arg.ReaderTabletGeneration; + event->ReaderTabletData = arg.ReaderTabletData; SendToProxy(item.GroupId, std::move(event), arg.Query, context); } } diff --git a/ydb/core/blob_depot/agent/storage_discover.cpp b/ydb/core/blob_depot/agent/storage_discover.cpp index 0453d6d311..9bd9aca994 100644 --- a/ydb/core/blob_depot/agent/storage_discover.cpp +++ b/ydb/core/blob_depot/agent/storage_discover.cpp @@ -117,7 +117,6 @@ namespace NKikimr::NBlobDepot { 0, 0, 0, - {}, {}}; TString error; if (!Agent.IssueRead(arg, error)) { diff --git a/ydb/core/blob_depot/agent/storage_get.cpp b/ydb/core/blob_depot/agent/storage_get.cpp index cdf8dae8bc..ef84be7052 100644 --- a/ydb/core/blob_depot/agent/storage_get.cpp +++ b/ydb/core/blob_depot/agent/storage_get.cpp @@ -37,8 +37,8 @@ namespace NKikimr::NBlobDepot { Agent.VirtualGroupId); AnswersRemain = msg.QuerySize; - if (msg.ReaderTabletId && msg.ReaderTabletGeneration) { - auto status = Agent.BlocksManager.CheckBlockForTablet(msg.ReaderTabletId.value(), msg.ReaderTabletGeneration.value(), this, nullptr); + if (msg.ReaderTabletData) { + auto status = Agent.BlocksManager.CheckBlockForTablet(msg.ReaderTabletData->Id, msg.ReaderTabletData->Generation, this, nullptr); if (status == NKikimrProto::BLOCKED) { EndWithError(status, "Fail TEvGet due to BLOCKED tablet generation"); return; @@ -83,8 +83,7 @@ namespace NKikimr::NBlobDepot { msg.Queries[queryIdx].Shift, msg.Queries[queryIdx].Size, queryIdx, - msg.ReaderTabletId, - msg.ReaderTabletGeneration}; + msg.ReaderTabletData}; TString error; const bool success = Agent.IssueRead(arg, error); if (!success) { diff --git a/ydb/core/blob_depot/agent/storage_range.cpp b/ydb/core/blob_depot/agent/storage_range.cpp index dc63aa9ca5..20a8141b4d 100644 --- a/ydb/core/blob_depot/agent/storage_range.cpp +++ b/ydb/core/blob_depot/agent/storage_range.cpp @@ -117,7 +117,6 @@ namespace NKikimr::NBlobDepot { 0, 0, index, - {}, {}}; TString error; if (!Agent.IssueRead(arg, error)) { diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp index 8122e89e90..b1b486e719 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.cpp @@ -285,12 +285,10 @@ void TGetImpl::PrepareRequests(TLogContext &logCtx, TDeque<std::unique_ptr<TEvBl vGet->Record.SetTabletId(TabletId); vGet->Record.SetAcquireBlockedGeneration(AcquireBlockedGeneration); - if (ReaderTabletId) { - vGet->Record.SetReaderTabletId(*ReaderTabletId); - } - - if (ReaderTabletGeneration) { - vGet->Record.SetReaderTabletGeneration(*ReaderTabletGeneration); + if (ReaderTabletData) { + auto msg = vGet->Record.MutableReaderTabletData(); + msg->SetId(ReaderTabletData->Id); + msg->SetGeneration(ReaderTabletData->Generation); } R_LOG_DEBUG_SX(logCtx, "BPG14", "Send get to orderNumber# " << diskOrderNumber diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h index e9821ce7ed..a5e274c41d 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h +++ b/ydb/core/blobstorage/dsproxy/dsproxy_get_impl.h @@ -51,8 +51,7 @@ class TGetImpl { const bool PhantomCheck; const bool Decommission; - std::optional<ui64> ReaderTabletId; - std::optional<ui32> ReaderTabletGeneration; + std::optional<TEvBlobStorage::TEvGet::TReaderTabletData> ReaderTabletData; public: TGetImpl(const TIntrusivePtr<TBlobStorageGroupInfo> &info, const TIntrusivePtr<TGroupQueues> &groupQueues, @@ -72,8 +71,7 @@ public: , RequestPrefix(requestPrefix) , PhantomCheck(ev->PhantomCheck) , Decommission(ev->Decommission) - , ReaderTabletId(ev->ReaderTabletId) - , ReaderTabletGeneration(ev->ReaderTabletGeneration) + , ReaderTabletData(ev->ReaderTabletData) { Y_VERIFY(QuerySize > 0); } @@ -85,8 +83,7 @@ public: ev->RestartCounter = counter; ev->PhantomCheck = PhantomCheck; ev->Decommission = Decommission; - ev->ReaderTabletId = ReaderTabletId; - ev->ReaderTabletGeneration = ReaderTabletGeneration; + ev->ReaderTabletData = ReaderTabletData; return ev; } diff --git a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp index 5ce00fbcc0..808813f5cc 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_multiget.cpp @@ -37,8 +37,7 @@ class TBlobStorageGroupMultiGetRequest : public TBlobStorageGroupRequestActor<TB TStackVec<TRequestInfo, TypicalDisksInGroup> RequestInfos; - std::optional<ui64> ReaderTabletId; - std::optional<ui32> ReaderTabletGeneration; + std::optional<TEvBlobStorage::TEvGet::TReaderTabletData> ReaderTabletData; void Handle(TEvBlobStorage::TEvGetResult::TPtr &ev) { RequestsInFlight--; @@ -121,8 +120,7 @@ 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; + ev->ReaderTabletData = ReaderTabletData; 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 ed3ca4ad38..87b4d72b5d 100644 --- a/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp +++ b/ydb/core/blobstorage/dsproxy/dsproxy_request.cpp @@ -10,17 +10,6 @@ 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/ut_blobstorage/blob_depot.cpp b/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp index 4ef1acb4e8..a05d17cb60 100644 --- a/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/blob_depot.cpp @@ -19,7 +19,7 @@ Y_UNIT_TEST_SUITE(BlobDepot) { TestBasicPutAndGet(tenv, 11, tenv.BlobDepot); } - Y_UNIT_TEST(GetBlockedTabletGeneration) { + Y_UNIT_TEST(TestBlockedEvGetRequest) { ui32 seed; Seed().LoadOrFail(&seed, sizeof(seed)); TBlobDepotTestEnvironment tenv(seed); @@ -57,8 +57,7 @@ Y_UNIT_TEST_SUITE(BlobDepot) { mustRestoreFirst, isIndexOnly, forceBlockedGeneration); - ev->ReaderTabletId = tabletId; - ev->ReaderTabletGeneration = tabletGeneration; + ev->ReaderTabletData = {tabletId, tabletGeneration}; auto sender = tenv.Env->Runtime->AllocateEdgeActor(nodeId); env.Runtime->WrapInActorContext(sender, [&] { diff --git a/ydb/core/blobstorage/ut_blobstorage/get.cpp b/ydb/core/blobstorage/ut_blobstorage/get.cpp index 30953ef526..062fc3f2e8 100644 --- a/ydb/core/blobstorage/ut_blobstorage/get.cpp +++ b/ydb/core/blobstorage/ut_blobstorage/get.cpp @@ -10,11 +10,8 @@ Y_UNIT_TEST_SUITE(Get) { getQueries[0].Id = blobId; auto ev = std::make_unique<TEvBlobStorage::TEvGet>(getQueries, 1, TInstant::Max(), NKikimrBlobStorage::AsyncRead); - if (readerTabletId) { - ev->ReaderTabletId = *readerTabletId; - } - if (readerTabletGeneration) { - ev->ReaderTabletGeneration = *readerTabletGeneration; + if (readerTabletId && readerTabletGeneration) { + ev->ReaderTabletData = {*readerTabletId, *readerTabletGeneration}; } test.Runtime->WrapInActorContext(test.Edge, [&] { SendToBSProxy(test.Edge, test.Info->GroupID, ev.release()); @@ -45,7 +42,7 @@ Y_UNIT_TEST_SUITE(Get) { UNIT_ASSERT_EQUAL(putResult->Status, status); } - void MakeGetTest() { + Y_UNIT_TEST(TestBlockedEvGetRequest) { TEnvironmentSetup env(true); TTestInfo test = InitTest(env); @@ -79,8 +76,4 @@ Y_UNIT_TEST_SUITE(Get) { // check that now TEvGet returns BLOCKED for blocked generation with reader params SendGet(test, originalBlobId, data, NKikimrProto::BLOCKED, tabletId, tabletGeneration); } - - Y_UNIT_TEST(EvGetReaderParams) { - MakeGetTest(); - } } diff --git a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp index dc5cfcbf65..7853e74814 100644 --- a/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp +++ b/ydb/core/blobstorage/vdisk/skeleton/blobstorage_skeleton.cpp @@ -880,9 +880,8 @@ 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}).Status != TBlocksCache::EStatus::OK) { + } else if (record.HasReaderTabletData() + && Hull->IsBlocked(record.GetReaderTabletData().GetId(), {record.GetReaderTabletData().GetGeneration(), 0}).Status != TBlocksCache::EStatus::OK) { ReplyError(NKikimrProto::BLOCKED, "tablet's generation is blocked", ev, ctx, now); } else { std::optional<THullDsSnap> fullSnap; diff --git a/ydb/core/keyvalue/keyvalue_storage_read_request.cpp b/ydb/core/keyvalue/keyvalue_storage_read_request.cpp index cae0568ba6..7d463d8736 100644 --- a/ydb/core/keyvalue/keyvalue_storage_read_request.cpp +++ b/ydb/core/keyvalue/keyvalue_storage_read_request.cpp @@ -190,8 +190,7 @@ public: auto ev = std::make_unique<TEvBlobStorage::TEvGet>( readQueries, batch.ReadItemIndecies.size(), IntermediateResult->Deadline, handleClass, false); - ev->ReaderTabletId = TabletInfo->TabletID; - ev->ReaderTabletGeneration = TabletGeneration; + ev->ReaderTabletData = {TabletInfo->TabletID, TabletGeneration}; SendToBSProxy(TActivationContext::AsActorContext(), batch.GroupId, ev.release(), batch.Cookie); diff --git a/ydb/core/keyvalue/keyvalue_storage_request.cpp b/ydb/core/keyvalue/keyvalue_storage_request.cpp index bd92f06168..020901a70b 100644 --- a/ydb/core/keyvalue/keyvalue_storage_request.cpp +++ b/ydb/core/keyvalue/keyvalue_storage_request.cpp @@ -590,8 +590,7 @@ public: Y_VERIFY(queryIdx == readQueryCount); auto ev = std::make_unique<TEvBlobStorage::TEvGet>(readQueries, readQueryCount, IntermediateResults->Deadline, handleClass, false); - ev->ReaderTabletId = TabletInfo->TabletID; - ev->ReaderTabletGeneration = TabletGeneration; + ev->ReaderTabletData = {TabletInfo->TabletID, TabletGeneration}; SendToBSProxy(ctx, prevGroup, ev.release(), cookie); return true; } diff --git a/ydb/core/keyvalue/keyvalue_ut.cpp b/ydb/core/keyvalue/keyvalue_ut.cpp index 64291abb68..a8babc46c1 100644 --- a/ydb/core/keyvalue/keyvalue_ut.cpp +++ b/ydb/core/keyvalue/keyvalue_ut.cpp @@ -1016,8 +1016,12 @@ Y_UNIT_TEST(TestBlockedEvGetRequest) { // key value tablet reads from dsproxy dsProxyActor = event->Recipient; } - keyValueTabletId = event->Get<TEvBlobStorage::TEvGet>()->ReaderTabletId; - keyValueTabletGeneration = event->Get<TEvBlobStorage::TEvGet>()->ReaderTabletGeneration; + + auto readerTabletData = event->Get<TEvBlobStorage::TEvGet>()->ReaderTabletData; + if (readerTabletData) { + keyValueTabletId = readerTabletData->Id; + keyValueTabletGeneration = readerTabletData->Generation; + } } return TTestActorRuntime::EEventAction::PROCESS; diff --git a/ydb/core/protos/blobstorage.proto b/ydb/core/protos/blobstorage.proto index e18aeba97b..2697d3e898 100644 --- a/ydb/core/protos/blobstorage.proto +++ b/ydb/core/protos/blobstorage.proto @@ -491,8 +491,14 @@ 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; + + message TReaderTabletData { + optional uint64 Id = 1; + optional uint32 Generation = 2; + } + + optional TReaderTabletData ReaderTabletData = 25; + optional bytes SnapshotId = 30; // read data from specific snapshot (if set) } |